Skip to content

Commit

Permalink
fix(cmd/gitlab_ci/setup_runner): Use token (instead of registration t…
Browse files Browse the repository at this point in the history
…oken) for new Gitlab 16
  • Loading branch information
ondrejsika committed Jan 2, 2024
1 parent d6094a7 commit 81bd30a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions cmd/gitlab_ci/setup_runner/setup_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var FlagGitlabUrl string
var FlagRegistrationToken string
var FlagToken string
var FlagGitlabName string
var FlagConcurrency int
var FlagDryRun bool
Expand All @@ -30,10 +30,10 @@ var Cmd = &cobra.Command{
}

gitlabUrl := FlagGitlabUrl
registrationToken := FlagRegistrationToken
token := FlagToken

if FlagGitlabName != "" {
gitlabUrl, registrationToken, err = vault_gitlab_ci.GetGitlabCiSecrets(FlagGitlabName)
gitlabUrl, token, err = vault_gitlab_ci.GetGitlabCiSecrets(FlagGitlabName)
if err != nil {
log.Fatal(err)
}
Expand All @@ -43,7 +43,7 @@ var Cmd = &cobra.Command{
log.Fatal("flags gitlab-url and registration-token OR flag gitlab (for Vault) are required")
}

err = setup_runner_utils.SetupGitlabRunnerDocker(gitlabUrl, registrationToken, hostname, FlagConcurrency, FlagDryRun)
err = setup_runner_utils.SetupGitlabRunnerDocker(gitlabUrl, token, hostname, FlagConcurrency, FlagDryRun)
if err != nil {
log.Fatal(err)
}
Expand All @@ -60,13 +60,13 @@ func init() {
"Gitlab URL",
)
Cmd.PersistentFlags().StringVarP(
&FlagRegistrationToken,
"registration-token",
&FlagToken,
"token",
"t",
"",
"Gitlab Registration Token",
"Gitlab Runner Token",
)
Cmd.MarkFlagsRequiredTogether("gitlab-url", "registration-token")
Cmd.MarkFlagsRequiredTogether("gitlab-url", "token")
Cmd.PersistentFlags().StringVarP(
&FlagGitlabName,
"gitlab",
Expand Down
2 changes: 1 addition & 1 deletion lib/vault_gitlab_ci/vault_gitlab_ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func GetGitlabCiSecrets(name string) (string, string, error) {
if err != nil {
return "", "", err
}
registrationToken, err := getString(data, "REGISTRATION_TOKEN", true)
registrationToken, err := getString(data, "TOKEN", true)
if err != nil {
return "", "", err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/sikalabs/slu/utils/exec_utils"
)

func SetupGitlabRunnerDocker(gitlabUrl, registrationToken, hostname string, concurrency int, dryRun bool) error {
func SetupGitlabRunnerDocker(gitlabUrl, token, hostname string, concurrency int, dryRun bool) error {
var err error
var args []string

Expand Down Expand Up @@ -52,7 +52,7 @@ func SetupGitlabRunnerDocker(gitlabUrl, registrationToken, hostname string, conc
"gitlab-runner", "register",
"--non-interactive",
"--url", gitlabUrl,
"--registration-token", registrationToken,
"--token", token,
"--name", hostname,
"--executor", "docker",
"--docker-pull-policy", "if-not-present",
Expand Down

0 comments on commit 81bd30a

Please sign in to comment.