diff --git a/cmd/garm-cli/cmd/credentials.go b/cmd/garm-cli/cmd/credentials.go index 72bf4ec3..e5ed7b5a 100644 --- a/cmd/garm-cli/cmd/credentials.go +++ b/cmd/garm-cli/cmd/credentials.go @@ -66,10 +66,10 @@ func init() { func formatGithubCredentials(creds []params.GithubCredentials) { t := table.NewWriter() - header := table.Row{"Name", "Description", "Base URL", "API URL", "Upload URL"} + header := table.Row{"Name", "Description", "Base URL", "API URL", "Upload URL", "Type"} t.AppendHeader(header) for _, val := range creds { - t.AppendRow(table.Row{val.Name, val.Description, val.BaseURL, val.APIBaseURL, val.UploadBaseURL}) + t.AppendRow(table.Row{val.Name, val.Description, val.BaseURL, val.APIBaseURL, val.UploadBaseURL, val.AuthType}) t.AppendSeparator() } fmt.Println(t.Render()) diff --git a/params/params.go b/params/params.go index 7b941435..873a7795 100644 --- a/params/params.go +++ b/params/params.go @@ -38,6 +38,7 @@ type ( JobStatus string RunnerStatus string WebhookEndpointType string + GithubAuthType string ) const ( @@ -89,6 +90,13 @@ const ( RunnerActive RunnerStatus = "active" ) +const ( + // GithubAuthTypePAT is the OAuth token based authentication + GithubAuthTypePAT GithubAuthType = "pat" + // GithubAuthTypeApp is the GitHub App based authentication + GithubAuthTypeApp GithubAuthType = "app" +) + type StatusMessage struct { CreatedAt time.Time `json:"created_at"` Message string `json:"message"` @@ -421,13 +429,14 @@ type ControllerInfo struct { } type GithubCredentials struct { - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - APIBaseURL string `json:"api_base_url"` - UploadBaseURL string `json:"upload_base_url"` - BaseURL string `json:"base_url"` - CABundle []byte `json:"ca_bundle,omitempty"` - HTTPClient *http.Client `json:"-"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + APIBaseURL string `json:"api_base_url"` + UploadBaseURL string `json:"upload_base_url"` + BaseURL string `json:"base_url"` + CABundle []byte `json:"ca_bundle,omitempty"` + AuthType GithubAuthType `toml:"auth_type" json:"auth-type"` + HTTPClient *http.Client `json:"-"` } func (g GithubCredentials) RootCertificateBundle() (CertificateBundle, error) { diff --git a/runner/runner.go b/runner/runner.go index 914660a7..c8873c4f 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -412,6 +412,7 @@ func (r *Runner) ListCredentials(ctx context.Context) ([]params.GithubCredential BaseURL: val.BaseEndpoint(), APIBaseURL: val.APIEndpoint(), UploadBaseURL: val.UploadEndpoint(), + AuthType: params.GithubAuthType(val.AuthType), }) } return ret, nil