Skip to content

Commit

Permalink
Expose the credential type through the API
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
  • Loading branch information
gabriel-samfira committed Mar 2, 2024
1 parent cbb2134 commit 4668461
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cmd/garm-cli/cmd/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
23 changes: 16 additions & 7 deletions params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type (
JobStatus string
RunnerStatus string
WebhookEndpointType string
GithubAuthType string
)

const (
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4668461

Please sign in to comment.