Skip to content

Commit

Permalink
Fix issue of missing user token for self-hosted runners
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-stephen committed Aug 23, 2024
1 parent bb4017f commit 4af6ed5
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 4af6ed5

Please sign in to comment.