Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue of missing user token for self-hosted runners #1071

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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