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

[feature-request] Allow setting up multiple npm tokens #6

Open
arthurw1 opened this issue Apr 17, 2021 · 6 comments
Open

[feature-request] Allow setting up multiple npm tokens #6

arthurw1 opened this issue Apr 17, 2021 · 6 comments

Comments

@arthurw1
Copy link

We have a use case that requires us to pull deps from multiple private npm repositories, each requiring a unique npm token. Will it make sense to request for this feature in this plugin?

Thanks!

@arthurw1
Copy link
Author

I'd be open to work on this PR, but will need some guidance on how to go about it!

@72636c
Copy link
Member

72636c commented Apr 19, 2021

Hey @arthurw1! I think the first step is to determine how the config will look like.

Do you have any ideas here? e.g.

- seek-oss/private-npm#v1.2.0:
    registry:
      - path: //registry.npmjs.org/
        env: MY_ENV_VAR
      - path: //myprivatenpm.com/
        file: my_token_file

@arthurw1
Copy link
Author

Hi @72636c

I was thinking of the following. Similar to your suggestion but without the registry nesting:

plugins:
  - seek-oss/private-npm#v1.2.0:
      - env: "TOKEN_1"
        registry: //myprivatenpm1.com/
      - env: "TOKEN_2"
        registry: //myprivatenpm2.com/

Do we need to accommodate for cases where file or token fields are provided instead?

@72636c
Copy link
Member

72636c commented Apr 20, 2021

LGTM! Let's start out with env support, and we can add the others later if there's a need.

There's an example of parsing out a string list in the Docker ECR Cache plugin: https://github.com/seek-oss/docker-ecr-cache-buildkite-plugin/blob/d2a4b4763f2fe9c01a79eab10633bddcbc8e4f4c/hooks/lib/stdlib.bash#L23-L26. The code here may be slightly more involved since we'd be accessing nested names like "BUILDKITE_PLUGIN_PRIVATE_NPM_${INDEX}_ENV" and "BUILDKITE_PLUGIN_PRIVATE_NPM_${INDEX}_REGISTRY".

@arthurw1
Copy link
Author

I see. Will look into it!

@arthurw1
Copy link
Author

arthurw1 commented May 4, 2021

@72636c

I ended up with a schema that is similar to your initial suggestion:

- seek-oss/private-npm#v1.2.0:
    multi-registries:
      - path: //registry.npmjs.org/
        env: MY_ENV_VAR
      - path: //myprivatenpm.com/
        file: my_token_file

The feature is added and seems to be working when running pre-command locally. But I'd also like to test if my plugin.yml is configured correctly and if the variables are mapped as expected -- what is the best way to do this?

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

No branches or pull requests

2 participants