Skip to content

Conversation

@bredondev
Copy link
Contributor

@bredondev bredondev commented Oct 9, 2017

  • Introduce sub-commands to add the possibility to set a variable on the fly, without a gitlab.env.yml.
  • The token can be retrieved from env variable.
  • New commands are :
    • glci sv <options> to set one variable.
    • glci sav <options> to set all variables in gitlab.env.yml.

see README here : https://github.com/bredondev/gitlab-ci-variables-cli/tree/onevar

Copy link
Contributor

@brendo brendo left a comment

Choose a reason for hiding this comment

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

Mostly good! Just a couple of little doc tweaks 👍

README.md Outdated

```sh
$ glci sv --token <gitlab-token> --url <gitlab-project-url> --key <gitlab-key> --value <gitlab-value>
Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line will be Set <key> = <value>...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated
- `gitlab-value` is the value of the variable you want to set

```sh
$ glci sv --token <gitlab-token> --url <gitlab-project-url> --key <gitlab-key> --value <gitlab-value>
Copy link
Contributor

Choose a reason for hiding this comment

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

Below we just use key, value, so perhaps the placeholders could be updated to reflect the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated
$ export GITLAB_TOKEN=this-is-my-gitlab-token
$ glci sv --url <gitlab-project-url> --key <gitlab-key> --value <gitlab-value>
Using token from environment variable GITLAB_TOKEN.
Set AWS_CREDENTIALS = <value> for gitlab-org/gitlab-ce.
Copy link
Contributor

Choose a reason for hiding this comment

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

As above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

README.md Outdated
$ glci sv --key <gitlab-key> --value <gitlab-value>
Using token from environment variable GITLAB_TOKEN.
No URL specified, using git remote `origin`.
Set NPM_INSTALL_TOKEN = <value> for gitlab-org/gitlab-ce.
Copy link
Contributor

Choose a reason for hiding this comment

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

And again :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and fixed :)

},
"bin": {
"setAllVars": "bin/setAllVariables.js"
"glci": "bin/glci.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

To retain BC, could we leave the old setAllVars as well?

Or, if we don't feel like that's important, the tool could just go to v2?

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 suggest going v2

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 with that 👍


// Check for token
if (!conf.token) {
if (!process.env.GITLAB_TOKEN) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't need this, the rc package will automatically look for environment variables:

environment variables prefixed with ${appname}_

I feel like that'd mean GITLAB_TOKEN would already register... unless it's case sensitive and looking for gitlab_token. Did you have problems without this code?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is case sensitive, e.g. if env variable GITLAB_TOKEN is set, it would be exposed as conf.TOKEN

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 didn't know rc could do that. However, doing so will lead to not knowing from where comes the token, command arguments or environment variable. Don't you think this is a problem ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's a problem, but I'm happy to support it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with Baptiste. Doing so saves some lines code, but takes more brain power to understand for the next contributor.

src/lib/utils.js Outdated

const gitlabEnvFileName = 'gitlab.env.yml';

async function getConf(cmd, bSingle = false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Having cmd here creates tight coupling between this utility method and program. To reduce coupling, we could pass doNotForce as a boolean argument, or options as an object argument, e.g. { doNotForce: true}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

src/lib/utils.js Outdated
}
}

if (bSingle) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic does not belong here. A property (i.e. key/value combination) is not part of config (i.e. information on how to connect to gitlab and how to handle existing values). This logic belongs in glci-sv.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

+ put convenience functions in a separate file (utils.js)

// Check for token
if (!conf.token) {
if (!process.env.GITLAB_TOKEN) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's a problem, but I'm happy to support it.

},
"bin": {
"setAllVars": "bin/setAllVariables.js"
"glci": "bin/glci.js"
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 with that 👍

@quangkhoa quangkhoa merged commit 3618c10 into temando:master Oct 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants