Skip to content

Implement 'config' command

What does this MR do?

This MR adds:

  • support for a --concurrent N flag to the gitlab-runner register command, which will be used to initialize the global concurrent value in the global section of config.toml.

    This flag is only taken into consideration if the config.toml file is being created, otherwise a warning is output and no action is taken.

  • a new gitlab-runner config command, used to initialize/update settings in the global section of config.toml.

    > gitlab-runner config --help
    NAME:
      gitlab-runner config - set global configuration
    
    USAGE:
      gitlab-runner config [command options] [arguments...]
    
    OPTIONS:
      -c value, --config value  Config file (default: "/Users/pedro/.gitlab-runner/config.toml") [$CONFIG_FILE]
      -n, --non-interactive     Run registration unattended [$REGISTER_NON_INTERACTIVE]
      --check-interval value    Define active checking interval of jobs (default: "0") [$REGISTER_CHECK_INTERVAL]
      --concurrent value        Limits how many jobs globally can be run concurrently (default: "1") [$REGISTER_CONCURRENT]
    
    > gitlab-runner config -c config.toml
    Please enter how many jobs globally can be run concurrently:
    [1]: 
    Global configuration set successfully.             

Why was this MR needed?

As per #1539, when users run gitlab-runner register they have no option to define the concurrent value in the config.toml file in the global section.

In a similar vein, users would like a way to initialize/update other global section values such as check_interval using an official tool without having to resort to error-prone hand-rolled scripts.

Are there points in the code the reviewer needs to double-check?

Right now the new command is called config, but there is already a file named config.go. There are a couple of approaches we could take to avoid the naming clash:

  • We could name the new file to global_config.go (and rename the command accordingly to gitlab-runner global-config), or
  • suffix the existing command files with _command, e.g. config_command.go.

If this MR is merged, this section should probably also be updated to mention the config command: https://docs.gitlab.com/runner/configuration/runner_autoscale_aws/index.html#the-global-section.

Does this MR meet the acceptance criteria?

  • Documentation created/updated
  • Added tests for this feature/bug
  • In case of conflicts with master - branch was rebased

What are the relevant issue numbers?

Closes #1539 and #4324

Edited by 🤖 GitLab Bot 🤖

Merge request reports