Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter registry credentials by language #2680

Merged
merged 3 commits into from
Jan 15, 2025
Merged

Conversation

marcogario
Copy link
Contributor

@marcogario marcogario commented Jan 10, 2025

Introduce the language parameter for the start-proxy action so we know which credentials we should use.

By specifying the language with disambiguating cases where the same registry has distinct credentials. For example, in Artifactory it is possible to use a token that is scoped to the nuget feed, while the maven repository uses the username/password combination.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

@marcogario marcogario self-assigned this Jan 10, 2025
src/start-proxy-action.ts Fixed Show fixed Hide fixed
@marcogario marcogario force-pushed the marcogario/filter_registries branch 2 times, most recently from 4263e13 to 0e7e3db Compare January 13, 2025 10:44
src/start-proxy-action.ts Fixed Show fixed Hide fixed
@marcogario marcogario force-pushed the marcogario/filter_registries branch from 0e7e3db to e02d65a Compare January 13, 2025 10:52
@marcogario marcogario force-pushed the marcogario/filter_registries branch from d9e8b07 to de0f9cf Compare January 13, 2025 16:15
@marcogario marcogario marked this pull request as ready for review January 13, 2025 16:17
@marcogario marcogario requested a review from a team as a code owner January 13, 2025 16:17
@marcogario marcogario requested review from aibaars and removed request for a team January 13, 2025 16:20
@@ -17,6 +17,12 @@ const PROXY_USER = "proxy_user";
const KEY_SIZE = 2048;
const KEY_EXPIRY_YEARS = 2;

const LANGUAGE_TO_REGISTRY_TYPE = {
"java-kotlin": "maven_repository",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you add kotlin as a standalone language?

Also there is languages.ts, which is where we've traditionally added language-specific logic. I think I'd prefer to move this declaration to that file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed a commit where this logic better integrates with languages.ts, by reusing the Language type defined there.

I am 50/50 on whether we should move this map there. The main reason against doing so is that this information is really only useful for the proxy action and even the names of the registry types are fairly arbitrary and dependent on the specifics of the proxy binary. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine if the logic doesn't go into language.ts.

@marcogario marcogario force-pushed the marcogario/filter_registries branch from f33e08c to 529f92f Compare January 14, 2025 14:21
src/start-proxy-action.ts Fixed Show fixed Hide fixed
src/start-proxy-action.ts Fixed Show fixed Hide fixed
src/start-proxy-action.ts Fixed Show fixed Hide fixed
src/start-proxy-action.ts Fixed Show fixed Hide fixed
@marcogario marcogario force-pushed the marcogario/filter_registries branch from 529f92f to 31d11b1 Compare January 14, 2025 14:29
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I have a suggestion, but it is purely stylistic and non-blocking.

Comment on lines +29 to +32
actions: "",
cpp: "",
go: "",
swift: "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
actions: "",
cpp: "",
go: "",
swift: "",
actions: undefined,
cpp: undefined,
go: undefined,
swift: undefined,

Comment on lines +212 to +214
const registryTypeForLanguage = language
? LANGUAGE_TO_REGISTRY_TYPE[language]
: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: If you apply the suggestion above, then this becomes simpler:

Suggested change
const registryTypeForLanguage = language
? LANGUAGE_TO_REGISTRY_TYPE[language]
: undefined;
const registryTypeForLanguage = LANGUAGE_TO_REGISTRY_TYPE[language];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need the check on language itself, though.

@marcogario marcogario merged commit 3b4f4d9 into main Jan 15, 2025
269 checks passed
@marcogario marcogario deleted the marcogario/filter_registries branch January 15, 2025 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants