Skip to content

Commit

Permalink
Merge pull request #1071 from CircleCI-Public/cs/fix-cli
Browse files Browse the repository at this point in the history
Fix issue of missing user token for self-hosted runners
  • Loading branch information
christian-stephen authored Aug 23, 2024
2 parents bb4017f + 4af6ed5 commit 0d8fde1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@ type runnerOpts struct {
r running
}

func NewCommand(rootConfig *settings.Config, preRunE validator.Validator) *cobra.Command {
// The runner API versioning is decoupled from the other Circle APIs. Here we make a copy of the root configuration,
// and update the rest endpoint accordingly
config := *rootConfig
config.RestEndpoint = "/api/v3"

func NewCommand(config *settings.Config, preRunE validator.Validator) *cobra.Command {
var opts runnerOpts
cmd := &cobra.Command{
Use: "runner",
Short: "Operate on runners",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// The runner API versioning is decoupled from the other Circle APIs. Here we update the rest endpoint accordingly
config.RestEndpoint = "/api/v3"

var host string
if strings.Contains(config.Host, "https://circleci.com") {
host = "https://runner.circleci.com"
} else {
host = config.Host
}
opts.r = runner.New(rest.NewFromConfig(host, &config))
opts.r = runner.New(rest.NewFromConfig(host, config))
},
}

Expand Down

0 comments on commit 0d8fde1

Please sign in to comment.