From f40420bfb64dfe6c47f80094dc40997c8a461fbd Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Wed, 12 Oct 2022 21:45:07 +0000 Subject: [PATCH 01/12] Add ability to specify github enpoints for creds The GitHub credentials section now allows setting some API endpoints that point the github client and the runner setup script to the propper URLs. This allows us to use garm with an on-prem github enterprise server. Signed-off-by: Gabriel Adrian Samfira --- cloudconfig/cloudconfig.go | 24 ++++++++++++ cloudconfig/templates.go | 32 +++++++++------ cmd/garm-cli/cmd/credentials.go | 4 +- config/config.go | 69 ++++++++++++++++++++++++++++++--- params/params.go | 13 ++++++- runner/common/pool.go | 4 +- runner/pool/organization.go | 8 ++-- runner/pool/pool.go | 4 +- runner/pool/repository.go | 8 ++-- runner/runner.go | 20 +++++++++- util/util.go | 55 +++++++++++++++++++------- 11 files changed, 196 insertions(+), 45 deletions(-) diff --git a/cloudconfig/cloudconfig.go b/cloudconfig/cloudconfig.go index e90baffc..bf0d3d58 100644 --- a/cloudconfig/cloudconfig.go +++ b/cloudconfig/cloudconfig.go @@ -15,6 +15,7 @@ package cloudconfig import ( + "crypto/x509" "encoding/base64" "fmt" "garm/config" @@ -73,6 +74,29 @@ type CloudInit struct { SystemInfo *SystemInfo `yaml:"system_info,omitempty"` RunCmd []string `yaml:"runcmd,omitempty"` WriteFiles []File `yaml:"write_files,omitempty"` + CACerts CACerts `yaml:"ca-certs,omitempty"` +} + +type CACerts struct { + RemoveDefaults bool `yaml:"remove-defaults"` + Trusted []string `yaml:"trusted"` +} + +func (c *CloudInit) AddCACert(cert []byte) error { + c.mux.Lock() + defer c.mux.Unlock() + + if cert == nil { + return nil + } + + roots := x509.NewCertPool() + if ok := roots.AppendCertsFromPEM(cert); !ok { + return fmt.Errorf("failed to parse CA cert bundle") + } + c.CACerts.Trusted = append(c.CACerts.Trusted, string(cert)) + + return nil } func (c *CloudInit) AddSSHKey(keys ...string) { diff --git a/cloudconfig/templates.go b/cloudconfig/templates.go index 0a4f203c..c68c88ef 100644 --- a/cloudconfig/templates.go +++ b/cloudconfig/templates.go @@ -52,7 +52,16 @@ function fail() { } sendStatus "downloading tools from {{ .DownloadURL }}" -curl -L -o "/home/runner/{{ .FileName }}" "{{ .DownloadURL }}" || fail "failed to download tools" + +TEMP_TOKEN="" + + + +if [ ! -z "{{ .TempDownloadToken }}" ]; then + TEMP_TOKEN="Authorization: Bearer {{ .TempDownloadToken }}" +fi + +curl -L -H "${TEMP_TOKEN}" -o "/home/runner/{{ .FileName }}" "{{ .DownloadURL }}" || fail "failed to download tools" mkdir -p /home/runner/actions-runner || fail "failed to create actions-runner folder" @@ -84,16 +93,17 @@ success "runner successfully installed" $AGENT_ID ` type InstallRunnerParams struct { - FileName string - DownloadURL string - RunnerUsername string - RunnerGroup string - RepoURL string - GithubToken string - RunnerName string - RunnerLabels string - CallbackURL string - CallbackToken string + FileName string + DownloadURL string + RunnerUsername string + RunnerGroup string + RepoURL string + GithubToken string + RunnerName string + RunnerLabels string + CallbackURL string + CallbackToken string + TempDownloadToken string } func InstallRunnerScript(params InstallRunnerParams) ([]byte, error) { diff --git a/cmd/garm-cli/cmd/credentials.go b/cmd/garm-cli/cmd/credentials.go index 4ecd8f47..a4986b8b 100644 --- a/cmd/garm-cli/cmd/credentials.go +++ b/cmd/garm-cli/cmd/credentials.go @@ -63,10 +63,10 @@ func init() { func formatGithubCredentials(creds []params.GithubCredentials) { t := table.NewWriter() - header := table.Row{"Name", "Description"} + header := table.Row{"Name", "Description", "Base URL", "API URL", "Upload URL"} t.AppendHeader(header) for _, val := range creds { - t.AppendRow(table.Row{val.Name, val.Description}) + t.AppendRow(table.Row{val.Name, val.Description, val.BaseURL, val.APIBaseURL, val.UploadBaseURL}) t.AppendSeparator() } fmt.Println(t.Render()) diff --git a/config/config.go b/config/config.go index dc72937f..8c76441e 100644 --- a/config/config.go +++ b/config/config.go @@ -18,7 +18,6 @@ import ( "crypto/tls" "crypto/x509" "fmt" - "io/ioutil" "log" "net" "os" @@ -66,7 +65,13 @@ const ( // of time and no new updates have been made to it's state, it will be removed. DefaultRunnerBootstrapTimeout = 20 + // DefaultGithubURL is the default URL where Github or Github Enterprise can be accessed GithubBaseURL = "https://github.com" + + // defaultBaseURL is the default URL for the github API + defaultBaseURL = "https://api.github.com/" + // uploadBaseURL is the default URL for guthub uploads + uploadBaseURL = "https://uploads.github.com/" ) var ( @@ -190,15 +195,69 @@ func (d *Default) Validate() error { // Github hold configuration options specific to interacting with github. // Currently that is just a OAuth2 personal token. type Github struct { - Name string `toml:"name" json:"name"` - Description string `toml:"description" json:"description"` - OAuth2Token string `toml:"oauth2_token" json:"oauth2-token"` + Name string `toml:"name" json:"name"` + Description string `toml:"description" json:"description"` + OAuth2Token string `toml:"oauth2_token" json:"oauth2-token"` + APIBaseURL string `toml:"api_base_url" json:"api-base-url"` + UploadBaseURL string `toml:"upload_base_url" json:"upload-base-url"` + BaseURL string `toml:"base_url" json:"base-url"` + // CACertBundlePath is the path on disk to a CA certificate bundle that + // can validate the endpoints defined above. Leave empty if not using a + // self signed certificate. + CACertBundlePath string `toml:"ca_cert_bundle" json:"ca-cert-bundle"` +} + +func (g *Github) APIEndpoint() string { + if g.APIBaseURL != "" { + return g.APIBaseURL + } + return defaultBaseURL +} + +func (g *Github) CACertBundle() ([]byte, error) { + if g.CACertBundlePath == "" { + // No CA bundle defined. + return nil, nil + } + if _, err := os.Stat(g.CACertBundlePath); err != nil { + return nil, errors.Wrap(err, "accessing CA bundle") + } + + contents, err := os.ReadFile(g.CACertBundlePath) + if err != nil { + return nil, errors.Wrap(err, "reading CA bundle") + } + + roots := x509.NewCertPool() + if ok := roots.AppendCertsFromPEM(contents); !ok { + return nil, fmt.Errorf("failed to parse CA cert bundle") + } + + return contents, nil +} + +func (g *Github) UploadEndpoint() string { + if g.UploadBaseURL == "" { + if g.APIBaseURL != "" { + return g.APIBaseURL + } + return uploadBaseURL + } + return g.UploadBaseURL +} + +func (g *Github) BaseEndpoint() string { + if g.BaseURL != "" { + return g.BaseURL + } + return GithubBaseURL } func (g *Github) Validate() error { if g.OAuth2Token == "" { return fmt.Errorf("missing github oauth2 token") } + return nil } @@ -372,7 +431,7 @@ func (t *TLSConfig) TLSConfig() (*tls.Config, error) { var roots *x509.CertPool if t.CACert != "" { - caCertPEM, err := ioutil.ReadFile(t.CACert) + caCertPEM, err := os.ReadFile(t.CACert) if err != nil { return nil, err } diff --git a/params/params.go b/params/params.go index 2f1ea43e..8f1f78ba 100644 --- a/params/params.go +++ b/params/params.go @@ -98,6 +98,8 @@ type BootstrapInstance struct { // provider supports it. SSHKeys []string `json:"ssh-keys"` + CACertBundle []byte `json:"ca-cert-bundle"` + OSArch config.OSArch `json:"arch"` Flavor string `json:"flavor"` Image string `json:"image"` @@ -141,6 +143,9 @@ type Internal struct { ControllerID string `json:"controller_id"` InstanceCallbackURL string `json:"instance_callback_url"` JWTSecret string `json:"jwt_secret"` + // GithubCredentialsDetails contains all info about the credentials, except the + // token, which is added above. + GithubCredentialsDetails GithubCredentials `json:"gh_creds_details"` } type Repository struct { @@ -186,8 +191,12 @@ type ControllerInfo struct { } type GithubCredentials struct { - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + BaseURL string `json:"base_url"` + APIBaseURL string `json:"api_base_url"` + UploadBaseURL string `json:"upload_base_url"` + CABundle []byte `json:"ca_bundle,omitempty"` } type Provider struct { diff --git a/runner/common/pool.go b/runner/common/pool.go index 5da97e95..ca4e31e2 100644 --- a/runner/common/pool.go +++ b/runner/common/pool.go @@ -27,7 +27,9 @@ const ( PoolConsilitationInterval = 5 * time.Second PoolReapTimeoutInterval = 5 * time.Minute - PoolToolUpdateInterval = 3 * time.Hour + // Temporary tools download token is valid for 1 hour by default. + // Set this to less than an hour so as not to run into 401 errors. + PoolToolUpdateInterval = 50 * time.Minute ) type PoolManager interface { diff --git a/runner/pool/organization.go b/runner/pool/organization.go index 546d28b2..4044e6e4 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -20,7 +20,6 @@ import ( "strings" "sync" - "garm/config" dbCommon "garm/database/common" runnerErrors "garm/errors" "garm/params" @@ -35,7 +34,7 @@ import ( var _ poolHelper = &organization{} func NewOrganizationPoolManager(ctx context.Context, cfg params.Organization, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { - ghc, err := util.GithubClient(ctx, cfgInternal.OAuth2Token) + ghc, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) if err != nil { return nil, errors.Wrap(err, "getting github client") } @@ -57,6 +56,7 @@ func NewOrganizationPoolManager(ctx context.Context, cfg params.Organization, cf quit: make(chan struct{}), done: make(chan struct{}), helper: helper, + credsDetails: cfgInternal.GithubCredentialsDetails, } return repo, nil } @@ -89,7 +89,7 @@ func (r *organization) UpdateState(param params.UpdatePoolStateParams) error { r.cfg.WebhookSecret = param.WebhookSecret - ghc, err := util.GithubClient(r.ctx, r.GetGithubToken()) + ghc, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) if err != nil { return errors.Wrap(err, "getting github client") } @@ -138,7 +138,7 @@ func (r *organization) ListPools() ([]params.Pool, error) { } func (r *organization) GithubURL() string { - return fmt.Sprintf("%s/%s", config.GithubBaseURL, r.cfg.Name) + return fmt.Sprintf("%s/%s", r.cfgInternal.GithubCredentialsDetails.BaseURL, r.cfg.Name) } func (r *organization) JwtToken() string { diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 92c9f00c..160da187 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -58,7 +58,8 @@ type basePool struct { quit chan struct{} done chan struct{} - helper poolHelper + helper poolHelper + credsDetails params.GithubCredentials mux sync.Mutex } @@ -454,6 +455,7 @@ func (r *basePool) addInstanceToProvider(instance params.Instance) error { Image: pool.Image, Labels: labels, PoolID: instance.PoolID, + CACertBundle: r.credsDetails.CABundle, } var instanceIDToDelete string diff --git a/runner/pool/repository.go b/runner/pool/repository.go index 6416efe5..8f0ed6d1 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -20,7 +20,6 @@ import ( "strings" "sync" - "garm/config" dbCommon "garm/database/common" runnerErrors "garm/errors" "garm/params" @@ -35,7 +34,7 @@ import ( var _ poolHelper = &repository{} func NewRepositoryPoolManager(ctx context.Context, cfg params.Repository, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { - ghc, err := util.GithubClient(ctx, cfgInternal.OAuth2Token) + ghc, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) if err != nil { return nil, errors.Wrap(err, "getting github client") } @@ -57,6 +56,7 @@ func NewRepositoryPoolManager(ctx context.Context, cfg params.Repository, cfgInt quit: make(chan struct{}), done: make(chan struct{}), helper: helper, + credsDetails: cfgInternal.GithubCredentialsDetails, } return repo, nil } @@ -91,7 +91,7 @@ func (r *repository) UpdateState(param params.UpdatePoolStateParams) error { r.cfg.WebhookSecret = param.WebhookSecret - ghc, err := util.GithubClient(r.ctx, r.GetGithubToken()) + ghc, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) if err != nil { return errors.Wrap(err, "getting github client") } @@ -140,7 +140,7 @@ func (r *repository) ListPools() ([]params.Pool, error) { } func (r *repository) GithubURL() string { - return fmt.Sprintf("%s/%s/%s", config.GithubBaseURL, r.cfg.Owner, r.cfg.Name) + return fmt.Sprintf("%s/%s/%s", r.cfgInternal.GithubCredentialsDetails.BaseURL, r.cfg.Owner, r.cfg.Name) } func (r *repository) JwtToken() string { diff --git a/runner/runner.go b/runner/runner.go index 63664b7c..808edefd 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -190,11 +190,24 @@ func (p *poolManagerCtrl) getInternalConfig(credsName string) (params.Internal, return params.Internal{}, runnerErrors.NewBadRequestError("invalid credential name (%s)", credsName) } + caBundle, err := creds.CACertBundle() + if err != nil { + return params.Internal{}, fmt.Errorf("fetching CA bundle for creds: %w", err) + } + return params.Internal{ OAuth2Token: creds.OAuth2Token, ControllerID: p.controllerID, InstanceCallbackURL: p.config.Default.CallbackURL, JWTSecret: p.config.JWTAuth.Secret, + GithubCredentialsDetails: params.GithubCredentials{ + Name: creds.Name, + Description: creds.Description, + BaseURL: creds.BaseURL, + APIBaseURL: creds.APIBaseURL, + UploadBaseURL: creds.UploadBaseURL, + CABundle: caBundle, + }, }, nil } @@ -219,8 +232,11 @@ func (r *Runner) ListCredentials(ctx context.Context) ([]params.GithubCredential for _, val := range r.config.Github { ret = append(ret, params.GithubCredentials{ - Name: val.Name, - Description: val.Description, + Name: val.Name, + Description: val.Description, + BaseURL: val.BaseEndpoint(), + APIBaseURL: val.APIEndpoint(), + UploadBaseURL: val.UploadEndpoint(), }) } return ret, nil diff --git a/util/util.go b/util/util.go index 993beace..f2ee210b 100644 --- a/util/util.go +++ b/util/util.go @@ -19,10 +19,13 @@ import ( "crypto/aes" "crypto/cipher" "crypto/rand" + "crypto/tls" + "crypto/x509" "encoding/base64" "fmt" "io" "io/ioutil" + "net/http" "os" "path" "regexp" @@ -160,14 +163,33 @@ func OSToOSType(os string) (config.OSType, error) { return osType, nil } -func GithubClient(ctx context.Context, token string) (common.GithubClient, error) { +func GithubClient(ctx context.Context, token string, credsDetails params.GithubCredentials) (common.GithubClient, error) { + var roots *x509.CertPool + if credsDetails.CABundle != nil && len(credsDetails.CABundle) > 0 { + roots = x509.NewCertPool() + ok := roots.AppendCertsFromPEM(credsDetails.CABundle) + if !ok { + return nil, fmt.Errorf("failed to parse CA cert") + } + } + httpTransport := &http.Transport{ + TLSClientConfig: &tls.Config{ + ClientCAs: roots, + }, + } + httpClient := &http.Client{Transport: httpTransport} + ctx = context.WithValue(ctx, oauth2.HTTPClient, httpClient) + ts := oauth2.StaticTokenSource( &oauth2.Token{AccessToken: token}, ) - tc := oauth2.NewClient(ctx, ts) - ghClient := github.NewClient(tc) + // ghClient := github.NewClient(tc) + ghClient, err := github.NewEnterpriseClient(credsDetails.APIBaseURL, credsDetails.UploadBaseURL, tc) + if err != nil { + return nil, errors.Wrap(err, "fetching github client") + } return ghClient.Actions, nil } @@ -176,16 +198,17 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne cloudCfg := cloudconfig.NewDefaultCloudInitConfig() installRunnerParams := cloudconfig.InstallRunnerParams{ - FileName: *tools.Filename, - DownloadURL: *tools.DownloadURL, - GithubToken: bootstrapParams.GithubRunnerAccessToken, - RunnerUsername: config.DefaultUser, - RunnerGroup: config.DefaultUser, - RepoURL: bootstrapParams.RepoURL, - RunnerName: runnerName, - RunnerLabels: strings.Join(bootstrapParams.Labels, ","), - CallbackURL: bootstrapParams.CallbackURL, - CallbackToken: bootstrapParams.InstanceToken, + FileName: *tools.Filename, + DownloadURL: *tools.DownloadURL, + TempDownloadToken: *tools.TempDownloadToken, + GithubToken: bootstrapParams.GithubRunnerAccessToken, + RunnerUsername: config.DefaultUser, + RunnerGroup: config.DefaultUser, + RepoURL: bootstrapParams.RepoURL, + RunnerName: runnerName, + RunnerLabels: strings.Join(bootstrapParams.Labels, ","), + CallbackURL: bootstrapParams.CallbackURL, + CallbackToken: bootstrapParams.InstanceToken, } installScript, err := cloudconfig.InstallRunnerScript(installRunnerParams) @@ -198,6 +221,12 @@ func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.Runne cloudCfg.AddRunCmd("/install_runner.sh") cloudCfg.AddRunCmd("rm -f /install_runner.sh") + if bootstrapParams.CACertBundle != nil && len(bootstrapParams.CACertBundle) > 0 { + if err := cloudCfg.AddCACert(bootstrapParams.CACertBundle); err != nil { + return "", errors.Wrap(err, "adding CA cert bundle") + } + } + asStr, err := cloudCfg.Serialize() if err != nil { return "", errors.Wrap(err, "creating cloud config") From 296333412a8e6ba679bb331a2aa939a836a7db9b Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 13 Oct 2022 16:09:28 +0000 Subject: [PATCH 02/12] Add enterprise support This change adds enterprise support throughout garm. Signed-off-by: Gabriel Adrian Samfira --- apiserver/controllers/enterprises.go | 282 ++++++++++++++ apiserver/controllers/instances.go | 26 +- apiserver/routers/routers.go | 39 ++ config/config.go | 10 +- database/common/common.go | 90 +++-- database/common/mocks/Store.go | 265 +++++++++++++ database/sql/enterprise.go | 367 ++++++++++++++++++ database/sql/models.go | 12 + database/sql/organizations.go | 6 +- database/sql/pools.go | 2 +- database/sql/repositories.go | 4 +- database/sql/sql.go | 3 +- database/sql/util.go | 15 + go.mod | 4 +- go.sum | 7 +- params/params.go | 11 +- params/requests.go | 17 + runner/common/mocks/GithubClient.go | 34 +- runner/common/mocks/GithubEnterpriseClient.go | 149 +++++++ runner/common/pool.go | 1 + runner/common/provider.go | 1 + runner/common/util.go | 16 +- runner/enterprises.go | 313 +++++++++++++++ runner/interfaces.go | 21 +- ...Controller.go => PoolManagerController.go} | 83 ++++ runner/pool/enterprise.go | 201 ++++++++++ runner/pool/interfaces.go | 2 +- runner/pool/organization.go | 29 +- runner/pool/pool.go | 2 +- runner/pool/repository.go | 28 +- runner/providers/lxd/lxd.go | 2 +- runner/runner.go | 86 ++-- runner/types.go | 1 + util/util.go | 11 +- 34 files changed, 2028 insertions(+), 112 deletions(-) create mode 100644 apiserver/controllers/enterprises.go create mode 100644 database/sql/enterprise.go create mode 100644 runner/common/mocks/GithubEnterpriseClient.go create mode 100644 runner/enterprises.go rename runner/mocks/{poolManagerController.go => PoolManagerController.go} (69%) create mode 100644 runner/pool/enterprise.go diff --git a/apiserver/controllers/enterprises.go b/apiserver/controllers/enterprises.go new file mode 100644 index 00000000..8591953f --- /dev/null +++ b/apiserver/controllers/enterprises.go @@ -0,0 +1,282 @@ +// Copyright 2022 Cloudbase Solutions SRL +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package controllers + +import ( + "encoding/json" + "log" + "net/http" + + "garm/apiserver/params" + gErrors "garm/errors" + runnerParams "garm/params" + + "github.com/gorilla/mux" +) + +func (a *APIController) CreateEnterpriseHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + var enterpriseData runnerParams.CreateEnterpriseParams + if err := json.NewDecoder(r.Body).Decode(&enterpriseData); err != nil { + handleError(w, gErrors.ErrBadRequest) + return + } + + enterprise, err := a.r.CreateEnterprise(ctx, enterpriseData) + if err != nil { + log.Printf("error creating enterprise: %+v", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(enterprise) +} + +func (a *APIController) ListEnterprisesHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + enterprise, err := a.r.ListEnterprises(ctx) + if err != nil { + log.Printf("listing enterprise: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(enterprise) +} + +func (a *APIController) GetEnterpriseByIDHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + vars := mux.Vars(r) + enterpriseID, ok := vars["enterpriseID"] + if !ok { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise ID specified", + }) + return + } + + enterprise, err := a.r.GetEnterpriseByID(ctx, enterpriseID) + if err != nil { + log.Printf("fetching enterprise: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(enterprise) +} + +func (a *APIController) DeleteEnterpriseHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + vars := mux.Vars(r) + enterpriseID, ok := vars["enterpriseID"] + if !ok { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise ID specified", + }) + return + } + + if err := a.r.DeleteEnterprise(ctx, enterpriseID); err != nil { + log.Printf("removing enterprise: %+v", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + +} + +func (a *APIController) UpdateEnterpriseHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + vars := mux.Vars(r) + enterpriseID, ok := vars["enterpriseID"] + if !ok { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise ID specified", + }) + return + } + + var updatePayload runnerParams.UpdateRepositoryParams + if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil { + handleError(w, gErrors.ErrBadRequest) + return + } + + enterprise, err := a.r.UpdateEnterprise(ctx, enterpriseID, updatePayload) + if err != nil { + log.Printf("error updating enterprise: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(enterprise) +} + +func (a *APIController) CreateEnterprisePoolHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + vars := mux.Vars(r) + enterpriseID, ok := vars["enterpriseID"] + if !ok { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise ID specified", + }) + return + } + + var poolData runnerParams.CreatePoolParams + if err := json.NewDecoder(r.Body).Decode(&poolData); err != nil { + log.Printf("failed to decode: %s", err) + handleError(w, gErrors.ErrBadRequest) + return + } + + pool, err := a.r.CreateEnterprisePool(ctx, enterpriseID, poolData) + if err != nil { + log.Printf("error creating enterprise pool: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(pool) +} + +func (a *APIController) ListEnterprisePoolsHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + vars := mux.Vars(r) + enterpriseID, ok := vars["enterpriseID"] + if !ok { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise ID specified", + }) + return + } + + pools, err := a.r.ListEnterprisePools(ctx, enterpriseID) + if err != nil { + log.Printf("listing pools: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(pools) +} + +func (a *APIController) GetEnterprisePoolHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + vars := mux.Vars(r) + enterpriseID, enterpriseOk := vars["enterpriseID"] + poolID, poolOk := vars["poolID"] + if !enterpriseOk || !poolOk { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise or pool ID specified", + }) + return + } + + pool, err := a.r.GetEnterprisePoolByID(ctx, enterpriseID, poolID) + if err != nil { + log.Printf("listing pools: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(pool) +} + +func (a *APIController) DeleteEnterprisePoolHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + vars := mux.Vars(r) + enterpriseID, enterpriseOk := vars["enterpriseID"] + poolID, poolOk := vars["poolID"] + if !enterpriseOk || !poolOk { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise or pool ID specified", + }) + return + } + + if err := a.r.DeleteEnterprisePool(ctx, enterpriseID, poolID); err != nil { + log.Printf("removing pool: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + +} + +func (a *APIController) UpdateEnterprisePoolHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + vars := mux.Vars(r) + enterpriseID, enterpriseOk := vars["enterpriseID"] + poolID, poolOk := vars["poolID"] + if !enterpriseOk || !poolOk { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise or pool ID specified", + }) + return + } + + var poolData runnerParams.UpdatePoolParams + if err := json.NewDecoder(r.Body).Decode(&poolData); err != nil { + log.Printf("failed to decode: %s", err) + handleError(w, gErrors.ErrBadRequest) + return + } + + pool, err := a.r.UpdateEnterprisePool(ctx, enterpriseID, poolID, poolData) + if err != nil { + log.Printf("error creating enterprise pool: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(pool) +} diff --git a/apiserver/controllers/instances.go b/apiserver/controllers/instances.go index b7332b6c..ee44dafe 100644 --- a/apiserver/controllers/instances.go +++ b/apiserver/controllers/instances.go @@ -136,7 +136,31 @@ func (a *APIController) ListOrgInstancesHandler(w http.ResponseWriter, r *http.R instances, err := a.r.ListOrgInstances(ctx, orgID) if err != nil { - log.Printf("listing pools: %s", err) + log.Printf("listing instances: %s", err) + handleError(w, err) + return + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(instances) +} + +func (a *APIController) ListEnterpriseInstancesHandler(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + vars := mux.Vars(r) + enterpriseID, ok := vars["enterpriseID"] + if !ok { + w.WriteHeader(http.StatusBadRequest) + json.NewEncoder(w).Encode(params.APIErrorResponse{ + Error: "Bad Request", + Details: "No enterprise ID specified", + }) + return + } + + instances, err := a.r.ListOrgInstances(ctx, enterpriseID) + if err != nil { + log.Printf("listing instances: %s", err) handleError(w, err) return } diff --git a/apiserver/routers/routers.go b/apiserver/routers/routers.go index 58b3fb6f..818c28e0 100644 --- a/apiserver/routers/routers.go +++ b/apiserver/routers/routers.go @@ -165,6 +165,45 @@ func NewAPIRouter(han *controllers.APIController, logWriter io.Writer, authMiddl apiRouter.Handle("/organizations/", log(logWriter, http.HandlerFunc(han.CreateOrgHandler))).Methods("POST", "OPTIONS") apiRouter.Handle("/organizations", log(logWriter, http.HandlerFunc(han.CreateOrgHandler))).Methods("POST", "OPTIONS") + ///////////////////////////// + // Enterprises and pools // + ///////////////////////////// + // Get pool + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(os.Stdout, http.HandlerFunc(han.GetEnterprisePoolHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(os.Stdout, http.HandlerFunc(han.GetEnterprisePoolHandler))).Methods("GET", "OPTIONS") + // Delete pool + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(os.Stdout, http.HandlerFunc(han.DeleteEnterprisePoolHandler))).Methods("DELETE", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(os.Stdout, http.HandlerFunc(han.DeleteEnterprisePoolHandler))).Methods("DELETE", "OPTIONS") + // Update pool + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(os.Stdout, http.HandlerFunc(han.UpdateEnterprisePoolHandler))).Methods("PUT", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(os.Stdout, http.HandlerFunc(han.UpdateEnterprisePoolHandler))).Methods("PUT", "OPTIONS") + // List pools + apiRouter.Handle("/enterprises/{enterpriseID}/pools/", log(os.Stdout, http.HandlerFunc(han.ListEnterprisePoolsHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools", log(os.Stdout, http.HandlerFunc(han.ListEnterprisePoolsHandler))).Methods("GET", "OPTIONS") + // Create pool + apiRouter.Handle("/enterprises/{enterpriseID}/pools/", log(os.Stdout, http.HandlerFunc(han.CreateEnterprisePoolHandler))).Methods("POST", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools", log(os.Stdout, http.HandlerFunc(han.CreateEnterprisePoolHandler))).Methods("POST", "OPTIONS") + + // Repo instances list + apiRouter.Handle("/enterprises/{enterpriseID}/instances/", log(os.Stdout, http.HandlerFunc(han.ListEnterpriseInstancesHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/instances", log(os.Stdout, http.HandlerFunc(han.ListEnterpriseInstancesHandler))).Methods("GET", "OPTIONS") + + // Get org + apiRouter.Handle("/enterprises/{enterpriseID}/", log(os.Stdout, http.HandlerFunc(han.GetEnterpriseByIDHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}", log(os.Stdout, http.HandlerFunc(han.GetEnterpriseByIDHandler))).Methods("GET", "OPTIONS") + // Update org + apiRouter.Handle("/enterprises/{enterpriseID}/", log(os.Stdout, http.HandlerFunc(han.UpdateEnterpriseHandler))).Methods("PUT", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}", log(os.Stdout, http.HandlerFunc(han.UpdateEnterpriseHandler))).Methods("PUT", "OPTIONS") + // Delete org + apiRouter.Handle("/enterprises/{enterpriseID}/", log(os.Stdout, http.HandlerFunc(han.DeleteEnterpriseHandler))).Methods("DELETE", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}", log(os.Stdout, http.HandlerFunc(han.DeleteEnterpriseHandler))).Methods("DELETE", "OPTIONS") + // List orgs + apiRouter.Handle("/enterprises/", log(os.Stdout, http.HandlerFunc(han.ListEnterprisesHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises", log(os.Stdout, http.HandlerFunc(han.ListEnterprisesHandler))).Methods("GET", "OPTIONS") + // Create org + apiRouter.Handle("/enterprises/", log(os.Stdout, http.HandlerFunc(han.CreateEnterpriseHandler))).Methods("POST", "OPTIONS") + apiRouter.Handle("/enterprises", log(os.Stdout, http.HandlerFunc(han.CreateEnterpriseHandler))).Methods("POST", "OPTIONS") + // Credentials and providers apiRouter.Handle("/credentials/", log(logWriter, http.HandlerFunc(han.ListCredentials))).Methods("GET", "OPTIONS") apiRouter.Handle("/credentials", log(logWriter, http.HandlerFunc(han.ListCredentials))).Methods("GET", "OPTIONS") diff --git a/config/config.go b/config/config.go index 8c76441e..d02daea5 100644 --- a/config/config.go +++ b/config/config.go @@ -65,12 +65,12 @@ const ( // of time and no new updates have been made to it's state, it will be removed. DefaultRunnerBootstrapTimeout = 20 - // DefaultGithubURL is the default URL where Github or Github Enterprise can be accessed - GithubBaseURL = "https://github.com" + // DefaultGithubURL is the default URL where Github or Github Enterprise can be accessed. + DefaultGithubURL = "https://github.com" - // defaultBaseURL is the default URL for the github API + // defaultBaseURL is the default URL for the github API. defaultBaseURL = "https://api.github.com/" - // uploadBaseURL is the default URL for guthub uploads + // uploadBaseURL is the default URL for guthub uploads. uploadBaseURL = "https://uploads.github.com/" ) @@ -250,7 +250,7 @@ func (g *Github) BaseEndpoint() string { if g.BaseURL != "" { return g.BaseURL } - return GithubBaseURL + return DefaultGithubURL } func (g *Github) Validate() error { diff --git a/database/common/common.go b/database/common/common.go index f710e3b1..d5955f54 100644 --- a/database/common/common.go +++ b/database/common/common.go @@ -19,7 +19,7 @@ import ( "garm/params" ) -type Store interface { +type RepoStore interface { CreateRepository(ctx context.Context, owner, name, credentialsName, webhookSecret string) (params.Repository, error) GetRepository(ctx context.Context, owner, name string) (params.Repository, error) GetRepositoryByID(ctx context.Context, repoID string) (params.Repository, error) @@ -27,6 +27,18 @@ type Store interface { DeleteRepository(ctx context.Context, repoID string) error UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error) + CreateRepositoryPool(ctx context.Context, repoId string, param params.CreatePoolParams) (params.Pool, error) + + GetRepositoryPool(ctx context.Context, repoID, poolID string) (params.Pool, error) + DeleteRepositoryPool(ctx context.Context, repoID, poolID string) error + UpdateRepositoryPool(ctx context.Context, repoID, poolID string, param params.UpdatePoolParams) (params.Pool, error) + FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error) + + ListRepoPools(ctx context.Context, repoID string) ([]params.Pool, error) + ListRepoInstances(ctx context.Context, repoID string) ([]params.Instance, error) +} + +type OrgStore interface { CreateOrganization(ctx context.Context, name, credentialsName, webhookSecret string) (params.Organization, error) GetOrganization(ctx context.Context, name string) (params.Organization, error) GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error) @@ -34,53 +46,77 @@ type Store interface { DeleteOrganization(ctx context.Context, orgID string) error UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error) - CreateRepositoryPool(ctx context.Context, repoId string, param params.CreatePoolParams) (params.Pool, error) CreateOrganizationPool(ctx context.Context, orgId string, param params.CreatePoolParams) (params.Pool, error) - - GetRepositoryPool(ctx context.Context, repoID, poolID string) (params.Pool, error) GetOrganizationPool(ctx context.Context, orgID, poolID string) (params.Pool, error) + DeleteOrganizationPool(ctx context.Context, orgID, poolID string) error + UpdateOrganizationPool(ctx context.Context, orgID, poolID string, param params.UpdatePoolParams) (params.Pool, error) - ListRepoPools(ctx context.Context, repoID string) ([]params.Pool, error) + FindOrganizationPoolByTags(ctx context.Context, orgID string, tags []string) (params.Pool, error) ListOrgPools(ctx context.Context, orgID string) ([]params.Pool, error) + ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error) +} + +type EnterpriseStore interface { + CreateEnterprise(ctx context.Context, name, credentialsName, webhookSecret string) (params.Enterprise, error) + GetEnterprise(ctx context.Context, name string) (params.Enterprise, error) + GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error) + ListEnterprises(ctx context.Context) ([]params.Enterprise, error) + DeleteEnterprise(ctx context.Context, enterpriseID string) error + UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) + + CreateEnterprisePool(ctx context.Context, enterpriseID string, param params.CreatePoolParams) (params.Pool, error) + GetEnterprisePool(ctx context.Context, enterpriseID, poolID string) (params.Pool, error) + DeleteEnterprisePool(ctx context.Context, enterpriseID, poolID string) error + UpdateEnterprisePool(ctx context.Context, enterpriseID, poolID string, param params.UpdatePoolParams) (params.Pool, error) + + FindEnterprisePoolByTags(ctx context.Context, enterpriseID string, tags []string) (params.Pool, error) + ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error) + ListEnterpriseInstances(ctx context.Context, enterpriseID string) ([]params.Instance, error) +} + +type PoolStore interface { // Probably a bad idea without some king of filter or at least pagination // TODO: add filter/pagination ListAllPools(ctx context.Context) ([]params.Pool, error) GetPoolByID(ctx context.Context, poolID string) (params.Pool, error) DeletePoolByID(ctx context.Context, poolID string) error - DeleteRepositoryPool(ctx context.Context, repoID, poolID string) error - DeleteOrganizationPool(ctx context.Context, orgID, poolID string) error - - UpdateRepositoryPool(ctx context.Context, repoID, poolID string, param params.UpdatePoolParams) (params.Pool, error) - UpdateOrganizationPool(ctx context.Context, orgID, poolID string, param params.UpdatePoolParams) (params.Pool, error) - - FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error) - FindOrganizationPoolByTags(ctx context.Context, orgID string, tags []string) (params.Pool, error) - - CreateInstance(ctx context.Context, poolID string, param params.CreateInstanceParams) (params.Instance, error) - DeleteInstance(ctx context.Context, poolID string, instanceName string) error - UpdateInstance(ctx context.Context, instanceID string, param params.UpdateInstanceParams) (params.Instance, error) - ListPoolInstances(ctx context.Context, poolID string) ([]params.Instance, error) - ListRepoInstances(ctx context.Context, repoID string) ([]params.Instance, error) - ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error) PoolInstanceCount(ctx context.Context, poolID string) (int64, error) - - // Probably a bad idea without some king of filter or at least pagination - // TODO: add filter/pagination - ListAllInstances(ctx context.Context) ([]params.Instance, error) - GetPoolInstanceByName(ctx context.Context, poolID string, instanceName string) (params.Instance, error) - GetInstanceByName(ctx context.Context, instanceName string) (params.Instance, error) - AddInstanceStatusMessage(ctx context.Context, instanceID string, statusMessage string) error +} +type UserStore interface { GetUser(ctx context.Context, user string) (params.User, error) GetUserByID(ctx context.Context, userID string) (params.User, error) CreateUser(ctx context.Context, user params.NewUserParams) (params.User, error) UpdateUser(ctx context.Context, user string, param params.UpdateUserParams) (params.User, error) HasAdminUser(ctx context.Context) bool +} + +type InstanceStore interface { + CreateInstance(ctx context.Context, poolID string, param params.CreateInstanceParams) (params.Instance, error) + DeleteInstance(ctx context.Context, poolID string, instanceName string) error + UpdateInstance(ctx context.Context, instanceID string, param params.UpdateInstanceParams) (params.Instance, error) + + // Probably a bad idea without some king of filter or at least pagination + // TODO: add filter/pagination + ListAllInstances(ctx context.Context) ([]params.Instance, error) + + GetInstanceByName(ctx context.Context, instanceName string) (params.Instance, error) + AddInstanceStatusMessage(ctx context.Context, instanceID string, statusMessage string) error +} + +//go:generate mockery --name=Store +type Store interface { + RepoStore + OrgStore + EnterpriseStore + PoolStore + UserStore + InstanceStore ControllerInfo() (params.ControllerInfo, error) InitController() (params.ControllerInfo, error) diff --git a/database/common/mocks/Store.go b/database/common/mocks/Store.go index 22bc598b..27d7f86e 100644 --- a/database/common/mocks/Store.go +++ b/database/common/mocks/Store.go @@ -49,6 +49,48 @@ func (_m *Store) ControllerInfo() (params.ControllerInfo, error) { return r0, r1 } +// CreateEnterprise provides a mock function with given fields: ctx, name, credentialsName, webhookSecret +func (_m *Store) CreateEnterprise(ctx context.Context, name string, credentialsName string, webhookSecret string) (params.Enterprise, error) { + ret := _m.Called(ctx, name, credentialsName, webhookSecret) + + var r0 params.Enterprise + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) params.Enterprise); ok { + r0 = rf(ctx, name, credentialsName, webhookSecret) + } else { + r0 = ret.Get(0).(params.Enterprise) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, name, credentialsName, webhookSecret) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateEnterprisePool provides a mock function with given fields: ctx, enterpriseID, param +func (_m *Store) CreateEnterprisePool(ctx context.Context, enterpriseID string, param params.CreatePoolParams) (params.Pool, error) { + ret := _m.Called(ctx, enterpriseID, param) + + var r0 params.Pool + if rf, ok := ret.Get(0).(func(context.Context, string, params.CreatePoolParams) params.Pool); ok { + r0 = rf(ctx, enterpriseID, param) + } else { + r0 = ret.Get(0).(params.Pool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, params.CreatePoolParams) error); ok { + r1 = rf(ctx, enterpriseID, param) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // CreateInstance provides a mock function with given fields: ctx, poolID, param func (_m *Store) CreateInstance(ctx context.Context, poolID string, param params.CreateInstanceParams) (params.Instance, error) { ret := _m.Called(ctx, poolID, param) @@ -175,6 +217,34 @@ func (_m *Store) CreateUser(ctx context.Context, user params.NewUserParams) (par return r0, r1 } +// DeleteEnterprise provides a mock function with given fields: ctx, enterpriseID +func (_m *Store) DeleteEnterprise(ctx context.Context, enterpriseID string) error { + ret := _m.Called(ctx, enterpriseID) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, enterpriseID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// DeleteEnterprisePool provides a mock function with given fields: ctx, enterpriseID, poolID +func (_m *Store) DeleteEnterprisePool(ctx context.Context, enterpriseID string, poolID string) error { + ret := _m.Called(ctx, enterpriseID, poolID) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, enterpriseID, poolID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // DeleteInstance provides a mock function with given fields: ctx, poolID, instanceName func (_m *Store) DeleteInstance(ctx context.Context, poolID string, instanceName string) error { ret := _m.Called(ctx, poolID, instanceName) @@ -259,6 +329,27 @@ func (_m *Store) DeleteRepositoryPool(ctx context.Context, repoID string, poolID return r0 } +// FindEnterprisePoolByTags provides a mock function with given fields: ctx, enterpriseID, tags +func (_m *Store) FindEnterprisePoolByTags(ctx context.Context, enterpriseID string, tags []string) (params.Pool, error) { + ret := _m.Called(ctx, enterpriseID, tags) + + var r0 params.Pool + if rf, ok := ret.Get(0).(func(context.Context, string, []string) params.Pool); ok { + r0 = rf(ctx, enterpriseID, tags) + } else { + r0 = ret.Get(0).(params.Pool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, []string) error); ok { + r1 = rf(ctx, enterpriseID, tags) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // FindOrganizationPoolByTags provides a mock function with given fields: ctx, orgID, tags func (_m *Store) FindOrganizationPoolByTags(ctx context.Context, orgID string, tags []string) (params.Pool, error) { ret := _m.Called(ctx, orgID, tags) @@ -301,6 +392,69 @@ func (_m *Store) FindRepositoryPoolByTags(ctx context.Context, repoID string, ta return r0, r1 } +// GetEnterprise provides a mock function with given fields: ctx, name +func (_m *Store) GetEnterprise(ctx context.Context, name string) (params.Enterprise, error) { + ret := _m.Called(ctx, name) + + var r0 params.Enterprise + if rf, ok := ret.Get(0).(func(context.Context, string) params.Enterprise); ok { + r0 = rf(ctx, name) + } else { + r0 = ret.Get(0).(params.Enterprise) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetEnterpriseByID provides a mock function with given fields: ctx, enterpriseID +func (_m *Store) GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error) { + ret := _m.Called(ctx, enterpriseID) + + var r0 params.Enterprise + if rf, ok := ret.Get(0).(func(context.Context, string) params.Enterprise); ok { + r0 = rf(ctx, enterpriseID) + } else { + r0 = ret.Get(0).(params.Enterprise) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, enterpriseID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetEnterprisePool provides a mock function with given fields: ctx, enterpriseID, poolID +func (_m *Store) GetEnterprisePool(ctx context.Context, enterpriseID string, poolID string) (params.Pool, error) { + ret := _m.Called(ctx, enterpriseID, poolID) + + var r0 params.Pool + if rf, ok := ret.Get(0).(func(context.Context, string, string) params.Pool); ok { + r0 = rf(ctx, enterpriseID, poolID) + } else { + r0 = ret.Get(0).(params.Pool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, enterpriseID, poolID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetInstanceByName provides a mock function with given fields: ctx, instanceName func (_m *Store) GetInstanceByName(ctx context.Context, instanceName string) (params.Instance, error) { ret := _m.Called(ctx, instanceName) @@ -613,6 +767,75 @@ func (_m *Store) ListAllPools(ctx context.Context) ([]params.Pool, error) { return r0, r1 } +// ListEnterpriseInstances provides a mock function with given fields: ctx, enterpriseID +func (_m *Store) ListEnterpriseInstances(ctx context.Context, enterpriseID string) ([]params.Instance, error) { + ret := _m.Called(ctx, enterpriseID) + + var r0 []params.Instance + if rf, ok := ret.Get(0).(func(context.Context, string) []params.Instance); ok { + r0 = rf(ctx, enterpriseID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]params.Instance) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, enterpriseID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListEnterprisePools provides a mock function with given fields: ctx, enterpriseID +func (_m *Store) ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error) { + ret := _m.Called(ctx, enterpriseID) + + var r0 []params.Pool + if rf, ok := ret.Get(0).(func(context.Context, string) []params.Pool); ok { + r0 = rf(ctx, enterpriseID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]params.Pool) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, enterpriseID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ListEnterprises provides a mock function with given fields: ctx +func (_m *Store) ListEnterprises(ctx context.Context) ([]params.Enterprise, error) { + ret := _m.Called(ctx) + + var r0 []params.Enterprise + if rf, ok := ret.Get(0).(func(context.Context) []params.Enterprise); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]params.Enterprise) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ListOrgInstances provides a mock function with given fields: ctx, orgID func (_m *Store) ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error) { ret := _m.Called(ctx, orgID) @@ -795,6 +1018,48 @@ func (_m *Store) PoolInstanceCount(ctx context.Context, poolID string) (int64, e return r0, r1 } +// UpdateEnterprise provides a mock function with given fields: ctx, enterpriseID, param +func (_m *Store) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) { + ret := _m.Called(ctx, enterpriseID, param) + + var r0 params.Enterprise + if rf, ok := ret.Get(0).(func(context.Context, string, params.UpdateRepositoryParams) params.Enterprise); ok { + r0 = rf(ctx, enterpriseID, param) + } else { + r0 = ret.Get(0).(params.Enterprise) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, params.UpdateRepositoryParams) error); ok { + r1 = rf(ctx, enterpriseID, param) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// UpdateEnterprisePool provides a mock function with given fields: ctx, enterpriseID, poolID, param +func (_m *Store) UpdateEnterprisePool(ctx context.Context, enterpriseID string, poolID string, param params.UpdatePoolParams) (params.Pool, error) { + ret := _m.Called(ctx, enterpriseID, poolID, param) + + var r0 params.Pool + if rf, ok := ret.Get(0).(func(context.Context, string, string, params.UpdatePoolParams) params.Pool); ok { + r0 = rf(ctx, enterpriseID, poolID, param) + } else { + r0 = ret.Get(0).(params.Pool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, string, params.UpdatePoolParams) error); ok { + r1 = rf(ctx, enterpriseID, poolID, param) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // UpdateInstance provides a mock function with given fields: ctx, instanceID, param func (_m *Store) UpdateInstance(ctx context.Context, instanceID string, param params.UpdateInstanceParams) (params.Instance, error) { ret := _m.Called(ctx, instanceID, param) diff --git a/database/sql/enterprise.go b/database/sql/enterprise.go new file mode 100644 index 00000000..b41cf35b --- /dev/null +++ b/database/sql/enterprise.go @@ -0,0 +1,367 @@ +package sql + +import ( + "context" + "fmt" + runnerErrors "garm/errors" + "garm/params" + "garm/util" + + "github.com/pkg/errors" + uuid "github.com/satori/go.uuid" + "gorm.io/gorm" +) + +func (s *sqlDatabase) CreateEnterprise(ctx context.Context, name, credentialsName, webhookSecret string) (params.Enterprise, error) { + secret := []byte{} + var err error + if webhookSecret != "" { + secret, err = util.Aes256EncodeString(webhookSecret, s.cfg.Passphrase) + if err != nil { + return params.Enterprise{}, fmt.Errorf("failed to encrypt string") + } + } + newEnterprise := Enterprise{ + Name: name, + WebhookSecret: secret, + CredentialsName: credentialsName, + } + + q := s.conn.Create(&newEnterprise) + if q.Error != nil { + return params.Enterprise{}, errors.Wrap(q.Error, "creating enterprise") + } + + param := s.sqlToCommonEnterprise(newEnterprise) + param.WebhookSecret = webhookSecret + + return param, nil +} + +func (s *sqlDatabase) GetEnterprise(ctx context.Context, name string) (params.Enterprise, error) { + enterprise, err := s.getEnterprise(ctx, name) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") + } + + param := s.sqlToCommonEnterprise(enterprise) + secret, err := util.Aes256DecodeString(enterprise.WebhookSecret, s.cfg.Passphrase) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "decrypting secret") + } + param.WebhookSecret = secret + + return param, nil +} + +func (s *sqlDatabase) GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error) { + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID, "Pools") + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") + } + + param := s.sqlToCommonEnterprise(enterprise) + secret, err := util.Aes256DecodeString(enterprise.WebhookSecret, s.cfg.Passphrase) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "decrypting secret") + } + param.WebhookSecret = secret + + return param, nil +} + +func (s *sqlDatabase) ListEnterprises(ctx context.Context) ([]params.Enterprise, error) { + var enterprises []Enterprise + q := s.conn.Find(&enterprises) + if q.Error != nil { + return []params.Enterprise{}, errors.Wrap(q.Error, "fetching enterprise from database") + } + + ret := make([]params.Enterprise, len(enterprises)) + for idx, val := range enterprises { + ret[idx] = s.sqlToCommonEnterprise(val) + } + + return ret, nil +} + +func (s *sqlDatabase) DeleteEnterprise(ctx context.Context, enterpriseID string) error { + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID) + if err != nil { + return errors.Wrap(err, "fetching enterprise") + } + + q := s.conn.Unscoped().Delete(&enterprise) + if q.Error != nil && !errors.Is(q.Error, gorm.ErrRecordNotFound) { + return errors.Wrap(q.Error, "deleting enterprise") + } + + return nil +} + +func (s *sqlDatabase) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) { + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") + } + + if param.CredentialsName != "" { + enterprise.CredentialsName = param.CredentialsName + } + + if param.WebhookSecret != "" { + secret, err := util.Aes256EncodeString(param.WebhookSecret, s.cfg.Passphrase) + if err != nil { + return params.Enterprise{}, fmt.Errorf("failed to encrypt string") + } + enterprise.WebhookSecret = secret + } + + q := s.conn.Save(&enterprise) + if q.Error != nil { + return params.Enterprise{}, errors.Wrap(q.Error, "saving enterprise") + } + + newParams := s.sqlToCommonEnterprise(enterprise) + secret, err := util.Aes256DecodeString(enterprise.WebhookSecret, s.cfg.Passphrase) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "decrypting secret") + } + newParams.WebhookSecret = secret + return newParams, nil +} + +func (s *sqlDatabase) CreateEnterprisePool(ctx context.Context, enterpriseID string, param params.CreatePoolParams) (params.Pool, error) { + if len(param.Tags) == 0 { + return params.Pool{}, runnerErrors.NewBadRequestError("no tags specified") + } + + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching enterprise") + } + + newPool := Pool{ + ProviderName: param.ProviderName, + MaxRunners: param.MaxRunners, + MinIdleRunners: param.MinIdleRunners, + Image: param.Image, + Flavor: param.Flavor, + OSType: param.OSType, + OSArch: param.OSArch, + EnterpriseID: enterprise.ID, + Enabled: param.Enabled, + RunnerBootstrapTimeout: param.RunnerBootstrapTimeout, + } + + _, err = s.getEnterprisePoolByUniqueFields(ctx, enterpriseID, newPool.ProviderName, newPool.Image, newPool.Flavor) + if err != nil { + if !errors.Is(err, runnerErrors.ErrNotFound) { + return params.Pool{}, errors.Wrap(err, "creating pool") + } + } else { + return params.Pool{}, runnerErrors.NewConflictError("pool with the same image and flavor already exists on this provider") + } + + tags := []Tag{} + for _, val := range param.Tags { + t, err := s.getOrCreateTag(val) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching tag") + } + tags = append(tags, t) + } + + q := s.conn.Create(&newPool) + if q.Error != nil { + return params.Pool{}, errors.Wrap(q.Error, "adding pool") + } + + for _, tt := range tags { + if err := s.conn.Model(&newPool).Association("Tags").Append(&tt); err != nil { + return params.Pool{}, errors.Wrap(err, "saving tag") + } + } + + pool, err := s.getPoolByID(ctx, newPool.ID.String(), "Tags", "Instances", "Enterprise", "Organization", "Repository") + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + + return s.sqlToCommonPool(pool), nil +} + +func (s *sqlDatabase) GetEnterprisePool(ctx context.Context, enterpriseID, poolID string) (params.Pool, error) { + pool, err := s.getEnterprisePool(ctx, enterpriseID, poolID, "Tags", "Instances") + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + return s.sqlToCommonPool(pool), nil +} + +func (s *sqlDatabase) DeleteEnterprisePool(ctx context.Context, enterpriseID, poolID string) error { + pool, err := s.getEnterprisePool(ctx, enterpriseID, poolID) + if err != nil { + return errors.Wrap(err, "looking up enterprise pool") + } + q := s.conn.Unscoped().Delete(&pool) + if q.Error != nil && !errors.Is(q.Error, gorm.ErrRecordNotFound) { + return errors.Wrap(q.Error, "deleting pool") + } + return nil +} + +func (s *sqlDatabase) UpdateEnterprisePool(ctx context.Context, enterpriseID, poolID string, param params.UpdatePoolParams) (params.Pool, error) { + pool, err := s.getEnterprisePool(ctx, enterpriseID, poolID, "Tags", "Instances", "Enterprise", "Organization", "Repository") + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + + return s.updatePool(pool, param) +} + +func (s *sqlDatabase) FindEnterprisePoolByTags(ctx context.Context, enterpriseID string, tags []string) (params.Pool, error) { + pool, err := s.findPoolByTags(enterpriseID, "enterprise_id", tags) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + return pool, nil +} + +func (s *sqlDatabase) ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error) { + pools, err := s.getEnterprisePools(ctx, enterpriseID, "Tags") + if err != nil { + return nil, errors.Wrap(err, "fetching pools") + } + + ret := make([]params.Pool, len(pools)) + for idx, pool := range pools { + ret[idx] = s.sqlToCommonPool(pool) + } + + return ret, nil +} + +func (s *sqlDatabase) ListEnterpriseInstances(ctx context.Context, enterpriseID string) ([]params.Instance, error) { + pools, err := s.getEnterprisePools(ctx, enterpriseID, "Instances") + if err != nil { + return nil, errors.Wrap(err, "fetching enterprise") + } + ret := []params.Instance{} + for _, pool := range pools { + for _, instance := range pool.Instances { + ret = append(ret, s.sqlToParamsInstance(instance)) + } + } + return ret, nil +} + +func (s *sqlDatabase) getEnterprise(ctx context.Context, name string) (Enterprise, error) { + var enterprise Enterprise + + q := s.conn.Where("name = ? COLLATE NOCASE", name) + q = q.First(&enterprise) + if q.Error != nil { + if errors.Is(q.Error, gorm.ErrRecordNotFound) { + return Enterprise{}, runnerErrors.ErrNotFound + } + return Enterprise{}, errors.Wrap(q.Error, "fetching enterprise from database") + } + return enterprise, nil +} + +func (s *sqlDatabase) getEnterpriseByID(ctx context.Context, id string, preload ...string) (Enterprise, error) { + u, err := uuid.FromString(id) + if err != nil { + return Enterprise{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id") + } + var enterprise Enterprise + + q := s.conn + if len(preload) > 0 { + for _, field := range preload { + q = q.Preload(field) + } + } + q = q.Where("id = ?", u).First(&enterprise) + + if q.Error != nil { + if errors.Is(q.Error, gorm.ErrRecordNotFound) { + return Enterprise{}, runnerErrors.ErrNotFound + } + return Enterprise{}, errors.Wrap(q.Error, "fetching enterprise from database") + } + return enterprise, nil +} + +func (s *sqlDatabase) getEnterprisePoolByUniqueFields(ctx context.Context, enterpriseID string, provider, image, flavor string) (Pool, error) { + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID) + if err != nil { + return Pool{}, errors.Wrap(err, "fetching enterprise") + } + + q := s.conn + var pool []Pool + err = q.Model(&enterprise).Association("Pools").Find(&pool, "provider_name = ? and image = ? and flavor = ?", provider, image, flavor) + if err != nil { + return Pool{}, errors.Wrap(err, "fetching pool") + } + if len(pool) == 0 { + return Pool{}, runnerErrors.ErrNotFound + } + + return pool[0], nil +} + +func (s *sqlDatabase) getEnterprisePool(ctx context.Context, enterpriseID, poolID string, preload ...string) (Pool, error) { + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID) + if err != nil { + return Pool{}, errors.Wrap(err, "fetching enterprise") + } + + u, err := uuid.FromString(poolID) + if err != nil { + return Pool{}, errors.Wrap(runnerErrors.ErrBadRequest, "parsing id") + } + + q := s.conn + if len(preload) > 0 { + for _, item := range preload { + q = q.Preload(item) + } + } + + var pool []Pool + err = q.Model(&enterprise).Association("Pools").Find(&pool, "id = ?", u) + if err != nil { + return Pool{}, errors.Wrap(err, "fetching pool") + } + if len(pool) == 0 { + return Pool{}, runnerErrors.ErrNotFound + } + + return pool[0], nil +} + +func (s *sqlDatabase) getEnterprisePools(ctx context.Context, enterpriseID string, preload ...string) ([]Pool, error) { + enterprise, err := s.getEnterpriseByID(ctx, enterpriseID) + if err != nil { + return nil, errors.Wrap(err, "fetching enterprise") + } + + var pools []Pool + + q := s.conn.Model(&enterprise) + if len(preload) > 0 { + for _, item := range preload { + q = q.Preload(item) + } + } + err = q.Association("Pools").Find(&pools) + + if err != nil { + return nil, errors.Wrap(err, "fetching pool") + } + + return pools, nil +} diff --git a/database/sql/models.go b/database/sql/models.go index bb88bda9..523c258b 100644 --- a/database/sql/models.go +++ b/database/sql/models.go @@ -71,6 +71,9 @@ type Pool struct { OrgID uuid.UUID `gorm:"index"` Organization Organization `gorm:"foreignKey:OrgID"` + EnterpriseID uuid.UUID `gorm:"index"` + Enterprise Enterprise `gorm:"foreignKey:EnterpriseID"` + Instances []Instance `gorm:"foreignKey:PoolID"` } @@ -93,6 +96,15 @@ type Organization struct { Pools []Pool `gorm:"foreignKey:OrgID"` } +type Enterprise struct { + Base + + CredentialsName string + Name string `gorm:"index:idx_ent_name_nocase,collate:nocase"` + WebhookSecret []byte + Pools []Pool `gorm:"foreignKey:EnterpriseID"` +} + type Address struct { Base diff --git a/database/sql/organizations.go b/database/sql/organizations.go index 78f989fa..35b4b241 100644 --- a/database/sql/organizations.go +++ b/database/sql/organizations.go @@ -72,7 +72,7 @@ func (s *sqlDatabase) ListOrganizations(ctx context.Context) ([]params.Organizat var orgs []Organization q := s.conn.Find(&orgs) if q.Error != nil { - return []params.Organization{}, errors.Wrap(q.Error, "fetching user from database") + return []params.Organization{}, errors.Wrap(q.Error, "fetching org from database") } ret := make([]params.Organization, len(orgs)) @@ -197,7 +197,7 @@ func (s *sqlDatabase) CreateOrganizationPool(ctx context.Context, orgId string, } } - pool, err := s.getPoolByID(ctx, newPool.ID.String(), "Tags", "Instances", "Organization", "Repository") + pool, err := s.getPoolByID(ctx, newPool.ID.String(), "Tags", "Instances", "Enterprise", "Organization", "Repository") if err != nil { return params.Pool{}, errors.Wrap(err, "fetching pool") } @@ -262,7 +262,7 @@ func (s *sqlDatabase) ListOrgInstances(ctx context.Context, orgID string) ([]par } func (s *sqlDatabase) UpdateOrganizationPool(ctx context.Context, orgID, poolID string, param params.UpdatePoolParams) (params.Pool, error) { - pool, err := s.getOrgPool(ctx, orgID, poolID, "Tags", "Instances", "Organization", "Repository") + pool, err := s.getOrgPool(ctx, orgID, poolID, "Tags", "Instances", "Enterprise", "Organization", "Repository") if err != nil { return params.Pool{}, errors.Wrap(err, "fetching pool") } diff --git a/database/sql/pools.go b/database/sql/pools.go index aac66a93..ae9f10ca 100644 --- a/database/sql/pools.go +++ b/database/sql/pools.go @@ -42,7 +42,7 @@ func (s *sqlDatabase) ListAllPools(ctx context.Context) ([]params.Pool, error) { } func (s *sqlDatabase) GetPoolByID(ctx context.Context, poolID string) (params.Pool, error) { - pool, err := s.getPoolByID(ctx, poolID, "Tags", "Instances", "Organization", "Repository") + pool, err := s.getPoolByID(ctx, poolID, "Tags", "Instances", "Enterprise", "Organization", "Repository") if err != nil { return params.Pool{}, errors.Wrap(err, "fetching pool by ID") } diff --git a/database/sql/repositories.go b/database/sql/repositories.go index f1d61426..73cf4295 100644 --- a/database/sql/repositories.go +++ b/database/sql/repositories.go @@ -205,7 +205,7 @@ func (s *sqlDatabase) CreateRepositoryPool(ctx context.Context, repoId string, p } } - pool, err := s.getPoolByID(ctx, newPool.ID.String(), "Tags", "Instances", "Organization", "Repository") + pool, err := s.getPoolByID(ctx, newPool.ID.String(), "Tags", "Instances", "Enterprise", "Organization", "Repository") if err != nil { return params.Pool{}, errors.Wrap(err, "fetching pool") } @@ -271,7 +271,7 @@ func (s *sqlDatabase) ListRepoInstances(ctx context.Context, repoID string) ([]p } func (s *sqlDatabase) UpdateRepositoryPool(ctx context.Context, repoID, poolID string, param params.UpdatePoolParams) (params.Pool, error) { - pool, err := s.getRepoPool(ctx, repoID, poolID, "Tags", "Instances", "Organization", "Repository") + pool, err := s.getRepoPool(ctx, repoID, poolID, "Tags", "Instances", "Enterprise", "Organization", "Repository") if err != nil { return params.Pool{}, errors.Wrap(err, "fetching pool") } diff --git a/database/sql/sql.go b/database/sql/sql.go index a523d354..440d5e7c 100644 --- a/database/sql/sql.go +++ b/database/sql/sql.go @@ -96,13 +96,14 @@ func (s *sqlDatabase) migrateDB() error { &Pool{}, &Repository{}, &Organization{}, + &Enterprise{}, &Address{}, &InstanceStatusUpdate{}, &Instance{}, &ControllerInfo{}, &User{}, ); err != nil { - return err + return errors.Wrap(err, "running auto migrate") } return nil diff --git a/database/sql/util.go b/database/sql/util.go index 40f640ba..484fcb8d 100644 --- a/database/sql/util.go +++ b/database/sql/util.go @@ -85,6 +85,21 @@ func (s *sqlDatabase) sqlToCommonOrganization(org Organization) params.Organizat return ret } +func (s *sqlDatabase) sqlToCommonEnterprise(enterprise Enterprise) params.Enterprise { + ret := params.Enterprise{ + ID: enterprise.ID.String(), + Name: enterprise.Name, + CredentialsName: enterprise.CredentialsName, + Pools: make([]params.Pool, len(enterprise.Pools)), + } + + for idx, pool := range enterprise.Pools { + ret.Pools[idx] = s.sqlToCommonPool(pool) + } + + return ret +} + func (s *sqlDatabase) sqlToCommonPool(pool Pool) params.Pool { ret := params.Pool{ ID: pool.ID.String(), diff --git a/go.mod b/go.mod index 316f65d9..745a51a0 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/BurntSushi/toml v0.4.1 github.com/go-resty/resty/v2 v2.7.0 github.com/golang-jwt/jwt v3.2.2+incompatible - github.com/google/go-github/v43 v43.0.0 + github.com/google/go-github/v47 v47.1.0 github.com/google/uuid v1.3.0 github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 @@ -71,3 +71,5 @@ require ( gopkg.in/macaroon-bakery.v2 v2.3.0 // indirect gopkg.in/macaroon.v2 v2.1.0 // indirect ) + +replace github.com/google/go-github/v47 => github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 diff --git a/go.sum b/go.sum index 6b59fc3e..09a99715 100644 --- a/go.sum +++ b/go.sum @@ -64,6 +64,8 @@ github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03D github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 h1:CNZ1asZM2ABO6DLFPS86CkGMEp5nFSQnpAECOOhYBGo= +github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1/go.mod h1:VPZBXNbFSJGjyjFRUKo9vZGawTajnWzC/YjGw/oFKi0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -116,9 +118,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= -github.com/google/go-github/v43 v43.0.0 h1:y+GL7LIsAIF2NZlJ46ZoC/D1W1ivZasT0lnWHMYPZ+U= -github.com/google/go-github/v43 v43.0.0/go.mod h1:ZkTvvmCXBvsfPpTHXnH/d2hP9Y0cTbvN9kr5xqyXOIc= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -438,7 +438,6 @@ golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= diff --git a/params/params.go b/params/params.go index 8f1f78ba..ae24ac78 100644 --- a/params/params.go +++ b/params/params.go @@ -19,7 +19,7 @@ import ( "garm/runner/providers/common" "time" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" uuid "github.com/satori/go.uuid" ) @@ -167,6 +167,15 @@ type Organization struct { WebhookSecret string `json:"-"` } +type Enterprise struct { + ID string `json:"id"` + Name string `json:"name"` + Pools []Pool `json:"pool,omitempty"` + CredentialsName string `json:"credentials_name"` + // Do not serialize sensitive info. + WebhookSecret string `json:"-"` +} + // Users holds information about a particular user type User struct { ID string `json:"id"` diff --git a/params/requests.go b/params/requests.go index a99159df..e2ded969 100644 --- a/params/requests.go +++ b/params/requests.go @@ -66,6 +66,23 @@ func (c *CreateOrgParams) Validate() error { return nil } +type CreateEnterpriseParams struct { + Name string `json:"name"` + CredentialsName string `json:"credentials_name"` + WebhookSecret string `json:"webhook_secret"` +} + +func (c *CreateEnterpriseParams) Validate() error { + if c.Name == "" { + return errors.NewBadRequestError("missing org name") + } + + if c.CredentialsName == "" { + return errors.NewBadRequestError("missing credentials name") + } + return nil +} + // NewUserParams holds the needed information to create // a new user type NewUserParams struct { diff --git a/runner/common/mocks/GithubClient.go b/runner/common/mocks/GithubClient.go index 58b8c0c4..4f1ae8dc 100644 --- a/runner/common/mocks/GithubClient.go +++ b/runner/common/mocks/GithubClient.go @@ -5,7 +5,7 @@ package mocks import ( context "context" - github "github.com/google/go-github/v43/github" + github "github.com/google/go-github/v47/github" mock "github.com/stretchr/testify/mock" ) @@ -78,6 +78,38 @@ func (_m *GithubClient) CreateRegistrationToken(ctx context.Context, owner strin return r0, r1, r2 } +// GetWorkflowJobByID provides a mock function with given fields: ctx, owner, repo, jobID +func (_m *GithubClient) GetWorkflowJobByID(ctx context.Context, owner string, repo string, jobID int64) (*github.WorkflowJob, *github.Response, error) { + ret := _m.Called(ctx, owner, repo, jobID) + + var r0 *github.WorkflowJob + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) *github.WorkflowJob); ok { + r0 = rf(ctx, owner, repo, jobID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*github.WorkflowJob) + } + } + + var r1 *github.Response + if rf, ok := ret.Get(1).(func(context.Context, string, string, int64) *github.Response); ok { + r1 = rf(ctx, owner, repo, jobID) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*github.Response) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string, string, int64) error); ok { + r2 = rf(ctx, owner, repo, jobID) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + // ListOrganizationRunnerApplicationDownloads provides a mock function with given fields: ctx, owner func (_m *GithubClient) ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*github.RunnerApplicationDownload, *github.Response, error) { ret := _m.Called(ctx, owner) diff --git a/runner/common/mocks/GithubEnterpriseClient.go b/runner/common/mocks/GithubEnterpriseClient.go new file mode 100644 index 00000000..c7cea9c4 --- /dev/null +++ b/runner/common/mocks/GithubEnterpriseClient.go @@ -0,0 +1,149 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + + github "github.com/google/go-github/v47/github" + mock "github.com/stretchr/testify/mock" +) + +// GithubEnterpriseClient is an autogenerated mock type for the GithubEnterpriseClient type +type GithubEnterpriseClient struct { + mock.Mock +} + +// CreateRegistrationToken provides a mock function with given fields: ctx, enterprise +func (_m *GithubEnterpriseClient) CreateRegistrationToken(ctx context.Context, enterprise string) (*github.RegistrationToken, *github.Response, error) { + ret := _m.Called(ctx, enterprise) + + var r0 *github.RegistrationToken + if rf, ok := ret.Get(0).(func(context.Context, string) *github.RegistrationToken); ok { + r0 = rf(ctx, enterprise) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*github.RegistrationToken) + } + } + + var r1 *github.Response + if rf, ok := ret.Get(1).(func(context.Context, string) *github.Response); ok { + r1 = rf(ctx, enterprise) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*github.Response) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, enterprise) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ListRunnerApplicationDownloads provides a mock function with given fields: ctx, enterprise +func (_m *GithubEnterpriseClient) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*github.RunnerApplicationDownload, *github.Response, error) { + ret := _m.Called(ctx, enterprise) + + var r0 []*github.RunnerApplicationDownload + if rf, ok := ret.Get(0).(func(context.Context, string) []*github.RunnerApplicationDownload); ok { + r0 = rf(ctx, enterprise) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*github.RunnerApplicationDownload) + } + } + + var r1 *github.Response + if rf, ok := ret.Get(1).(func(context.Context, string) *github.Response); ok { + r1 = rf(ctx, enterprise) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*github.Response) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string) error); ok { + r2 = rf(ctx, enterprise) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// ListRunners provides a mock function with given fields: ctx, enterprise, opts +func (_m *GithubEnterpriseClient) ListRunners(ctx context.Context, enterprise string, opts *github.ListOptions) (*github.Runners, *github.Response, error) { + ret := _m.Called(ctx, enterprise, opts) + + var r0 *github.Runners + if rf, ok := ret.Get(0).(func(context.Context, string, *github.ListOptions) *github.Runners); ok { + r0 = rf(ctx, enterprise, opts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*github.Runners) + } + } + + var r1 *github.Response + if rf, ok := ret.Get(1).(func(context.Context, string, *github.ListOptions) *github.Response); ok { + r1 = rf(ctx, enterprise, opts) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).(*github.Response) + } + } + + var r2 error + if rf, ok := ret.Get(2).(func(context.Context, string, *github.ListOptions) error); ok { + r2 = rf(ctx, enterprise, opts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// RemoveRunner provides a mock function with given fields: ctx, enterprise, runnerID +func (_m *GithubEnterpriseClient) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*github.Response, error) { + ret := _m.Called(ctx, enterprise, runnerID) + + var r0 *github.Response + if rf, ok := ret.Get(0).(func(context.Context, string, int64) *github.Response); ok { + r0 = rf(ctx, enterprise, runnerID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*github.Response) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, string, int64) error); ok { + r1 = rf(ctx, enterprise, runnerID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +type mockConstructorTestingTNewGithubEnterpriseClient interface { + mock.TestingT + Cleanup(func()) +} + +// NewGithubEnterpriseClient creates a new instance of GithubEnterpriseClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewGithubEnterpriseClient(t mockConstructorTestingTNewGithubEnterpriseClient) *GithubEnterpriseClient { + mock := &GithubEnterpriseClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/runner/common/pool.go b/runner/common/pool.go index ca4e31e2..f4cba170 100644 --- a/runner/common/pool.go +++ b/runner/common/pool.go @@ -32,6 +32,7 @@ const ( PoolToolUpdateInterval = 50 * time.Minute ) +//go:generate mockery --all type PoolManager interface { ID() string WebhookSecret() string diff --git a/runner/common/provider.go b/runner/common/provider.go index 510f4b3f..6575dd4f 100644 --- a/runner/common/provider.go +++ b/runner/common/provider.go @@ -19,6 +19,7 @@ import ( "garm/params" ) +//go:generate mockery --all type Provider interface { // CreateInstance creates a new compute instance in the provider. CreateInstance(ctx context.Context, bootstrapParams params.BootstrapInstance) (params.Instance, error) diff --git a/runner/common/util.go b/runner/common/util.go index 4a848ee3..16ee2133 100644 --- a/runner/common/util.go +++ b/runner/common/util.go @@ -3,11 +3,13 @@ package common import ( "context" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" ) // GithubClient that describes the minimum list of functions we need to interact with github. // Allows for easier testing. +// +//go:generate mockery --all type GithubClient interface { // GetWorkflowJobByID gets details about a single workflow job. GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*github.WorkflowJob, *github.Response, error) @@ -31,3 +33,15 @@ type GithubClient interface { // CreateOrganizationRegistrationToken creates a runner registration token for an organization. CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*github.RegistrationToken, *github.Response, error) } + +type GithubEnterpriseClient interface { + // ListRunners lists all runners within a repository. + ListRunners(ctx context.Context, enterprise string, opts *github.ListOptions) (*github.Runners, *github.Response, error) + // RemoveRunner removes one runner from an enterprise. + RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*github.Response, error) + // CreateRegistrationToken creates a runner registration token for an enterprise. + CreateRegistrationToken(ctx context.Context, enterprise string) (*github.RegistrationToken, *github.Response, error) + // ListRunnerApplicationDownloads returns a list of github runner application downloads for the + // various supported operating systems and architectures. + ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*github.RunnerApplicationDownload, *github.Response, error) +} diff --git a/runner/enterprises.go b/runner/enterprises.go new file mode 100644 index 00000000..7750b91e --- /dev/null +++ b/runner/enterprises.go @@ -0,0 +1,313 @@ +package runner + +import ( + "context" + "garm/auth" + "garm/config" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" + "log" + "strings" + + "github.com/pkg/errors" +) + +func (r *Runner) CreateEnterprise(ctx context.Context, param params.CreateEnterpriseParams) (enterprise params.Enterprise, err error) { + if !auth.IsAdmin(ctx) { + return enterprise, runnerErrors.ErrUnauthorized + } + + err = param.Validate() + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "validating params") + } + + creds, ok := r.credentials[param.CredentialsName] + if !ok { + return params.Enterprise{}, runnerErrors.NewBadRequestError("credentials %s not defined", param.CredentialsName) + } + + _, err = r.store.GetEnterprise(ctx, param.Name) + if err != nil { + if !errors.Is(err, runnerErrors.ErrNotFound) { + return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") + } + } else { + return params.Enterprise{}, runnerErrors.NewConflictError("enterprise %s already exists", param.Name) + } + + enterprise, err = r.store.CreateEnterprise(ctx, param.Name, creds.Name, param.WebhookSecret) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "creating enterprise") + } + + defer func() { + if err != nil { + r.store.DeleteEnterprise(ctx, enterprise.ID) + } + }() + + var poolMgr common.PoolManager + poolMgr, err = r.poolManagerCtrl.CreateEnterprisePoolManager(r.ctx, enterprise, r.providers, r.store) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "creating enterprise pool manager") + } + if err := poolMgr.Start(); err != nil { + if deleteErr := r.poolManagerCtrl.DeleteEnterprisePoolManager(enterprise); deleteErr != nil { + log.Printf("failed to cleanup pool manager for enterprise %s", enterprise.ID) + } + return params.Enterprise{}, errors.Wrap(err, "starting enterprise pool manager") + } + return enterprise, nil +} + +func (r *Runner) ListEnterprises(ctx context.Context) ([]params.Enterprise, error) { + if !auth.IsAdmin(ctx) { + return nil, runnerErrors.ErrUnauthorized + } + + enterprises, err := r.store.ListEnterprises(ctx) + if err != nil { + return nil, errors.Wrap(err, "listing enterprises") + } + + return enterprises, nil +} + +func (r *Runner) GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error) { + if !auth.IsAdmin(ctx) { + return params.Enterprise{}, runnerErrors.ErrUnauthorized + } + + enterprise, err := r.store.GetEnterpriseByID(ctx, enterpriseID) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") + } + return enterprise, nil +} + +func (r *Runner) DeleteEnterprise(ctx context.Context, enterpriseID string) error { + if !auth.IsAdmin(ctx) { + return runnerErrors.ErrUnauthorized + } + + enterprise, err := r.store.GetEnterpriseByID(ctx, enterpriseID) + if err != nil { + return errors.Wrap(err, "fetching enterprise") + } + + pools, err := r.store.ListEnterprisePools(ctx, enterpriseID) + if err != nil { + return errors.Wrap(err, "fetching enterprise pools") + } + + if len(pools) > 0 { + poolIds := []string{} + for _, pool := range pools { + poolIds = append(poolIds, pool.ID) + } + + return runnerErrors.NewBadRequestError("enterprise has pools defined (%s)", strings.Join(poolIds, ", ")) + } + + if err := r.poolManagerCtrl.DeleteEnterprisePoolManager(enterprise); err != nil { + return errors.Wrap(err, "deleting enterprise pool manager") + } + + if err := r.store.DeleteEnterprise(ctx, enterpriseID); err != nil { + return errors.Wrapf(err, "removing enterprise %s", enterpriseID) + } + return nil +} + +func (r *Runner) UpdateEnterprise(ctx context.Context, enterpriseID string, param params.UpdateRepositoryParams) (params.Enterprise, error) { + if !auth.IsAdmin(ctx) { + return params.Enterprise{}, runnerErrors.ErrUnauthorized + } + + r.mux.Lock() + defer r.mux.Unlock() + + enterprise, err := r.store.GetEnterpriseByID(ctx, enterpriseID) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") + } + + if param.CredentialsName != "" { + // Check that credentials are set before saving to db + if _, ok := r.credentials[param.CredentialsName]; !ok { + return params.Enterprise{}, runnerErrors.NewBadRequestError("invalid credentials (%s) for enterprise %s", param.CredentialsName, enterprise.Name) + } + } + + enterprise, err = r.store.UpdateEnterprise(ctx, enterpriseID, param) + if err != nil { + return params.Enterprise{}, errors.Wrap(err, "updating enterprise") + } + + poolMgr, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise) + if err != nil { + newState := params.UpdatePoolStateParams{ + WebhookSecret: enterprise.WebhookSecret, + } + // stop the pool mgr + if err := poolMgr.RefreshState(newState); err != nil { + return params.Enterprise{}, errors.Wrap(err, "updating enterprise pool manager") + } + } else { + if _, err := r.poolManagerCtrl.CreateEnterprisePoolManager(r.ctx, enterprise, r.providers, r.store); err != nil { + return params.Enterprise{}, errors.Wrap(err, "creating enterprise pool manager") + } + } + + return enterprise, nil +} + +func (r *Runner) CreateEnterprisePool(ctx context.Context, enterpriseID string, param params.CreatePoolParams) (params.Pool, error) { + if !auth.IsAdmin(ctx) { + return params.Pool{}, runnerErrors.ErrUnauthorized + } + + r.mux.Lock() + defer r.mux.Unlock() + + enterprise, err := r.store.GetEnterpriseByID(ctx, enterpriseID) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching enterprise") + } + + if _, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise); err != nil { + return params.Pool{}, runnerErrors.ErrNotFound + } + + createPoolParams, err := r.appendTagsToCreatePoolParams(param) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool params") + } + + if param.RunnerBootstrapTimeout == 0 { + param.RunnerBootstrapTimeout = config.DefaultRunnerBootstrapTimeout + } + + pool, err := r.store.CreateEnterprisePool(ctx, enterpriseID, createPoolParams) + if err != nil { + return params.Pool{}, errors.Wrap(err, "creating pool") + } + + return pool, nil +} + +func (r *Runner) GetEnterprisePoolByID(ctx context.Context, enterpriseID, poolID string) (params.Pool, error) { + if !auth.IsAdmin(ctx) { + return params.Pool{}, runnerErrors.ErrUnauthorized + } + + pool, err := r.store.GetEnterprisePool(ctx, enterpriseID, poolID) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + return pool, nil +} + +func (r *Runner) DeleteEnterprisePool(ctx context.Context, enterpriseID, poolID string) error { + if !auth.IsAdmin(ctx) { + return runnerErrors.ErrUnauthorized + } + + // TODO: dedup instance count verification + pool, err := r.store.GetEnterprisePool(ctx, enterpriseID, poolID) + if err != nil { + return errors.Wrap(err, "fetching pool") + } + + instances, err := r.store.ListPoolInstances(ctx, pool.ID) + if err != nil { + return errors.Wrap(err, "fetching instances") + } + + // TODO: implement a count function + if len(instances) > 0 { + runnerIDs := []string{} + for _, run := range instances { + runnerIDs = append(runnerIDs, run.ID) + } + return runnerErrors.NewBadRequestError("pool has runners: %s", strings.Join(runnerIDs, ", ")) + } + + if err := r.store.DeleteEnterprisePool(ctx, enterpriseID, poolID); err != nil { + return errors.Wrap(err, "deleting pool") + } + return nil +} + +func (r *Runner) ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error) { + if !auth.IsAdmin(ctx) { + return []params.Pool{}, runnerErrors.ErrUnauthorized + } + + pools, err := r.store.ListEnterprisePools(ctx, enterpriseID) + if err != nil { + return nil, errors.Wrap(err, "fetching pools") + } + return pools, nil +} + +func (r *Runner) UpdateEnterprisePool(ctx context.Context, enterpriseID, poolID string, param params.UpdatePoolParams) (params.Pool, error) { + if !auth.IsAdmin(ctx) { + return params.Pool{}, runnerErrors.ErrUnauthorized + } + + pool, err := r.store.GetEnterprisePool(ctx, enterpriseID, poolID) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + + maxRunners := pool.MaxRunners + minIdleRunners := pool.MinIdleRunners + + if param.MaxRunners != nil { + maxRunners = *param.MaxRunners + } + if param.MinIdleRunners != nil { + minIdleRunners = *param.MinIdleRunners + } + + if minIdleRunners > maxRunners { + return params.Pool{}, runnerErrors.NewBadRequestError("min_idle_runners cannot be larger than max_runners") + } + + newPool, err := r.store.UpdateEnterprisePool(ctx, enterpriseID, poolID, param) + if err != nil { + return params.Pool{}, errors.Wrap(err, "updating pool") + } + return newPool, nil +} + +func (r *Runner) ListEnterpriseInstances(ctx context.Context, enterpriseID string) ([]params.Instance, error) { + if !auth.IsAdmin(ctx) { + return nil, runnerErrors.ErrUnauthorized + } + + instances, err := r.store.ListEnterpriseInstances(ctx, enterpriseID) + if err != nil { + return []params.Instance{}, errors.Wrap(err, "fetching instances") + } + return instances, nil +} + +func (r *Runner) findEnterprisePoolManager(name string) (common.PoolManager, error) { + r.mux.Lock() + defer r.mux.Unlock() + + enterprise, err := r.store.GetEnterprise(r.ctx, name) + if err != nil { + return nil, errors.Wrap(err, "fetching enterprise") + } + + poolManager, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise) + if err != nil { + return nil, errors.Wrap(err, "fetching pool manager for enterprise") + } + return poolManager, nil +} diff --git a/runner/interfaces.go b/runner/interfaces.go index 9bb375c3..d7ccc0a8 100644 --- a/runner/interfaces.go +++ b/runner/interfaces.go @@ -21,16 +21,31 @@ import ( "garm/runner/common" ) -//go:generate mockery --name=PoolManagerController - -type PoolManagerController interface { +type RepoPoolManager interface { CreateRepoPoolManager(ctx context.Context, repo params.Repository, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) GetRepoPoolManager(repo params.Repository) (common.PoolManager, error) DeleteRepoPoolManager(repo params.Repository) error GetRepoPoolManagers() (map[string]common.PoolManager, error) +} +type OrgPoolManager interface { CreateOrgPoolManager(ctx context.Context, org params.Organization, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) GetOrgPoolManager(org params.Organization) (common.PoolManager, error) DeleteOrgPoolManager(org params.Organization) error GetOrgPoolManagers() (map[string]common.PoolManager, error) } + +type EnterprisePoolManager interface { + CreateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) + GetEnterprisePoolManager(enterprise params.Enterprise) (common.PoolManager, error) + DeleteEnterprisePoolManager(enterprise params.Enterprise) error + GetEnterprisePoolManagers() (map[string]common.PoolManager, error) +} + +//go:generate mockery --name=PoolManagerController + +type PoolManagerController interface { + RepoPoolManager + OrgPoolManager + EnterprisePoolManager +} diff --git a/runner/mocks/poolManagerController.go b/runner/mocks/PoolManagerController.go similarity index 69% rename from runner/mocks/poolManagerController.go rename to runner/mocks/PoolManagerController.go index 6229ff6a..a310f483 100644 --- a/runner/mocks/poolManagerController.go +++ b/runner/mocks/PoolManagerController.go @@ -18,6 +18,29 @@ type PoolManagerController struct { mock.Mock } +// CreateEnterprisePoolManager provides a mock function with given fields: ctx, enterprise, providers, store +func (_m *PoolManagerController) CreateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) { + ret := _m.Called(ctx, enterprise, providers, store) + + var r0 common.PoolManager + if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise, map[string]common.Provider, databasecommon.Store) common.PoolManager); ok { + r0 = rf(ctx, enterprise, providers, store) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, params.Enterprise, map[string]common.Provider, databasecommon.Store) error); ok { + r1 = rf(ctx, enterprise, providers, store) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // CreateOrgPoolManager provides a mock function with given fields: ctx, org, providers, store func (_m *PoolManagerController) CreateOrgPoolManager(ctx context.Context, org params.Organization, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) { ret := _m.Called(ctx, org, providers, store) @@ -64,6 +87,20 @@ func (_m *PoolManagerController) CreateRepoPoolManager(ctx context.Context, repo return r0, r1 } +// DeleteEnterprisePoolManager provides a mock function with given fields: enterprise +func (_m *PoolManagerController) DeleteEnterprisePoolManager(enterprise params.Enterprise) error { + ret := _m.Called(enterprise) + + var r0 error + if rf, ok := ret.Get(0).(func(params.Enterprise) error); ok { + r0 = rf(enterprise) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // DeleteOrgPoolManager provides a mock function with given fields: org func (_m *PoolManagerController) DeleteOrgPoolManager(org params.Organization) error { ret := _m.Called(org) @@ -92,6 +129,52 @@ func (_m *PoolManagerController) DeleteRepoPoolManager(repo params.Repository) e return r0 } +// GetEnterprisePoolManager provides a mock function with given fields: enterprise +func (_m *PoolManagerController) GetEnterprisePoolManager(enterprise params.Enterprise) (common.PoolManager, error) { + ret := _m.Called(enterprise) + + var r0 common.PoolManager + if rf, ok := ret.Get(0).(func(params.Enterprise) common.PoolManager); ok { + r0 = rf(enterprise) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(params.Enterprise) error); ok { + r1 = rf(enterprise) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetEnterprisePoolManagers provides a mock function with given fields: +func (_m *PoolManagerController) GetEnterprisePoolManagers() (map[string]common.PoolManager, error) { + ret := _m.Called() + + var r0 map[string]common.PoolManager + if rf, ok := ret.Get(0).(func() map[string]common.PoolManager); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetOrgPoolManager provides a mock function with given fields: org func (_m *PoolManagerController) GetOrgPoolManager(org params.Organization) (common.PoolManager, error) { ret := _m.Called(org) diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go new file mode 100644 index 00000000..e829d2a8 --- /dev/null +++ b/runner/pool/enterprise.go @@ -0,0 +1,201 @@ +package pool + +import ( + "context" + "fmt" + "math" + "strings" + "sync" + + dbCommon "garm/database/common" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" + "garm/util" + + "github.com/google/go-github/v47/github" + "github.com/pkg/errors" +) + +// test that we implement PoolManager +var _ poolHelper = &organization{} + +func NewEnterprisePoolManager(ctx context.Context, cfg params.Enterprise, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { + ghc, ghEnterpriseClient, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) + if err != nil { + return nil, errors.Wrap(err, "getting github client") + } + + helper := &enterprise{ + cfg: cfg, + cfgInternal: cfgInternal, + ctx: ctx, + ghcli: ghc, + ghcEnterpriseCli: ghEnterpriseClient, + id: cfg.ID, + store: store, + } + + repo := &basePool{ + ctx: ctx, + store: store, + providers: providers, + controllerID: cfgInternal.ControllerID, + quit: make(chan struct{}), + done: make(chan struct{}), + helper: helper, + credsDetails: cfgInternal.GithubCredentialsDetails, + } + return repo, nil +} + +type enterprise struct { + cfg params.Enterprise + cfgInternal params.Internal + ctx context.Context + ghcli common.GithubClient + ghcEnterpriseCli common.GithubEnterpriseClient + id string + store dbCommon.Store + + mux sync.Mutex +} + +func (r *enterprise) GetRunnerNameFromWorkflow(job params.WorkflowJob) (string, error) { + workflow, _, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Repository.Owner.Login, job.Repository.Name, job.WorkflowJob.ID) + if err != nil { + return "", errors.Wrap(err, "fetching workflow info") + } + if workflow.RunnerName != nil { + return *workflow.RunnerName, nil + } + return "", fmt.Errorf("failed to find runner name from workflow") +} + +func (r *enterprise) UpdateState(param params.UpdatePoolStateParams) error { + r.mux.Lock() + defer r.mux.Unlock() + + r.cfg.WebhookSecret = param.WebhookSecret + + ghc, ghcEnterprise, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) + if err != nil { + return errors.Wrap(err, "getting github client") + } + r.ghcli = ghc + r.ghcEnterpriseCli = ghcEnterprise + return nil +} + +func (r *enterprise) GetGithubToken() string { + return r.cfgInternal.OAuth2Token +} + +func (r *enterprise) GetGithubRunners() ([]*github.Runner, error) { + opts := github.ListOptions{ + PerPage: 100, + Page: 1, + } + runners, _, err := r.ghcEnterpriseCli.ListRunners(r.ctx, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") + } + ret := []*github.Runner{} + ret = append(ret, runners.Runners...) + pages := math.Ceil(float64(runners.TotalCount) / float64(100)) + if pages > 1 { + for i := 2; i <= int(pages); i++ { + opts.Page = i + runners, _, err = r.ghcEnterpriseCli.ListRunners(r.ctx, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") + } + ret = append(ret, runners.Runners...) + } + } + + return ret, nil +} + +func (r *enterprise) FetchTools() ([]*github.RunnerApplicationDownload, error) { + r.mux.Lock() + defer r.mux.Unlock() + tools, _, err := r.ghcEnterpriseCli.ListRunnerApplicationDownloads(r.ctx, r.cfg.Name) + if err != nil { + return nil, errors.Wrap(err, "fetching runner tools") + } + + return tools, nil +} + +func (r *enterprise) FetchDbInstances() ([]params.Instance, error) { + return r.store.ListEnterpriseInstances(r.ctx, r.id) +} + +func (r *enterprise) RemoveGithubRunner(runnerID int64) (*github.Response, error) { + return r.ghcEnterpriseCli.RemoveRunner(r.ctx, r.cfg.Name, runnerID) +} + +func (r *enterprise) ListPools() ([]params.Pool, error) { + pools, err := r.store.ListEnterprisePools(r.ctx, r.id) + if err != nil { + return nil, errors.Wrap(err, "fetching pools") + } + return pools, nil +} + +func (r *enterprise) GithubURL() string { + return fmt.Sprintf("%s/enterprises/%s", r.cfgInternal.GithubCredentialsDetails.BaseURL, r.cfg.Name) +} + +func (r *enterprise) JwtToken() string { + return r.cfgInternal.JWTSecret +} + +func (r *enterprise) GetGithubRegistrationToken() (string, error) { + tk, _, err := r.ghcEnterpriseCli.CreateRegistrationToken(r.ctx, r.cfg.Name) + + if err != nil { + return "", errors.Wrap(err, "creating runner token") + } + return *tk.Token, nil +} + +func (r *enterprise) String() string { + return r.cfg.Name +} + +func (r *enterprise) WebhookSecret() string { + return r.cfg.WebhookSecret +} + +func (r *enterprise) GetCallbackURL() string { + return r.cfgInternal.InstanceCallbackURL +} + +func (r *enterprise) FindPoolByTags(labels []string) (params.Pool, error) { + pool, err := r.store.FindEnterprisePoolByTags(r.ctx, r.id, labels) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching suitable pool") + } + return pool, nil +} + +func (r *enterprise) GetPoolByID(poolID string) (params.Pool, error) { + pool, err := r.store.GetEnterprisePool(r.ctx, r.id, poolID) + if err != nil { + return params.Pool{}, errors.Wrap(err, "fetching pool") + } + return pool, nil +} + +func (r *enterprise) ValidateOwner(job params.WorkflowJob) error { + if !strings.EqualFold(job.Enterprise.Slug, r.cfg.Name) { + return runnerErrors.NewBadRequestError("job not meant for this pool manager") + } + return nil +} + +func (r *enterprise) ID() string { + return r.id +} diff --git a/runner/pool/interfaces.go b/runner/pool/interfaces.go index 182dc452..7e5a87ee 100644 --- a/runner/pool/interfaces.go +++ b/runner/pool/interfaces.go @@ -17,7 +17,7 @@ package pool import ( "garm/params" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" ) type poolHelper interface { diff --git a/runner/pool/organization.go b/runner/pool/organization.go index 4044e6e4..b2fe6d6e 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -17,6 +17,7 @@ package pool import ( "context" "fmt" + "math" "strings" "sync" @@ -26,7 +27,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" "github.com/pkg/errors" ) @@ -34,7 +35,7 @@ import ( var _ poolHelper = &organization{} func NewOrganizationPoolManager(ctx context.Context, cfg params.Organization, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { - ghc, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) + ghc, _, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) if err != nil { return nil, errors.Wrap(err, "getting github client") } @@ -89,7 +90,7 @@ func (r *organization) UpdateState(param params.UpdatePoolStateParams) error { r.cfg.WebhookSecret = param.WebhookSecret - ghc, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) + ghc, _, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) if err != nil { return errors.Wrap(err, "getting github client") } @@ -102,12 +103,30 @@ func (r *organization) GetGithubToken() string { } func (r *organization) GetGithubRunners() ([]*github.Runner, error) { - runners, _, err := r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, nil) + opts := github.ListOptions{ + PerPage: 100, + Page: 1, + } + runners, _, err := r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, &opts) if err != nil { return nil, errors.Wrap(err, "fetching runners") } - return runners.Runners, nil + ret := []*github.Runner{} + ret = append(ret, runners.Runners...) + pages := math.Ceil(float64(runners.TotalCount) / float64(100)) + if pages > 1 { + for i := 2; i <= int(pages); i++ { + opts.Page = i + runners, _, err = r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") + } + ret = append(ret, runners.Runners...) + } + } + + return ret, nil } func (r *organization) FetchTools() ([]*github.RunnerApplicationDownload, error) { diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 160da187..6c39b3f2 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -30,7 +30,7 @@ import ( "garm/runner/common" providerCommon "garm/runner/providers/common" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" "github.com/google/uuid" "github.com/pkg/errors" ) diff --git a/runner/pool/repository.go b/runner/pool/repository.go index 8f0ed6d1..ebbf76e1 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -17,6 +17,7 @@ package pool import ( "context" "fmt" + "math" "strings" "sync" @@ -26,7 +27,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" "github.com/pkg/errors" ) @@ -34,7 +35,7 @@ import ( var _ poolHelper = &repository{} func NewRepositoryPoolManager(ctx context.Context, cfg params.Repository, cfgInternal params.Internal, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { - ghc, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) + ghc, _, err := util.GithubClient(ctx, cfgInternal.OAuth2Token, cfgInternal.GithubCredentialsDetails) if err != nil { return nil, errors.Wrap(err, "getting github client") } @@ -91,7 +92,7 @@ func (r *repository) UpdateState(param params.UpdatePoolStateParams) error { r.cfg.WebhookSecret = param.WebhookSecret - ghc, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) + ghc, _, err := util.GithubClient(r.ctx, r.GetGithubToken(), r.cfgInternal.GithubCredentialsDetails) if err != nil { return errors.Wrap(err, "getting github client") } @@ -104,12 +105,29 @@ func (r *repository) GetGithubToken() string { } func (r *repository) GetGithubRunners() ([]*github.Runner, error) { - runners, _, err := r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, nil) + opts := github.ListOptions{ + PerPage: 100, + Page: 1, + } + runners, _, err := r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, &opts) if err != nil { return nil, errors.Wrap(err, "fetching runners") } + ret := []*github.Runner{} + ret = append(ret, runners.Runners...) + pages := math.Ceil(float64(runners.TotalCount) / float64(100)) + if pages > 1 { + for i := 2; i <= int(pages); i++ { + opts.Page = i + runners, _, err = r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") + } + ret = append(ret, runners.Runners...) + } + } - return runners.Runners, nil + return ret, nil } func (r *repository) FetchTools() ([]*github.RunnerApplicationDownload, error) { diff --git a/runner/providers/lxd/lxd.go b/runner/providers/lxd/lxd.go index d92b180b..6d19cb3f 100644 --- a/runner/providers/lxd/lxd.go +++ b/runner/providers/lxd/lxd.go @@ -25,7 +25,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" lxd "github.com/lxc/lxd/client" "github.com/lxc/lxd/shared/api" "github.com/pkg/errors" diff --git a/runner/runner.go b/runner/runner.go index 808edefd..ca25f29e 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -23,9 +23,7 @@ import ( "encoding/json" "fmt" "hash" - "io/ioutil" "log" - "path/filepath" "strings" "sync" "time" @@ -43,7 +41,6 @@ import ( "garm/util" "github.com/pkg/errors" - "golang.org/x/crypto/ssh" ) func NewRunner(ctx context.Context, cfg config.Config) (*Runner, error) { @@ -100,6 +97,7 @@ type poolManagerCtrl struct { repositories map[string]common.PoolManager organizations map[string]common.PoolManager + enterprises map[string]common.PoolManager } func (p *poolManagerCtrl) CreateRepoPoolManager(ctx context.Context, repo params.Repository, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { @@ -184,6 +182,47 @@ func (p *poolManagerCtrl) GetOrgPoolManagers() (map[string]common.PoolManager, e return p.organizations, nil } +func (p *poolManagerCtrl) CreateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) { + p.mux.Lock() + defer p.mux.Unlock() + + cfgInternal, err := p.getInternalConfig(enterprise.CredentialsName) + if err != nil { + return nil, errors.Wrap(err, "fetching internal config") + } + poolManager, err := pool.NewEnterprisePoolManager(ctx, enterprise, cfgInternal, providers, store) + if err != nil { + return nil, errors.Wrap(err, "creating enterprise pool manager") + } + p.enterprises[enterprise.ID] = poolManager + return poolManager, nil +} + +func (p *poolManagerCtrl) GetEnterprisePoolManager(enterprise params.Enterprise) (common.PoolManager, error) { + if enterprisePoolMgr, ok := p.enterprises[enterprise.ID]; ok { + return enterprisePoolMgr, nil + } + return nil, errors.Wrapf(runnerErrors.ErrNotFound, "enterprise %s pool manager not loaded", enterprise.Name) +} + +func (p *poolManagerCtrl) DeleteEnterprisePoolManager(enterprise params.Enterprise) error { + p.mux.Lock() + defer p.mux.Unlock() + + poolMgr, ok := p.enterprises[enterprise.ID] + if ok { + if err := poolMgr.Stop(); err != nil { + return errors.Wrap(err, "stopping enterprise pool manager") + } + delete(p.enterprises, enterprise.ID) + } + return nil +} + +func (p *poolManagerCtrl) GetEnterprisePoolManagers() (map[string]common.PoolManager, error) { + return p.enterprises, nil +} + func (p *poolManagerCtrl) getInternalConfig(credsName string) (params.Internal, error) { creds, ok := p.credentials[credsName] if !ok { @@ -472,6 +511,8 @@ func (r *Runner) DispatchWorkflowJob(hookTargetType, signature string, jobData [ poolManager, err = r.findRepoPoolManager(job.Repository.Owner.Login, job.Repository.Name) case OrganizationHook: poolManager, err = r.findOrgPoolManager(job.Organization.Login) + case EnterpriseHook: + poolManager, err = r.findEnterprisePoolManager(job.Enterprise.Slug) default: return runnerErrors.NewBadRequestError("cannot handle hook target type %s", hookTargetType) } @@ -496,45 +537,6 @@ func (r *Runner) DispatchWorkflowJob(hookTargetType, signature string, jobData [ return nil } -func (r *Runner) sshDir() string { - return filepath.Join(r.config.Default.ConfigDir, "ssh") -} - -func (r *Runner) sshKeyPath() string { - keyPath := filepath.Join(r.sshDir(), "runner_rsa_key") - return keyPath -} - -func (r *Runner) sshPubKeyPath() string { - keyPath := filepath.Join(r.sshDir(), "runner_rsa_key.pub") - return keyPath -} - -func (r *Runner) parseSSHKey() (ssh.Signer, error) { - r.mux.Lock() - defer r.mux.Unlock() - - key, err := ioutil.ReadFile(r.sshKeyPath()) - if err != nil { - return nil, errors.Wrapf(err, "reading private key %s", r.sshKeyPath()) - } - - signer, err := ssh.ParsePrivateKey(key) - if err != nil { - return nil, errors.Wrapf(err, "parsing private key %s", r.sshKeyPath()) - } - - return signer, nil -} - -func (r *Runner) sshPubKey() ([]byte, error) { - key, err := ioutil.ReadFile(r.sshPubKeyPath()) - if err != nil { - return nil, errors.Wrapf(err, "reading public key %s", r.sshPubKeyPath()) - } - return key, nil -} - func (r *Runner) appendTagsToCreatePoolParams(param params.CreatePoolParams) (params.CreatePoolParams, error) { if err := param.Validate(); err != nil { return params.CreatePoolParams{}, errors.Wrapf(runnerErrors.ErrBadRequest, "validating params: %s", err) diff --git a/runner/types.go b/runner/types.go index 96efcd24..a03b9d53 100644 --- a/runner/types.go +++ b/runner/types.go @@ -21,6 +21,7 @@ type HookTargetType string const ( RepoHook HookTargetType = "repository" OrganizationHook HookTargetType = "organization" + EnterpriseHook HookTargetType = "business" ) var ( diff --git a/util/util.go b/util/util.go index f2ee210b..58e5626e 100644 --- a/util/util.go +++ b/util/util.go @@ -38,7 +38,7 @@ import ( "garm/params" "garm/runner/common" - "github.com/google/go-github/v43/github" + "github.com/google/go-github/v47/github" "github.com/pkg/errors" "golang.org/x/crypto/bcrypt" "golang.org/x/oauth2" @@ -163,13 +163,13 @@ func OSToOSType(os string) (config.OSType, error) { return osType, nil } -func GithubClient(ctx context.Context, token string, credsDetails params.GithubCredentials) (common.GithubClient, error) { +func GithubClient(ctx context.Context, token string, credsDetails params.GithubCredentials) (common.GithubClient, common.GithubEnterpriseClient, error) { var roots *x509.CertPool if credsDetails.CABundle != nil && len(credsDetails.CABundle) > 0 { roots = x509.NewCertPool() ok := roots.AppendCertsFromPEM(credsDetails.CABundle) if !ok { - return nil, fmt.Errorf("failed to parse CA cert") + return nil, nil, fmt.Errorf("failed to parse CA cert") } } httpTransport := &http.Transport{ @@ -185,13 +185,12 @@ func GithubClient(ctx context.Context, token string, credsDetails params.GithubC ) tc := oauth2.NewClient(ctx, ts) - // ghClient := github.NewClient(tc) ghClient, err := github.NewEnterpriseClient(credsDetails.APIBaseURL, credsDetails.UploadBaseURL, tc) if err != nil { - return nil, errors.Wrap(err, "fetching github client") + return nil, nil, errors.Wrap(err, "fetching github client") } - return ghClient.Actions, nil + return ghClient.Actions, ghClient.Enterprise, nil } func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.RunnerApplicationDownload, runnerName string) (string, error) { From fb344ab2f22f8313aa7cd1de444501f108c2baf2 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 13 Oct 2022 16:10:20 +0000 Subject: [PATCH 03/12] Update vendor Signed-off-by: Gabriel Adrian Samfira --- .../go-github/v43/github/repos_merging.go | 38 - .../google/go-github/{v43 => v47}/AUTHORS | 0 .../google/go-github/{v43 => v47}/LICENSE | 0 .../go-github/{v43 => v47}/github/actions.go | 2 +- .../{v43 => v47}/github/actions_artifacts.go | 49 +- .../github/actions_runner_groups.go | 36 +- .../{v43 => v47}/github/actions_runners.go | 32 +- .../{v43 => v47}/github/actions_secrets.go | 40 +- .../github/actions_workflow_jobs.go | 37 +- .../github/actions_workflow_runs.go | 83 +- .../{v43 => v47}/github/actions_workflows.go | 22 +- .../go-github/{v43 => v47}/github/activity.go | 19 +- .../{v43 => v47}/github/activity_events.go | 20 +- .../github/activity_notifications.go | 20 +- .../{v43 => v47}/github/activity_star.go | 15 +- .../{v43 => v47}/github/activity_watching.go | 12 +- .../go-github/{v43 => v47}/github/admin.go | 6 +- .../{v43 => v47}/github/admin_orgs.go | 0 .../{v43 => v47}/github/admin_stats.go | 2 +- .../{v43 => v47}/github/admin_users.go | 0 .../go-github/{v43 => v47}/github/apps.go | 35 +- .../{v43 => v47}/github/apps_hooks.go | 4 +- .../github/apps_hooks_deliveries.go | 6 +- .../{v43 => v47}/github/apps_installation.go | 10 +- .../{v43 => v47}/github/apps_manifest.go | 2 +- .../{v43 => v47}/github/apps_marketplace.go | 14 +- .../{v43 => v47}/github/authorizations.go | 14 +- .../go-github/{v43 => v47}/github/billing.go | 30 +- .../go-github/{v43 => v47}/github/checks.go | 40 +- .../{v43 => v47}/github/code-scanning.go | 84 +- .../{v43 => v47}/github/dependabot.go | 2 +- .../{v43 => v47}/github/dependabot_secrets.go | 54 +- .../go-github/{v43 => v47}/github/doc.go | 21 +- .../{v43 => v47}/github/enterprise.go | 2 +- .../github/enterprise_actions_runners.go | 25 +- .../github/enterprise_audit_log.go | 2 +- .../go-github/{v43 => v47}/github/event.go | 6 + .../{v43 => v47}/github/event_types.go | 131 ++- .../go-github/{v43 => v47}/github/gists.go | 36 +- .../{v43 => v47}/github/gists_comments.go | 10 +- .../go-github/{v43 => v47}/github/git.go | 2 +- .../{v43 => v47}/github/git_blobs.go | 25 +- .../{v43 => v47}/github/git_commits.go | 4 +- .../go-github/{v43 => v47}/github/git_refs.go | 12 +- .../go-github/{v43 => v47}/github/git_tags.go | 16 +- .../{v43 => v47}/github/git_trees.go | 4 +- .../{v43 => v47}/github/github-accessors.go | 972 ++++++++++++++---- .../go-github/{v43 => v47}/github/github.go | 147 ++- .../{v43 => v47}/github/gitignore.go | 6 +- .../{v43 => v47}/github/interactions.go | 2 +- .../{v43 => v47}/github/interactions_orgs.go | 6 +- .../{v43 => v47}/github/interactions_repos.go | 6 +- .../{v43 => v47}/github/issue_import.go | 0 .../go-github/{v43 => v47}/github/issues.go | 42 +- .../{v43 => v47}/github/issues_assignees.go | 22 +- .../{v43 => v47}/github/issues_comments.go | 12 +- .../{v43 => v47}/github/issues_events.go | 6 +- .../{v43 => v47}/github/issues_labels.go | 22 +- .../{v43 => v47}/github/issues_milestones.go | 10 +- .../{v43 => v47}/github/issues_timeline.go | 8 +- .../go-github/{v43 => v47}/github/licenses.go | 6 +- .../go-github/{v43 => v47}/github/messages.go | 55 +- .../{v43 => v47}/github/migrations.go | 14 +- .../github/migrations_source_import.go | 20 +- .../{v43 => v47}/github/migrations_user.go | 18 +- .../go-github/{v43 => v47}/github/misc.go | 18 +- .../go-github/{v43 => v47}/github/orgs.go | 31 +- .../github/orgs_actions_allowed.go | 15 +- .../github/orgs_actions_permissions.go | 13 +- .../{v43 => v47}/github/orgs_audit_log.go | 3 +- .../go-github/v47/github/orgs_custom_roles.go | 46 + .../{v43 => v47}/github/orgs_hooks.go | 28 +- .../github/orgs_hooks_deliveries.go | 6 +- .../{v43 => v47}/github/orgs_members.go | 37 +- .../github/orgs_outside_collaborators.go | 6 +- .../{v43 => v47}/github/orgs_packages.go | 16 +- .../{v43 => v47}/github/orgs_projects.go | 4 +- .../github/orgs_users_blocking.go | 8 +- .../go-github/{v43 => v47}/github/packages.go | 0 .../go-github/{v43 => v47}/github/projects.go | 44 +- .../go-github/{v43 => v47}/github/pulls.go | 24 +- .../{v43 => v47}/github/pulls_comments.go | 14 +- .../{v43 => v47}/github/pulls_reviewers.go | 6 +- .../{v43 => v47}/github/pulls_reviews.go | 48 +- .../go-github/v47/github/pulls_threads.go | 17 + .../{v43 => v47}/github/reactions.go | 52 +- .../go-github/{v43 => v47}/github/repos.go | 361 ++++--- .../v47/github/repos_actions_allowed.go | 49 + .../v47/github/repos_actions_permissions.go | 62 ++ .../{v43 => v47}/github/repos_autolinks.go | 20 +- .../go-github/v47/github/repos_codeowners.go | 46 + .../github/repos_collaborators.go | 17 +- .../{v43 => v47}/github/repos_comments.go | 12 +- .../{v43 => v47}/github/repos_commits.go | 16 +- .../github/repos_community_health.go | 2 +- .../{v43 => v47}/github/repos_contents.go | 70 +- .../{v43 => v47}/github/repos_deployments.go | 14 +- .../{v43 => v47}/github/repos_environments.go | 8 +- .../{v43 => v47}/github/repos_forks.go | 8 +- .../{v43 => v47}/github/repos_hooks.go | 124 ++- .../github/repos_hooks_deliveries.go | 27 +- .../{v43 => v47}/github/repos_invitations.go | 6 +- .../{v43 => v47}/github/repos_keys.go | 8 +- .../google/go-github/v47/github/repos_lfs.go | 49 + .../go-github/v47/github/repos_merging.go | 72 ++ .../{v43 => v47}/github/repos_pages.go | 22 +- .../github/repos_prereceive_hooks.go | 0 .../{v43 => v47}/github/repos_projects.go | 4 +- .../{v43 => v47}/github/repos_releases.go | 35 +- .../{v43 => v47}/github/repos_stats.go | 20 +- .../{v43 => v47}/github/repos_statuses.go | 6 +- .../google/go-github/v47/github/repos_tags.go | 76 ++ .../{v43 => v47}/github/repos_traffic.go | 8 +- .../go-github/{v43 => v47}/github/scim.go | 22 +- .../go-github/{v43 => v47}/github/search.go | 87 +- .../{v43 => v47}/github/secret_scanning.go | 22 +- .../go-github/{v43 => v47}/github/strings.go | 0 .../go-github/{v43 => v47}/github/teams.go | 83 +- .../github/teams_discussion_comments.go | 20 +- .../{v43 => v47}/github/teams_discussions.go | 20 +- .../{v43 => v47}/github/teams_members.go | 20 +- .../{v43 => v47}/github/timestamp.go | 0 .../go-github/{v43 => v47}/github/users.go | 25 +- .../github/users_administration.go | 0 .../{v43 => v47}/github/users_blocking.go | 8 +- .../{v43 => v47}/github/users_emails.go | 6 +- .../{v43 => v47}/github/users_followers.go | 16 +- .../{v43 => v47}/github/users_gpg_keys.go | 10 +- .../{v43 => v47}/github/users_keys.go | 10 +- .../{v43 => v47}/github/users_packages.go | 32 +- .../{v43 => v47}/github/users_projects.go | 4 +- .../{v43 => v47}/github/with_appengine.go | 0 .../{v43 => v47}/github/without_appengine.go | 0 vendor/modules.txt | 5 +- 134 files changed, 2947 insertions(+), 1419 deletions(-) delete mode 100644 vendor/github.com/google/go-github/v43/github/repos_merging.go rename vendor/github.com/google/go-github/{v43 => v47}/AUTHORS (100%) rename vendor/github.com/google/go-github/{v43 => v47}/LICENSE (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions.go (77%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_artifacts.go (70%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_runner_groups.go (81%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_runners.go (83%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_secrets.go (83%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_workflow_jobs.go (77%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_workflow_runs.go (74%) rename vendor/github.com/google/go-github/{v43 => v47}/github/actions_workflows.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/activity.go (80%) rename vendor/github.com/google/go-github/{v43 => v47}/github/activity_events.go (79%) rename vendor/github.com/google/go-github/{v43 => v47}/github/activity_notifications.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/activity_star.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/activity_watching.go (84%) rename vendor/github.com/google/go-github/{v43 => v47}/github/admin.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/admin_orgs.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/admin_stats.go (97%) rename vendor/github.com/google/go-github/{v43 => v47}/github/admin_users.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/apps.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/apps_hooks.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/apps_hooks_deliveries.go (84%) rename vendor/github.com/google/go-github/{v43 => v47}/github/apps_installation.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/apps_manifest.go (92%) rename vendor/github.com/google/go-github/{v43 => v47}/github/apps_marketplace.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/authorizations.go (92%) rename vendor/github.com/google/go-github/{v43 => v47}/github/billing.go (84%) rename vendor/github.com/google/go-github/{v43 => v47}/github/checks.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/code-scanning.go (75%) rename vendor/github.com/google/go-github/{v43 => v47}/github/dependabot.go (77%) rename vendor/github.com/google/go-github/{v43 => v47}/github/dependabot_secrets.go (70%) rename vendor/github.com/google/go-github/{v43 => v47}/github/doc.go (94%) rename vendor/github.com/google/go-github/{v43 => v47}/github/enterprise.go (75%) rename vendor/github.com/google/go-github/{v43 => v47}/github/enterprise_actions_runners.go (62%) rename vendor/github.com/google/go-github/{v43 => v47}/github/enterprise_audit_log.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/event.go (95%) rename vendor/github.com/google/go-github/{v43 => v47}/github/event_types.go (90%) rename vendor/github.com/google/go-github/{v43 => v47}/github/gists.go (83%) rename vendor/github.com/google/go-github/{v43 => v47}/github/gists_comments.go (83%) rename vendor/github.com/google/go-github/{v43 => v47}/github/git.go (77%) rename vendor/github.com/google/go-github/{v43 => v47}/github/git_blobs.go (80%) rename vendor/github.com/google/go-github/{v43 => v47}/github/git_commits.go (96%) rename vendor/github.com/google/go-github/{v43 => v47}/github/git_refs.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/git_tags.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/git_trees.go (95%) rename vendor/github.com/google/go-github/{v43 => v47}/github/github-accessors.go (96%) rename vendor/github.com/google/go-github/{v43 => v47}/github/github.go (90%) rename vendor/github.com/google/go-github/{v43 => v47}/github/gitignore.go (81%) rename vendor/github.com/google/go-github/{v43 => v47}/github/interactions.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/interactions_orgs.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/interactions_repos.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issue_import.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues_assignees.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues_comments.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues_events.go (94%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues_labels.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues_milestones.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/issues_timeline.go (97%) rename vendor/github.com/google/go-github/{v43 => v47}/github/licenses.go (89%) rename vendor/github.com/google/go-github/{v43 => v47}/github/messages.go (89%) rename vendor/github.com/google/go-github/{v43 => v47}/github/migrations.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/migrations_source_import.go (90%) rename vendor/github.com/google/go-github/{v43 => v47}/github/migrations_user.go (89%) rename vendor/github.com/google/go-github/{v43 => v47}/github/misc.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs.go (81%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_actions_allowed.go (76%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_actions_permissions.go (81%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_audit_log.go (97%) create mode 100644 vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_hooks.go (78%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_hooks_deliveries.go (84%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_members.go (83%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_outside_collaborators.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_packages.go (81%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_projects.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/orgs_users_blocking.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/packages.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/projects.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/pulls.go (92%) rename vendor/github.com/google/go-github/{v43 => v47}/github/pulls_comments.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/pulls_reviewers.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/pulls_reviews.go (85%) create mode 100644 vendor/github.com/google/go-github/v47/github/pulls_threads.go rename vendor/github.com/google/go-github/{v43 => v47}/github/reactions.go (83%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos.go (79%) create mode 100644 vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go create mode 100644 vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_autolinks.go (77%) create mode 100644 vendor/github.com/google/go-github/v47/github/repos_codeowners.go rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_collaborators.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_comments.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_commits.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_community_health.go (95%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_contents.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_deployments.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_environments.go (94%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_forks.go (89%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_hooks.go (67%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_hooks_deliveries.go (75%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_invitations.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_keys.go (82%) create mode 100644 vendor/github.com/google/go-github/v47/github/repos_lfs.go create mode 100644 vendor/github.com/google/go-github/v47/github/repos_merging.go rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_pages.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_prereceive_hooks.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_projects.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_releases.go (89%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_stats.go (91%) rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_statuses.go (91%) create mode 100644 vendor/github.com/google/go-github/v47/github/repos_tags.go rename vendor/github.com/google/go-github/{v43 => v47}/github/repos_traffic.go (90%) rename vendor/github.com/google/go-github/{v43 => v47}/github/scim.go (84%) rename vendor/github.com/google/go-github/{v43 => v47}/github/search.go (84%) rename vendor/github.com/google/go-github/{v43 => v47}/github/secret_scanning.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/strings.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/teams.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/teams_discussion_comments.go (87%) rename vendor/github.com/google/go-github/{v43 => v47}/github/teams_discussions.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/teams_members.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/timestamp.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users.go (86%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_administration.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_blocking.go (82%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_emails.go (80%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_followers.go (74%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_gpg_keys.go (85%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_keys.go (78%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_packages.go (75%) rename vendor/github.com/google/go-github/{v43 => v47}/github/users_projects.go (88%) rename vendor/github.com/google/go-github/{v43 => v47}/github/with_appengine.go (100%) rename vendor/github.com/google/go-github/{v43 => v47}/github/without_appengine.go (100%) diff --git a/vendor/github.com/google/go-github/v43/github/repos_merging.go b/vendor/github.com/google/go-github/v43/github/repos_merging.go deleted file mode 100644 index 7edda3ef..00000000 --- a/vendor/github.com/google/go-github/v43/github/repos_merging.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// RepositoryMergeRequest represents a request to merge a branch in a -// repository. -type RepositoryMergeRequest struct { - Base *string `json:"base,omitempty"` - Head *string `json:"head,omitempty"` - CommitMessage *string `json:"commit_message,omitempty"` -} - -// Merge a branch in the specified repository. -// -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#merge-a-branch -func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/merges", owner, repo) - req, err := s.client.NewRequest("POST", u, request) - if err != nil { - return nil, nil, err - } - - commit := new(RepositoryCommit) - resp, err := s.client.Do(ctx, req, commit) - if err != nil { - return nil, resp, err - } - - return commit, resp, nil -} diff --git a/vendor/github.com/google/go-github/v43/AUTHORS b/vendor/github.com/google/go-github/v47/AUTHORS similarity index 100% rename from vendor/github.com/google/go-github/v43/AUTHORS rename to vendor/github.com/google/go-github/v47/AUTHORS diff --git a/vendor/github.com/google/go-github/v43/LICENSE b/vendor/github.com/google/go-github/v47/LICENSE similarity index 100% rename from vendor/github.com/google/go-github/v43/LICENSE rename to vendor/github.com/google/go-github/v47/LICENSE diff --git a/vendor/github.com/google/go-github/v43/github/actions.go b/vendor/github.com/google/go-github/v47/github/actions.go similarity index 77% rename from vendor/github.com/google/go-github/v43/github/actions.go rename to vendor/github.com/google/go-github/v47/github/actions.go index ce15d95f..8d552f2d 100644 --- a/vendor/github.com/google/go-github/v43/github/actions.go +++ b/vendor/github.com/google/go-github/v47/github/actions.go @@ -8,5 +8,5 @@ package github // ActionsService handles communication with the actions related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/ +// GitHub API docs: https://docs.github.com/en/rest/actions/ type ActionsService service diff --git a/vendor/github.com/google/go-github/v43/github/actions_artifacts.go b/vendor/github.com/google/go-github/v47/github/actions_artifacts.go similarity index 70% rename from vendor/github.com/google/go-github/v43/github/actions_artifacts.go rename to vendor/github.com/google/go-github/v47/github/actions_artifacts.go index 4aa7dc44..99329d98 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_artifacts.go +++ b/vendor/github.com/google/go-github/v47/github/actions_artifacts.go @@ -16,7 +16,7 @@ import ( // data between jobs in a workflow and provide storage for data // once a workflow is complete. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#artifacts +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts type Artifact struct { ID *int64 `json:"id,omitempty"` NodeID *string `json:"node_id,omitempty"` @@ -30,7 +30,7 @@ type Artifact struct { // ArtifactList represents a list of GitHub artifacts. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#artifacts +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#artifacts type ArtifactList struct { TotalCount *int64 `json:"total_count,omitempty"` Artifacts []*Artifact `json:"artifacts,omitempty"` @@ -38,7 +38,7 @@ type ArtifactList struct { // ListArtifacts lists all artifacts that belong to a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-artifacts-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-artifacts-for-a-repository func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo) u, err := addOptions(u, opts) @@ -62,7 +62,7 @@ func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, // ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-run-artifacts +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*ArtifactList, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/artifacts", owner, repo, runID) u, err := addOptions(u, opts) @@ -86,7 +86,7 @@ func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, re // GetArtifact gets a specific artifact for a workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-an-artifact +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#get-an-artifact func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID) @@ -106,52 +106,31 @@ func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, ar // DownloadArtifact gets a redirect URL to download an archive for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#download-an-artifact +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#download-an-artifact func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID) - resp, err := s.getDownloadArtifactFromURL(ctx, u, followRedirects) + resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) if err != nil { return nil, nil, err } + defer resp.Body.Close() if resp.StatusCode != http.StatusFound { return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) } + parsedURL, err := url.Parse(resp.Header.Get("Location")) + if err != nil { + return nil, newResponse(resp), err + } + return parsedURL, newResponse(resp), nil } -func (s *ActionsService) getDownloadArtifactFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) { - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, err - } - - var resp *http.Response - // Use http.DefaultTransport if no custom Transport is configured - req = withContext(ctx, req) - if s.client.client.Transport == nil { - resp, err = http.DefaultTransport.RoundTrip(req) - } else { - resp, err = s.client.client.Transport.RoundTrip(req) - } - if err != nil { - return nil, err - } - resp.Body.Close() - - // If redirect response is returned, follow it - if followRedirects && resp.StatusCode == http.StatusMovedPermanently { - u = resp.Header.Get("Location") - resp, err = s.getDownloadArtifactFromURL(ctx, u, false) - } - return resp, err -} - // DeleteArtifact deletes a workflow run artifact. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-an-artifact +// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#delete-an-artifact func (s *ActionsService) DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID) diff --git a/vendor/github.com/google/go-github/v43/github/actions_runner_groups.go b/vendor/github.com/google/go-github/v47/github/actions_runner_groups.go similarity index 81% rename from vendor/github.com/google/go-github/v43/github/actions_runner_groups.go rename to vendor/github.com/google/go-github/v47/github/actions_runner_groups.go index 2d6a1546..6d892491 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_runner_groups.go +++ b/vendor/github.com/google/go-github/v47/github/actions_runner_groups.go @@ -61,10 +61,18 @@ type SetRunnerGroupRunnersRequest struct { Runners []int64 `json:"runners"` } +// ListOrgRunnerGroupOptions extend ListOptions to have the optional parameters VisibleToRepository. +type ListOrgRunnerGroupOptions struct { + ListOptions + + // Only return runner groups that are allowed to be used by this repository. + VisibleToRepository string `url:"visible_to_repository,omitempty"` +} + // ListOrganizationRunnerGroups lists all self-hosted runner groups configured in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-self-hosted-runner-groups-for-an-organization -func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOptions) (*RunnerGroups, *Response, error) { +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runner-groups-for-an-organization +func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org string, opts *ListOrgRunnerGroupOptions) (*RunnerGroups, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups", org) u, err := addOptions(u, opts) if err != nil { @@ -87,7 +95,7 @@ func (s *ActionsService) ListOrganizationRunnerGroups(ctx context.Context, org s // GetOrganizationRunnerGroup gets a specific self-hosted runner group for an organization using its RunnerGroup ID. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-a-self-hosted-runner-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#get-a-self-hosted-runner-group-for-an-organization func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*RunnerGroup, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID) req, err := s.client.NewRequest("GET", u, nil) @@ -106,7 +114,7 @@ func (s *ActionsService) GetOrganizationRunnerGroup(ctx context.Context, org str // DeleteOrganizationRunnerGroup deletes a self-hosted runner group from an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-a-self-hosted-runner-group-from-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#delete-a-self-hosted-runner-group-from-an-organization func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org string, groupID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID) @@ -120,7 +128,7 @@ func (s *ActionsService) DeleteOrganizationRunnerGroup(ctx context.Context, org // CreateOrganizationRunnerGroup creates a new self-hosted runner group for an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#create-a-self-hosted-runner-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#create-a-self-hosted-runner-group-for-an-organization func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org string, createReq CreateRunnerGroupRequest) (*RunnerGroup, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups", org) req, err := s.client.NewRequest("POST", u, createReq) @@ -139,7 +147,7 @@ func (s *ActionsService) CreateOrganizationRunnerGroup(ctx context.Context, org // UpdateOrganizationRunnerGroup updates a self-hosted runner group for an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#update-a-self-hosted-runner-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#update-a-self-hosted-runner-group-for-an-organization func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org string, groupID int64, updateReq UpdateRunnerGroupRequest) (*RunnerGroup, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v", org, groupID) req, err := s.client.NewRequest("PATCH", u, updateReq) @@ -158,7 +166,7 @@ func (s *ActionsService) UpdateOrganizationRunnerGroup(ctx context.Context, org // ListRepositoryAccessRunnerGroup lists the repositories with access to a self-hosted runner group configured in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-repository-access-to-a-self-hosted-runner-group-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-repository-access-to-a-self-hosted-runner-group-in-an-organization func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, opts *ListOptions) (*ListRepositories, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID) u, err := addOptions(u, opts) @@ -183,7 +191,7 @@ func (s *ActionsService) ListRepositoryAccessRunnerGroup(ctx context.Context, or // SetRepositoryAccessRunnerGroup replaces the list of repositories that have access to a self-hosted runner group configured in an organization // with a new List of repositories. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-repository-access-for-a-self-hosted-runner-group-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#set-repository-access-for-a-self-hosted-runner-group-in-an-organization func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID int64, ids SetRepoAccessRunnerGroupRequest) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories", org, groupID) @@ -198,7 +206,7 @@ func (s *ActionsService) SetRepositoryAccessRunnerGroup(ctx context.Context, org // AddRepositoryAccessRunnerGroup adds a repository to the list of selected repositories that can access a self-hosted runner group. // The runner group must have visibility set to 'selected'. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#add-repository-access-to-a-self-hosted-runner-group-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#add-repository-access-to-a-self-hosted-runner-group-in-an-organization func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID) @@ -213,7 +221,7 @@ func (s *ActionsService) AddRepositoryAccessRunnerGroup(ctx context.Context, org // RemoveRepositoryAccessRunnerGroup removes a repository from the list of selected repositories that can access a self-hosted runner group. // The runner group must have visibility set to 'selected'. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#remove-repository-access-to-a-self-hosted-runner-group-in-an-organization func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context, org string, groupID, repoID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/repositories/%v", org, groupID, repoID) @@ -227,7 +235,7 @@ func (s *ActionsService) RemoveRepositoryAccessRunnerGroup(ctx context.Context, // ListRunnerGroupRunners lists self-hosted runners that are in a specific organization group. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-self-hosted-runners-in-a-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#list-self-hosted-runners-in-a-group-for-an-organization func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string, groupID int64, opts *ListOptions) (*Runners, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID) u, err := addOptions(u, opts) @@ -252,7 +260,7 @@ func (s *ActionsService) ListRunnerGroupRunners(ctx context.Context, org string, // SetRunnerGroupRunners replaces the list of self-hosted runners that are part of an organization runner group // with a new list of runners. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-self-hosted-runners-in-a-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#set-self-hosted-runners-in-a-group-for-an-organization func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string, groupID int64, ids SetRunnerGroupRunnersRequest) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners", org, groupID) @@ -266,7 +274,7 @@ func (s *ActionsService) SetRunnerGroupRunners(ctx context.Context, org string, // AddRunnerGroupRunners adds a self-hosted runner to a runner group configured in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#add-a-self-hosted-runner-to-a-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#add-a-self-hosted-runner-to-a-group-for-an-organization func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID) @@ -281,7 +289,7 @@ func (s *ActionsService) AddRunnerGroupRunners(ctx context.Context, org string, // RemoveRunnerGroupRunners removes a self-hosted runner from a group configured in an organization. // The runner is then returned to the default group. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#remove-a-self-hosted-runner-from-a-group-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runner-groups#remove-a-self-hosted-runner-from-a-group-for-an-organization func (s *ActionsService) RemoveRunnerGroupRunners(ctx context.Context, org string, groupID, runnerID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runner-groups/%v/runners/%v", org, groupID, runnerID) diff --git a/vendor/github.com/google/go-github/v43/github/actions_runners.go b/vendor/github.com/google/go-github/v47/github/actions_runners.go similarity index 83% rename from vendor/github.com/google/go-github/v43/github/actions_runners.go rename to vendor/github.com/google/go-github/v47/github/actions_runners.go index f37e1aa4..40c6be3a 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_runners.go +++ b/vendor/github.com/google/go-github/v47/github/actions_runners.go @@ -28,7 +28,7 @@ type ActionsEnabledOnOrgRepos struct { // ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-runner-applications-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository func (s *ActionsService) ListRunnerApplicationDownloads(ctx context.Context, owner, repo string) ([]*RunnerApplicationDownload, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runners/downloads", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -53,7 +53,7 @@ type RegistrationToken struct { // CreateRegistrationToken creates a token that can be used to add a self-hosted runner. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-registration-token-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-a-repository func (s *ActionsService) CreateRegistrationToken(ctx context.Context, owner, repo string) (*RegistrationToken, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runners/registration-token", owner, repo) @@ -96,7 +96,7 @@ type Runners struct { // ListRunners lists all the self-hosted runners for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-self-hosted-runners-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-a-repository func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, opts *ListOptions) (*Runners, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runners", owner, repo) u, err := addOptions(u, opts) @@ -120,7 +120,7 @@ func (s *ActionsService) ListRunners(ctx context.Context, owner, repo string, op // GetRunner gets a specific self-hosted runner for a repository using its runner ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-self-hosted-runner-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-a-repository func (s *ActionsService) GetRunner(ctx context.Context, owner, repo string, runnerID int64) (*Runner, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID) req, err := s.client.NewRequest("GET", u, nil) @@ -145,7 +145,7 @@ type RemoveToken struct { // CreateRemoveToken creates a token that can be used to remove a self-hosted runner from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-remove-token-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-remove-token-for-a-repository func (s *ActionsService) CreateRemoveToken(ctx context.Context, owner, repo string) (*RemoveToken, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runners/remove-token", owner, repo) @@ -165,7 +165,7 @@ func (s *ActionsService) CreateRemoveToken(ctx context.Context, owner, repo stri // RemoveRunner forces the removal of a self-hosted runner in a repository using the runner id. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-a-self-hosted-runner-from-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-a-repository func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, runnerID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runners/%v", owner, repo, runnerID) @@ -179,7 +179,7 @@ func (s *ActionsService) RemoveRunner(ctx context.Context, owner, repo string, r // ListOrganizationRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-runner-applications-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-an-organization func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context.Context, owner string) ([]*RunnerApplicationDownload, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runners/downloads", owner) req, err := s.client.NewRequest("GET", u, nil) @@ -198,7 +198,7 @@ func (s *ActionsService) ListOrganizationRunnerApplicationDownloads(ctx context. // CreateOrganizationRegistrationToken creates a token that can be used to add a self-hosted runner to an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-registration-token-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-an-organization func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context, owner string) (*RegistrationToken, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runners/registration-token", owner) @@ -218,7 +218,7 @@ func (s *ActionsService) CreateOrganizationRegistrationToken(ctx context.Context // ListOrganizationRunners lists all the self-hosted runners for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-self-hosted-runners-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-organization func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner string, opts *ListOptions) (*Runners, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runners", owner) u, err := addOptions(u, opts) @@ -242,7 +242,7 @@ func (s *ActionsService) ListOrganizationRunners(ctx context.Context, owner stri // ListEnabledReposInOrg lists the selected repositories that are enabled for GitHub Actions in an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-selected-repositories-enabled-for-github-actions-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization func (s *ActionsService) ListEnabledReposInOrg(ctx context.Context, owner string, opts *ListOptions) (*ActionsEnabledOnOrgRepos, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner) u, err := addOptions(u, opts) @@ -266,7 +266,7 @@ func (s *ActionsService) ListEnabledReposInOrg(ctx context.Context, owner string // SetEnabledReposInOrg replaces the list of selected repositories that are enabled for GitHub Actions in an organization.. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-selected-repositories-enabled-for-github-actions-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-selected-repositories-enabled-for-github-actions-in-an-organization func (s *ActionsService) SetEnabledReposInOrg(ctx context.Context, owner string, repositoryIDs []int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions/repositories", owner) @@ -287,7 +287,7 @@ func (s *ActionsService) SetEnabledReposInOrg(ctx context.Context, owner string, // AddEnabledReposInOrg adds a repository to the list of selected repositories that are enabled for GitHub Actions in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#enable-a-selected-repository-for-github-actions-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#enable-a-selected-repository-for-github-actions-in-an-organization func (s *ActionsService) AddEnabledReposInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID) @@ -306,7 +306,7 @@ func (s *ActionsService) AddEnabledReposInOrg(ctx context.Context, owner string, // RemoveEnabledRepoInOrg removes a single repository from the list of enabled repos for GitHub Actions in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#disable-a-selected-repository-for-github-actions-in-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#disable-a-selected-repository-for-github-actions-in-an-organization func (s *ActionsService) RemoveEnabledRepoInOrg(ctx context.Context, owner string, repositoryID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions/repositories/%v", owner, repositoryID) @@ -325,7 +325,7 @@ func (s *ActionsService) RemoveEnabledRepoInOrg(ctx context.Context, owner strin // GetOrganizationRunner gets a specific self-hosted runner for an organization using its runner ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-self-hosted-runner-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-an-organization func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Runner, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID) req, err := s.client.NewRequest("GET", u, nil) @@ -344,7 +344,7 @@ func (s *ActionsService) GetOrganizationRunner(ctx context.Context, owner string // CreateOrganizationRemoveToken creates a token that can be used to remove a self-hosted runner from an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-remove-token-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-remove-token-for-an-organization func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owner string) (*RemoveToken, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/runners/remove-token", owner) @@ -364,7 +364,7 @@ func (s *ActionsService) CreateOrganizationRemoveToken(ctx context.Context, owne // RemoveOrganizationRunner forces the removal of a self-hosted runner from an organization using the runner id. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-a-self-hosted-runner-from-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-organization func (s *ActionsService) RemoveOrganizationRunner(ctx context.Context, owner string, runnerID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/actions/runners/%v", owner, runnerID) diff --git a/vendor/github.com/google/go-github/v43/github/actions_secrets.go b/vendor/github.com/google/go-github/v47/github/actions_secrets.go similarity index 83% rename from vendor/github.com/google/go-github/v43/github/actions_secrets.go rename to vendor/github.com/google/go-github/v47/github/actions_secrets.go index 29f70a1a..316badb7 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_secrets.go +++ b/vendor/github.com/google/go-github/v47/github/actions_secrets.go @@ -64,7 +64,7 @@ func (s *ActionsService) getPublicKey(ctx context.Context, url string) (*PublicK // GetRepoPublicKey gets a public key that should be used for secret encryption. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-repository-public-key +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-public-key func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) { url := fmt.Sprintf("repos/%v/%v/actions/secrets/public-key", owner, repo) return s.getPublicKey(ctx, url) @@ -72,7 +72,7 @@ func (s *ActionsService) GetRepoPublicKey(ctx context.Context, owner, repo strin // GetOrgPublicKey gets a public key that should be used for secret encryption. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-an-organization-public-key +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-public-key func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/public-key", org) return s.getPublicKey(ctx, url) @@ -80,7 +80,7 @@ func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*Publ // GetEnvPublicKey gets a public key that should be used for secret encryption. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-an-environment-public-key +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key func (s *ActionsService) GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) { url := fmt.Sprintf("repositories/%v/environments/%v/secrets/public-key", repoID, env) return s.getPublicKey(ctx, url) @@ -124,7 +124,7 @@ func (s *ActionsService) listSecrets(ctx context.Context, url string, opts *List // ListRepoSecrets lists all secrets available in a repository // without revealing their encrypted values. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-repository-secrets +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-repository-secrets func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) { url := fmt.Sprintf("repos/%v/%v/actions/secrets", owner, repo) return s.listSecrets(ctx, url, opts) @@ -133,7 +133,7 @@ func (s *ActionsService) ListRepoSecrets(ctx context.Context, owner, repo string // ListOrgSecrets lists all secrets available in an organization // without revealing their encrypted values. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-organization-secrets +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-organization-secrets func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets", org) return s.listSecrets(ctx, url, opts) @@ -141,7 +141,7 @@ func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *L // ListEnvSecrets lists all secrets available in an environment. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-environment-secrets +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-environment-secrets func (s *ActionsService) ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) { url := fmt.Sprintf("repositories/%v/environments/%v/secrets", repoID, env) return s.listSecrets(ctx, url, opts) @@ -164,7 +164,7 @@ func (s *ActionsService) getSecret(ctx context.Context, url string) (*Secret, *R // GetRepoSecret gets a single repository secret without revealing its encrypted value. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-repository-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-a-repository-secret func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) { url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name) return s.getSecret(ctx, url) @@ -172,7 +172,7 @@ func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name st // GetOrgSecret gets a single organization secret without revealing its encrypted value. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-organization-secret func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name) return s.getSecret(ctx, url) @@ -180,13 +180,13 @@ func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*S // GetEnvSecret gets a single environment secret without revealing its encrypted value. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#list-environment-secrets +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret func (s *ActionsService) GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) { url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName) return s.getSecret(ctx, url) } -// SelectedRepoIDs are the repository IDs that have access to the secret. +// SelectedRepoIDs are the repository IDs that have access to the actions secrets. type SelectedRepoIDs []int64 // EncryptedSecret represents a secret that is encrypted using a public key. @@ -213,7 +213,7 @@ func (s *ActionsService) putSecret(ctx context.Context, url string, eSecret *Enc // CreateOrUpdateRepoSecret creates or updates a repository secret with an encrypted value. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-or-update-a-repository-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, eSecret.Name) return s.putSecret(ctx, url, eSecret) @@ -221,7 +221,7 @@ func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, re // CreateOrUpdateOrgSecret creates or updates an organization secret with an encrypted value. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-or-update-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-organization-secret func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, eSecret.Name) return s.putSecret(ctx, url, eSecret) @@ -229,7 +229,7 @@ func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string // CreateOrUpdateEnvSecret creates or updates a single environment secret with an encrypted value. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#create-or-update-an-environment-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret func (s *ActionsService) CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) { url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, eSecret.Name) return s.putSecret(ctx, url, eSecret) @@ -246,7 +246,7 @@ func (s *ActionsService) deleteSecret(ctx context.Context, url string) (*Respons // DeleteRepoSecret deletes a secret in a repository using the secret name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-a-repository-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-a-repository-secret func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/actions/secrets/%v", owner, repo, name) return s.deleteSecret(ctx, url) @@ -254,7 +254,7 @@ func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name // DeleteOrgSecret deletes a secret in an organization using the secret name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-organization-secret func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v", org, name) return s.deleteSecret(ctx, url) @@ -262,7 +262,7 @@ func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string) // DeleteEnvSecret deletes a secret in an environment using the secret name. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-an-environment-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret func (s *ActionsService) DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) { url := fmt.Sprintf("repositories/%v/environments/%v/secrets/%v", repoID, env, secretName) return s.deleteSecret(ctx, url) @@ -296,7 +296,7 @@ func (s *ActionsService) listSelectedReposForSecret(ctx context.Context, url str // ListSelectedReposForOrgSecret lists all repositories that have access to a secret. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-selected-repositories-for-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#list-selected-repositories-for-an-organization-secret func (s *ActionsService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name) return s.listSelectedReposForSecret(ctx, url, opts) @@ -317,7 +317,7 @@ func (s *ActionsService) setSelectedReposForSecret(ctx context.Context, url stri // SetSelectedReposForOrgSecret sets the repositories that have access to a secret. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#set-selected-repositories-for-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#set-selected-repositories-for-an-organization-secret func (s *ActionsService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories", org, name) return s.setSelectedReposForSecret(ctx, url, ids) @@ -334,7 +334,7 @@ func (s *ActionsService) addSelectedRepoToSecret(ctx context.Context, url string // AddSelectedRepoToOrgSecret adds a repository to an organization secret. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#add-selected-repository-to-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#add-selected-repository-to-an-organization-secret func (s *ActionsService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID) return s.addSelectedRepoToSecret(ctx, url) @@ -351,7 +351,7 @@ func (s *ActionsService) removeSelectedRepoFromSecret(ctx context.Context, url s // RemoveSelectedRepoFromOrgSecret removes a repository from an organization secret. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#remove-selected-repository-from-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/actions/secrets#remove-selected-repository-from-an-organization-secret func (s *ActionsService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { url := fmt.Sprintf("orgs/%v/actions/secrets/%v/repositories/%v", org, name, *repo.ID) return s.removeSelectedRepoFromSecret(ctx, url) diff --git a/vendor/github.com/google/go-github/v43/github/actions_workflow_jobs.go b/vendor/github.com/google/go-github/v47/github/actions_workflow_jobs.go similarity index 77% rename from vendor/github.com/google/go-github/v43/github/actions_workflow_jobs.go rename to vendor/github.com/google/go-github/v47/github/actions_workflow_jobs.go index 66b8ff6e..2867e82a 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_workflow_jobs.go +++ b/vendor/github.com/google/go-github/v47/github/actions_workflow_jobs.go @@ -66,7 +66,7 @@ type ListWorkflowJobsOptions struct { // ListWorkflowJobs lists all jobs for a workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-jobs-for-a-workflow-run +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo string, runID int64, opts *ListWorkflowJobsOptions) (*Jobs, *Response, error) { u := fmt.Sprintf("repos/%s/%s/actions/runs/%v/jobs", owner, repo, runID) u, err := addOptions(u, opts) @@ -90,7 +90,7 @@ func (s *ActionsService) ListWorkflowJobs(ctx context.Context, owner, repo strin // GetWorkflowJobByID gets a specific job in a workflow run by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-job-for-a-workflow-run +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo string, jobID int64) (*WorkflowJob, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v", owner, repo, jobID) @@ -110,45 +110,20 @@ func (s *ActionsService) GetWorkflowJobByID(ctx context.Context, owner, repo str // GetWorkflowJobLogs gets a redirect URL to download a plain text file of logs for a workflow job. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#download-job-logs-for-a-workflow-run +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run func (s *ActionsService) GetWorkflowJobLogs(ctx context.Context, owner, repo string, jobID int64, followRedirects bool) (*url.URL, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/logs", owner, repo, jobID) - resp, err := s.getWorkflowLogsFromURL(ctx, u, followRedirects) + resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) if err != nil { return nil, nil, err } + defer resp.Body.Close() if resp.StatusCode != http.StatusFound { return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) } + parsedURL, err := url.Parse(resp.Header.Get("Location")) return parsedURL, newResponse(resp), err } - -func (s *ActionsService) getWorkflowLogsFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) { - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, err - } - - var resp *http.Response - // Use http.DefaultTransport if no custom Transport is configured - req = withContext(ctx, req) - if s.client.client.Transport == nil { - resp, err = http.DefaultTransport.RoundTrip(req) - } else { - resp, err = s.client.client.Transport.RoundTrip(req) - } - if err != nil { - return nil, err - } - resp.Body.Close() - - // If redirect response is returned, follow it - if followRedirects && resp.StatusCode == http.StatusMovedPermanently { - u = resp.Header.Get("Location") - resp, err = s.getWorkflowLogsFromURL(ctx, u, false) - } - return resp, err -} diff --git a/vendor/github.com/google/go-github/v43/github/actions_workflow_runs.go b/vendor/github.com/google/go-github/v47/github/actions_workflow_runs.go similarity index 74% rename from vendor/github.com/google/go-github/v43/github/actions_workflow_runs.go rename to vendor/github.com/google/go-github/v47/github/actions_workflow_runs.go index 273d2cc4..9fd01c4a 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_workflow_runs.go +++ b/vendor/github.com/google/go-github/v47/github/actions_workflow_runs.go @@ -44,6 +44,7 @@ type WorkflowRun struct { WorkflowURL *string `json:"workflow_url,omitempty"` Repository *Repository `json:"repository,omitempty"` HeadRepository *Repository `json:"head_repository,omitempty"` + Actor *User `json:"actor,omitempty"` } // WorkflowRuns represents a slice of repository action workflow run. @@ -93,6 +94,14 @@ type WorkflowRunAttemptOptions struct { ExcludePullRequests *bool `url:"exclude_pull_requests,omitempty"` } +// PendingDeploymentsRequest specifies body parameters to PendingDeployments. +type PendingDeploymentsRequest struct { + EnvironmentIDs []int64 `json:"environment_ids"` + // State can be one of: "approved", "rejected". + State string `json:"state"` + Comment string `json:"comment"` +} + func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { u, err := addOptions(endpoint, opts) if err != nil { @@ -115,7 +124,7 @@ func (s *ActionsService) listWorkflowRuns(ctx context.Context, endpoint string, // ListWorkflowRunsByID lists all workflow runs by workflow ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-runs +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowID) return s.listWorkflowRuns(ctx, u, opts) @@ -123,7 +132,7 @@ func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo s // ListWorkflowRunsByFileName lists all workflow runs by workflow file name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-runs +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, repo, workflowFileName string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { u := fmt.Sprintf("repos/%s/%s/actions/workflows/%v/runs", owner, repo, workflowFileName) return s.listWorkflowRuns(ctx, u, opts) @@ -131,7 +140,7 @@ func (s *ActionsService) ListWorkflowRunsByFileName(ctx context.Context, owner, // ListRepositoryWorkflowRuns lists all workflow runs for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-workflow-runs-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#list-workflow-runs-for-a-repository func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner, repo string, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error) { u := fmt.Sprintf("repos/%s/%s/actions/runs", owner, repo) u, err := addOptions(u, opts) @@ -155,7 +164,7 @@ func (s *ActionsService) ListRepositoryWorkflowRuns(ctx context.Context, owner, // GetWorkflowRunByID gets a specific workflow run by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow-run +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRun, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID) @@ -175,7 +184,7 @@ func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo str // GetWorkflowRunAttempt gets a specific workflow run attempt. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow-run-attempt +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run-attempt func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo string, runID int64, attemptNumber int, opts *WorkflowRunAttemptOptions) (*WorkflowRun, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/attempts/%v", owner, repo, runID, attemptNumber) u, err := addOptions(u, opts) @@ -199,7 +208,7 @@ func (s *ActionsService) GetWorkflowRunAttempt(ctx context.Context, owner, repo // RerunWorkflowByID re-runs a workflow by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#re-run-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-workflow func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun", owner, repo, runID) @@ -211,9 +220,37 @@ func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo stri return s.client.Do(ctx, req, nil) } +// RerunFailedJobsByID re-runs all of the failed jobs and their dependent jobs in a workflow run by ID. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-failed-jobs-from-a-workflow-run +func (s *ActionsService) RerunFailedJobsByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/rerun-failed-jobs", owner, repo, runID) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + +// RerunJobByID re-runs a job and its dependent jobs in a workflow run by ID. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#re-run-a-job-from-a-workflow-run +func (s *ActionsService) RerunJobByID(ctx context.Context, owner, repo string, jobID int64) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/jobs/%v/rerun", owner, repo, jobID) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + // CancelWorkflowRunByID cancels a workflow run by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#cancel-a-workflow-run +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#cancel-a-workflow-run func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/cancel", owner, repo, runID) @@ -227,25 +264,27 @@ func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo // GetWorkflowRunLogs gets a redirect URL to download a plain text file of logs for a workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#download-workflow-run-logs +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#download-workflow-run-logs func (s *ActionsService) GetWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64, followRedirects bool) (*url.URL, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID) - resp, err := s.getWorkflowLogsFromURL(ctx, u, followRedirects) + resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) if err != nil { return nil, nil, err } + defer resp.Body.Close() if resp.StatusCode != http.StatusFound { return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) } + parsedURL, err := url.Parse(resp.Header.Get("Location")) return parsedURL, newResponse(resp), err } // DeleteWorkflowRun deletes a workflow run by ID. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-a-workflow-run func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo string, runID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v", owner, repo, runID) @@ -259,7 +298,7 @@ func (s *ActionsService) DeleteWorkflowRun(ctx context.Context, owner, repo stri // DeleteWorkflowRunLogs deletes all logs for a workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#delete-workflow-run-logs +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#delete-workflow-run-logs func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo string, runID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/logs", owner, repo, runID) @@ -273,7 +312,7 @@ func (s *ActionsService) DeleteWorkflowRunLogs(ctx context.Context, owner, repo // GetWorkflowRunUsageByID gets a specific workflow usage run by run ID in the unit of billable milliseconds. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-workflow-run-usage +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#get-workflow-run-usage func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRunUsage, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/timing", owner, repo, runID) @@ -290,3 +329,23 @@ func (s *ActionsService) GetWorkflowRunUsageByID(ctx context.Context, owner, rep return workflowRunUsage, resp, nil } + +// PendingDeployments approve or reject pending deployments that are waiting on approval by a required reviewer. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/workflow-runs#review-pending-deployments-for-a-workflow-run +func (s *ActionsService) PendingDeployments(ctx context.Context, owner, repo string, runID int64, request *PendingDeploymentsRequest) ([]*Deployment, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/pending_deployments", owner, repo, runID) + + req, err := s.client.NewRequest("POST", u, request) + if err != nil { + return nil, nil, err + } + + var deployments []*Deployment + resp, err := s.client.Do(ctx, req, &deployments) + if err != nil { + return nil, resp, err + } + + return deployments, resp, nil +} diff --git a/vendor/github.com/google/go-github/v43/github/actions_workflows.go b/vendor/github.com/google/go-github/v47/github/actions_workflows.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/actions_workflows.go rename to vendor/github.com/google/go-github/v47/github/actions_workflows.go index e0568462..9973a5d3 100644 --- a/vendor/github.com/google/go-github/v43/github/actions_workflows.go +++ b/vendor/github.com/google/go-github/v47/github/actions_workflows.go @@ -61,7 +61,7 @@ type CreateWorkflowDispatchEventRequest struct { // ListWorkflows lists all workflows in a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#list-repository-workflows +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#list-repository-workflows func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error) { u := fmt.Sprintf("repos/%s/%s/actions/workflows", owner, repo) u, err := addOptions(u, opts) @@ -85,7 +85,7 @@ func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, // GetWorkflowByID gets a specific workflow by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-a-workflow func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowID) @@ -94,7 +94,7 @@ func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string // GetWorkflowByFileName gets a specific workflow by file name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-a-workflow func (s *ActionsService) GetWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Workflow, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v", owner, repo, workflowFileName) @@ -118,7 +118,7 @@ func (s *ActionsService) getWorkflow(ctx context.Context, url string) (*Workflow // GetWorkflowUsageByID gets a specific workflow usage by ID in the unit of billable milliseconds. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-workflow-usage +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-workflow-usage func (s *ActionsService) GetWorkflowUsageByID(ctx context.Context, owner, repo string, workflowID int64) (*WorkflowUsage, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowID) @@ -127,7 +127,7 @@ func (s *ActionsService) GetWorkflowUsageByID(ctx context.Context, owner, repo s // GetWorkflowUsageByFileName gets a specific workflow usage by file name in the unit of billable milliseconds. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#get-workflow-usage +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#get-workflow-usage func (s *ActionsService) GetWorkflowUsageByFileName(ctx context.Context, owner, repo, workflowFileName string) (*WorkflowUsage, *Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/timing", owner, repo, workflowFileName) @@ -151,7 +151,7 @@ func (s *ActionsService) getWorkflowUsage(ctx context.Context, url string) (*Wor // CreateWorkflowDispatchEventByID manually triggers a GitHub Actions workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-workflow-dispatch-event +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, owner, repo string, workflowID int64, event CreateWorkflowDispatchEventRequest) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowID) @@ -160,7 +160,7 @@ func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, ow // CreateWorkflowDispatchEventByFileName manually triggers a GitHub Actions workflow run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#create-a-workflow-dispatch-event +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#create-a-workflow-dispatch-event func (s *ActionsService) CreateWorkflowDispatchEventByFileName(ctx context.Context, owner, repo, workflowFileName string, event CreateWorkflowDispatchEventRequest) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/dispatches", owner, repo, workflowFileName) @@ -178,7 +178,7 @@ func (s *ActionsService) createWorkflowDispatchEvent(ctx context.Context, url st // EnableWorkflowByID enables a workflow and sets the state of the workflow to "active". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#enable-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#enable-a-workflow func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowID) return s.doNewPutRequest(ctx, u) @@ -186,7 +186,7 @@ func (s *ActionsService) EnableWorkflowByID(ctx context.Context, owner, repo str // EnableWorkflowByFileName enables a workflow and sets the state of the workflow to "active". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#enable-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#enable-a-workflow func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/enable", owner, repo, workflowFileName) return s.doNewPutRequest(ctx, u) @@ -194,7 +194,7 @@ func (s *ActionsService) EnableWorkflowByFileName(ctx context.Context, owner, re // DisableWorkflowByID disables a workflow and sets the state of the workflow to "disabled_manually". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#disable-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#disable-a-workflow func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowID) return s.doNewPutRequest(ctx, u) @@ -202,7 +202,7 @@ func (s *ActionsService) DisableWorkflowByID(ctx context.Context, owner, repo st // DisableWorkflowByFileName disables a workflow and sets the state of the workflow to "disabled_manually". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/actions/#disable-a-workflow +// GitHub API docs: https://docs.github.com/en/rest/actions/workflows#disable-a-workflow func (s *ActionsService) DisableWorkflowByFileName(ctx context.Context, owner, repo, workflowFileName string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/actions/workflows/%v/disable", owner, repo, workflowFileName) return s.doNewPutRequest(ctx, u) diff --git a/vendor/github.com/google/go-github/v43/github/activity.go b/vendor/github.com/google/go-github/v47/github/activity.go similarity index 80% rename from vendor/github.com/google/go-github/v43/github/activity.go rename to vendor/github.com/google/go-github/v47/github/activity.go index e683afb9..9cd9f9b7 100644 --- a/vendor/github.com/google/go-github/v43/github/activity.go +++ b/vendor/github.com/google/go-github/v47/github/activity.go @@ -10,7 +10,7 @@ import "context" // ActivityService handles communication with the activity related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/ +// GitHub API docs: https://docs.github.com/en/rest/activity/ type ActivityService service // FeedLink represents a link to a related resource. @@ -45,14 +45,15 @@ type FeedLinks struct { // ListFeeds lists all the feeds available to the authenticated user. // // GitHub provides several timeline resources in Atom format: -// Timeline: The GitHub global public timeline -// User: The public timeline for any user, using URI template -// Current user public: The public timeline for the authenticated user -// Current user: The private timeline for the authenticated user -// Current user actor: The private timeline for activity created by the -// authenticated user -// Current user organizations: The private timeline for the organizations -// the authenticated user is a member of. +// +// Timeline: The GitHub global public timeline +// User: The public timeline for any user, using URI template +// Current user public: The public timeline for the authenticated user +// Current user: The private timeline for the authenticated user +// Current user actor: The private timeline for activity created by the +// authenticated user +// Current user organizations: The private timeline for the organizations +// the authenticated user is a member of. // // Note: Private feeds are only returned when authenticating via Basic Auth // since current feed URIs use the older, non revocable auth tokens. diff --git a/vendor/github.com/google/go-github/v43/github/activity_events.go b/vendor/github.com/google/go-github/v47/github/activity_events.go similarity index 79% rename from vendor/github.com/google/go-github/v43/github/activity_events.go rename to vendor/github.com/google/go-github/v47/github/activity_events.go index 19dc15cf..d6f0f043 100644 --- a/vendor/github.com/google/go-github/v43/github/activity_events.go +++ b/vendor/github.com/google/go-github/v47/github/activity_events.go @@ -12,7 +12,7 @@ import ( // ListEvents drinks from the firehose of all public events across GitHub. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([]*Event, *Response, error) { u, err := addOptions("events", opts) if err != nil { @@ -35,7 +35,7 @@ func (s *ActivityService) ListEvents(ctx context.Context, opts *ListOptions) ([] // ListRepositoryEvents lists events for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-events +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-repository-events func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("repos/%v/%v/events", owner, repo) u, err := addOptions(u, opts) @@ -59,7 +59,7 @@ func (s *ActivityService) ListRepositoryEvents(ctx context.Context, owner, repo // ListIssueEventsForRepository lists issue events for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events-for-a-repository func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo) u, err := addOptions(u, opts) @@ -83,7 +83,7 @@ func (s *ActivityService) ListIssueEventsForRepository(ctx context.Context, owne // ListEventsForRepoNetwork lists public events for a network of repositories. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-for-a-network-of-repositories +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events-for-a-network-of-repositories func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("networks/%v/%v/events", owner, repo) u, err := addOptions(u, opts) @@ -107,7 +107,7 @@ func (s *ActivityService) ListEventsForRepoNetwork(ctx context.Context, owner, r // ListEventsForOrganization lists public events for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-organization-events +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-organization-events func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org string, opts *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("orgs/%v/events", org) u, err := addOptions(u, opts) @@ -132,8 +132,8 @@ func (s *ActivityService) ListEventsForOrganization(ctx context.Context, org str // ListEventsPerformedByUser lists the events performed by a user. If publicOnly is // true, only public events will be returned. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-events-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events-for-a-user func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) { var u string if publicOnly { @@ -163,8 +163,8 @@ func (s *ActivityService) ListEventsPerformedByUser(ctx context.Context, user st // ListEventsReceivedByUser lists the events received by a user. If publicOnly is // true, only public events will be returned. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-events-received-by-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-public-events-received-by-a-user +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-events-received-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-public-events-received-by-a-user func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user string, publicOnly bool, opts *ListOptions) ([]*Event, *Response, error) { var u string if publicOnly { @@ -194,7 +194,7 @@ func (s *ActivityService) ListEventsReceivedByUser(ctx context.Context, user str // ListUserEventsForOrganization provides the user’s organization dashboard. You // must be authenticated as the user to view this. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-organization-events-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/events#list-organization-events-for-the-authenticated-user func (s *ActivityService) ListUserEventsForOrganization(ctx context.Context, org, user string, opts *ListOptions) ([]*Event, *Response, error) { u := fmt.Sprintf("users/%v/events/orgs/%v", user, org) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/activity_notifications.go b/vendor/github.com/google/go-github/v47/github/activity_notifications.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/activity_notifications.go rename to vendor/github.com/google/go-github/v47/github/activity_notifications.go index 009cc5e3..38a31845 100644 --- a/vendor/github.com/google/go-github/v43/github/activity_notifications.go +++ b/vendor/github.com/google/go-github/v47/github/activity_notifications.go @@ -19,7 +19,7 @@ type Notification struct { // Reason identifies the event that triggered the notification. // - // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity#notification-reasons + // GitHub API docs: https://docs.github.com/en/rest/activity#notification-reasons Reason *string `json:"reason,omitempty"` Unread *bool `json:"unread,omitempty"` @@ -49,7 +49,7 @@ type NotificationListOptions struct { // ListNotifications lists all notifications for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-notifications-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-notifications-for-the-authenticated-user func (s *ActivityService) ListNotifications(ctx context.Context, opts *NotificationListOptions) ([]*Notification, *Response, error) { u := "notifications" u, err := addOptions(u, opts) @@ -74,7 +74,7 @@ func (s *ActivityService) ListNotifications(ctx context.Context, opts *Notificat // ListRepositoryNotifications lists all notifications in a given repository // for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repository-notifications-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#list-repository-notifications-for-the-authenticated-user func (s *ActivityService) ListRepositoryNotifications(ctx context.Context, owner, repo string, opts *NotificationListOptions) ([]*Notification, *Response, error) { u := fmt.Sprintf("repos/%v/%v/notifications", owner, repo) u, err := addOptions(u, opts) @@ -102,7 +102,7 @@ type markReadOptions struct { // MarkNotificationsRead marks all notifications up to lastRead as read. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity#mark-as-read +// GitHub API docs: https://docs.github.com/en/rest/activity#mark-as-read func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead time.Time) (*Response, error) { opts := &markReadOptions{ LastReadAt: lastRead, @@ -118,7 +118,7 @@ func (s *ActivityService) MarkNotificationsRead(ctx context.Context, lastRead ti // MarkRepositoryNotificationsRead marks all notifications up to lastRead in // the specified repository as read. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#mark-repository-notifications-as-read +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-repository-notifications-as-read func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, owner, repo string, lastRead time.Time) (*Response, error) { opts := &markReadOptions{ LastReadAt: lastRead, @@ -134,7 +134,7 @@ func (s *ActivityService) MarkRepositoryNotificationsRead(ctx context.Context, o // GetThread gets the specified notification thread. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-thread +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notification, *Response, error) { u := fmt.Sprintf("notifications/threads/%v", id) @@ -154,7 +154,7 @@ func (s *ActivityService) GetThread(ctx context.Context, id string) (*Notificati // MarkThreadRead marks the specified thread as read. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#mark-a-thread-as-read +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#mark-a-thread-as-read func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Response, error) { u := fmt.Sprintf("notifications/threads/%v", id) @@ -169,7 +169,7 @@ func (s *ActivityService) MarkThreadRead(ctx context.Context, id string) (*Respo // GetThreadSubscription checks to see if the authenticated user is subscribed // to a thread. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-thread-subscription-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#get-a-thread-subscription-for-the-authenticated-user func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) (*Subscription, *Response, error) { u := fmt.Sprintf("notifications/threads/%v/subscription", id) @@ -190,7 +190,7 @@ func (s *ActivityService) GetThreadSubscription(ctx context.Context, id string) // SetThreadSubscription sets the subscription for the specified thread for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#set-a-thread-subscription +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#set-a-thread-subscription func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, subscription *Subscription) (*Subscription, *Response, error) { u := fmt.Sprintf("notifications/threads/%v/subscription", id) @@ -211,7 +211,7 @@ func (s *ActivityService) SetThreadSubscription(ctx context.Context, id string, // DeleteThreadSubscription deletes the subscription for the specified thread // for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#delete-a-thread-subscription +// GitHub API docs: https://docs.github.com/en/rest/activity/notifications#delete-a-thread-subscription func (s *ActivityService) DeleteThreadSubscription(ctx context.Context, id string) (*Response, error) { u := fmt.Sprintf("notifications/threads/%v/subscription", id) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/activity_star.go b/vendor/github.com/google/go-github/v47/github/activity_star.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/activity_star.go rename to vendor/github.com/google/go-github/v47/github/activity_star.go index ad07aac7..65a316f5 100644 --- a/vendor/github.com/google/go-github/v43/github/activity_star.go +++ b/vendor/github.com/google/go-github/v47/github/activity_star.go @@ -25,7 +25,7 @@ type Stargazer struct { // ListStargazers lists people who have starred the specified repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-stargazers +// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-stargazers func (s *ActivityService) ListStargazers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Stargazer, *Response, error) { u := fmt.Sprintf("repos/%s/%s/stargazers", owner, repo) u, err := addOptions(u, opts) @@ -67,8 +67,8 @@ type ActivityListStarredOptions struct { // ListStarred lists all the repos starred by a user. Passing the empty string // will list the starred repositories for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-starred-by-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-starred-by-a-user +// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-repositories-starred-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/starring#list-repositories-starred-by-a-user func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *ActivityListStarredOptions) ([]*StarredRepository, *Response, error) { var u string if user != "" { @@ -101,13 +101,14 @@ func (s *ActivityService) ListStarred(ctx context.Context, user string, opts *Ac // IsStarred checks if a repository is starred by authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#check-if-a-repository-is-starred-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/starring#check-if-a-repository-is-starred-by-the-authenticated-user func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bool, *Response, error) { u := fmt.Sprintf("user/starred/%v/%v", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, nil, err } + resp, err := s.client.Do(ctx, req, nil) starred, err := parseBoolResponse(err) return starred, resp, err @@ -115,24 +116,26 @@ func (s *ActivityService) IsStarred(ctx context.Context, owner, repo string) (bo // Star a repository as the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#star-a-repository-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/starring#star-a-repository-for-the-authenticated-user func (s *ActivityService) Star(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("user/starred/%v/%v", owner, repo) req, err := s.client.NewRequest("PUT", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } // Unstar a repository as the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#unstar-a-repository-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/starring#unstar-a-repository-for-the-authenticated-user func (s *ActivityService) Unstar(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("user/starred/%v/%v", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } diff --git a/vendor/github.com/google/go-github/v43/github/activity_watching.go b/vendor/github.com/google/go-github/v47/github/activity_watching.go similarity index 84% rename from vendor/github.com/google/go-github/v43/github/activity_watching.go rename to vendor/github.com/google/go-github/v47/github/activity_watching.go index 16cceb53..2d6fafcc 100644 --- a/vendor/github.com/google/go-github/v43/github/activity_watching.go +++ b/vendor/github.com/google/go-github/v47/github/activity_watching.go @@ -27,7 +27,7 @@ type Subscription struct { // ListWatchers lists watchers of a particular repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-watchers +// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-watchers func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) { u := fmt.Sprintf("repos/%s/%s/subscribers", owner, repo) u, err := addOptions(u, opts) @@ -52,8 +52,8 @@ func (s *ActivityService) ListWatchers(ctx context.Context, owner, repo string, // ListWatched lists the repositories the specified user is watching. Passing // the empty string will fetch watched repos for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-watched-by-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#list-repositories-watched-by-a-user +// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/activity/watching#list-repositories-watched-by-a-user func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *ListOptions) ([]*Repository, *Response, error) { var u string if user != "" { @@ -84,7 +84,7 @@ func (s *ActivityService) ListWatched(ctx context.Context, user string, opts *Li // repository for the authenticated user. If the authenticated user is not // watching the repository, a nil Subscription is returned. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#get-a-repository-subscription +// GitHub API docs: https://docs.github.com/en/rest/activity/watching#get-a-repository-subscription func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, repo string) (*Subscription, *Response, error) { u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) @@ -111,7 +111,7 @@ func (s *ActivityService) GetRepositorySubscription(ctx context.Context, owner, // To ignore notifications made within a repository, set subscription.Ignored to true. // To stop watching a repository, use DeleteRepositorySubscription. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#set-a-repository-subscription +// GitHub API docs: https://docs.github.com/en/rest/activity/watching#set-a-repository-subscription func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, repo string, subscription *Subscription) (*Subscription, *Response, error) { u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) @@ -135,7 +135,7 @@ func (s *ActivityService) SetRepositorySubscription(ctx context.Context, owner, // This is used to stop watching a repository. To control whether or not to // receive notifications from a repository, use SetRepositorySubscription. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/activity/#delete-a-repository-subscription +// GitHub API docs: https://docs.github.com/en/rest/activity/watching#delete-a-repository-subscription func (s *ActivityService) DeleteRepositorySubscription(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("repos/%s/%s/subscription", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/admin.go b/vendor/github.com/google/go-github/v47/github/admin.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/admin.go rename to vendor/github.com/google/go-github/v47/github/admin.go index 7bf0f22b..1b28ef64 100644 --- a/vendor/github.com/google/go-github/v43/github/admin.go +++ b/vendor/github.com/google/go-github/v47/github/admin.go @@ -14,7 +14,7 @@ import ( // GitHub API. These API routes are normally only accessible for GitHub // Enterprise installations. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise/ +// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin type AdminService service // TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group. @@ -82,7 +82,7 @@ func (m Enterprise) String() string { // UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise/ldap/#update-ldap-mapping-for-a-user +// GitHub API docs: https://docs.github.com/en/enterprise-server/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) { u := fmt.Sprintf("admin/ldap/users/%v/mapping", user) req, err := s.client.NewRequest("PATCH", u, mapping) @@ -101,7 +101,7 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m // UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise/ldap/#update-ldap-mapping-for-a-team +// GitHub API docs: https://docs.github.com/en/rest/enterprise/ldap/#update-ldap-mapping-for-a-team func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) { u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team) req, err := s.client.NewRequest("PATCH", u, mapping) diff --git a/vendor/github.com/google/go-github/v43/github/admin_orgs.go b/vendor/github.com/google/go-github/v47/github/admin_orgs.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/admin_orgs.go rename to vendor/github.com/google/go-github/v47/github/admin_orgs.go diff --git a/vendor/github.com/google/go-github/v43/github/admin_stats.go b/vendor/github.com/google/go-github/v47/github/admin_stats.go similarity index 97% rename from vendor/github.com/google/go-github/v43/github/admin_stats.go rename to vendor/github.com/google/go-github/v47/github/admin_stats.go index 0744ffa4..ef294f44 100644 --- a/vendor/github.com/google/go-github/v43/github/admin_stats.go +++ b/vendor/github.com/google/go-github/v47/github/admin_stats.go @@ -153,7 +153,7 @@ func (s RepoStats) String() string { // Please note that this is only available to site administrators, // otherwise it will error with a 404 not found (instead of 401 or 403). // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/admin_stats/ +// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/admin_stats/ func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) { u := fmt.Sprintf("enterprise/stats/all") req, err := s.client.NewRequest("GET", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/admin_users.go b/vendor/github.com/google/go-github/v47/github/admin_users.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/admin_users.go rename to vendor/github.com/google/go-github/v47/github/admin_users.go diff --git a/vendor/github.com/google/go-github/v43/github/apps.go b/vendor/github.com/google/go-github/v47/github/apps.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/apps.go rename to vendor/github.com/google/go-github/v47/github/apps.go index 3823a121..98d8a6fd 100644 --- a/vendor/github.com/google/go-github/v43/github/apps.go +++ b/vendor/github.com/google/go-github/v47/github/apps.go @@ -14,7 +14,7 @@ import ( // AppsService provides access to the installation related functions // in the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/ +// GitHub API docs: https://docs.github.com/en/rest/apps/ type AppsService service // App represents a GitHub App. @@ -59,8 +59,9 @@ type InstallationTokenOptions struct { // InstallationPermissions lists the repository and organization permissions for an installation. // // Permission names taken from: -// https://docs.github.com/en/enterprise-server@3.0/rest/reference/apps#create-an-installation-access-token-for-an-app -// https://docs.github.com/en/rest/reference/apps#create-an-installation-access-token-for-an-app +// +// https://docs.github.com/en/enterprise-server@3.0/rest/apps#create-an-installation-access-token-for-an-app +// https://docs.github.com/en/rest/apps#create-an-installation-access-token-for-an-app type InstallationPermissions struct { Actions *string `json:"actions,omitempty"` Administration *string `json:"administration,omitempty"` @@ -76,7 +77,9 @@ type InstallationPermissions struct { Metadata *string `json:"metadata,omitempty"` Members *string `json:"members,omitempty"` OrganizationAdministration *string `json:"organization_administration,omitempty"` + OrganizationCustomRoles *string `json:"organization_custom_roles,omitempty"` OrganizationHooks *string `json:"organization_hooks,omitempty"` + OrganizationPackages *string `json:"organization_packages,omitempty"` OrganizationPlan *string `json:"organization_plan,omitempty"` OrganizationPreReceiveHooks *string `json:"organization_pre_receive_hooks,omitempty"` OrganizationProjects *string `json:"organization_projects,omitempty"` @@ -148,8 +151,8 @@ func (i Installation) String() string { // You can find this on the settings page for your GitHub App // (e.g., https://github.com/settings/apps/:app_slug). // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-the-authenticated-app -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-an-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-app func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) { var u string if appSlug != "" { @@ -174,7 +177,7 @@ func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, // ListInstallations lists the installations that the current GitHub App has. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-installations-for-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#list-installations-for-the-authenticated-app func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) { u, err := addOptions("app/installations", opts) if err != nil { @@ -197,14 +200,14 @@ func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) // GetInstallation returns the specified installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-an-installation-for-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-installation-for-the-authenticated-app func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) { return s.getInstallation(ctx, fmt.Sprintf("app/installations/%v", id)) } // ListUserInstallations lists installations that are accessible to the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-app-installations-accessible-to-the-user-access-token +// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-app-installations-accessible-to-the-user-access-token func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error) { u, err := addOptions("user/installations", opts) if err != nil { @@ -229,7 +232,7 @@ func (s *AppsService) ListUserInstallations(ctx context.Context, opts *ListOptio // SuspendInstallation suspends the specified installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#suspend-an-app-installation +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#suspend-an-app-installation func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Response, error) { u := fmt.Sprintf("app/installations/%v/suspended", id) @@ -243,7 +246,7 @@ func (s *AppsService) SuspendInstallation(ctx context.Context, id int64) (*Respo // UnsuspendInstallation unsuspends the specified installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#unsuspend-an-app-installation +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#unsuspend-an-app-installation func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Response, error) { u := fmt.Sprintf("app/installations/%v/suspended", id) @@ -257,7 +260,7 @@ func (s *AppsService) UnsuspendInstallation(ctx context.Context, id int64) (*Res // DeleteInstallation deletes the specified installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#delete-an-installation-for-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#delete-an-installation-for-the-authenticated-app func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Response, error) { u := fmt.Sprintf("app/installations/%v", id) @@ -271,7 +274,7 @@ func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Respon // CreateInstallationToken creates a new installation token. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-an-installation-access-token-for-an-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error) { u := fmt.Sprintf("app/installations/%v/access_tokens", id) @@ -291,7 +294,7 @@ func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opt // CreateAttachment creates a new attachment on user comment containing a url. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-a-content-attachment +// TODO: Find GitHub API docs. func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID int64, title, body string) (*Attachment, *Response, error) { u := fmt.Sprintf("content_references/%v/attachments", contentReferenceID) payload := &Attachment{Title: String(title), Body: String(body)} @@ -314,14 +317,14 @@ func (s *AppsService) CreateAttachment(ctx context.Context, contentReferenceID i // FindOrganizationInstallation finds the organization's installation information. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-an-organization-installation-for-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-an-organization-installation-for-the-authenticated-app func (s *AppsService) FindOrganizationInstallation(ctx context.Context, org string) (*Installation, *Response, error) { return s.getInstallation(ctx, fmt.Sprintf("orgs/%v/installation", org)) } // FindRepositoryInstallation finds the repository's installation information. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-a-repository-installation-for-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-a-repository-installation-for-the-authenticated-app func (s *AppsService) FindRepositoryInstallation(ctx context.Context, owner, repo string) (*Installation, *Response, error) { return s.getInstallation(ctx, fmt.Sprintf("repos/%v/%v/installation", owner, repo)) } @@ -335,7 +338,7 @@ func (s *AppsService) FindRepositoryInstallationByID(ctx context.Context, id int // FindUserInstallation finds the user's installation information. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#get-a-user-installation-for-the-authenticated-app +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#get-a-user-installation-for-the-authenticated-app func (s *AppsService) FindUserInstallation(ctx context.Context, user string) (*Installation, *Response, error) { return s.getInstallation(ctx, fmt.Sprintf("users/%v/installation", user)) } diff --git a/vendor/github.com/google/go-github/v43/github/apps_hooks.go b/vendor/github.com/google/go-github/v47/github/apps_hooks.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/apps_hooks.go rename to vendor/github.com/google/go-github/v47/github/apps_hooks.go index ed8396f4..e3bd2afc 100644 --- a/vendor/github.com/google/go-github/v43/github/apps_hooks.go +++ b/vendor/github.com/google/go-github/v47/github/apps_hooks.go @@ -12,7 +12,7 @@ import ( // GetHookConfig returns the webhook configuration for a GitHub App. // The underlying transport must be authenticated as an app. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#get-a-webhook-configuration-for-an-app +// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-webhook-configuration-for-an-app func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) { req, err := s.client.NewRequest("GET", "app/hook/config", nil) if err != nil { @@ -31,7 +31,7 @@ func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response // UpdateHookConfig updates the webhook configuration for a GitHub App. // The underlying transport must be authenticated as an app. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#update-a-webhook-configuration-for-an-app +// GitHub API docs: https://docs.github.com/en/rest/apps#update-a-webhook-configuration-for-an-app func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) { req, err := s.client.NewRequest("PATCH", "app/hook/config", config) if err != nil { diff --git a/vendor/github.com/google/go-github/v43/github/apps_hooks_deliveries.go b/vendor/github.com/google/go-github/v47/github/apps_hooks_deliveries.go similarity index 84% rename from vendor/github.com/google/go-github/v43/github/apps_hooks_deliveries.go rename to vendor/github.com/google/go-github/v47/github/apps_hooks_deliveries.go index 0b631b80..33102f36 100644 --- a/vendor/github.com/google/go-github/v43/github/apps_hooks_deliveries.go +++ b/vendor/github.com/google/go-github/v47/github/apps_hooks_deliveries.go @@ -12,7 +12,7 @@ import ( // ListHookDeliveries lists deliveries of an App webhook. // -// GitHub API docs: https://docs.github.com/en/rest/reference/apps#list-deliveries-for-an-app-webhook +// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) { u, err := addOptions("app/hook/deliveries", opts) if err != nil { @@ -35,7 +35,7 @@ func (s *AppsService) ListHookDeliveries(ctx context.Context, opts *ListCursorOp // GetHookDelivery returns the App webhook delivery with the specified ID. // -// GitHub API docs: https://docs.github.com/en/rest/reference/apps#get-a-delivery-for-an-app-webhook +// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) { u := fmt.Sprintf("app/hook/deliveries/%v", deliveryID) req, err := s.client.NewRequest("GET", u, nil) @@ -54,7 +54,7 @@ func (s *AppsService) GetHookDelivery(ctx context.Context, deliveryID int64) (*H // RedeliverHookDelivery redelivers a delivery for an App webhook. // -// GitHub API docs: https://docs.github.com/en/rest/reference/apps#redeliver-a-delivery-for-an-app-webhook +// GitHub API docs: https://docs.github.com/en/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook func (s *AppsService) RedeliverHookDelivery(ctx context.Context, deliveryID int64) (*HookDelivery, *Response, error) { u := fmt.Sprintf("app/hook/deliveries/%v/attempts", deliveryID) req, err := s.client.NewRequest("POST", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/apps_installation.go b/vendor/github.com/google/go-github/v47/github/apps_installation.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/apps_installation.go rename to vendor/github.com/google/go-github/v47/github/apps_installation.go index 521860d6..b6190807 100644 --- a/vendor/github.com/google/go-github/v43/github/apps_installation.go +++ b/vendor/github.com/google/go-github/v47/github/apps_installation.go @@ -19,7 +19,7 @@ type ListRepositories struct { // ListRepos lists the repositories that are accessible to the authenticated installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-repositories-accessible-to-the-app-installation +// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-repositories-accessible-to-the-app-installation func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRepositories, *Response, error) { u, err := addOptions("installation/repositories", opts) if err != nil { @@ -52,7 +52,7 @@ func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) (*ListRe // ListUserRepos lists repositories that are accessible // to the authenticated user for an installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-repositories-accessible-to-the-user-access-token +// GitHub API docs: https://docs.github.com/en/rest/apps/installations#list-repositories-accessible-to-the-user-access-token func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOptions) (*ListRepositories, *Response, error) { u := fmt.Sprintf("user/installations/%v/repositories", id) u, err := addOptions(u, opts) @@ -84,7 +84,7 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOpt // AddRepository adds a single repository to an installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#add-a-repository-to-an-app-installation +// GitHub API docs: https://docs.github.com/en/rest/apps/installations#add-a-repository-to-an-app-installation func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) { u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID) req, err := s.client.NewRequest("PUT", u, nil) @@ -103,7 +103,7 @@ func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) ( // RemoveRepository removes a single repository from an installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#remove-a-repository-from-an-app-installation +// GitHub API docs: https://docs.github.com/en/rest/apps/installations#remove-a-repository-from-an-app-installation func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) { u := fmt.Sprintf("user/installations/%v/repositories/%v", instID, repoID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -116,7 +116,7 @@ func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64 // RevokeInstallationToken revokes an installation token. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#revoke-an-installation-access-token +// GitHub API docs: https://docs.github.com/en/rest/apps/installations#revoke-an-installation-access-token func (s *AppsService) RevokeInstallationToken(ctx context.Context) (*Response, error) { u := "installation/token" req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/apps_manifest.go b/vendor/github.com/google/go-github/v47/github/apps_manifest.go similarity index 92% rename from vendor/github.com/google/go-github/v43/github/apps_manifest.go rename to vendor/github.com/google/go-github/v47/github/apps_manifest.go index 164f4939..fa4c8537 100644 --- a/vendor/github.com/google/go-github/v43/github/apps_manifest.go +++ b/vendor/github.com/google/go-github/v47/github/apps_manifest.go @@ -31,7 +31,7 @@ type AppConfig struct { // CompleteAppManifest completes the App manifest handshake flow for the given // code. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-a-github-app-from-a-manifest +// GitHub API docs: https://docs.github.com/en/rest/apps/apps#create-a-github-app-from-a-manifest func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) { u := fmt.Sprintf("app-manifests/%s/conversions", code) req, err := s.client.NewRequest("POST", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/apps_marketplace.go b/vendor/github.com/google/go-github/v47/github/apps_marketplace.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/apps_marketplace.go rename to vendor/github.com/google/go-github/v47/github/apps_marketplace.go index 13d09f2e..82530136 100644 --- a/vendor/github.com/google/go-github/v43/github/apps_marketplace.go +++ b/vendor/github.com/google/go-github/v47/github/apps_marketplace.go @@ -13,7 +13,7 @@ import ( // MarketplaceService handles communication with the marketplace related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#marketplace +// GitHub API docs: https://docs.github.com/en/rest/apps#marketplace type MarketplaceService struct { client *Client // Stubbed controls whether endpoints that return stubbed data are used @@ -21,7 +21,7 @@ type MarketplaceService struct { // for testing your GitHub Apps. Stubbed data is hard-coded and will not // change based on actual subscriptions. // - // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#testing-with-stubbed-endpoints + // GitHub API docs: https://docs.github.com/en/rest/apps#testing-with-stubbed-endpoints Stubbed bool } @@ -77,7 +77,7 @@ type MarketplacePlanAccount struct { // ListPlans lists all plans for your Marketplace listing. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-plans +// GitHub API docs: https://docs.github.com/en/rest/apps#list-plans func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ([]*MarketplacePlan, *Response, error) { uri := s.marketplaceURI("plans") u, err := addOptions(uri, opts) @@ -101,7 +101,7 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opts *ListOptions) ( // ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan. // -// GitHub API docs: https://docs.github.com/en/rest/reference/apps#list-accounts-for-a-plan +// GitHub API docs: https://docs.github.com/en/rest/apps#list-accounts-for-a-plan func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opts *ListOptions) ([]*MarketplacePlanAccount, *Response, error) { uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID)) u, err := addOptions(uri, opts) @@ -125,7 +125,7 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID // GetPlanAccountForAccount get GitHub account (user or organization) associated with an account. // -// GitHub API docs: https://docs.github.com/en/rest/reference/apps#get-a-subscription-plan-for-an-account +// GitHub API docs: https://docs.github.com/en/rest/apps#get-a-subscription-plan-for-an-account func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accountID int64) (*MarketplacePlanAccount, *Response, error) { uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID)) @@ -145,8 +145,8 @@ func (s *MarketplaceService) GetPlanAccountForAccount(ctx context.Context, accou // ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-subscriptions-for-the-authenticated-user-stubbed -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#list-subscriptions-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user-stubbed +// GitHub API docs: https://docs.github.com/en/rest/apps/marketplace#list-subscriptions-for-the-authenticated-user func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opts *ListOptions) ([]*MarketplacePurchase, *Response, error) { uri := "user/marketplace_purchases" if s.Stubbed { diff --git a/vendor/github.com/google/go-github/v43/github/authorizations.go b/vendor/github.com/google/go-github/v47/github/authorizations.go similarity index 92% rename from vendor/github.com/google/go-github/v43/github/authorizations.go rename to vendor/github.com/google/go-github/v47/github/authorizations.go index 76a14c3d..ea0897e3 100644 --- a/vendor/github.com/google/go-github/v43/github/authorizations.go +++ b/vendor/github.com/google/go-github/v47/github/authorizations.go @@ -12,7 +12,7 @@ import ( // Scope models a GitHub authorization scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth/#scopes +// GitHub API docs: https://docs.github.com/en/rest/oauth/#scopes type Scope string // This is the set of scopes for GitHub API V3 @@ -50,7 +50,7 @@ const ( // This service requires HTTP Basic Authentication; it cannot be accessed using // an OAuth token. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth_authorizations/ +// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations type AuthorizationsService service // Authorization represents an individual GitHub authorization. @@ -121,7 +121,7 @@ func (a AuthorizationRequest) String() string { // fields. That is, you may provide only one of "Scopes", or "AddScopes", or // "RemoveScopes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/oauth_authorizations/#update-an-existing-authorization +// GitHub API docs: https://docs.github.com/en/rest/oauth-authorizations#update-an-existing-authorization type AuthorizationUpdateRequest struct { Scopes []string `json:"scopes,omitempty"` AddScopes []string `json:"add_scopes,omitempty"` @@ -143,7 +143,7 @@ func (a AuthorizationUpdateRequest) String() string { // // The returned Authorization.User field will be populated. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#check-a-token +// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#check-a-token func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) { u := fmt.Sprintf("applications/%v/token", clientID) @@ -176,7 +176,7 @@ func (s *AuthorizationsService) Check(ctx context.Context, clientID, accessToken // // The returned Authorization.User field will be populated. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#reset-a-token +// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#reset-a-token func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken string) (*Authorization, *Response, error) { u := fmt.Sprintf("applications/%v/token", clientID) @@ -205,7 +205,7 @@ func (s *AuthorizationsService) Reset(ctx context.Context, clientID, accessToken // username is the OAuth application clientID, and the password is its // clientSecret. Invalid tokens will return a 404 Not Found. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#delete-an-app-token +// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-token func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToken string) (*Response, error) { u := fmt.Sprintf("applications/%v/token", clientID) @@ -226,7 +226,7 @@ func (s *AuthorizationsService) Revoke(ctx context.Context, clientID, accessToke // grant will also delete all OAuth tokens associated with the application for // the user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#delete-an-app-authorization +// GitHub API docs: https://docs.github.com/en/rest/apps/oauth-applications#delete-an-app-authorization func (s *AuthorizationsService) DeleteGrant(ctx context.Context, clientID, accessToken string) (*Response, error) { u := fmt.Sprintf("applications/%v/grant", clientID) diff --git a/vendor/github.com/google/go-github/v43/github/billing.go b/vendor/github.com/google/go-github/v47/github/billing.go similarity index 84% rename from vendor/github.com/google/go-github/v43/github/billing.go rename to vendor/github.com/google/go-github/v47/github/billing.go index 8921833b..d516cd0c 100644 --- a/vendor/github.com/google/go-github/v43/github/billing.go +++ b/vendor/github.com/google/go-github/v47/github/billing.go @@ -13,7 +13,7 @@ import ( // BillingService provides access to the billing related functions // in the GitHub API. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing +// GitHub API docs: https://docs.github.com/en/rest/billing type BillingService service // ActionBilling represents a GitHub Action billing. @@ -65,7 +65,7 @@ type AdvancedSecurityCommittersBreakdown struct { // GetActionsBillingOrg returns the summary of the free and paid GitHub Actions minutes used for an Org. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-actions-billing-for-an-organization func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) (*ActionBilling, *Response, error) { u := fmt.Sprintf("orgs/%v/settings/billing/actions", org) req, err := s.client.NewRequest("GET", u, nil) @@ -79,12 +79,12 @@ func (s *BillingService) GetActionsBillingOrg(ctx context.Context, org string) ( return nil, resp, err } - return actionsOrgBilling, resp, err + return actionsOrgBilling, resp, nil } // GetPackagesBillingOrg returns the free and paid storage used for GitHub Packages in gigabytes for an Org. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-packages-billing-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-packages-billing-for-an-organization func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) (*PackageBilling, *Response, error) { u := fmt.Sprintf("orgs/%v/settings/billing/packages", org) req, err := s.client.NewRequest("GET", u, nil) @@ -98,13 +98,13 @@ func (s *BillingService) GetPackagesBillingOrg(ctx context.Context, org string) return nil, resp, err } - return packagesOrgBilling, resp, err + return packagesOrgBilling, resp, nil } // GetStorageBillingOrg returns the estimated paid and estimated total storage used for GitHub Actions // and GitHub Packages in gigabytes for an Org. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-shared-storage-billing-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/billing#get-shared-storage-billing-for-an-organization func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) (*StorageBilling, *Response, error) { u := fmt.Sprintf("orgs/%v/settings/billing/shared-storage", org) req, err := s.client.NewRequest("GET", u, nil) @@ -118,12 +118,12 @@ func (s *BillingService) GetStorageBillingOrg(ctx context.Context, org string) ( return nil, resp, err } - return storageOrgBilling, resp, err + return storageOrgBilling, resp, nil } // GetAdvancedSecurityActiveCommittersOrg returns the GitHub Advanced Security active committers for an organization per repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-advanced-security-active-committers-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-advanced-security-active-committers-for-an-organization func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Context, org string) (*ActiveCommitters, *Response, error) { u := fmt.Sprintf("orgs/%v/settings/billing/advanced-security", org) req, err := s.client.NewRequest("GET", u, nil) @@ -137,12 +137,12 @@ func (s *BillingService) GetAdvancedSecurityActiveCommittersOrg(ctx context.Cont return nil, resp, err } - return activeOrgCommitters, resp, err + return activeOrgCommitters, resp, nil } // GetActionsBillingUser returns the summary of the free and paid GitHub Actions minutes used for a user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-actions-billing-for-a-user func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) (*ActionBilling, *Response, error) { u := fmt.Sprintf("users/%v/settings/billing/actions", user) req, err := s.client.NewRequest("GET", u, nil) @@ -156,12 +156,12 @@ func (s *BillingService) GetActionsBillingUser(ctx context.Context, user string) return nil, resp, err } - return actionsUserBilling, resp, err + return actionsUserBilling, resp, nil } // GetPackagesBillingUser returns the free and paid storage used for GitHub Packages in gigabytes for a user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-github-packages-billing-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/billing#get-github-packages-billing-for-a-user func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string) (*PackageBilling, *Response, error) { u := fmt.Sprintf("users/%v/settings/billing/packages", user) req, err := s.client.NewRequest("GET", u, nil) @@ -175,13 +175,13 @@ func (s *BillingService) GetPackagesBillingUser(ctx context.Context, user string return nil, resp, err } - return packagesUserBilling, resp, err + return packagesUserBilling, resp, nil } // GetStorageBillingUser returns the estimated paid and estimated total storage used for GitHub Actions // and GitHub Packages in gigabytes for a user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/billing#get-shared-storage-billing-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/billing#get-shared-storage-billing-for-a-user func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) (*StorageBilling, *Response, error) { u := fmt.Sprintf("users/%v/settings/billing/shared-storage", user) req, err := s.client.NewRequest("GET", u, nil) @@ -195,5 +195,5 @@ func (s *BillingService) GetStorageBillingUser(ctx context.Context, user string) return nil, resp, err } - return storageUserBilling, resp, err + return storageUserBilling, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/checks.go b/vendor/github.com/google/go-github/v47/github/checks.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/checks.go rename to vendor/github.com/google/go-github/v47/github/checks.go index 8e388e86..12d08530 100644 --- a/vendor/github.com/google/go-github/v43/github/checks.go +++ b/vendor/github.com/google/go-github/v47/github/checks.go @@ -13,7 +13,7 @@ import ( // ChecksService provides access to the Checks API in the // GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/ +// GitHub API docs: https://docs.github.com/en/rest/checks/ type ChecksService service // CheckRun represents a GitHub check run on a repository associated with a GitHub app. @@ -98,7 +98,7 @@ func (c CheckSuite) String() string { // GetCheckRun gets a check-run for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#get-a-check-run +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#get-a-check-run func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID) req, err := s.client.NewRequest("GET", u, nil) @@ -119,7 +119,7 @@ func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, che // GetCheckSuite gets a single check suite. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#get-a-check-suite +// GitHub API docs: https://docs.github.com/en/rest/checks/suites#get-a-check-suite func (s *ChecksService) GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-suites/%v", owner, repo, checkSuiteID) req, err := s.client.NewRequest("GET", u, nil) @@ -161,7 +161,7 @@ type CheckRunAction struct { // CreateCheckRun creates a check run for repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#create-a-check-run +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#create-a-check-run func (s *ChecksService) CreateCheckRun(ctx context.Context, owner, repo string, opts CreateCheckRunOptions) (*CheckRun, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-runs", owner, repo) req, err := s.client.NewRequest("POST", u, opts) @@ -194,7 +194,7 @@ type UpdateCheckRunOptions struct { // UpdateCheckRun updates a check run for a specific commit in a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#update-a-check-run +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#update-a-check-run func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opts UpdateCheckRunOptions) (*CheckRun, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-runs/%v", owner, repo, checkRunID) req, err := s.client.NewRequest("PATCH", u, opts) @@ -215,7 +215,7 @@ func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, // ListCheckRunAnnotations lists the annotations for a check run. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-run-annotations +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-run-annotations func (s *ChecksService) ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opts *ListOptions) ([]*CheckRunAnnotation, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-runs/%v/annotations", owner, repo, checkRunID) u, err := addOptions(u, opts) @@ -257,7 +257,7 @@ type ListCheckRunsResults struct { // ListCheckRunsForRef lists check runs for a specific ref. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-runs-for-a-git-reference +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-runs-for-a-git-reference func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/check-runs", owner, repo, refURLEscape(ref)) u, err := addOptions(u, opts) @@ -283,7 +283,7 @@ func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, re // ListCheckRunsCheckSuite lists check runs for a check suite. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-runs-in-a-check-suite +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#list-check-runs-in-a-check-suite func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-suites/%v/check-runs", owner, repo, checkSuiteID) u, err := addOptions(u, opts) @@ -307,6 +307,22 @@ func (s *ChecksService) ListCheckRunsCheckSuite(ctx context.Context, owner, repo return checkRunResults, resp, nil } +// ReRequestCheckRun triggers GitHub to rerequest an existing check run. +// +// GitHub API docs: https://docs.github.com/en/rest/checks/runs#rerequest-a-check-run +func (s *ChecksService) ReRequestCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/check-runs/%v/rerequest", owner, repo, checkRunID) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, err + } + + req.Header.Set("Accept", mediaTypeCheckRunsPreview) + + return s.client.Do(ctx, req, nil) +} + // ListCheckSuiteOptions represents parameters to list check suites. type ListCheckSuiteOptions struct { CheckName *string `url:"check_name,omitempty"` // Filters checks suites by the name of the check run. @@ -323,7 +339,7 @@ type ListCheckSuiteResults struct { // ListCheckSuitesForRef lists check suite for a specific ref. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#list-check-suites-for-a-git-reference +// GitHub API docs: https://docs.github.com/en/rest/checks/suites#list-check-suites-for-a-git-reference func (s *ChecksService) ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/check-suites", owner, repo, refURLEscape(ref)) u, err := addOptions(u, opts) @@ -371,7 +387,7 @@ type PreferenceList struct { // SetCheckSuitePreferences changes the default automatic flow when creating check suites. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#update-repository-preferences-for-check-suites +// GitHub API docs: https://docs.github.com/en/rest/checks/suites#update-repository-preferences-for-check-suites func (s *ChecksService) SetCheckSuitePreferences(ctx context.Context, owner, repo string, opts CheckSuitePreferenceOptions) (*CheckSuitePreferenceResults, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-suites/preferences", owner, repo) req, err := s.client.NewRequest("PATCH", u, opts) @@ -398,7 +414,7 @@ type CreateCheckSuiteOptions struct { // CreateCheckSuite manually creates a check suite for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#create-a-check-suite +// GitHub API docs: https://docs.github.com/en/rest/checks/suites#create-a-check-suite func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string, opts CreateCheckSuiteOptions) (*CheckSuite, *Response, error) { u := fmt.Sprintf("repos/%v/%v/check-suites", owner, repo) req, err := s.client.NewRequest("POST", u, opts) @@ -419,7 +435,7 @@ func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string // ReRequestCheckSuite triggers GitHub to rerequest an existing check suite, without pushing new code to a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/checks/#rerequest-a-check-suite +// GitHub API docs: https://docs.github.com/en/rest/checks/suites#rerequest-a-check-suite func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/check-suites/%v/rerequest", owner, repo, checkSuiteID) diff --git a/vendor/github.com/google/go-github/v43/github/code-scanning.go b/vendor/github.com/google/go-github/v47/github/code-scanning.go similarity index 75% rename from vendor/github.com/google/go-github/v43/github/code-scanning.go rename to vendor/github.com/google/go-github/v47/github/code-scanning.go index 9616f3a2..df8ed86b 100644 --- a/vendor/github.com/google/go-github/v43/github/code-scanning.go +++ b/vendor/github.com/google/go-github/v47/github/code-scanning.go @@ -15,7 +15,7 @@ import ( // CodeScanningService handles communication with the code scanning related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/ +// GitHub API docs: https://docs.github.com/en/rest/code-scanning type CodeScanningService service // Rule represents the complete details of GitHub Code Scanning alert type. @@ -65,24 +65,29 @@ type Tool struct { // Alert represents an individual GitHub Code Scanning Alert on a single repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-alerts-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/code-scanning type Alert struct { - RuleID *string `json:"rule_id,omitempty"` - RuleSeverity *string `json:"rule_severity,omitempty"` - RuleDescription *string `json:"rule_description,omitempty"` - Rule *Rule `json:"rule,omitempty"` - Tool *Tool `json:"tool,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - State *string `json:"state,omitempty"` - ClosedBy *User `json:"closed_by,omitempty"` - ClosedAt *Timestamp `json:"closed_at,omitempty"` - URL *string `json:"url,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` - DismissedBy *User `json:"dismissed_by,omitempty"` - DismissedAt *Timestamp `json:"dismissed_at,omitempty"` - DismissedReason *string `json:"dismissed_reason,omitempty"` - InstancesURL *string `json:"instances_url,omitempty"` + Number *int `json:"number,omitempty"` + Repository *Repository `json:"repository,omitempty"` + RuleID *string `json:"rule_id,omitempty"` + RuleSeverity *string `json:"rule_severity,omitempty"` + RuleDescription *string `json:"rule_description,omitempty"` + Rule *Rule `json:"rule,omitempty"` + Tool *Tool `json:"tool,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + FixedAt *Timestamp `json:"fixed_at,omitempty"` + State *string `json:"state,omitempty"` + ClosedBy *User `json:"closed_by,omitempty"` + ClosedAt *Timestamp `json:"closed_at,omitempty"` + URL *string `json:"url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + MostRecentInstance *MostRecentInstance `json:"most_recent_instance,omitempty"` + Instances []*MostRecentInstance `json:"instances,omitempty"` + DismissedBy *User `json:"dismissed_by,omitempty"` + DismissedAt *Timestamp `json:"dismissed_at,omitempty"` + DismissedReason *string `json:"dismissed_reason,omitempty"` + InstancesURL *string `json:"instances_url,omitempty"` } // ID returns the ID associated with an alert. It is the number at the end of the security alert's URL. @@ -132,7 +137,7 @@ type AnalysesListOptions struct { // ScanningAnalysis represents an individual GitHub Code Scanning ScanningAnalysis on a single repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/code-scanning type ScanningAnalysis struct { ID *int64 `json:"id,omitempty"` Ref *string `json:"ref,omitempty"` @@ -153,7 +158,7 @@ type ScanningAnalysis struct { // SarifAnalysis specifies the results of a code scanning job. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data +// GitHub API docs: https://docs.github.com/en/rest/code-scanning type SarifAnalysis struct { CommitSHA *string `json:"commit_sha,omitempty"` Ref *string `json:"ref,omitempty"` @@ -165,19 +170,46 @@ type SarifAnalysis struct { // SarifID identifies a sarif analysis upload. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data +// GitHub API docs: https://docs.github.com/en/rest/code-scanning type SarifID struct { ID *string `json:"id,omitempty"` URL *string `json:"url,omitempty"` } +// ListAlertsForOrg lists code scanning alerts for an org. +// +// You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events +// read permission to use this endpoint. +// +// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-alerts-for-an-organization +func (s *CodeScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *AlertListOptions) ([]*Alert, *Response, error) { + u := fmt.Sprintf("orgs/%v/code-scanning/alerts", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var alerts []*Alert + resp, err := s.client.Do(ctx, req, &alerts) + if err != nil { + return nil, resp, err + } + + return alerts, resp, nil +} + // ListAlertsForRepo lists code scanning alerts for a repository. // // Lists all open code scanning alerts for the default branch (usually master) and protected branches in a repository. // You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events // read permission to use this endpoint. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/#list-code-scanning-alerts-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-alerts-for-a-repository func (s *CodeScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *AlertListOptions) ([]*Alert, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts", owner, repo) u, err := addOptions(u, opts) @@ -206,7 +238,7 @@ func (s *CodeScanningService) ListAlertsForRepo(ctx context.Context, owner, repo // // The security alert_id is the number at the end of the security alert's URL. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/code-scanning/#get-a-code-scanning-alert +// GitHub API docs: https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-alert func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string, id int64) (*Alert, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/alerts/%v", owner, repo, id) @@ -230,7 +262,7 @@ func (s *CodeScanningService) GetAlert(ctx context.Context, owner, repo string, // You must use an access token with the security_events scope to use this endpoint. GitHub Apps must have the security_events // write permission to use this endpoint. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#upload-an-analysis-as-sarif-data +// GitHub API docs: https://docs.github.com/en/rest/code-scanning#upload-an-analysis-as-sarif-data func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo string, sarif *SarifAnalysis) (*SarifID, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/sarifs", owner, repo) @@ -254,7 +286,7 @@ func (s *CodeScanningService) UploadSarif(ctx context.Context, owner, repo strin // You must use an access token with the security_events scope to use this endpoint. // GitHub Apps must have the security_events read permission to use this endpoint. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/code-scanning#list-code-scanning-analyses-for-a-repository func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, repo string, opts *AnalysesListOptions) ([]*ScanningAnalysis, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses", owner, repo) u, err := addOptions(u, opts) @@ -283,7 +315,7 @@ func (s *CodeScanningService) ListAnalysesForRepo(ctx context.Context, owner, re // // The security analysis_id is the ID of the analysis, as returned from the ListAnalysesForRepo operation. // -// GitHub API docs: https://docs.github.com/en/rest/reference/code-scanning#get-a-code-scanning-analysis-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-analysis-for-a-repository func (s *CodeScanningService) GetAnalysis(ctx context.Context, owner, repo string, id int64) (*ScanningAnalysis, *Response, error) { u := fmt.Sprintf("repos/%v/%v/code-scanning/analyses/%v", owner, repo, id) diff --git a/vendor/github.com/google/go-github/v43/github/dependabot.go b/vendor/github.com/google/go-github/v47/github/dependabot.go similarity index 77% rename from vendor/github.com/google/go-github/v43/github/dependabot.go rename to vendor/github.com/google/go-github/v47/github/dependabot.go index 8ee0c0c7..07e68b50 100644 --- a/vendor/github.com/google/go-github/v43/github/dependabot.go +++ b/vendor/github.com/google/go-github/v47/github/dependabot.go @@ -8,5 +8,5 @@ package github // DependabotService handles communication with the Dependabot related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/dependabot/ +// GitHub API docs: https://docs.github.com/en/rest/dependabot/ type DependabotService service diff --git a/vendor/github.com/google/go-github/v43/github/dependabot_secrets.go b/vendor/github.com/google/go-github/v47/github/dependabot_secrets.go similarity index 70% rename from vendor/github.com/google/go-github/v43/github/dependabot_secrets.go rename to vendor/github.com/google/go-github/v47/github/dependabot_secrets.go index a6645339..8318cd81 100644 --- a/vendor/github.com/google/go-github/v43/github/dependabot_secrets.go +++ b/vendor/github.com/google/go-github/v47/github/dependabot_secrets.go @@ -27,7 +27,7 @@ func (s *DependabotService) getPublicKey(ctx context.Context, url string) (*Publ // GetRepoPublicKey gets a public key that should be used for Dependabot secret encryption. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-a-repository-public-key +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-public-key func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo string) (*PublicKey, *Response, error) { url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/public-key", owner, repo) return s.getPublicKey(ctx, url) @@ -35,7 +35,7 @@ func (s *DependabotService) GetRepoPublicKey(ctx context.Context, owner, repo st // GetOrgPublicKey gets a public key that should be used for Dependabot secret encryption. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-an-organization-public-key +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-public-key func (s *DependabotService) GetOrgPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/public-key", org) return s.getPublicKey(ctx, url) @@ -64,7 +64,7 @@ func (s *DependabotService) listSecrets(ctx context.Context, url string, opts *L // ListRepoSecrets lists all Dependabot secrets available in a repository // without revealing their encrypted values. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#list-repository-secrets +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-repository-secrets func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo string, opts *ListOptions) (*Secrets, *Response, error) { url := fmt.Sprintf("repos/%v/%v/dependabot/secrets", owner, repo) return s.listSecrets(ctx, url, opts) @@ -73,7 +73,7 @@ func (s *DependabotService) ListRepoSecrets(ctx context.Context, owner, repo str // ListOrgSecrets lists all Dependabot secrets available in an organization // without revealing their encrypted values. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#list-organization-secrets +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-organization-secrets func (s *DependabotService) ListOrgSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets", org) return s.listSecrets(ctx, url, opts) @@ -96,7 +96,7 @@ func (s *DependabotService) getSecret(ctx context.Context, url string) (*Secret, // GetRepoSecret gets a single repository Dependabot secret without revealing its encrypted value. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-a-repository-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-a-repository-secret func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error) { url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name) return s.getSecret(ctx, url) @@ -104,13 +104,26 @@ func (s *DependabotService) GetRepoSecret(ctx context.Context, owner, repo, name // GetOrgSecret gets a single organization Dependabot secret without revealing its encrypted value. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#get-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#get-an-organization-secret func (s *DependabotService) GetOrgSecret(ctx context.Context, org, name string) (*Secret, *Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name) return s.getSecret(ctx, url) } -func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *EncryptedSecret) (*Response, error) { +// DependabotEncryptedSecret represents a secret that is encrypted using a public key for Dependabot. +// +// The value of EncryptedValue must be your secret, encrypted with +// LibSodium (see documentation here: https://libsodium.gitbook.io/doc/bindings_for_other_languages) +// using the public key retrieved using the GetPublicKey method. +type DependabotEncryptedSecret struct { + Name string `json:"-"` + KeyID string `json:"key_id"` + EncryptedValue string `json:"encrypted_value"` + Visibility string `json:"visibility,omitempty"` + SelectedRepositoryIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids,omitempty"` +} + +func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret *DependabotEncryptedSecret) (*Response, error) { req, err := s.client.NewRequest("PUT", url, eSecret) if err != nil { return nil, err @@ -121,16 +134,16 @@ func (s *DependabotService) putSecret(ctx context.Context, url string, eSecret * // CreateOrUpdateRepoSecret creates or updates a repository Dependabot secret with an encrypted value. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#create-or-update-a-repository-secret -func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error) { +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-a-repository-secret +func (s *DependabotService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *DependabotEncryptedSecret) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, eSecret.Name) return s.putSecret(ctx, url, eSecret) } // CreateOrUpdateOrgSecret creates or updates an organization Dependabot secret with an encrypted value. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#create-or-update-an-organization-secret -func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error) { +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#create-or-update-an-organization-secret +func (s *DependabotService) CreateOrUpdateOrgSecret(ctx context.Context, org string, eSecret *DependabotEncryptedSecret) (*Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, eSecret.Name) return s.putSecret(ctx, url, eSecret) } @@ -146,7 +159,7 @@ func (s *DependabotService) deleteSecret(ctx context.Context, url string) (*Resp // DeleteRepoSecret deletes a Dependabot secret in a repository using the secret name. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#delete-a-repository-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-a-repository-secret func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/dependabot/secrets/%v", owner, repo, name) return s.deleteSecret(ctx, url) @@ -154,7 +167,7 @@ func (s *DependabotService) DeleteRepoSecret(ctx context.Context, owner, repo, n // DeleteOrgSecret deletes a Dependabot secret in an organization using the secret name. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#delete-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#delete-an-organization-secret func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name string) (*Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v", org, name) return s.deleteSecret(ctx, url) @@ -162,7 +175,7 @@ func (s *DependabotService) DeleteOrgSecret(ctx context.Context, org, name strin // ListSelectedReposForOrgSecret lists all repositories that have access to a Dependabot secret. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#list-selected-repositories-for-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#list-selected-repositories-for-an-organization-secret func (s *DependabotService) ListSelectedReposForOrgSecret(ctx context.Context, org, name string, opts *ListOptions) (*SelectedReposList, *Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name) u, err := addOptions(url, opts) @@ -184,13 +197,16 @@ func (s *DependabotService) ListSelectedReposForOrgSecret(ctx context.Context, o return result, resp, nil } +// DependabotSecretsSelectedRepoIDs are the repository IDs that have access to the dependabot secrets. +type DependabotSecretsSelectedRepoIDs []string + // SetSelectedReposForOrgSecret sets the repositories that have access to a Dependabot secret. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#set-selected-repositories-for-an-organization-secret -func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids SelectedRepoIDs) (*Response, error) { +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#set-selected-repositories-for-an-organization-secret +func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, org, name string, ids DependabotSecretsSelectedRepoIDs) (*Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories", org, name) type repoIDs struct { - SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"` + SelectedIDs DependabotSecretsSelectedRepoIDs `json:"selected_repository_ids"` } req, err := s.client.NewRequest("PUT", url, repoIDs{SelectedIDs: ids}) @@ -203,7 +219,7 @@ func (s *DependabotService) SetSelectedReposForOrgSecret(ctx context.Context, or // AddSelectedRepoToOrgSecret adds a repository to an organization Dependabot secret. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#add-selected-repository-to-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#add-selected-repository-to-an-organization-secret func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID) req, err := s.client.NewRequest("PUT", url, nil) @@ -216,7 +232,7 @@ func (s *DependabotService) AddSelectedRepoToOrgSecret(ctx context.Context, org, // RemoveSelectedRepoFromOrgSecret removes a repository from an organization Dependabot secret. // -// GitHub API docs: https://docs.github.com/en/rest/reference/dependabot#remove-selected-repository-from-an-organization-secret +// GitHub API docs: https://docs.github.com/en/rest/dependabot/secrets#remove-selected-repository-from-an-organization-secret func (s *DependabotService) RemoveSelectedRepoFromOrgSecret(ctx context.Context, org, name string, repo *Repository) (*Response, error) { url := fmt.Sprintf("orgs/%v/dependabot/secrets/%v/repositories/%v", org, name, *repo.ID) req, err := s.client.NewRequest("DELETE", url, nil) diff --git a/vendor/github.com/google/go-github/v43/github/doc.go b/vendor/github.com/google/go-github/v47/github/doc.go similarity index 94% rename from vendor/github.com/google/go-github/v43/github/doc.go rename to vendor/github.com/google/go-github/v47/github/doc.go index 8f16c658..9ab7f558 100644 --- a/vendor/github.com/google/go-github/v43/github/doc.go +++ b/vendor/github.com/google/go-github/v47/github/doc.go @@ -8,7 +8,7 @@ Package github provides a client for using the GitHub API. Usage: - import "github.com/google/go-github/v43/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) + import "github.com/google/go-github/v47/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) import "github.com/google/go-github/github" // with go modules disabled Construct a new GitHub client, then use the various services on the client to @@ -29,7 +29,7 @@ Some API methods have optional parameters that can be passed. For example: The services of a client divide the API into logical chunks and correspond to the structure of the GitHub API documentation at -https://docs.github.com/en/free-pro-team@latest/rest/reference/. +https://docs.github.com/en/rest . NOTE: Using the https://godoc.org/context package, one can easily pass cancelation signals and deadlines to various services of the client for @@ -38,7 +38,7 @@ can be used as a starting point. For more sample code snippets, head over to the https://github.com/google/go-github/tree/master/example directory. -Authentication +# Authentication The go-github library does not directly handle authentication. Instead, when creating a new client, pass an http.Client that can handle authentication for @@ -110,7 +110,7 @@ To authenticate as an app, using a JWT: // Use client... } -Rate Limiting +# Rate Limiting GitHub imposes a rate limit on all API clients. Unauthenticated clients are limited to 60 requests per hour, while authenticated clients can make up to @@ -137,9 +137,9 @@ For secondary rate limits, you can check if its type is *github.AbuseRateLimitEr } Learn more about GitHub rate limiting at -https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#rate-limiting. +https://docs.github.com/en/rest/rate-limit . -Accepted Status +# Accepted Status Some endpoints may return a 202 Accepted status code, meaning that the information required is not yet ready and was scheduled to be gathered on @@ -154,7 +154,7 @@ To detect this condition of error, you can check if its type is log.Println("scheduled on GitHub side") } -Conditional Requests +# Conditional Requests The GitHub API has good support for conditional requests which will help prevent you from burning through your rate limit, as well as help speed up your @@ -163,9 +163,9 @@ instead designed to work with a caching http.Transport. We recommend using https://github.com/gregjones/httpcache for that. Learn more about GitHub conditional requests at -https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#conditional-requests. +https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requests. -Creating and Updating Resources +# Creating and Updating Resources All structs for GitHub resources use pointer values for all non-repeated fields. This allows distinguishing between unset fields and those set to a zero-value. @@ -181,7 +181,7 @@ bool, and int values. For example: Users who have worked with protocol buffers should find this pattern familiar. -Pagination +# Pagination All requests for resource collections (repos, pull requests, issues, etc.) support pagination. Pagination options are described in the @@ -208,6 +208,5 @@ github.Response struct. } opt.Page = resp.NextPage } - */ package github diff --git a/vendor/github.com/google/go-github/v43/github/enterprise.go b/vendor/github.com/google/go-github/v47/github/enterprise.go similarity index 75% rename from vendor/github.com/google/go-github/v43/github/enterprise.go rename to vendor/github.com/google/go-github/v47/github/enterprise.go index f6a5af83..1c9b0695 100644 --- a/vendor/github.com/google/go-github/v43/github/enterprise.go +++ b/vendor/github.com/google/go-github/v47/github/enterprise.go @@ -8,5 +8,5 @@ package github // EnterpriseService provides access to the enterprise related functions // in the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/ +// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/ type EnterpriseService service diff --git a/vendor/github.com/google/go-github/v43/github/enterprise_actions_runners.go b/vendor/github.com/google/go-github/v47/github/enterprise_actions_runners.go similarity index 62% rename from vendor/github.com/google/go-github/v43/github/enterprise_actions_runners.go rename to vendor/github.com/google/go-github/v47/github/enterprise_actions_runners.go index d2758fe8..935f1897 100644 --- a/vendor/github.com/google/go-github/v43/github/enterprise_actions_runners.go +++ b/vendor/github.com/google/go-github/v47/github/enterprise_actions_runners.go @@ -10,9 +10,28 @@ import ( "fmt" ) +// ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository +func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*RunnerApplicationDownload, *Response, error) { + u := fmt.Sprintf("enterprises/%v/actions/runners/downloads", enterprise) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var rads []*RunnerApplicationDownload + resp, err := s.client.Do(ctx, req, &rads) + if err != nil { + return nil, resp, err + } + + return rads, resp, nil +} + // CreateRegistrationToken creates a token that can be used to add a self-hosted runner. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/#create-a-registration-token-for-an-enterprise +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#create-a-registration-token-for-an-enterprise func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterprise string) (*RegistrationToken, *Response, error) { u := fmt.Sprintf("enterprises/%v/actions/runners/registration-token", enterprise) @@ -32,7 +51,7 @@ func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterpr // ListRunners lists all the self-hosted runners for a enterprise. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/#list-self-hosted-runners-for-an-enterprise +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-enterprise func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) { u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise) u, err := addOptions(u, opts) @@ -56,7 +75,7 @@ func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, // RemoveRunner forces the removal of a self-hosted runner from an enterprise using the runner id. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/enterprise-admin/#delete-a-self-hosted-runner-from-an-enterprise +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#delete-a-self-hosted-runner-from-an-enterprise func (s *EnterpriseService) RemoveRunner(ctx context.Context, enterprise string, runnerID int64) (*Response, error) { u := fmt.Sprintf("enterprises/%v/actions/runners/%v", enterprise, runnerID) diff --git a/vendor/github.com/google/go-github/v43/github/enterprise_audit_log.go b/vendor/github.com/google/go-github/v47/github/enterprise_audit_log.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/enterprise_audit_log.go rename to vendor/github.com/google/go-github/v47/github/enterprise_audit_log.go index b889a7e5..40648673 100644 --- a/vendor/github.com/google/go-github/v43/github/enterprise_audit_log.go +++ b/vendor/github.com/google/go-github/v47/github/enterprise_audit_log.go @@ -12,7 +12,7 @@ import ( // GetAuditLog gets the audit-log entries for an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/enterprise-admin#get-the-audit-log-for-an-enterprise +// GitHub API docs: https://docs.github.com/en/rest/enterprise-admin/audit-log#get-the-audit-log-for-an-enterprise func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) { u := fmt.Sprintf("enterprises/%v/audit-log", enterprise) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/event.go b/vendor/github.com/google/go-github/v47/github/event.go similarity index 95% rename from vendor/github.com/google/go-github/v43/github/event.go rename to vendor/github.com/google/go-github/v47/github/event.go index 9a39e2e9..4cacf0a8 100644 --- a/vendor/github.com/google/go-github/v43/github/event.go +++ b/vendor/github.com/google/go-github/v47/github/event.go @@ -36,6 +36,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &CheckRunEvent{} case "CheckSuiteEvent": payload = &CheckSuiteEvent{} + case "CodeScanningAlertEvent": + payload = &CodeScanningAlertEvent{} case "CommitCommentEvent": payload = &CommitCommentEvent{} case "ContentReferenceEvent": @@ -102,6 +104,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &PullRequestReviewEvent{} case "PullRequestReviewCommentEvent": payload = &PullRequestReviewCommentEvent{} + case "PullRequestReviewThreadEvent": + payload = &PullRequestReviewThreadEvent{} case "PullRequestTargetEvent": payload = &PullRequestTargetEvent{} case "PushEvent": @@ -112,6 +116,8 @@ func (e *Event) ParsePayload() (payload interface{}, err error) { payload = &RepositoryEvent{} case "RepositoryDispatchEvent": payload = &RepositoryDispatchEvent{} + case "RepositoryImportEvent": + payload = &RepositoryImportEvent{} case "RepositoryVulnerabilityAlertEvent": payload = &RepositoryVulnerabilityAlertEvent{} case "SecretScanningAlertEvent": diff --git a/vendor/github.com/google/go-github/v43/github/event_types.go b/vendor/github.com/google/go-github/v47/github/event_types.go similarity index 90% rename from vendor/github.com/google/go-github/v43/github/event_types.go rename to vendor/github.com/google/go-github/v47/github/event_types.go index c940ec8f..b5503618 100644 --- a/vendor/github.com/google/go-github/v43/github/event_types.go +++ b/vendor/github.com/google/go-github/v47/github/event_types.go @@ -106,10 +106,11 @@ type CreateEvent struct { RefType *string `json:"ref_type,omitempty"` MasterBranch *string `json:"master_branch,omitempty"` Description *string `json:"description,omitempty"` + PusherType *string `json:"pusher_type,omitempty"` // The following fields are only populated by Webhook events. - PusherType *string `json:"pusher_type,omitempty"` Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } @@ -493,13 +494,14 @@ type IssuesEvent struct { type LabelEvent struct { // Action is the action that was performed. Possible values are: // "created", "edited", "deleted" - Action *string `json:"action,omitempty"` - Label *Label `json:"label,omitempty"` + Action *string `json:"action,omitempty"` + Label *Label `json:"label,omitempty"` + Changes *EditChange `json:"changes,omitempty"` // The following fields are only populated by Webhook events. - Changes *EditChange `json:"changes,omitempty"` Repo *Repository `json:"repository,omitempty"` Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } @@ -574,6 +576,9 @@ type MetaEvent struct { Hook *Hook `json:"hook,omitempty"` // The following fields are only populated by Webhook events. + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } @@ -682,7 +687,12 @@ type PingEvent struct { // The ID of the webhook that triggered the ping. HookID *int64 `json:"hook_id,omitempty"` // The webhook configuration. - Hook *Hook `json:"hook,omitempty"` + Hook *Hook `json:"hook,omitempty"` + + // The following fields are only populated by Webhook events. + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } @@ -830,12 +840,30 @@ type PullRequestReviewCommentEvent struct { Installation *Installation `json:"installation,omitempty"` } +// PullRequestReviewThreadEvent is triggered when a comment made as part of a +// review of a pull request is marked resolved or unresolved. +// The Webhook event name is "pull_request_review_thread". +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_thread +type PullRequestReviewThreadEvent struct { + // Action is the action that was performed on the comment. + // Possible values are: "resolved", "unresolved". + Action *string `json:"action,omitempty"` + Thread *PullRequestThread `json:"thread,omitempty"` + PullRequest *PullRequest `json:"pull_request,omitempty"` + + // The following fields are only populated by Webhook events. + Repo *Repository `json:"repository,omitempty"` + Sender *User `json:"sender,omitempty"` + Installation *Installation `json:"installation,omitempty"` +} + // PullRequestTargetEvent is triggered when a pull request is assigned, unassigned, labeled, // unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, // locked, unlocked, a pull request review is requested, or a review request is removed. // The Webhook event name is "pull_request_target". // -// GitHub API docs: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target +// GitHub API docs: https://docs.github.com/en/actions/events-that-trigger-workflows#pull_request_target type PullRequestTargetEvent struct { // Action is the action that was performed. Possible values are: // "assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened", @@ -885,6 +913,7 @@ type PushEvent struct { DistinctSize *int `json:"distinct_size,omitempty"` // The following fields are only populated by Webhook events. + Action *string `json:"action,omitempty"` After *string `json:"after,omitempty"` Created *bool `json:"created,omitempty"` Deleted *bool `json:"deleted,omitempty"` @@ -926,8 +955,8 @@ type HeadCommit struct { Modified []string `json:"modified,omitempty"` } -func (p HeadCommit) String() string { - return Stringify(p) +func (h HeadCommit) String() string { + return Stringify(h) } // PushEventRepository represents the repo object in a PushEvent payload. @@ -1032,6 +1061,17 @@ type RepositoryDispatchEvent struct { Installation *Installation `json:"installation,omitempty"` } +// RepositoryImportEvent represents the activity related to a repository being imported to GitHub. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#repository_import +type RepositoryImportEvent struct { + // Status represents the final state of the import. This can be one of "success", "cancelled", or "failure". + Status *string `json:"status,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` +} + // RepositoryVulnerabilityAlertEvent is triggered when a security alert is created, dismissed, or resolved. // // GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#repository_vulnerability_alert @@ -1039,14 +1079,17 @@ type RepositoryVulnerabilityAlertEvent struct { // Action is the action that was performed. Possible values are: "create", "dismiss", "resolve". Action *string `json:"action,omitempty"` - //The security alert of the vulnerable dependency. + // The security alert of the vulnerable dependency. Alert *RepositoryVulnerabilityAlert `json:"alert,omitempty"` - //The repository of the vulnerable dependency. + // The repository of the vulnerable dependency. Repository *Repository `json:"repository,omitempty"` // The following fields are only populated by Webhook events. Installation *Installation `json:"installation,omitempty"` + + // The user that triggered the event. + Sender *User `json:"sender,omitempty"` } // RepositoryVulnerabilityAlert represents a repository security alert. @@ -1248,3 +1291,71 @@ type WorkflowRunEvent struct { Sender *User `json:"sender,omitempty"` Installation *Installation `json:"installation,omitempty"` } + +// SecurityAdvisory represents the advisory object in SecurityAdvisoryEvent payload. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory +type SecurityAdvisory struct { + GHSAID *string `json:"ghsa_id,omitempty"` + Summary *string `json:"summary,omitempty"` + Description *string `json:"description,omitempty"` + Severity *string `json:"severity,omitempty"` + Identifiers []*AdvisoryIdentifier `json:"identifiers,omitempty"` + References []*AdvisoryReference `json:"references,omitempty"` + PublishedAt *Timestamp `json:"published_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + WithdrawnAt *Timestamp `json:"withdrawn_at,omitempty"` + Vulnerabilities []*AdvisoryVulnerability `json:"vulnerabilities,omitempty"` +} + +// AdvisoryIdentifier represents the identifier for a Security Advisory. +type AdvisoryIdentifier struct { + Value *string `json:"value,omitempty"` + Type *string `json:"type,omitempty"` +} + +// AdvisoryReference represents the reference url for the security advisory. +type AdvisoryReference struct { + URL *string `json:"url,omitempty"` +} + +// AdvisoryVulnerability represents the vulnerability object for a Security Advisory. +type AdvisoryVulnerability struct { + Package *VulnerabilityPackage `json:"package,omitempty"` + Severity *string `json:"severity,omitempty"` + VulnerableVersionRange *string `json:"vulnerable_version_range,omitempty"` + FirstPatchedVersion *FirstPatchedVersion `json:"first_patched_version,omitempty"` +} + +// VulnerabilityPackage represents the package object for an Advisory Vulnerability. +type VulnerabilityPackage struct { + Ecosystem *string `json:"ecosystem,omitempty"` + Name *string `json:"name,omitempty"` +} + +// FirstPatchedVersion represents the identifier for the first patched version of that vulnerability. +type FirstPatchedVersion struct { + Identifier *string `json:"identifier,omitempty"` +} + +// SecurityAdvisoryEvent is triggered when a security-related vulnerability is found in software on GitHub. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#security_advisory +type SecurityAdvisoryEvent struct { + Action *string `json:"action,omitempty"` + SecurityAdvisory *SecurityAdvisory `json:"security_advisory,omitempty"` +} + +// CodeScanningAlertEvent is triggered when a code scanning finds a potential vulnerability or error in your code. +// +// GitHub API docs: https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#code_scanning_alert +type CodeScanningAlertEvent struct { + Action *string `json:"action,omitempty"` + Alert *Alert `json:"alert,omitempty"` + Ref *string `json:"ref,omitempty"` + // CommitOID is the commit SHA of the code scanning alert + CommitOID *string `json:"commit_oid,omitempty"` + Repo *Repository `json:"repository,omitempty"` + Org *Organization `json:"organization,omitempty"` + Sender *User `json:"sender,omitempty"` +} diff --git a/vendor/github.com/google/go-github/v43/github/gists.go b/vendor/github.com/google/go-github/v47/github/gists.go similarity index 83% rename from vendor/github.com/google/go-github/v43/github/gists.go rename to vendor/github.com/google/go-github/v47/github/gists.go index 4971c6bf..ecdc6f27 100644 --- a/vendor/github.com/google/go-github/v43/github/gists.go +++ b/vendor/github.com/google/go-github/v47/github/gists.go @@ -14,7 +14,7 @@ import ( // GistsService handles communication with the Gist related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/ +// GitHub API docs: https://docs.github.com/en/rest/gists type GistsService service // Gist represents a GitHub's gist. @@ -96,8 +96,8 @@ type GistListOptions struct { // is authenticated, it will returns all gists for the authenticated // user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gists-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gists-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gists-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gists-for-a-user func (s *GistsService) List(ctx context.Context, user string, opts *GistListOptions) ([]*Gist, *Response, error) { var u string if user != "" { @@ -126,7 +126,7 @@ func (s *GistsService) List(ctx context.Context, user string, opts *GistListOpti // ListAll lists all public gists. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-public-gists +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-public-gists func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) { u, err := addOptions("gists/public", opts) if err != nil { @@ -149,7 +149,7 @@ func (s *GistsService) ListAll(ctx context.Context, opts *GistListOptions) ([]*G // ListStarred lists starred gists of authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-starred-gists +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-starred-gists func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) ([]*Gist, *Response, error) { u, err := addOptions("gists/starred", opts) if err != nil { @@ -172,7 +172,7 @@ func (s *GistsService) ListStarred(ctx context.Context, opts *GistListOptions) ( // Get a single gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#get-a-gist func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, error) { u := fmt.Sprintf("gists/%v", id) req, err := s.client.NewRequest("GET", u, nil) @@ -191,7 +191,7 @@ func (s *GistsService) Get(ctx context.Context, id string) (*Gist, *Response, er // GetRevision gets a specific revision of a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist-revision +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#get-a-gist-revision func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, *Response, error) { u := fmt.Sprintf("gists/%v/%v", id, sha) req, err := s.client.NewRequest("GET", u, nil) @@ -210,7 +210,7 @@ func (s *GistsService) GetRevision(ctx context.Context, id, sha string) (*Gist, // Create a gist for authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#create-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#create-a-gist func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response, error) { u := "gists" req, err := s.client.NewRequest("POST", u, gist) @@ -229,7 +229,7 @@ func (s *GistsService) Create(ctx context.Context, gist *Gist) (*Gist, *Response // Edit a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#update-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#update-a-gist func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, *Response, error) { u := fmt.Sprintf("gists/%v", id) req, err := s.client.NewRequest("PATCH", u, gist) @@ -248,7 +248,7 @@ func (s *GistsService) Edit(ctx context.Context, id string, gist *Gist) (*Gist, // ListCommits lists commits of a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-commits +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gist-commits func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOptions) ([]*GistCommit, *Response, error) { u := fmt.Sprintf("gists/%v/commits", id) u, err := addOptions(u, opts) @@ -272,49 +272,53 @@ func (s *GistsService) ListCommits(ctx context.Context, id string, opts *ListOpt // Delete a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#delete-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#delete-a-gist func (s *GistsService) Delete(ctx context.Context, id string) (*Response, error) { u := fmt.Sprintf("gists/%v", id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } // Star a gist on behalf of authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#star-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#star-a-gist func (s *GistsService) Star(ctx context.Context, id string) (*Response, error) { u := fmt.Sprintf("gists/%v/star", id) req, err := s.client.NewRequest("PUT", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } // Unstar a gist on a behalf of authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#unstar-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#unstar-a-gist func (s *GistsService) Unstar(ctx context.Context, id string) (*Response, error) { u := fmt.Sprintf("gists/%v/star", id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } // IsStarred checks if a gist is starred by authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#check-if-a-gist-is-starred +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#check-if-a-gist-is-starred func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Response, error) { u := fmt.Sprintf("gists/%v/star", id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, nil, err } + resp, err := s.client.Do(ctx, req, nil) starred, err := parseBoolResponse(err) return starred, resp, err @@ -322,7 +326,7 @@ func (s *GistsService) IsStarred(ctx context.Context, id string) (bool, *Respons // Fork a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#fork-a-gist +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#fork-a-gist func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, error) { u := fmt.Sprintf("gists/%v/forks", id) req, err := s.client.NewRequest("POST", u, nil) @@ -341,7 +345,7 @@ func (s *GistsService) Fork(ctx context.Context, id string) (*Gist, *Response, e // ListForks lists forks of a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-forks +// GitHub API docs: https://docs.github.com/en/rest/gists/gists#list-gist-forks func (s *GistsService) ListForks(ctx context.Context, id string, opts *ListOptions) ([]*GistFork, *Response, error) { u := fmt.Sprintf("gists/%v/forks", id) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/gists_comments.go b/vendor/github.com/google/go-github/v47/github/gists_comments.go similarity index 83% rename from vendor/github.com/google/go-github/v43/github/gists_comments.go rename to vendor/github.com/google/go-github/v47/github/gists_comments.go index a9452c96..d551e9a1 100644 --- a/vendor/github.com/google/go-github/v43/github/gists_comments.go +++ b/vendor/github.com/google/go-github/v47/github/gists_comments.go @@ -26,7 +26,7 @@ func (g GistComment) String() string { // ListComments lists all comments for a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#list-gist-comments +// GitHub API docs: https://docs.github.com/en/rest/gists/comments#list-gist-comments func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *ListOptions) ([]*GistComment, *Response, error) { u := fmt.Sprintf("gists/%v/comments", gistID) u, err := addOptions(u, opts) @@ -50,7 +50,7 @@ func (s *GistsService) ListComments(ctx context.Context, gistID string, opts *Li // GetComment retrieves a single comment from a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#get-a-gist-comment +// GitHub API docs: https://docs.github.com/en/rest/gists/comments#get-a-gist-comment func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID int64) (*GistComment, *Response, error) { u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) req, err := s.client.NewRequest("GET", u, nil) @@ -69,7 +69,7 @@ func (s *GistsService) GetComment(ctx context.Context, gistID string, commentID // CreateComment creates a comment for a gist. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#create-a-gist-comment +// GitHub API docs: https://docs.github.com/en/rest/gists/comments#create-a-gist-comment func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment *GistComment) (*GistComment, *Response, error) { u := fmt.Sprintf("gists/%v/comments", gistID) req, err := s.client.NewRequest("POST", u, comment) @@ -88,7 +88,7 @@ func (s *GistsService) CreateComment(ctx context.Context, gistID string, comment // EditComment edits an existing gist comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#update-a-gist-comment +// GitHub API docs: https://docs.github.com/en/rest/gists/comments#update-a-gist-comment func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID int64, comment *GistComment) (*GistComment, *Response, error) { u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) req, err := s.client.NewRequest("PATCH", u, comment) @@ -107,7 +107,7 @@ func (s *GistsService) EditComment(ctx context.Context, gistID string, commentID // DeleteComment deletes a gist comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gists/#delete-a-gist-comment +// GitHub API docs: https://docs.github.com/en/rest/gists/comments#delete-a-gist-comment func (s *GistsService) DeleteComment(ctx context.Context, gistID string, commentID int64) (*Response, error) { u := fmt.Sprintf("gists/%v/comments/%v", gistID, commentID) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/git.go b/vendor/github.com/google/go-github/v47/github/git.go similarity index 77% rename from vendor/github.com/google/go-github/v43/github/git.go rename to vendor/github.com/google/go-github/v47/github/git.go index 36b33f5e..8960de7b 100644 --- a/vendor/github.com/google/go-github/v43/github/git.go +++ b/vendor/github.com/google/go-github/v47/github/git.go @@ -8,5 +8,5 @@ package github // GitService handles communication with the git data related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/ +// GitHub API docs: https://docs.github.com/en/rest/git/ type GitService service diff --git a/vendor/github.com/google/go-github/v43/github/git_blobs.go b/vendor/github.com/google/go-github/v47/github/git_blobs.go similarity index 80% rename from vendor/github.com/google/go-github/v43/github/git_blobs.go rename to vendor/github.com/google/go-github/v47/github/git_blobs.go index 6bc59c6f..da0485cc 100644 --- a/vendor/github.com/google/go-github/v43/github/git_blobs.go +++ b/vendor/github.com/google/go-github/v47/github/git_blobs.go @@ -23,7 +23,7 @@ type Blob struct { // GetBlob fetches a blob from a repo given a SHA. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-blob +// GitHub API docs: https://docs.github.com/en/rest/git/blobs#get-a-blob func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha string) (*Blob, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha) req, err := s.client.NewRequest("GET", u, nil) @@ -33,29 +33,38 @@ func (s *GitService) GetBlob(ctx context.Context, owner string, repo string, sha blob := new(Blob) resp, err := s.client.Do(ctx, req, blob) - return blob, resp, err + if err != nil { + return nil, resp, err + } + + return blob, resp, nil } // GetBlobRaw fetches a blob's contents from a repo. // Unlike GetBlob, it returns the raw bytes rather than the base64-encoded data. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-blob +// GitHub API docs: https://docs.github.com/en/rest/git/blobs#get-a-blob func (s *GitService) GetBlobRaw(ctx context.Context, owner, repo, sha string) ([]byte, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/blobs/%v", owner, repo, sha) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } + req.Header.Set("Accept", "application/vnd.github.v3.raw") var buf bytes.Buffer resp, err := s.client.Do(ctx, req, &buf) - return buf.Bytes(), resp, err + if err != nil { + return nil, resp, err + } + + return buf.Bytes(), resp, nil } // CreateBlob creates a blob object. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-blob +// GitHub API docs: https://docs.github.com/en/rest/git/blobs#create-a-blob func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, blob *Blob) (*Blob, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/blobs", owner, repo) req, err := s.client.NewRequest("POST", u, blob) @@ -65,5 +74,9 @@ func (s *GitService) CreateBlob(ctx context.Context, owner string, repo string, t := new(Blob) resp, err := s.client.Do(ctx, req, t) - return t, resp, err + if err != nil { + return nil, resp, err + } + + return t, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/git_commits.go b/vendor/github.com/google/go-github/v47/github/git_commits.go similarity index 96% rename from vendor/github.com/google/go-github/v43/github/git_commits.go rename to vendor/github.com/google/go-github/v47/github/git_commits.go index 7a728bee..baedb3d6 100644 --- a/vendor/github.com/google/go-github/v43/github/git_commits.go +++ b/vendor/github.com/google/go-github/v47/github/git_commits.go @@ -70,7 +70,7 @@ func (c CommitAuthor) String() string { // GetCommit fetches the Commit object for a given SHA. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-commit +// GitHub API docs: https://docs.github.com/en/rest/git/commits#get-a-commit func (s *GitService) GetCommit(ctx context.Context, owner string, repo string, sha string) (*Commit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/commits/%v", owner, repo, sha) req, err := s.client.NewRequest("GET", u, nil) @@ -104,7 +104,7 @@ type createCommit struct { // data if omitted. If the commit.Author is omitted, it will be filled in with // the authenticated user’s information and the current date. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-commit +// GitHub API docs: https://docs.github.com/en/rest/git/commits#create-a-commit func (s *GitService) CreateCommit(ctx context.Context, owner string, repo string, commit *Commit) (*Commit, *Response, error) { if commit == nil { return nil, nil, fmt.Errorf("commit must be provided") diff --git a/vendor/github.com/google/go-github/v43/github/git_refs.go b/vendor/github.com/google/go-github/v47/github/git_refs.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/git_refs.go rename to vendor/github.com/google/go-github/v47/github/git_refs.go index 259f27fa..e839c30f 100644 --- a/vendor/github.com/google/go-github/v43/github/git_refs.go +++ b/vendor/github.com/google/go-github/v47/github/git_refs.go @@ -49,7 +49,7 @@ type updateRefRequest struct { // GetRef fetches a single reference in a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-reference +// GitHub API docs: https://docs.github.com/en/rest/git/refs#get-a-reference func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref string) (*Reference, *Response, error) { ref = strings.TrimPrefix(ref, "refs/") u := fmt.Sprintf("repos/%v/%v/git/ref/%v", owner, repo, refURLEscape(ref)) @@ -88,7 +88,7 @@ type ReferenceListOptions struct { // ListMatchingRefs lists references in a repository that match a supplied ref. // Use an empty ref to list all references. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#list-matching-references +// GitHub API docs: https://docs.github.com/en/rest/git/refs#list-matching-references func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error) { var ref string if opts != nil { @@ -116,7 +116,7 @@ func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, o // CreateRef creates a new ref in a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-reference +// GitHub API docs: https://docs.github.com/en/rest/git/refs#create-a-reference func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, ref *Reference) (*Reference, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/refs", owner, repo) req, err := s.client.NewRequest("POST", u, &createRefRequest{ @@ -139,10 +139,10 @@ func (s *GitService) CreateRef(ctx context.Context, owner string, repo string, r // UpdateRef updates an existing ref in a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#update-a-reference +// GitHub API docs: https://docs.github.com/en/rest/git/refs#update-a-reference func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, ref *Reference, force bool) (*Reference, *Response, error) { refPath := strings.TrimPrefix(*ref.Ref, "refs/") - u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refPath) + u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(refPath)) req, err := s.client.NewRequest("PATCH", u, &updateRefRequest{ SHA: ref.Object.SHA, Force: &force, @@ -162,7 +162,7 @@ func (s *GitService) UpdateRef(ctx context.Context, owner string, repo string, r // DeleteRef deletes a ref from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#delete-a-reference +// GitHub API docs: https://docs.github.com/en/rest/git/refs#delete-a-reference func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) { ref = strings.TrimPrefix(ref, "refs/") u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref)) diff --git a/vendor/github.com/google/go-github/v43/github/git_tags.go b/vendor/github.com/google/go-github/v47/github/git_tags.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/git_tags.go rename to vendor/github.com/google/go-github/v47/github/git_tags.go index 10029c45..30d7b2c2 100644 --- a/vendor/github.com/google/go-github/v43/github/git_tags.go +++ b/vendor/github.com/google/go-github/v47/github/git_tags.go @@ -35,7 +35,7 @@ type createTagRequest struct { // GetTag fetches a tag from a repo given a SHA. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-tag +// GitHub API docs: https://docs.github.com/en/rest/git/tags#get-a-tag func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha string) (*Tag, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/tags/%v", owner, repo, sha) req, err := s.client.NewRequest("GET", u, nil) @@ -45,12 +45,16 @@ func (s *GitService) GetTag(ctx context.Context, owner string, repo string, sha tag := new(Tag) resp, err := s.client.Do(ctx, req, tag) - return tag, resp, err + if err != nil { + return nil, resp, err + } + + return tag, resp, nil } // CreateTag creates a tag object. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-tag-object +// GitHub API docs: https://docs.github.com/en/rest/git/tags#create-a-tag-object func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, tag *Tag) (*Tag, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/tags", owner, repo) @@ -72,5 +76,9 @@ func (s *GitService) CreateTag(ctx context.Context, owner string, repo string, t t := new(Tag) resp, err := s.client.Do(ctx, req, t) - return t, resp, err + if err != nil { + return nil, resp, err + } + + return t, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/git_trees.go b/vendor/github.com/google/go-github/v47/github/git_trees.go similarity index 95% rename from vendor/github.com/google/go-github/v43/github/git_trees.go rename to vendor/github.com/google/go-github/v47/github/git_trees.go index e655e93a..db28976e 100644 --- a/vendor/github.com/google/go-github/v43/github/git_trees.go +++ b/vendor/github.com/google/go-github/v47/github/git_trees.go @@ -93,7 +93,7 @@ func (t *TreeEntry) MarshalJSON() ([]byte, error) { // GetTree fetches the Tree object for a given sha hash from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#get-a-tree +// GitHub API docs: https://docs.github.com/en/rest/git/trees#get-a-tree func (s *GitService) GetTree(ctx context.Context, owner string, repo string, sha string, recursive bool) (*Tree, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/trees/%v", owner, repo, sha) if recursive { @@ -124,7 +124,7 @@ type createTree struct { // path modifying that tree are specified, it will overwrite the contents of // that tree with the new path contents and write a new tree out. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/git/#create-a-tree +// GitHub API docs: https://docs.github.com/en/rest/git/trees#create-a-tree func (s *GitService) CreateTree(ctx context.Context, owner string, repo string, baseTree string, entries []*TreeEntry) (*Tree, *Response, error) { u := fmt.Sprintf("repos/%v/%v/git/trees", owner, repo) diff --git a/vendor/github.com/google/go-github/v43/github/github-accessors.go b/vendor/github.com/google/go-github/v47/github/github-accessors.go similarity index 96% rename from vendor/github.com/google/go-github/v43/github/github-accessors.go rename to vendor/github.com/google/go-github/v47/github/github-accessors.go index 6c13f545..398ed7a3 100644 --- a/vendor/github.com/google/go-github/v43/github/github-accessors.go +++ b/vendor/github.com/google/go-github/v47/github/github-accessors.go @@ -4,6 +4,8 @@ // license that can be found in the LICENSE file. // Code generated by gen-accessors; DO NOT EDIT. +// Instead, please run "go generate ./..." as described here: +// https://github.com/google/go-github/blob/master/CONTRIBUTING.md#submitting-a-patch package github @@ -60,6 +62,30 @@ func (a *ActionsPermissions) GetSelectedActionsURL() string { return *a.SelectedActionsURL } +// GetAllowedActions returns the AllowedActions field if it's non-nil, zero value otherwise. +func (a *ActionsPermissionsRepository) GetAllowedActions() string { + if a == nil || a.AllowedActions == nil { + return "" + } + return *a.AllowedActions +} + +// GetEnabled returns the Enabled field if it's non-nil, zero value otherwise. +func (a *ActionsPermissionsRepository) GetEnabled() bool { + if a == nil || a.Enabled == nil { + return false + } + return *a.Enabled +} + +// GetSelectedActionsURL returns the SelectedActionsURL field if it's non-nil, zero value otherwise. +func (a *ActionsPermissionsRepository) GetSelectedActionsURL() string { + if a == nil || a.SelectedActionsURL == nil { + return "" + } + return *a.SelectedActionsURL +} + // GetURL returns the URL field if it's non-nil, zero value otherwise. func (a *AdminEnforcement) GetURL() string { if a == nil || a.URL == nil { @@ -172,6 +198,62 @@ func (a *AdvancedSecurityCommittersBreakdown) GetUserLogin() string { return *a.UserLogin } +// GetType returns the Type field if it's non-nil, zero value otherwise. +func (a *AdvisoryIdentifier) GetType() string { + if a == nil || a.Type == nil { + return "" + } + return *a.Type +} + +// GetValue returns the Value field if it's non-nil, zero value otherwise. +func (a *AdvisoryIdentifier) GetValue() string { + if a == nil || a.Value == nil { + return "" + } + return *a.Value +} + +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (a *AdvisoryReference) GetURL() string { + if a == nil || a.URL == nil { + return "" + } + return *a.URL +} + +// GetFirstPatchedVersion returns the FirstPatchedVersion field. +func (a *AdvisoryVulnerability) GetFirstPatchedVersion() *FirstPatchedVersion { + if a == nil { + return nil + } + return a.FirstPatchedVersion +} + +// GetPackage returns the Package field. +func (a *AdvisoryVulnerability) GetPackage() *VulnerabilityPackage { + if a == nil { + return nil + } + return a.Package +} + +// GetSeverity returns the Severity field if it's non-nil, zero value otherwise. +func (a *AdvisoryVulnerability) GetSeverity() string { + if a == nil || a.Severity == nil { + return "" + } + return *a.Severity +} + +// GetVulnerableVersionRange returns the VulnerableVersionRange field if it's non-nil, zero value otherwise. +func (a *AdvisoryVulnerability) GetVulnerableVersionRange() string { + if a == nil || a.VulnerableVersionRange == nil { + return "" + } + return *a.VulnerableVersionRange +} + // GetClosedAt returns the ClosedAt field if it's non-nil, zero value otherwise. func (a *Alert) GetClosedAt() Timestamp { if a == nil || a.ClosedAt == nil { @@ -220,6 +302,14 @@ func (a *Alert) GetDismissedReason() string { return *a.DismissedReason } +// GetFixedAt returns the FixedAt field if it's non-nil, zero value otherwise. +func (a *Alert) GetFixedAt() Timestamp { + if a == nil || a.FixedAt == nil { + return Timestamp{} + } + return *a.FixedAt +} + // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. func (a *Alert) GetHTMLURL() string { if a == nil || a.HTMLURL == nil { @@ -244,6 +334,22 @@ func (a *Alert) GetMostRecentInstance() *MostRecentInstance { return a.MostRecentInstance } +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (a *Alert) GetNumber() int { + if a == nil || a.Number == nil { + return 0 + } + return *a.Number +} + +// GetRepository returns the Repository field. +func (a *Alert) GetRepository() *Repository { + if a == nil { + return nil + } + return a.Repository +} + // GetRule returns the Rule field. func (a *Alert) GetRule() *Rule { if a == nil { @@ -292,6 +398,14 @@ func (a *Alert) GetTool() *Tool { return a.Tool } +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *Alert) GetUpdatedAt() Timestamp { + if a == nil || a.UpdatedAt == nil { + return Timestamp{} + } + return *a.UpdatedAt +} + // GetURL returns the URL field if it's non-nil, zero value otherwise. func (a *Alert) GetURL() string { if a == nil || a.URL == nil { @@ -916,6 +1030,14 @@ func (a *AuditEntry) GetRepositoryPublic() bool { return *a.RepositoryPublic } +// GetRunAttempt returns the RunAttempt field if it's non-nil, zero value otherwise. +func (a *AuditEntry) GetRunAttempt() int64 { + if a == nil || a.RunAttempt == nil { + return 0 + } + return *a.RunAttempt +} + // GetRunnerGroupID returns the RunnerGroupID field if it's non-nil, zero value otherwise. func (a *AuditEntry) GetRunnerGroupID() int64 { if a == nil || a.RunnerGroupID == nil { @@ -1252,6 +1374,14 @@ func (a *Autolink) GetID() int64 { return *a.ID } +// GetIsAlphanumeric returns the IsAlphanumeric field if it's non-nil, zero value otherwise. +func (a *Autolink) GetIsAlphanumeric() bool { + if a == nil || a.IsAlphanumeric == nil { + return false + } + return *a.IsAlphanumeric +} + // GetKeyPrefix returns the KeyPrefix field if it's non-nil, zero value otherwise. func (a *Autolink) GetKeyPrefix() string { if a == nil || a.KeyPrefix == nil { @@ -1268,6 +1398,14 @@ func (a *Autolink) GetURLTemplate() string { return *a.URLTemplate } +// GetIsAlphanumeric returns the IsAlphanumeric field if it's non-nil, zero value otherwise. +func (a *AutolinkOptions) GetIsAlphanumeric() bool { + if a == nil || a.IsAlphanumeric == nil { + return false + } + return *a.IsAlphanumeric +} + // GetKeyPrefix returns the KeyPrefix field if it's non-nil, zero value otherwise. func (a *AutolinkOptions) GetKeyPrefix() string { if a == nil || a.KeyPrefix == nil { @@ -2172,6 +2310,14 @@ func (c *CodeOfConduct) GetURL() string { return *c.URL } +// GetSuggestion returns the Suggestion field if it's non-nil, zero value otherwise. +func (c *CodeownersError) GetSuggestion() string { + if c == nil || c.Suggestion == nil { + return "" + } + return *c.Suggestion +} + // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. func (c *CodeResult) GetHTMLURL() string { if c == nil || c.HTMLURL == nil { @@ -2212,6 +2358,62 @@ func (c *CodeResult) GetSHA() string { return *c.SHA } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (c *CodeScanningAlertEvent) GetAction() string { + if c == nil || c.Action == nil { + return "" + } + return *c.Action +} + +// GetAlert returns the Alert field. +func (c *CodeScanningAlertEvent) GetAlert() *Alert { + if c == nil { + return nil + } + return c.Alert +} + +// GetCommitOID returns the CommitOID field if it's non-nil, zero value otherwise. +func (c *CodeScanningAlertEvent) GetCommitOID() string { + if c == nil || c.CommitOID == nil { + return "" + } + return *c.CommitOID +} + +// GetOrg returns the Org field. +func (c *CodeScanningAlertEvent) GetOrg() *Organization { + if c == nil { + return nil + } + return c.Org +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (c *CodeScanningAlertEvent) GetRef() string { + if c == nil || c.Ref == nil { + return "" + } + return *c.Ref +} + +// GetRepo returns the Repo field. +func (c *CodeScanningAlertEvent) GetRepo() *Repository { + if c == nil { + return nil + } + return c.Repo +} + +// GetSender returns the Sender field. +func (c *CodeScanningAlertEvent) GetSender() *User { + if c == nil { + return nil + } + return c.Sender +} + // GetIncompleteResults returns the IncompleteResults field if it's non-nil, zero value otherwise. func (c *CodeSearchResult) GetIncompleteResults() bool { if c == nil || c.IncompleteResults == nil { @@ -3268,6 +3470,14 @@ func (c *CreateEvent) GetMasterBranch() string { return *c.MasterBranch } +// GetOrg returns the Org field. +func (c *CreateEvent) GetOrg() *Organization { + if c == nil { + return nil + } + return c.Org +} + // GetPusherType returns the PusherType field if it's non-nil, zero value otherwise. func (c *CreateEvent) GetPusherType() string { if c == nil || c.PusherType == nil { @@ -3380,6 +3590,22 @@ func (c *CreateUserProjectOptions) GetBody() string { return *c.Body } +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (c *CustomRepoRoles) GetID() int64 { + if c == nil || c.ID == nil { + return 0 + } + return *c.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CustomRepoRoles) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + // GetInstallation returns the Installation field. func (d *DeleteEvent) GetInstallation() *Installation { if d == nil { @@ -4932,6 +5158,14 @@ func (f *Feeds) GetUserURL() string { return *f.UserURL } +// GetIdentifier returns the Identifier field if it's non-nil, zero value otherwise. +func (f *FirstPatchedVersion) GetIdentifier() string { + if f == nil || f.Identifier == nil { + return "" + } + return *f.Identifier +} + // GetForkee returns the Forkee field. func (f *ForkEvent) GetForkee() *Repository { if f == nil { @@ -6356,6 +6590,14 @@ func (i *InstallationPermissions) GetOrganizationAdministration() string { return *i.OrganizationAdministration } +// GetOrganizationCustomRoles returns the OrganizationCustomRoles field if it's non-nil, zero value otherwise. +func (i *InstallationPermissions) GetOrganizationCustomRoles() string { + if i == nil || i.OrganizationCustomRoles == nil { + return "" + } + return *i.OrganizationCustomRoles +} + // GetOrganizationHooks returns the OrganizationHooks field if it's non-nil, zero value otherwise. func (i *InstallationPermissions) GetOrganizationHooks() string { if i == nil || i.OrganizationHooks == nil { @@ -6364,6 +6606,14 @@ func (i *InstallationPermissions) GetOrganizationHooks() string { return *i.OrganizationHooks } +// GetOrganizationPackages returns the OrganizationPackages field if it's non-nil, zero value otherwise. +func (i *InstallationPermissions) GetOrganizationPackages() string { + if i == nil || i.OrganizationPackages == nil { + return "" + } + return *i.OrganizationPackages +} + // GetOrganizationPlan returns the OrganizationPlan field if it's non-nil, zero value otherwise. func (i *InstallationPermissions) GetOrganizationPlan() string { if i == nil || i.OrganizationPlan == nil { @@ -7428,6 +7678,14 @@ func (i *IssueRequest) GetState() string { return *i.State } +// GetStateReason returns the StateReason field if it's non-nil, zero value otherwise. +func (i *IssueRequest) GetStateReason() string { + if i == nil || i.StateReason == nil { + return "" + } + return *i.StateReason +} + // GetTitle returns the Title field if it's non-nil, zero value otherwise. func (i *IssueRequest) GetTitle() string { if i == nil || i.Title == nil { @@ -7708,6 +7966,14 @@ func (l *LabelEvent) GetRepo() *Repository { return l.Repo } +// GetSender returns the Sender field. +func (l *LabelEvent) GetSender() *User { + if l == nil { + return nil + } + return l.Sender +} + // GetColor returns the Color field if it's non-nil, zero value otherwise. func (l *LabelResult) GetColor() string { if l == nil || l.Color == nil { @@ -8548,6 +8814,30 @@ func (m *MetaEvent) GetInstallation() *Installation { return m.Installation } +// GetOrg returns the Org field. +func (m *MetaEvent) GetOrg() *Organization { + if m == nil { + return nil + } + return m.Org +} + +// GetRepo returns the Repo field. +func (m *MetaEvent) GetRepo() *Repository { + if m == nil { + return nil + } + return m.Repo +} + +// GetSender returns the Sender field. +func (m *MetaEvent) GetSender() *User { + if m == nil { + return nil + } + return m.Sender +} + // GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. func (m *Metric) GetHTMLURL() string { if m == nil || m.HTMLURL == nil { @@ -9140,6 +9430,14 @@ func (o *OAuthAPP) GetURL() string { return *o.URL } +// GetAdvancedSecurityEnabledForNewRepos returns the AdvancedSecurityEnabledForNewRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetAdvancedSecurityEnabledForNewRepos() bool { + if o == nil || o.AdvancedSecurityEnabledForNewRepos == nil { + return false + } + return *o.AdvancedSecurityEnabledForNewRepos +} + // GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise. func (o *Organization) GetAvatarURL() string { if o == nil || o.AvatarURL == nil { @@ -9204,6 +9502,30 @@ func (o *Organization) GetDefaultRepoSettings() string { return *o.DefaultRepoSettings } +// GetDependabotAlertsEnabledForNewRepos returns the DependabotAlertsEnabledForNewRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetDependabotAlertsEnabledForNewRepos() bool { + if o == nil || o.DependabotAlertsEnabledForNewRepos == nil { + return false + } + return *o.DependabotAlertsEnabledForNewRepos +} + +// GetDependabotSecurityUpdatesEnabledForNewRepos returns the DependabotSecurityUpdatesEnabledForNewRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetDependabotSecurityUpdatesEnabledForNewRepos() bool { + if o == nil || o.DependabotSecurityUpdatesEnabledForNewRepos == nil { + return false + } + return *o.DependabotSecurityUpdatesEnabledForNewRepos +} + +// GetDependencyGraphEnabledForNewRepos returns the DependencyGraphEnabledForNewRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetDependencyGraphEnabledForNewRepos() bool { + if o == nil || o.DependencyGraphEnabledForNewRepos == nil { + return false + } + return *o.DependencyGraphEnabledForNewRepos +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (o *Organization) GetDescription() string { if o == nil || o.Description == nil { @@ -9388,6 +9710,14 @@ func (o *Organization) GetMembersCanCreateRepos() bool { return *o.MembersCanCreateRepos } +// GetMembersCanForkPrivateRepos returns the MembersCanForkPrivateRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetMembersCanForkPrivateRepos() bool { + if o == nil || o.MembersCanForkPrivateRepos == nil { + return false + } + return *o.MembersCanForkPrivateRepos +} + // GetMembersURL returns the MembersURL field if it's non-nil, zero value otherwise. func (o *Organization) GetMembersURL() string { if o == nil || o.MembersURL == nil { @@ -9468,6 +9798,22 @@ func (o *Organization) GetReposURL() string { return *o.ReposURL } +// GetSecretScanningEnabledForNewRepos returns the SecretScanningEnabledForNewRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetSecretScanningEnabledForNewRepos() bool { + if o == nil || o.SecretScanningEnabledForNewRepos == nil { + return false + } + return *o.SecretScanningEnabledForNewRepos +} + +// GetSecretScanningPushProtectionEnabledForNewRepos returns the SecretScanningPushProtectionEnabledForNewRepos field if it's non-nil, zero value otherwise. +func (o *Organization) GetSecretScanningPushProtectionEnabledForNewRepos() bool { + if o == nil || o.SecretScanningPushProtectionEnabledForNewRepos == nil { + return false + } + return *o.SecretScanningPushProtectionEnabledForNewRepos +} + // GetTotalPrivateRepos returns the TotalPrivateRepos field if it's non-nil, zero value otherwise. func (o *Organization) GetTotalPrivateRepos() int { if o == nil || o.TotalPrivateRepos == nil { @@ -9516,6 +9862,22 @@ func (o *Organization) GetURL() string { return *o.URL } +// GetWebCommitSignoffRequired returns the WebCommitSignoffRequired field if it's non-nil, zero value otherwise. +func (o *Organization) GetWebCommitSignoffRequired() bool { + if o == nil || o.WebCommitSignoffRequired == nil { + return false + } + return *o.WebCommitSignoffRequired +} + +// GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. +func (o *OrganizationCustomRepoRoles) GetTotalCount() int { + if o == nil || o.TotalCount == nil { + return 0 + } + return *o.TotalCount +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (o *OrganizationEvent) GetAction() string { if o == nil || o.Action == nil { @@ -10532,12 +10894,12 @@ func (p *PagesUpdate) GetPublic() bool { return *p.Public } -// GetSource returns the Source field if it's non-nil, zero value otherwise. -func (p *PagesUpdate) GetSource() string { - if p == nil || p.Source == nil { - return "" +// GetSource returns the Source field. +func (p *PagesUpdate) GetSource() *PagesSource { + if p == nil { + return nil } - return *p.Source + return p.Source } // GetHook returns the Hook field. @@ -10564,6 +10926,30 @@ func (p *PingEvent) GetInstallation() *Installation { return p.Installation } +// GetOrg returns the Org field. +func (p *PingEvent) GetOrg() *Organization { + if p == nil { + return nil + } + return p.Org +} + +// GetRepo returns the Repo field. +func (p *PingEvent) GetRepo() *Repository { + if p == nil { + return nil + } + return p.Repo +} + +// GetSender returns the Sender field. +func (p *PingEvent) GetSender() *User { + if p == nil { + return nil + } + return p.Sender +} + // GetZen returns the Zen field if it's non-nil, zero value otherwise. func (p *PingEvent) GetZen() string { if p == nil || p.Zen == nil { @@ -12612,6 +12998,14 @@ func (p *PullRequestReviewRequest) GetNodeID() string { return *p.NodeID } +// GetBypassPullRequestAllowances returns the BypassPullRequestAllowances field. +func (p *PullRequestReviewsEnforcement) GetBypassPullRequestAllowances() *BypassPullRequestAllowances { + if p == nil { + return nil + } + return p.BypassPullRequestAllowances +} + // GetDismissalRestrictions returns the DismissalRestrictions field. func (p *PullRequestReviewsEnforcement) GetDismissalRestrictions() *DismissalRestrictions { if p == nil { @@ -12620,6 +13014,14 @@ func (p *PullRequestReviewsEnforcement) GetDismissalRestrictions() *DismissalRes return p.DismissalRestrictions } +// GetBypassPullRequestAllowancesRequest returns the BypassPullRequestAllowancesRequest field. +func (p *PullRequestReviewsEnforcementRequest) GetBypassPullRequestAllowancesRequest() *BypassPullRequestAllowancesRequest { + if p == nil { + return nil + } + return p.BypassPullRequestAllowancesRequest +} + // GetDismissalRestrictionsRequest returns the DismissalRestrictionsRequest field. func (p *PullRequestReviewsEnforcementRequest) GetDismissalRestrictionsRequest() *DismissalRestrictionsRequest { if p == nil { @@ -12628,6 +13030,14 @@ func (p *PullRequestReviewsEnforcementRequest) GetDismissalRestrictionsRequest() return p.DismissalRestrictionsRequest } +// GetBypassPullRequestAllowancesRequest returns the BypassPullRequestAllowancesRequest field. +func (p *PullRequestReviewsEnforcementUpdate) GetBypassPullRequestAllowancesRequest() *BypassPullRequestAllowancesRequest { + if p == nil { + return nil + } + return p.BypassPullRequestAllowancesRequest +} + // GetDismissalRestrictionsRequest returns the DismissalRestrictionsRequest field. func (p *PullRequestReviewsEnforcementUpdate) GetDismissalRestrictionsRequest() *DismissalRestrictionsRequest { if p == nil { @@ -12652,6 +13062,54 @@ func (p *PullRequestReviewsEnforcementUpdate) GetRequireCodeOwnerReviews() bool return *p.RequireCodeOwnerReviews } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (p *PullRequestReviewThreadEvent) GetAction() string { + if p == nil || p.Action == nil { + return "" + } + return *p.Action +} + +// GetInstallation returns the Installation field. +func (p *PullRequestReviewThreadEvent) GetInstallation() *Installation { + if p == nil { + return nil + } + return p.Installation +} + +// GetPullRequest returns the PullRequest field. +func (p *PullRequestReviewThreadEvent) GetPullRequest() *PullRequest { + if p == nil { + return nil + } + return p.PullRequest +} + +// GetRepo returns the Repo field. +func (p *PullRequestReviewThreadEvent) GetRepo() *Repository { + if p == nil { + return nil + } + return p.Repo +} + +// GetSender returns the Sender field. +func (p *PullRequestReviewThreadEvent) GetSender() *User { + if p == nil { + return nil + } + return p.Sender +} + +// GetThread returns the Thread field. +func (p *PullRequestReviewThreadEvent) GetThread() *PullRequestThread { + if p == nil { + return nil + } + return p.Thread +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (p *PullRequestTargetEvent) GetAction() string { if p == nil || p.Action == nil { @@ -12764,6 +13222,22 @@ func (p *PullRequestTargetEvent) GetSender() *User { return p.Sender } +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (p *PullRequestThread) GetID() int64 { + if p == nil || p.ID == nil { + return 0 + } + return *p.ID +} + +// GetNodeID returns the NodeID field if it's non-nil, zero value otherwise. +func (p *PullRequestThread) GetNodeID() string { + if p == nil || p.NodeID == nil { + return "" + } + return *p.NodeID +} + // GetMergablePulls returns the MergablePulls field if it's non-nil, zero value otherwise. func (p *PullStats) GetMergablePulls() int { if p == nil || p.MergablePulls == nil { @@ -12820,6 +13294,14 @@ func (p *PunchCard) GetHour() int { return *p.Hour } +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (p *PushEvent) GetAction() string { + if p == nil || p.Action == nil { + return "" + } + return *p.Action +} + // GetAfter returns the After field if it's non-nil, zero value otherwise. func (p *PushEvent) GetAfter() string { if p == nil || p.After == nil { @@ -13268,6 +13750,22 @@ func (p *PushEventRepository) GetWatchersCount() int { return *p.WatchersCount } +// GetActionsRunnerRegistration returns the ActionsRunnerRegistration field. +func (r *RateLimits) GetActionsRunnerRegistration() *Rate { + if r == nil { + return nil + } + return r.ActionsRunnerRegistration +} + +// GetCodeScanningUpload returns the CodeScanningUpload field. +func (r *RateLimits) GetCodeScanningUpload() *Rate { + if r == nil { + return nil + } + return r.CodeScanningUpload +} + // GetCore returns the Core field. func (r *RateLimits) GetCore() *Rate { if r == nil { @@ -13276,6 +13774,30 @@ func (r *RateLimits) GetCore() *Rate { return r.Core } +// GetGraphQL returns the GraphQL field. +func (r *RateLimits) GetGraphQL() *Rate { + if r == nil { + return nil + } + return r.GraphQL +} + +// GetIntegrationManifest returns the IntegrationManifest field. +func (r *RateLimits) GetIntegrationManifest() *Rate { + if r == nil { + return nil + } + return r.IntegrationManifest +} + +// GetSCIM returns the SCIM field. +func (r *RateLimits) GetSCIM() *Rate { + if r == nil { + return nil + } + return r.SCIM +} + // GetSearch returns the Search field. func (r *RateLimits) GetSearch() *Rate { if r == nil { @@ -13284,6 +13806,14 @@ func (r *RateLimits) GetSearch() *Rate { return r.Search } +// GetSourceImport returns the SourceImport field. +func (r *RateLimits) GetSourceImport() *Rate { + if r == nil { + return nil + } + return r.SourceImport +} + // GetContent returns the Content field if it's non-nil, zero value otherwise. func (r *Reaction) GetContent() string { if r == nil || r.Content == nil { @@ -13636,6 +14166,38 @@ func (r *RenameOrgResponse) GetURL() string { return *r.URL } +// GetBranch returns the Branch field if it's non-nil, zero value otherwise. +func (r *RepoMergeUpstreamRequest) GetBranch() string { + if r == nil || r.Branch == nil { + return "" + } + return *r.Branch +} + +// GetBaseBranch returns the BaseBranch field if it's non-nil, zero value otherwise. +func (r *RepoMergeUpstreamResult) GetBaseBranch() string { + if r == nil || r.BaseBranch == nil { + return "" + } + return *r.BaseBranch +} + +// GetMergeType returns the MergeType field if it's non-nil, zero value otherwise. +func (r *RepoMergeUpstreamResult) GetMergeType() string { + if r == nil || r.MergeType == nil { + return "" + } + return *r.MergeType +} + +// GetMessage returns the Message field if it's non-nil, zero value otherwise. +func (r *RepoMergeUpstreamResult) GetMessage() string { + if r == nil || r.Message == nil { + return "" + } + return *r.Message +} + // GetFrom returns the From field if it's non-nil, zero value otherwise. func (r *RepoName) GetFrom() string { if r == nil || r.From == nil { @@ -13700,6 +14262,14 @@ func (r *Repository) GetAllowSquashMerge() bool { return *r.AllowSquashMerge } +// GetAllowUpdateBranch returns the AllowUpdateBranch field if it's non-nil, zero value otherwise. +func (r *Repository) GetAllowUpdateBranch() bool { + if r == nil || r.AllowUpdateBranch == nil { + return false + } + return *r.AllowUpdateBranch +} + // GetArchived returns the Archived field if it's non-nil, zero value otherwise. func (r *Repository) GetArchived() bool { if r == nil || r.Archived == nil { @@ -14108,6 +14678,22 @@ func (r *Repository) GetMasterBranch() string { return *r.MasterBranch } +// GetMergeCommitMessage returns the MergeCommitMessage field if it's non-nil, zero value otherwise. +func (r *Repository) GetMergeCommitMessage() string { + if r == nil || r.MergeCommitMessage == nil { + return "" + } + return *r.MergeCommitMessage +} + +// GetMergeCommitTitle returns the MergeCommitTitle field if it's non-nil, zero value otherwise. +func (r *Repository) GetMergeCommitTitle() string { + if r == nil || r.MergeCommitTitle == nil { + return "" + } + return *r.MergeCommitTitle +} + // GetMergesURL returns the MergesURL field if it's non-nil, zero value otherwise. func (r *Repository) GetMergesURL() string { if r == nil || r.MergesURL == nil { @@ -14244,6 +14830,14 @@ func (r *Repository) GetReleasesURL() string { return *r.ReleasesURL } +// GetRoleName returns the RoleName field if it's non-nil, zero value otherwise. +func (r *Repository) GetRoleName() string { + if r == nil || r.RoleName == nil { + return "" + } + return *r.RoleName +} + // GetSecurityAndAnalysis returns the SecurityAndAnalysis field. func (r *Repository) GetSecurityAndAnalysis() *SecurityAndAnalysis { if r == nil { @@ -14268,6 +14862,22 @@ func (r *Repository) GetSource() *Repository { return r.Source } +// GetSquashMergeCommitMessage returns the SquashMergeCommitMessage field if it's non-nil, zero value otherwise. +func (r *Repository) GetSquashMergeCommitMessage() string { + if r == nil || r.SquashMergeCommitMessage == nil { + return "" + } + return *r.SquashMergeCommitMessage +} + +// GetSquashMergeCommitTitle returns the SquashMergeCommitTitle field if it's non-nil, zero value otherwise. +func (r *Repository) GetSquashMergeCommitTitle() string { + if r == nil || r.SquashMergeCommitTitle == nil { + return "" + } + return *r.SquashMergeCommitTitle +} + // GetSSHURL returns the SSHURL field if it's non-nil, zero value otherwise. func (r *Repository) GetSSHURL() string { if r == nil || r.SSHURL == nil { @@ -14388,6 +14998,14 @@ func (r *Repository) GetURL() string { return *r.URL } +// GetUseSquashPRTitleAsDefault returns the UseSquashPRTitleAsDefault field if it's non-nil, zero value otherwise. +func (r *Repository) GetUseSquashPRTitleAsDefault() bool { + if r == nil || r.UseSquashPRTitleAsDefault == nil { + return false + } + return *r.UseSquashPRTitleAsDefault +} + // GetVisibility returns the Visibility field if it's non-nil, zero value otherwise. func (r *Repository) GetVisibility() string { if r == nil || r.Visibility == nil { @@ -14828,6 +15446,38 @@ func (r *RepositoryEvent) GetSender() *User { return r.Sender } +// GetOrg returns the Org field. +func (r *RepositoryImportEvent) GetOrg() *Organization { + if r == nil { + return nil + } + return r.Org +} + +// GetRepo returns the Repo field. +func (r *RepositoryImportEvent) GetRepo() *Repository { + if r == nil { + return nil + } + return r.Repo +} + +// GetSender returns the Sender field. +func (r *RepositoryImportEvent) GetSender() *User { + if r == nil { + return nil + } + return r.Sender +} + +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (r *RepositoryImportEvent) GetStatus() string { + if r == nil || r.Status == nil { + return "" + } + return *r.Status +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (r *RepositoryInvitation) GetCreatedAt() Timestamp { if r == nil || r.CreatedAt == nil { @@ -15340,6 +15990,14 @@ func (r *RepositoryVulnerabilityAlertEvent) GetRepository() *Repository { return r.Repository } +// GetSender returns the Sender field. +func (r *RepositoryVulnerabilityAlertEvent) GetSender() *User { + if r == nil { + return nil + } + return r.Sender +} + // GetForkRepos returns the ForkRepos field if it's non-nil, zero value otherwise. func (r *RepoStats) GetForkRepos() int { if r == nil || r.ForkRepos == nil { @@ -16236,6 +16894,78 @@ func (s *SecretScanningAlertUpdateOptions) GetState() string { return *s.State } +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetDescription() string { + if s == nil || s.Description == nil { + return "" + } + return *s.Description +} + +// GetGHSAID returns the GHSAID field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetGHSAID() string { + if s == nil || s.GHSAID == nil { + return "" + } + return *s.GHSAID +} + +// GetPublishedAt returns the PublishedAt field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetPublishedAt() Timestamp { + if s == nil || s.PublishedAt == nil { + return Timestamp{} + } + return *s.PublishedAt +} + +// GetSeverity returns the Severity field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetSeverity() string { + if s == nil || s.Severity == nil { + return "" + } + return *s.Severity +} + +// GetSummary returns the Summary field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetSummary() string { + if s == nil || s.Summary == nil { + return "" + } + return *s.Summary +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetUpdatedAt() Timestamp { + if s == nil || s.UpdatedAt == nil { + return Timestamp{} + } + return *s.UpdatedAt +} + +// GetWithdrawnAt returns the WithdrawnAt field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisory) GetWithdrawnAt() Timestamp { + if s == nil || s.WithdrawnAt == nil { + return Timestamp{} + } + return *s.WithdrawnAt +} + +// GetAction returns the Action field if it's non-nil, zero value otherwise. +func (s *SecurityAdvisoryEvent) GetAction() string { + if s == nil || s.Action == nil { + return "" + } + return *s.Action +} + +// GetSecurityAdvisory returns the SecurityAdvisory field. +func (s *SecurityAdvisoryEvent) GetSecurityAdvisory() *SecurityAdvisory { + if s == nil { + return nil + } + return s.SecurityAdvisory +} + // GetAdvancedSecurity returns the AdvancedSecurity field. func (s *SecurityAndAnalysis) GetAdvancedSecurity() *AdvancedSecurity { if s == nil { @@ -16716,6 +17446,22 @@ func (t *Tag) GetVerification() *SignatureVerification { return t.Verification } +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (t *TagProtection) GetID() int64 { + if t == nil || t.ID == nil { + return 0 + } + return *t.ID +} + +// GetPattern returns the Pattern field if it's non-nil, zero value otherwise. +func (t *TagProtection) GetPattern() string { + if t == nil || t.Pattern == nil { + return "" + } + return *t.Pattern +} + // GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise. func (t *TaskStep) GetCompletedAt() Timestamp { if t == nil || t.CompletedAt == nil { @@ -18228,6 +18974,14 @@ func (u *User) GetReposURL() string { return *u.ReposURL } +// GetRoleName returns the RoleName field if it's non-nil, zero value otherwise. +func (u *User) GetRoleName() string { + if u == nil || u.RoleName == nil { + return "" + } + return *u.RoleName +} + // GetSiteAdmin returns the SiteAdmin field if it's non-nil, zero value otherwise. func (u *User) GetSiteAdmin() bool { if u == nil || u.SiteAdmin == nil { @@ -18732,6 +19486,22 @@ func (u *UserSuspendOptions) GetReason() string { return *u.Reason } +// GetEcosystem returns the Ecosystem field if it's non-nil, zero value otherwise. +func (v *VulnerabilityPackage) GetEcosystem() string { + if v == nil || v.Ecosystem == nil { + return "" + } + return *v.Ecosystem +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (v *VulnerabilityPackage) GetName() string { + if v == nil || v.Name == nil { + return "" + } + return *v.Name +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (w *WatchEvent) GetAction() string { if w == nil || w.Action == nil { @@ -18764,190 +19534,6 @@ func (w *WatchEvent) GetSender() *User { return w.Sender } -// GetEmail returns the Email field if it's non-nil, zero value otherwise. -func (w *WebHookAuthor) GetEmail() string { - if w == nil || w.Email == nil { - return "" - } - return *w.Email -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (w *WebHookAuthor) GetName() string { - if w == nil || w.Name == nil { - return "" - } - return *w.Name -} - -// GetUsername returns the Username field if it's non-nil, zero value otherwise. -func (w *WebHookAuthor) GetUsername() string { - if w == nil || w.Username == nil { - return "" - } - return *w.Username -} - -// GetAuthor returns the Author field. -func (w *WebHookCommit) GetAuthor() *WebHookAuthor { - if w == nil { - return nil - } - return w.Author -} - -// GetCommitter returns the Committer field. -func (w *WebHookCommit) GetCommitter() *WebHookAuthor { - if w == nil { - return nil - } - return w.Committer -} - -// GetDistinct returns the Distinct field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetDistinct() bool { - if w == nil || w.Distinct == nil { - return false - } - return *w.Distinct -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetID() string { - if w == nil || w.ID == nil { - return "" - } - return *w.ID -} - -// GetMessage returns the Message field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetMessage() string { - if w == nil || w.Message == nil { - return "" - } - return *w.Message -} - -// GetTimestamp returns the Timestamp field if it's non-nil, zero value otherwise. -func (w *WebHookCommit) GetTimestamp() time.Time { - if w == nil || w.Timestamp == nil { - return time.Time{} - } - return *w.Timestamp -} - -// GetAction returns the Action field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetAction() string { - if w == nil || w.Action == nil { - return "" - } - return *w.Action -} - -// GetAfter returns the After field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetAfter() string { - if w == nil || w.After == nil { - return "" - } - return *w.After -} - -// GetBefore returns the Before field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetBefore() string { - if w == nil || w.Before == nil { - return "" - } - return *w.Before -} - -// GetCompare returns the Compare field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetCompare() string { - if w == nil || w.Compare == nil { - return "" - } - return *w.Compare -} - -// GetCreated returns the Created field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetCreated() bool { - if w == nil || w.Created == nil { - return false - } - return *w.Created -} - -// GetDeleted returns the Deleted field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetDeleted() bool { - if w == nil || w.Deleted == nil { - return false - } - return *w.Deleted -} - -// GetForced returns the Forced field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetForced() bool { - if w == nil || w.Forced == nil { - return false - } - return *w.Forced -} - -// GetHeadCommit returns the HeadCommit field. -func (w *WebHookPayload) GetHeadCommit() *WebHookCommit { - if w == nil { - return nil - } - return w.HeadCommit -} - -// GetInstallation returns the Installation field. -func (w *WebHookPayload) GetInstallation() *Installation { - if w == nil { - return nil - } - return w.Installation -} - -// GetOrganization returns the Organization field. -func (w *WebHookPayload) GetOrganization() *Organization { - if w == nil { - return nil - } - return w.Organization -} - -// GetPusher returns the Pusher field. -func (w *WebHookPayload) GetPusher() *User { - if w == nil { - return nil - } - return w.Pusher -} - -// GetRef returns the Ref field if it's non-nil, zero value otherwise. -func (w *WebHookPayload) GetRef() string { - if w == nil || w.Ref == nil { - return "" - } - return *w.Ref -} - -// GetRepo returns the Repo field. -func (w *WebHookPayload) GetRepo() *Repository { - if w == nil { - return nil - } - return w.Repo -} - -// GetSender returns the Sender field. -func (w *WebHookPayload) GetSender() *User { - if w == nil { - return nil - } - return w.Sender -} - // GetTotal returns the Total field if it's non-nil, zero value otherwise. func (w *WeeklyCommitActivity) GetTotal() int { if w == nil || w.Total == nil { @@ -19340,6 +19926,14 @@ func (w *WorkflowJobEvent) GetWorkflowJob() *WorkflowJob { return w.WorkflowJob } +// GetActor returns the Actor field. +func (w *WorkflowRun) GetActor() *User { + if w == nil { + return nil + } + return w.Actor +} + // GetArtifactsURL returns the ArtifactsURL field if it's non-nil, zero value otherwise. func (w *WorkflowRun) GetArtifactsURL() string { if w == nil || w.ArtifactsURL == nil { diff --git a/vendor/github.com/google/go-github/v43/github/github.go b/vendor/github.com/google/go-github/v47/github/github.go similarity index 90% rename from vendor/github.com/google/go-github/v43/github/github.go rename to vendor/github.com/google/go-github/v47/github/github.go index 164b2d06..da923dbb 100644 --- a/vendor/github.com/google/go-github/v43/github/github.go +++ b/vendor/github.com/google/go-github/v47/github/github.go @@ -28,9 +28,11 @@ import ( ) const ( - defaultBaseURL = "https://api.github.com/" - uploadBaseURL = "https://uploads.github.com/" - userAgent = "go-github" + Version = "v47.0.0" + + defaultBaseURL = "https://api.github.com/" + defaultUserAgent = "go-github" + "/" + Version + uploadBaseURL = "https://uploads.github.com/" headerRateLimit = "X-RateLimit-Limit" headerRateRemaining = "X-RateLimit-Remaining" @@ -130,10 +132,10 @@ const ( // https://developer.github.com/changes/2019-04-11-pulls-branches-for-commit/ mediaTypeListPullsOrBranchesForCommitPreview = "application/vnd.github.groot-preview+json" - // https://docs.github.com/en/free-pro-team@latest/rest/reference/previews/#repository-creation-permissions + // https://docs.github.com/en/rest/previews/#repository-creation-permissions mediaTypeMemberAllowedRepoCreationTypePreview = "application/vnd.github.surtur-preview+json" - // https://docs.github.com/en/free-pro-team@latest/rest/reference/previews/#create-and-use-repository-templates + // https://docs.github.com/en/rest/previews/#create-and-use-repository-templates mediaTypeRepositoryTemplatePreview = "application/vnd.github.baptiste-preview+json" // https://developer.github.com/changes/2019-10-03-multi-line-comments/ @@ -301,7 +303,7 @@ func NewClient(httpClient *http.Client) *Client { baseURL, _ := url.Parse(defaultBaseURL) uploadURL, _ := url.Parse(uploadBaseURL) - c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: userAgent, UploadURL: uploadURL} + c := &Client{client: httpClient, BaseURL: baseURL, UserAgent: defaultUserAgent, UploadURL: uploadURL} c.common.client = c c.Actions = (*ActionsService)(&c.common) c.Activity = (*ActivityService)(&c.common) @@ -353,6 +355,7 @@ func NewEnterpriseClient(baseURL, uploadURL string, httpClient *http.Client) (*C if err != nil { return nil, err } + if !strings.HasSuffix(baseEndpoint.Path, "/") { baseEndpoint.Path += "/" } @@ -366,6 +369,7 @@ func NewEnterpriseClient(baseURL, uploadURL string, httpClient *http.Client) (*C if err != nil { return nil, err } + if !strings.HasSuffix(uploadEndpoint.Path, "/") { uploadEndpoint.Path += "/" } @@ -390,6 +394,7 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ if !strings.HasSuffix(c.BaseURL.Path, "/") { return nil, fmt.Errorf("BaseURL must have a trailing slash, but %q does not", c.BaseURL) } + u, err := c.BaseURL.Parse(urlStr) if err != nil { return nil, err @@ -421,6 +426,33 @@ func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Requ return req, nil } +// NewFormRequest creates an API request. A relative URL can be provided in urlStr, +// in which case it is resolved relative to the BaseURL of the Client. +// Relative URLs should always be specified without a preceding slash. +// Body is sent with Content-Type: application/x-www-form-urlencoded. +func (c *Client) NewFormRequest(urlStr string, body io.Reader) (*http.Request, error) { + if !strings.HasSuffix(c.BaseURL.Path, "/") { + return nil, fmt.Errorf("BaseURL must have a trailing slash, but %q does not", c.BaseURL) + } + + u, err := c.BaseURL.Parse(urlStr) + if err != nil { + return nil, err + } + + req, err := http.NewRequest(http.MethodPost, u.String(), body) + if err != nil { + return nil, err + } + + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + req.Header.Set("Accept", mediaTypeV3) + if c.UserAgent != "" { + req.Header.Set("User-Agent", c.UserAgent) + } + return req, nil +} + // NewUploadRequest creates an upload request. A relative URL can be provided in // urlStr, in which case it is resolved relative to the UploadURL of the Client. // Relative URLs should always be specified without a preceding slash. @@ -437,6 +469,7 @@ func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, m if err != nil { return nil, err } + req.ContentLength = size if mediaType == "" { @@ -621,6 +654,7 @@ func (c *Client) BareDo(ctx context.Context, req *http.Request) (*Response, erro if ctx == nil { return nil, errNonNilContext } + req = withContext(ctx, req) rateLimitCategory := category(req.URL.Path) @@ -765,7 +799,7 @@ func compareHTTPResponse(r1, r2 *http.Response) bool { /* An ErrorResponse reports one or more errors caused by an API request. -GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors +GitHub API docs: https://docs.github.com/en/rest/#client-errors */ type ErrorResponse struct { Response *http.Response // HTTP response that caused this error @@ -775,7 +809,7 @@ type ErrorResponse struct { Block *ErrorBlock `json:"block,omitempty"` // Most errors will also include a documentation_url field pointing // to some content that might help you resolve the error, see - // https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors + // https://docs.github.com/en/rest/#client-errors DocumentationURL string `json:"documentation_url,omitempty"` } @@ -895,7 +929,7 @@ func (ae *AcceptedError) Is(target error) bool { } // AbuseRateLimitError occurs when GitHub returns 403 Forbidden response with the -// "documentation_url" field value equal to "https://docs.github.com/en/free-pro-team@latest/rest/overview/resources-in-the-rest-api#secondary-rate-limits". +// "documentation_url" field value equal to "https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits". type AbuseRateLimitError struct { Response *http.Response // HTTP response that caused this error Message string `json:"message"` // error message @@ -942,23 +976,23 @@ func sanitizeURL(uri *url.URL) *url.URL { An Error reports more details on an individual error in an ErrorResponse. These are the possible validation error codes: - missing: - resource does not exist - missing_field: - a required field on a resource has not been set - invalid: - the formatting of a field is invalid - already_exists: - another resource has the same valid as this field - custom: - some resources return this (e.g. github.User.CreateKey()), additional - information is set in the Message field of the Error + missing: + resource does not exist + missing_field: + a required field on a resource has not been set + invalid: + the formatting of a field is invalid + already_exists: + another resource has the same valid as this field + custom: + some resources return this (e.g. github.User.CreateKey()), additional + information is set in the Message field of the Error GitHub error responses structure are often undocumented and inconsistent. Sometimes error is just a simple string (Issue #540). In such cases, Message represents an error message as a workaround. -GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#client-errors +GitHub API docs: https://docs.github.com/en/rest/#client-errors */ type Error struct { Resource string `json:"resource"` // resource on which the error occurred @@ -996,6 +1030,7 @@ func CheckResponse(r *http.Response) error { if c := r.StatusCode; 200 <= c && c <= 299 { return nil } + errorResponse := &ErrorResponse{Response: r} data, err := ioutil.ReadAll(r.Body) if err == nil && data != nil { @@ -1076,15 +1111,26 @@ type RateLimits struct { // requests are limited to 60 per hour. Authenticated requests are // limited to 5,000 per hour. // - // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/#rate-limiting + // GitHub API docs: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting Core *Rate `json:"core"` // The rate limit for search API requests. Unauthenticated requests // are limited to 10 requests per minutes. Authenticated requests are // limited to 30 per minute. // - // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#rate-limit + // GitHub API docs: https://docs.github.com/en/rest/search#rate-limit Search *Rate `json:"search"` + + // GitHub API docs: https://docs.github.com/en/graphql/overview/resource-limitations#rate-limit + GraphQL *Rate `json:"graphql"` + + // GitHub API dos: https://docs.github.com/en/rest/rate-limit + IntegrationManifest *Rate `json:"integration_manifest"` + + SourceImport *Rate `json:"source_import"` + CodeScanningUpload *Rate `json:"code_scanning_upload"` + ActionsRunnerRegistration *Rate `json:"actions_runner_registration"` + SCIM *Rate `json:"scim"` } func (r RateLimits) String() string { @@ -1096,6 +1142,12 @@ type rateLimitCategory uint8 const ( coreCategory rateLimitCategory = iota searchCategory + graphqlCategory + integrationManifestCategory + sourceImportCategory + codeScanningUploadCategory + actionsRunnerRegistrationCategory + scimCategory categories // An array of this length will be able to contain all rate limit categories. ) @@ -1136,6 +1188,24 @@ func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error) if response.Resources.Search != nil { c.rateLimits[searchCategory] = *response.Resources.Search } + if response.Resources.GraphQL != nil { + c.rateLimits[graphqlCategory] = *response.Resources.GraphQL + } + if response.Resources.IntegrationManifest != nil { + c.rateLimits[integrationManifestCategory] = *response.Resources.IntegrationManifest + } + if response.Resources.SourceImport != nil { + c.rateLimits[sourceImportCategory] = *response.Resources.SourceImport + } + if response.Resources.CodeScanningUpload != nil { + c.rateLimits[codeScanningUploadCategory] = *response.Resources.CodeScanningUpload + } + if response.Resources.ActionsRunnerRegistration != nil { + c.rateLimits[actionsRunnerRegistrationCategory] = *response.Resources.ActionsRunnerRegistration + } + if response.Resources.SCIM != nil { + c.rateLimits[scimCategory] = *response.Resources.SCIM + } c.rateMu.Unlock() } @@ -1173,7 +1243,7 @@ that need to use a higher rate limit associated with your OAuth application. This will add the client id and secret as a base64-encoded string in the format ClientID:ClientSecret and apply it as an "Authorization": "Basic" header. -See https://docs.github.com/en/free-pro-team@latest/rest/reference/#unauthenticated-rate-limited-requests for +See https://docs.github.com/en/rest/#unauthenticated-rate-limited-requests for more information. */ type UnauthenticatedRateLimitedTransport struct { @@ -1279,6 +1349,35 @@ func formatRateReset(d time.Duration) string { return fmt.Sprintf("[rate reset in %v]", timeString) } +// When using roundTripWithOptionalFollowRedirect, note that it +// is the responsibility of the caller to close the response body. +func (c *Client) roundTripWithOptionalFollowRedirect(ctx context.Context, u string, followRedirects bool) (*http.Response, error) { + req, err := c.NewRequest("GET", u, nil) + if err != nil { + return nil, err + } + + var resp *http.Response + // Use http.DefaultTransport if no custom Transport is configured + req = withContext(ctx, req) + if c.client.Transport == nil { + resp, err = http.DefaultTransport.RoundTrip(req) + } else { + resp, err = c.client.Transport.RoundTrip(req) + } + if err != nil { + return nil, err + } + + // If redirect response is returned, follow it + if followRedirects && resp.StatusCode == http.StatusMovedPermanently { + resp.Body.Close() + u = resp.Header.Get("Location") + resp, err = c.roundTripWithOptionalFollowRedirect(ctx, u, false) + } + return resp, err +} + // Bool is a helper routine that allocates a new bool value // to store v and returns a pointer to it. func Bool(v bool) *bool { return &v } diff --git a/vendor/github.com/google/go-github/v43/github/gitignore.go b/vendor/github.com/google/go-github/v47/github/gitignore.go similarity index 81% rename from vendor/github.com/google/go-github/v43/github/gitignore.go rename to vendor/github.com/google/go-github/v47/github/gitignore.go index 2f9d0bcf..a20a868b 100644 --- a/vendor/github.com/google/go-github/v43/github/gitignore.go +++ b/vendor/github.com/google/go-github/v47/github/gitignore.go @@ -13,7 +13,7 @@ import ( // GitignoresService provides access to the gitignore related functions in the // GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/ +// GitHub API docs: https://docs.github.com/en/rest/gitignore/ type GitignoresService service // Gitignore represents a .gitignore file as returned by the GitHub API. @@ -28,7 +28,7 @@ func (g Gitignore) String() string { // List all available Gitignore templates. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/#listing-available-templates +// GitHub API docs: https://docs.github.com/en/rest/gitignore/#listing-available-templates func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, error) { req, err := s.client.NewRequest("GET", "gitignore/templates", nil) if err != nil { @@ -46,7 +46,7 @@ func (s *GitignoresService) List(ctx context.Context) ([]string, *Response, erro // Get a Gitignore by name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/gitignore/#get-a-gitignore-template +// GitHub API docs: https://docs.github.com/en/rest/gitignore#get-a-gitignore-template func (s *GitignoresService) Get(ctx context.Context, name string) (*Gitignore, *Response, error) { u := fmt.Sprintf("gitignore/templates/%v", name) req, err := s.client.NewRequest("GET", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/interactions.go b/vendor/github.com/google/go-github/v47/github/interactions.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/interactions.go rename to vendor/github.com/google/go-github/v47/github/interactions.go index 3b00d3c0..a690f612 100644 --- a/vendor/github.com/google/go-github/v43/github/interactions.go +++ b/vendor/github.com/google/go-github/v47/github/interactions.go @@ -8,7 +8,7 @@ package github // InteractionsService handles communication with the repository and organization related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/ +// GitHub API docs: https://docs.github.com/en/rest/interactions/ type InteractionsService service // InteractionRestriction represents the interaction restrictions for repository and organization. diff --git a/vendor/github.com/google/go-github/v43/github/interactions_orgs.go b/vendor/github.com/google/go-github/v47/github/interactions_orgs.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/interactions_orgs.go rename to vendor/github.com/google/go-github/v47/github/interactions_orgs.go index d22a9e74..5c7663f5 100644 --- a/vendor/github.com/google/go-github/v43/github/interactions_orgs.go +++ b/vendor/github.com/google/go-github/v47/github/interactions_orgs.go @@ -12,7 +12,7 @@ import ( // GetRestrictionsForOrg fetches the interaction restrictions for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#get-interaction-restrictions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#get-interaction-restrictions-for-an-organization func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organization string) (*InteractionRestriction, *Response, error) { u := fmt.Sprintf("orgs/%v/interaction-limits", organization) req, err := s.client.NewRequest("GET", u, nil) @@ -39,7 +39,7 @@ func (s *InteractionsService) GetRestrictionsForOrg(ctx context.Context, organiz // in public repositories for the given organization. // Possible values are: "existing_users", "contributors_only", "collaborators_only". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#set-interaction-restrictions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#set-interaction-restrictions-for-an-organization func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, organization, limit string) (*InteractionRestriction, *Response, error) { u := fmt.Sprintf("orgs/%v/interaction-limits", organization) @@ -65,7 +65,7 @@ func (s *InteractionsService) UpdateRestrictionsForOrg(ctx context.Context, orga // RemoveRestrictionsFromOrg removes the interaction restrictions for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#remove-interaction-restrictions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/interactions/orgs#remove-interaction-restrictions-for-an-organization func (s *InteractionsService) RemoveRestrictionsFromOrg(ctx context.Context, organization string) (*Response, error) { u := fmt.Sprintf("orgs/%v/interaction-limits", organization) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/interactions_repos.go b/vendor/github.com/google/go-github/v47/github/interactions_repos.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/interactions_repos.go rename to vendor/github.com/google/go-github/v47/github/interactions_repos.go index 13fffd64..41e6c531 100644 --- a/vendor/github.com/google/go-github/v43/github/interactions_repos.go +++ b/vendor/github.com/google/go-github/v47/github/interactions_repos.go @@ -12,7 +12,7 @@ import ( // GetRestrictionsForRepo fetches the interaction restrictions for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#get-interaction-restrictions-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#get-interaction-restrictions-for-a-repository func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner, repo string) (*InteractionRestriction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -39,7 +39,7 @@ func (s *InteractionsService) GetRestrictionsForRepo(ctx context.Context, owner, // for the given repository. // Possible values are: "existing_users", "contributors_only", "collaborators_only". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#set-interaction-restrictions-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#set-interaction-restrictions-for-a-repository func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, owner, repo, limit string) (*InteractionRestriction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo) @@ -65,7 +65,7 @@ func (s *InteractionsService) UpdateRestrictionsForRepo(ctx context.Context, own // RemoveRestrictionsFromRepo removes the interaction restrictions for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/interactions/#remove-interaction-restrictions-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/interactions/repos#remove-interaction-restrictions-for-a-repository func (s *InteractionsService) RemoveRestrictionsFromRepo(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/interaction-limits", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/issue_import.go b/vendor/github.com/google/go-github/v47/github/issue_import.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/issue_import.go rename to vendor/github.com/google/go-github/v47/github/issue_import.go diff --git a/vendor/github.com/google/go-github/v43/github/issues.go b/vendor/github.com/google/go-github/v47/github/issues.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/issues.go rename to vendor/github.com/google/go-github/v47/github/issues.go index f35f2b56..351ec09c 100644 --- a/vendor/github.com/google/go-github/v43/github/issues.go +++ b/vendor/github.com/google/go-github/v47/github/issues.go @@ -14,7 +14,7 @@ import ( // IssuesService handles communication with the issue related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/ +// GitHub API docs: https://docs.github.com/en/rest/issues/ type IssuesService service // Issue represents a GitHub issue on a repository. @@ -54,7 +54,7 @@ type Issue struct { NodeID *string `json:"node_id,omitempty"` // TextMatches is only populated from search results that request text matches - // See: search.go and https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#text-match-metadata + // See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata TextMatches []*TextMatch `json:"text_matches,omitempty"` // ActiveLockReason is populated only when LockReason is provided while locking the issue. @@ -77,13 +77,15 @@ func (i Issue) IsPullRequest() bool { // It is separate from Issue above because otherwise Labels // and Assignee fail to serialize to the correct JSON. type IssueRequest struct { - Title *string `json:"title,omitempty"` - Body *string `json:"body,omitempty"` - Labels *[]string `json:"labels,omitempty"` - Assignee *string `json:"assignee,omitempty"` - State *string `json:"state,omitempty"` - Milestone *int `json:"milestone,omitempty"` - Assignees *[]string `json:"assignees,omitempty"` + Title *string `json:"title,omitempty"` + Body *string `json:"body,omitempty"` + Labels *[]string `json:"labels,omitempty"` + Assignee *string `json:"assignee,omitempty"` + State *string `json:"state,omitempty"` + // StateReason can be 'completed' or 'not_planned'. + StateReason *string `json:"state_reason,omitempty"` + Milestone *int `json:"milestone,omitempty"` + Assignees *[]string `json:"assignees,omitempty"` } // IssueListOptions specifies the optional parameters to the IssuesService.List @@ -128,8 +130,8 @@ type PullRequestLinks struct { // organization repositories; if false, list only owned and member // repositories. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-user-account-issues-assigned-to-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issues-assigned-to-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-user-account-issues-assigned-to-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-issues-assigned-to-the-authenticated-user func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error) { var u string if all { @@ -143,7 +145,7 @@ func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptio // ListByOrg fetches the issues in the specified organization for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-organization-issues-assigned-to-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-organization-issues-assigned-to-the-authenticated-user func (s *IssuesService) ListByOrg(ctx context.Context, org string, opts *IssueListOptions) ([]*Issue, *Response, error) { u := fmt.Sprintf("orgs/%v/issues", org) return s.listIssues(ctx, u, opts) @@ -214,7 +216,7 @@ type IssueListByRepoOptions struct { // ListByRepo lists the issues for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-repository-issues +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#list-repository-issues func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues", owner, repo) u, err := addOptions(u, opts) @@ -241,7 +243,7 @@ func (s *IssuesService) ListByRepo(ctx context.Context, owner string, repo strin // Get a single issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#get-an-issue func (s *IssuesService) Get(ctx context.Context, owner string, repo string, number int) (*Issue, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -263,7 +265,7 @@ func (s *IssuesService) Get(ctx context.Context, owner string, repo string, numb // Create a new issue on the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#create-an-issue func (s *IssuesService) Create(ctx context.Context, owner string, repo string, issue *IssueRequest) (*Issue, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues", owner, repo) req, err := s.client.NewRequest("POST", u, issue) @@ -280,9 +282,9 @@ func (s *IssuesService) Create(ctx context.Context, owner string, repo string, i return i, resp, nil } -// Edit an issue. +// Edit (update) an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#update-an-issue func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, number int, issue *IssueRequest) (*Issue, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d", owner, repo, number) req, err := s.client.NewRequest("PATCH", u, issue) @@ -303,7 +305,7 @@ func (s *IssuesService) Edit(ctx context.Context, owner string, repo string, num // // This is a helper method to explicitly update an issue with a `null` milestone, thereby removing it. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#update-an-issue func (s *IssuesService) RemoveMilestone(ctx context.Context, owner, repo string, issueNumber int) (*Issue, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%v", owner, repo, issueNumber) req, err := s.client.NewRequest("PATCH", u, &struct { @@ -333,7 +335,7 @@ type LockIssueOptions struct { // Lock an issue's conversation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#lock-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#lock-an-issue func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, number int, opts *LockIssueOptions) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number) req, err := s.client.NewRequest("PUT", u, opts) @@ -346,7 +348,7 @@ func (s *IssuesService) Lock(ctx context.Context, owner string, repo string, num // Unlock an issue's conversation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#unlock-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/issues#unlock-an-issue func (s *IssuesService) Unlock(ctx context.Context, owner string, repo string, number int) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/lock", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/issues_assignees.go b/vendor/github.com/google/go-github/v47/github/issues_assignees.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/issues_assignees.go rename to vendor/github.com/google/go-github/v47/github/issues_assignees.go index 9f15aea4..b7f2e802 100644 --- a/vendor/github.com/google/go-github/v43/github/issues_assignees.go +++ b/vendor/github.com/google/go-github/v47/github/issues_assignees.go @@ -13,7 +13,7 @@ import ( // ListAssignees fetches all available assignees (owners and collaborators) to // which issues may be assigned. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-assignees +// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#list-assignees func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, opts *ListOptions) ([]*User, *Response, error) { u := fmt.Sprintf("repos/%v/%v/assignees", owner, repo) u, err := addOptions(u, opts) @@ -25,6 +25,7 @@ func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, o if err != nil { return nil, nil, err } + var assignees []*User resp, err := s.client.Do(ctx, req, &assignees) if err != nil { @@ -36,13 +37,14 @@ func (s *IssuesService) ListAssignees(ctx context.Context, owner, repo string, o // IsAssignee checks if a user is an assignee for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#check-if-a-user-can-be-assigned +// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#check-if-a-user-can-be-assigned func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string) (bool, *Response, error) { u := fmt.Sprintf("repos/%v/%v/assignees/%v", owner, repo, user) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return false, nil, err } + resp, err := s.client.Do(ctx, req, nil) assignee, err := parseBoolResponse(err) return assignee, resp, err @@ -50,7 +52,7 @@ func (s *IssuesService) IsAssignee(ctx context.Context, owner, repo, user string // AddAssignees adds the provided GitHub users as assignees to the issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#add-assignees-to-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#add-assignees-to-an-issue func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { users := &struct { Assignees []string `json:"assignees,omitempty"` @@ -63,12 +65,16 @@ func (s *IssuesService) AddAssignees(ctx context.Context, owner, repo string, nu issue := &Issue{} resp, err := s.client.Do(ctx, req, issue) - return issue, resp, err + if err != nil { + return nil, resp, err + } + + return issue, resp, nil } // RemoveAssignees removes the provided GitHub users as assignees from the issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#remove-assignees-from-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/assignees#remove-assignees-from-an-issue func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*Issue, *Response, error) { users := &struct { Assignees []string `json:"assignees,omitempty"` @@ -81,5 +87,9 @@ func (s *IssuesService) RemoveAssignees(ctx context.Context, owner, repo string, issue := &Issue{} resp, err := s.client.Do(ctx, req, issue) - return issue, resp, err + if err != nil { + return nil, resp, err + } + + return issue, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/issues_comments.go b/vendor/github.com/google/go-github/v47/github/issues_comments.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/issues_comments.go rename to vendor/github.com/google/go-github/v47/github/issues_comments.go index 6dd6d132..361ee49a 100644 --- a/vendor/github.com/google/go-github/v43/github/issues_comments.go +++ b/vendor/github.com/google/go-github/v47/github/issues_comments.go @@ -50,8 +50,8 @@ type IssueListCommentsOptions struct { // ListComments lists all comments on the specified issue. Specifying an issue // number of 0 will return all comments on all issues for the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-comments -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-comments-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments +// GitHub API docs: https://docs.github.com/en/rest/issues/comments#list-issue-comments-for-a-repository func (s *IssuesService) ListComments(ctx context.Context, owner string, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error) { var u string if number == 0 { @@ -83,7 +83,7 @@ func (s *IssuesService) ListComments(ctx context.Context, owner string, repo str // GetComment fetches the specified issue comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue-comment +// GitHub API docs: https://docs.github.com/en/rest/issues/comments#get-an-issue-comment func (s *IssuesService) GetComment(ctx context.Context, owner string, repo string, commentID int64) (*IssueComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID) @@ -106,7 +106,7 @@ func (s *IssuesService) GetComment(ctx context.Context, owner string, repo strin // CreateComment creates a new comment on the specified issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-an-issue-comment +// GitHub API docs: https://docs.github.com/en/rest/issues/comments#create-an-issue-comment func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/comments", owner, repo, number) req, err := s.client.NewRequest("POST", u, comment) @@ -125,7 +125,7 @@ func (s *IssuesService) CreateComment(ctx context.Context, owner string, repo st // EditComment updates an issue comment. // A non-nil comment.Body must be provided. Other comment fields should be left nil. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-an-issue-comment +// GitHub API docs: https://docs.github.com/en/rest/issues/comments#update-an-issue-comment func (s *IssuesService) EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *IssueComment) (*IssueComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID) req, err := s.client.NewRequest("PATCH", u, comment) @@ -143,7 +143,7 @@ func (s *IssuesService) EditComment(ctx context.Context, owner string, repo stri // DeleteComment deletes an issue comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-an-issue-comment +// GitHub API docs: https://docs.github.com/en/rest/issues/comments#delete-an-issue-comment func (s *IssuesService) DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/comments/%d", owner, repo, commentID) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/issues_events.go b/vendor/github.com/google/go-github/v47/github/issues_events.go similarity index 94% rename from vendor/github.com/google/go-github/v43/github/issues_events.go rename to vendor/github.com/google/go-github/v47/github/issues_events.go index 384779cf..d8ffc0b5 100644 --- a/vendor/github.com/google/go-github/v43/github/issues_events.go +++ b/vendor/github.com/google/go-github/v47/github/issues_events.go @@ -100,7 +100,7 @@ type DismissedReview struct { // ListIssueEvents lists events for the specified issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events +// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*IssueEvent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%v/events", owner, repo, number) u, err := addOptions(u, opts) @@ -126,7 +126,7 @@ func (s *IssuesService) ListIssueEvents(ctx context.Context, owner, repo string, // ListRepositoryEvents lists events for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-issue-events-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/issues/events#list-issue-events-for-a-repository func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo string, opts *ListOptions) ([]*IssueEvent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/events", owner, repo) u, err := addOptions(u, opts) @@ -150,7 +150,7 @@ func (s *IssuesService) ListRepositoryEvents(ctx context.Context, owner, repo st // GetEvent returns the specified issue event. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-an-issue-event +// GitHub API docs: https://docs.github.com/en/rest/issues/events#get-an-issue-event func (s *IssuesService) GetEvent(ctx context.Context, owner, repo string, id int64) (*IssueEvent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/events/%v", owner, repo, id) diff --git a/vendor/github.com/google/go-github/v43/github/issues_labels.go b/vendor/github.com/google/go-github/v47/github/issues_labels.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/issues_labels.go rename to vendor/github.com/google/go-github/v47/github/issues_labels.go index 40f069a9..d0f865c0 100644 --- a/vendor/github.com/google/go-github/v43/github/issues_labels.go +++ b/vendor/github.com/google/go-github/v47/github/issues_labels.go @@ -27,7 +27,7 @@ func (l Label) String() string { // ListLabels lists all labels for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-labels-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-a-repository func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/labels", owner, repo) u, err := addOptions(u, opts) @@ -51,7 +51,7 @@ func (s *IssuesService) ListLabels(ctx context.Context, owner string, repo strin // GetLabel gets a single label. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-a-label +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#get-a-label func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string, name string) (*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name) req, err := s.client.NewRequest("GET", u, nil) @@ -70,7 +70,7 @@ func (s *IssuesService) GetLabel(ctx context.Context, owner string, repo string, // CreateLabel creates a new label on the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-a-label +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#create-a-label func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo string, label *Label) (*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/labels", owner, repo) req, err := s.client.NewRequest("POST", u, label) @@ -89,7 +89,7 @@ func (s *IssuesService) CreateLabel(ctx context.Context, owner string, repo stri // EditLabel edits a label. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-a-label +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#update-a-label func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string, name string, label *Label) (*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name) req, err := s.client.NewRequest("PATCH", u, label) @@ -108,7 +108,7 @@ func (s *IssuesService) EditLabel(ctx context.Context, owner string, repo string // DeleteLabel deletes a label. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-a-label +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#delete-a-label func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo string, name string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/labels/%v", owner, repo, name) req, err := s.client.NewRequest("DELETE", u, nil) @@ -120,7 +120,7 @@ func (s *IssuesService) DeleteLabel(ctx context.Context, owner string, repo stri // ListLabelsByIssue lists all labels for an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-labels-for-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-an-issue func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) u, err := addOptions(u, opts) @@ -144,7 +144,7 @@ func (s *IssuesService) ListLabelsByIssue(ctx context.Context, owner string, rep // AddLabelsToIssue adds labels to an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#add-labels-to-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#add-labels-to-an-issue func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) req, err := s.client.NewRequest("POST", u, labels) @@ -163,7 +163,7 @@ func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner string, repo // RemoveLabelForIssue removes a label for an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#remove-a-label-from-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#remove-a-label-from-an-issue func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels/%v", owner, repo, number, label) req, err := s.client.NewRequest("DELETE", u, nil) @@ -176,7 +176,7 @@ func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner string, r // ReplaceLabelsForIssue replaces all labels for an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#set-labels-for-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#set-labels-for-an-issue func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) req, err := s.client.NewRequest("PUT", u, labels) @@ -195,7 +195,7 @@ func (s *IssuesService) ReplaceLabelsForIssue(ctx context.Context, owner string, // RemoveLabelsForIssue removes all labels for an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#remove-all-labels-from-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#remove-all-labels-from-an-issue func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string, repo string, number int) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, nil) @@ -208,7 +208,7 @@ func (s *IssuesService) RemoveLabelsForIssue(ctx context.Context, owner string, // ListLabelsForMilestone lists labels for every issue in a milestone. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-labels-for-issues-in-a-milestone +// GitHub API docs: https://docs.github.com/en/rest/issues/labels#list-labels-for-issues-in-a-milestone func (s *IssuesService) ListLabelsForMilestone(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*Label, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones/%d/labels", owner, repo, number) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/issues_milestones.go b/vendor/github.com/google/go-github/v47/github/issues_milestones.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/issues_milestones.go rename to vendor/github.com/google/go-github/v47/github/issues_milestones.go index f9b1f193..3c9be240 100644 --- a/vendor/github.com/google/go-github/v43/github/issues_milestones.go +++ b/vendor/github.com/google/go-github/v47/github/issues_milestones.go @@ -55,7 +55,7 @@ type MilestoneListOptions struct { // ListMilestones lists all milestones for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-milestones +// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#list-milestones func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo string, opts *MilestoneListOptions) ([]*Milestone, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo) u, err := addOptions(u, opts) @@ -79,7 +79,7 @@ func (s *IssuesService) ListMilestones(ctx context.Context, owner string, repo s // GetMilestone gets a single milestone. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#get-a-milestone +// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#get-a-milestone func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo string, number int) (*Milestone, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -98,7 +98,7 @@ func (s *IssuesService) GetMilestone(ctx context.Context, owner string, repo str // CreateMilestone creates a new milestone on the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#create-a-milestone +// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#create-a-milestone func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo string, milestone *Milestone) (*Milestone, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones", owner, repo) req, err := s.client.NewRequest("POST", u, milestone) @@ -117,7 +117,7 @@ func (s *IssuesService) CreateMilestone(ctx context.Context, owner string, repo // EditMilestone edits a milestone. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#update-a-milestone +// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#update-a-milestone func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo string, number int, milestone *Milestone) (*Milestone, *Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) req, err := s.client.NewRequest("PATCH", u, milestone) @@ -136,7 +136,7 @@ func (s *IssuesService) EditMilestone(ctx context.Context, owner string, repo st // DeleteMilestone deletes a milestone. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#delete-a-milestone +// GitHub API docs: https://docs.github.com/en/rest/issues/milestones#delete-a-milestone func (s *IssuesService) DeleteMilestone(ctx context.Context, owner string, repo string, number int) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/milestones/%d", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/issues_timeline.go b/vendor/github.com/google/go-github/v47/github/issues_timeline.go similarity index 97% rename from vendor/github.com/google/go-github/v43/github/issues_timeline.go rename to vendor/github.com/google/go-github/v47/github/issues_timeline.go index 845e3f76..9ec498e4 100644 --- a/vendor/github.com/google/go-github/v43/github/issues_timeline.go +++ b/vendor/github.com/google/go-github/v47/github/issues_timeline.go @@ -161,7 +161,7 @@ type Source struct { // ListIssueTimeline lists events for the specified issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/#list-timeline-events-for-an-issue +// GitHub API docs: https://docs.github.com/en/rest/issues/timeline#list-timeline-events-for-an-issue func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Timeline, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%v/timeline", owner, repo, number) u, err := addOptions(u, opts) @@ -180,5 +180,9 @@ func (s *IssuesService) ListIssueTimeline(ctx context.Context, owner, repo strin var events []*Timeline resp, err := s.client.Do(ctx, req, &events) - return events, resp, err + if err != nil { + return nil, resp, err + } + + return events, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/licenses.go b/vendor/github.com/google/go-github/v47/github/licenses.go similarity index 89% rename from vendor/github.com/google/go-github/v43/github/licenses.go rename to vendor/github.com/google/go-github/v47/github/licenses.go index 85e36266..0877b6d1 100644 --- a/vendor/github.com/google/go-github/v43/github/licenses.go +++ b/vendor/github.com/google/go-github/v47/github/licenses.go @@ -13,7 +13,7 @@ import ( // LicensesService handles communication with the license related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/ +// GitHub API docs: https://docs.github.com/en/rest/licenses/ type LicensesService service // RepositoryLicense represents the license for a repository. @@ -60,7 +60,7 @@ func (l License) String() string { // List popular open source licenses. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#list-all-licenses +// GitHub API docs: https://docs.github.com/en/rest/licenses/#list-all-licenses func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, error) { req, err := s.client.NewRequest("GET", "licenses", nil) if err != nil { @@ -78,7 +78,7 @@ func (s *LicensesService) List(ctx context.Context) ([]*License, *Response, erro // Get extended metadata for one license. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-a-license +// GitHub API docs: https://docs.github.com/en/rest/licenses#get-a-license func (s *LicensesService) Get(ctx context.Context, licenseName string) (*License, *Response, error) { u := fmt.Sprintf("licenses/%s", licenseName) diff --git a/vendor/github.com/google/go-github/v43/github/messages.go b/vendor/github.com/google/go-github/v47/github/messages.go similarity index 89% rename from vendor/github.com/google/go-github/v43/github/messages.go rename to vendor/github.com/google/go-github/v47/github/messages.go index c1e8161b..320bd734 100644 --- a/vendor/github.com/google/go-github/v43/github/messages.go +++ b/vendor/github.com/google/go-github/v47/github/messages.go @@ -48,6 +48,7 @@ var ( "branch_protection_rule": "BranchProtectionRuleEvent", "check_run": "CheckRunEvent", "check_suite": "CheckSuiteEvent", + "code_scanning_alert": "CodeScanningAlertEvent", "commit_comment": "CommitCommentEvent", "content_reference": "ContentReferenceEvent", "create": "CreateEvent", @@ -81,10 +82,12 @@ var ( "pull_request": "PullRequestEvent", "pull_request_review": "PullRequestReviewEvent", "pull_request_review_comment": "PullRequestReviewCommentEvent", + "pull_request_review_thread": "PullRequestReviewThreadEvent", "pull_request_target": "PullRequestTargetEvent", "push": "PushEvent", "repository": "RepositoryEvent", "repository_dispatch": "RepositoryDispatchEvent", + "repository_import": "RepositoryImportEvent", "repository_vulnerability_alert": "RepositoryVulnerabilityAlertEvent", "release": "ReleaseEvent", "secret_scanning_alert": "SecretScanningAlertEvent", @@ -154,13 +157,13 @@ func messageMAC(signature string) ([]byte, func() hash.Hash, error) { // // Example usage: // -// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { -// // read signature from request -// signature := "" -// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey) -// if err != nil { ... } -// // Process payload... -// } +// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { +// // read signature from request +// signature := "" +// payload, err := github.ValidatePayloadFromBody(r.Header.Get("Content-Type"), r.Body, signature, s.webhookSecretKey) +// if err != nil { ... } +// // Process payload... +// } func ValidatePayloadFromBody(contentType string, readable io.Reader, signature string, secretToken []byte) (payload []byte, err error) { var body []byte // Raw body that GitHub uses to calculate the signature. @@ -218,12 +221,11 @@ func ValidatePayloadFromBody(contentType string, readable io.Reader, signature s // // Example usage: // -// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { -// payload, err := github.ValidatePayload(r, s.webhookSecretKey) -// if err != nil { ... } -// // Process payload... -// } -// +// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { +// payload, err := github.ValidatePayload(r, s.webhookSecretKey) +// if err != nil { ... } +// // Process payload... +// } func ValidatePayload(r *http.Request, secretToken []byte) (payload []byte, err error) { signature := r.Header.Get(SHA256SignatureHeader) if signature == "" { @@ -276,20 +278,19 @@ func DeliveryID(r *http.Request) string { // // Example usage: // -// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { -// payload, err := github.ValidatePayload(r, s.webhookSecretKey) -// if err != nil { ... } -// event, err := github.ParseWebHook(github.WebHookType(r), payload) -// if err != nil { ... } -// switch event := event.(type) { -// case *github.CommitCommentEvent: -// processCommitCommentEvent(event) -// case *github.CreateEvent: -// processCreateEvent(event) -// ... -// } -// } -// +// func (s *GitHubEventMonitor) ServeHTTP(w http.ResponseWriter, r *http.Request) { +// payload, err := github.ValidatePayload(r, s.webhookSecretKey) +// if err != nil { ... } +// event, err := github.ParseWebHook(github.WebHookType(r), payload) +// if err != nil { ... } +// switch event := event.(type) { +// case *github.CommitCommentEvent: +// processCommitCommentEvent(event) +// case *github.CreateEvent: +// processCreateEvent(event) +// ... +// } +// } func ParseWebHook(messageType string, payload []byte) (interface{}, error) { eventType, ok := eventTypeMapping[messageType] if !ok { diff --git a/vendor/github.com/google/go-github/v43/github/migrations.go b/vendor/github.com/google/go-github/v47/github/migrations.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/migrations.go rename to vendor/github.com/google/go-github/v47/github/migrations.go index 7694021f..67989c07 100644 --- a/vendor/github.com/google/go-github/v43/github/migrations.go +++ b/vendor/github.com/google/go-github/v47/github/migrations.go @@ -16,7 +16,7 @@ import ( // MigrationService provides access to the migration related functions // in the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migration/ +// GitHub API docs: https://docs.github.com/en/rest/migration/ type MigrationService service // Migration represents a GitHub migration (archival). @@ -74,7 +74,7 @@ type startMigration struct { // StartMigration starts the generation of a migration archive. // repos is a slice of repository names to migrate. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#start-an-organization-migration +// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#start-an-organization-migration func (s *MigrationService) StartMigration(ctx context.Context, org string, repos []string, opts *MigrationOptions) (*Migration, *Response, error) { u := fmt.Sprintf("orgs/%v/migrations", org) @@ -103,7 +103,7 @@ func (s *MigrationService) StartMigration(ctx context.Context, org string, repos // ListMigrations lists the most recent migrations. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#list-organization-migrations +// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#list-organization-migrations func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts *ListOptions) ([]*Migration, *Response, error) { u := fmt.Sprintf("orgs/%v/migrations", org) u, err := addOptions(u, opts) @@ -131,7 +131,7 @@ func (s *MigrationService) ListMigrations(ctx context.Context, org string, opts // MigrationStatus gets the status of a specific migration archive. // id is the migration ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-an-organization-migration-status +// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#get-an-organization-migration-status func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id int64) (*Migration, *Response, error) { u := fmt.Sprintf("orgs/%v/migrations/%v", org, id) @@ -155,7 +155,7 @@ func (s *MigrationService) MigrationStatus(ctx context.Context, org string, id i // MigrationArchiveURL fetches a migration archive URL. // id is the migration ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#download-an-organization-migration-archive +// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#download-an-organization-migration-archive func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, id int64) (url string, err error) { u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id) @@ -192,7 +192,7 @@ func (s *MigrationService) MigrationArchiveURL(ctx context.Context, org string, // DeleteMigration deletes a previous migration archive. // id is the migration ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#delete-an-organization-migration-archive +// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#delete-an-organization-migration-archive func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/migrations/%v/archive", org, id) @@ -212,7 +212,7 @@ func (s *MigrationService) DeleteMigration(ctx context.Context, org string, id i // You should unlock each migrated repository and delete them when the migration // is complete and you no longer need the source data. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#unlock-an-organization-repository +// GitHub API docs: https://docs.github.com/en/rest/migrations/orgs#unlock-an-organization-repository func (s *MigrationService) UnlockRepo(ctx context.Context, org string, id int64, repo string) (*Response, error) { u := fmt.Sprintf("orgs/%v/migrations/%v/repos/%v/lock", org, id, repo) diff --git a/vendor/github.com/google/go-github/v43/github/migrations_source_import.go b/vendor/github.com/google/go-github/v47/github/migrations_source_import.go similarity index 90% rename from vendor/github.com/google/go-github/v43/github/migrations_source_import.go rename to vendor/github.com/google/go-github/v47/github/migrations_source_import.go index e34b3acd..74a04b22 100644 --- a/vendor/github.com/google/go-github/v43/github/migrations_source_import.go +++ b/vendor/github.com/google/go-github/v47/github/migrations_source_import.go @@ -115,7 +115,7 @@ func (i Import) String() string { // SourceImportAuthor identifies an author imported from a source repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migration/source_imports/#get-commit-authors +// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-commit-authors type SourceImportAuthor struct { ID *int64 `json:"id,omitempty"` RemoteID *string `json:"remote_id,omitempty"` @@ -132,7 +132,7 @@ func (a SourceImportAuthor) String() string { // LargeFile identifies a file larger than 100MB found during a repository import. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migration/source_imports/#get-large-files +// GitHub API docs: https://docs.github.com/en/rest/migration/source_imports/#get-large-files type LargeFile struct { RefName *string `json:"ref_name,omitempty"` Path *string `json:"path,omitempty"` @@ -146,7 +146,7 @@ func (f LargeFile) String() string { // StartImport initiates a repository import. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#start-an-import +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#start-an-import func (s *MigrationService) StartImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import", owner, repo) req, err := s.client.NewRequest("PUT", u, in) @@ -165,7 +165,7 @@ func (s *MigrationService) StartImport(ctx context.Context, owner, repo string, // ImportProgress queries for the status and progress of an ongoing repository import. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-an-import-status +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-an-import-status func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo string) (*Import, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -184,7 +184,7 @@ func (s *MigrationService) ImportProgress(ctx context.Context, owner, repo strin // UpdateImport initiates a repository import. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#update-an-import +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-an-import func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import", owner, repo) req, err := s.client.NewRequest("PATCH", u, in) @@ -213,7 +213,7 @@ func (s *MigrationService) UpdateImport(ctx context.Context, owner, repo string, // This method and MapCommitAuthor allow you to provide correct Git author // information. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-commit-authors +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-commit-authors func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string) ([]*SourceImportAuthor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/authors", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -234,7 +234,7 @@ func (s *MigrationService) CommitAuthors(ctx context.Context, owner, repo string // application can continue updating authors any time before you push new // commits to the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#map-a-commit-author +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#map-a-commit-author func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo string, id int64, author *SourceImportAuthor) (*SourceImportAuthor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/authors/%v", owner, repo, id) req, err := s.client.NewRequest("PATCH", u, author) @@ -255,7 +255,7 @@ func (s *MigrationService) MapCommitAuthor(ctx context.Context, owner, repo stri // files larger than 100MB. Only the UseLFS field on the provided Import is // used. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#update-git-lfs-preference +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#update-git-lfs-preference func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo string, in *Import) (*Import, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/lfs", owner, repo) req, err := s.client.NewRequest("PATCH", u, in) @@ -274,7 +274,7 @@ func (s *MigrationService) SetLFSPreference(ctx context.Context, owner, repo str // LargeFiles lists files larger than 100MB found during the import. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-large-files +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#get-large-files func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) ([]*LargeFile, *Response, error) { u := fmt.Sprintf("repos/%v/%v/import/large_files", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -293,7 +293,7 @@ func (s *MigrationService) LargeFiles(ctx context.Context, owner, repo string) ( // CancelImport stops an import for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#cancel-an-import +// GitHub API docs: https://docs.github.com/en/rest/migrations/source-imports#cancel-an-import func (s *MigrationService) CancelImport(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/import", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/migrations_user.go b/vendor/github.com/google/go-github/v47/github/migrations_user.go similarity index 89% rename from vendor/github.com/google/go-github/v43/github/migrations_user.go rename to vendor/github.com/google/go-github/v47/github/migrations_user.go index 5e8aaec5..6586fdb2 100644 --- a/vendor/github.com/google/go-github/v43/github/migrations_user.go +++ b/vendor/github.com/google/go-github/v47/github/migrations_user.go @@ -67,7 +67,7 @@ type startUserMigration struct { // StartUserMigration starts the generation of a migration archive. // repos is a slice of repository names to migrate. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#start-a-user-migration +// GitHub API docs: https://docs.github.com/en/rest/migrations/users#start-a-user-migration func (s *MigrationService) StartUserMigration(ctx context.Context, repos []string, opts *UserMigrationOptions) (*UserMigration, *Response, error) { u := "user/migrations" @@ -96,9 +96,13 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin // ListUserMigrations lists the most recent migrations. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#list-user-migrations -func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigration, *Response, error) { +// GitHub API docs: https://docs.github.com/en/rest/migrations/users#list-user-migrations +func (s *MigrationService) ListUserMigrations(ctx context.Context, opts *ListOptions) ([]*UserMigration, *Response, error) { u := "user/migrations" + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -120,7 +124,7 @@ func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigra // UserMigrationStatus gets the status of a specific migration archive. // id is the migration ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#get-a-user-migration-status +// GitHub API docs: https://docs.github.com/en/rest/migrations/users#get-a-user-migration-status func (s *MigrationService) UserMigrationStatus(ctx context.Context, id int64) (*UserMigration, *Response, error) { u := fmt.Sprintf("user/migrations/%v", id) @@ -144,7 +148,7 @@ func (s *MigrationService) UserMigrationStatus(ctx context.Context, id int64) (* // UserMigrationArchiveURL gets the URL for a specific migration archive. // id is the migration ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#download-a-user-migration-archive +// GitHub API docs: https://docs.github.com/en/rest/migrations/users#download-a-user-migration-archive func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64) (string, error) { url := fmt.Sprintf("user/migrations/%v/archive", id) @@ -178,7 +182,7 @@ func (s *MigrationService) UserMigrationArchiveURL(ctx context.Context, id int64 // DeleteUserMigration will delete a previous migration archive. // id is the migration ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#delete-a-user-migration-archive +// GitHub API docs: https://docs.github.com/en/rest/migrations/users#delete-a-user-migration-archive func (s *MigrationService) DeleteUserMigration(ctx context.Context, id int64) (*Response, error) { url := fmt.Sprintf("user/migrations/%v/archive", id) @@ -198,7 +202,7 @@ func (s *MigrationService) DeleteUserMigration(ctx context.Context, id int64) (* // You should unlock each migrated repository and delete them when the migration // is complete and you no longer need the source data. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/migrations/#unlock-a-user-repository +// GitHub API docs: https://docs.github.com/en/rest/migrations/users#unlock-a-user-repository func (s *MigrationService) UnlockUserRepo(ctx context.Context, id int64, repo string) (*Response, error) { url := fmt.Sprintf("user/migrations/%v/repos/%v/lock", id, repo) diff --git a/vendor/github.com/google/go-github/v43/github/misc.go b/vendor/github.com/google/go-github/v47/github/misc.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/misc.go rename to vendor/github.com/google/go-github/v47/github/misc.go index 7672e08a..89615241 100644 --- a/vendor/github.com/google/go-github/v43/github/misc.go +++ b/vendor/github.com/google/go-github/v47/github/misc.go @@ -39,7 +39,7 @@ type markdownRequest struct { // Markdown renders an arbitrary Markdown document. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/markdown/ +// GitHub API docs: https://docs.github.com/en/rest/markdown/ func (c *Client) Markdown(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) { request := &markdownRequest{Text: String(text)} if opts != nil { @@ -67,7 +67,7 @@ func (c *Client) Markdown(ctx context.Context, text string, opts *MarkdownOption // ListEmojis returns the emojis available to use on GitHub. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/emojis/ +// GitHub API docs: https://docs.github.com/en/rest/emojis/ func (c *Client) ListEmojis(ctx context.Context) (map[string]string, *Response, error) { req, err := c.NewRequest("GET", "emojis", nil) if err != nil { @@ -97,7 +97,7 @@ func (c *CodeOfConduct) String() string { // ListCodesOfConduct returns all codes of conduct. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/codes_of_conduct/#list-all-codes-of-conduct +// GitHub API docs: https://docs.github.com/en/rest/codes_of_conduct/#list-all-codes-of-conduct func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Response, error) { req, err := c.NewRequest("GET", "codes_of_conduct", nil) if err != nil { @@ -118,7 +118,7 @@ func (c *Client) ListCodesOfConduct(ctx context.Context) ([]*CodeOfConduct, *Res // GetCodeOfConduct returns an individual code of conduct. // -// https://docs.github.com/en/free-pro-team@latest/rest/reference/codes_of_conduct/#get-an-individual-code-of-conduct +// https://docs.github.com/en/rest/codes_of_conduct/#get-an-individual-code-of-conduct func (c *Client) GetCodeOfConduct(ctx context.Context, key string) (*CodeOfConduct, *Response, error) { u := fmt.Sprintf("codes_of_conduct/%s", key) req, err := c.NewRequest("GET", u, nil) @@ -176,13 +176,21 @@ type APIMeta struct { // An array of SSH keys. SSHKeys []string `json:"ssh_keys,omitempty"` + + // An array of IP addresses in CIDR format specifying the addresses + // which serve GitHub websites. + Web []string `json:"web,omitempty"` + + // An array of IP addresses in CIDR format specifying the addresses + // which serve GitHub APIs. + API []string `json:"api,omitempty"` } // APIMeta returns information about GitHub.com, the service. Or, if you access // this endpoint on your organization’s GitHub Enterprise installation, this // endpoint provides information about that installation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/meta#get-github-meta-information +// GitHub API docs: https://docs.github.com/en/rest/meta#get-github-meta-information func (c *Client) APIMeta(ctx context.Context) (*APIMeta, *Response, error) { req, err := c.NewRequest("GET", "meta", nil) if err != nil { diff --git a/vendor/github.com/google/go-github/v43/github/orgs.go b/vendor/github.com/google/go-github/v47/github/orgs.go similarity index 81% rename from vendor/github.com/google/go-github/v43/github/orgs.go rename to vendor/github.com/google/go-github/v47/github/orgs.go index 62f6ed24..8105afad 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs.go +++ b/vendor/github.com/google/go-github/v47/github/orgs.go @@ -14,7 +14,7 @@ import ( // OrganizationsService provides access to the organization related functions // in the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/ +// GitHub API docs: https://docs.github.com/en/rest/orgs/ type OrganizationsService service // Organization represents a GitHub organization account. @@ -65,6 +65,9 @@ type Organization struct { MembersCanCreatePrivateRepos *bool `json:"members_can_create_private_repositories,omitempty"` MembersCanCreateInternalRepos *bool `json:"members_can_create_internal_repositories,omitempty"` + // MembersCanForkPrivateRepos toggles whether organization members can fork private organization repositories. + MembersCanForkPrivateRepos *bool `json:"members_can_fork_private_repositories,omitempty"` + // MembersAllowedRepositoryCreationType denotes if organization members can create repositories // and the type of repositories they can create. Possible values are: "all", "private", or "none". // @@ -79,6 +82,20 @@ type Organization struct { MembersCanCreatePublicPages *bool `json:"members_can_create_public_pages,omitempty"` // MembersCanCreatePrivatePages toggles whether organization members can create private GitHub Pages sites. MembersCanCreatePrivatePages *bool `json:"members_can_create_private_pages,omitempty"` + // WebCommitSignoffRequire toggles + WebCommitSignoffRequired *bool `json:"web_commit_signoff_required,omitempty"` + // AdvancedSecurityAuditLogEnabled toggles whether the advanced security audit log is enabled. + AdvancedSecurityEnabledForNewRepos *bool `json:"advanced_security_enabled_for_new_repositories,omitempty"` + // DependabotAlertsEnabled toggles whether dependabot alerts are enabled. + DependabotAlertsEnabledForNewRepos *bool `json:"dependabot_alerts_enabled_for_new_repositories,omitempty"` + // DependabotSecurityUpdatesEnabled toggles whether dependabot security updates are enabled. + DependabotSecurityUpdatesEnabledForNewRepos *bool `json:"dependabot_security_updates_enabled_for_new_repositories,omitempty"` + // DependabotGraphEnabledForNewRepos toggles whether dependabot graph is enabled on new repositories. + DependencyGraphEnabledForNewRepos *bool `json:"dependency_graph_enabled_for_new_repositories,omitempty"` + // SecretScanningEnabled toggles whether secret scanning is enabled on new repositories. + SecretScanningEnabledForNewRepos *bool `json:"secret_scanning_enabled_for_new_repositories,omitempty"` + // SecretScanningPushProtectionEnabledForNewRepos toggles whether secret scanning push protection is enabled on new repositories. + SecretScanningPushProtectionEnabledForNewRepos *bool `json:"secret_scanning_push_protection_enabled_for_new_repositories,omitempty"` // API URLs URL *string `json:"url,omitempty"` @@ -132,7 +149,7 @@ type OrganizationsListOptions struct { // listing the next set of organizations, use the ID of the last-returned organization // as the opts.Since parameter for the next call. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organizations +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error) { u, err := addOptions("organizations", opts) if err != nil { @@ -155,8 +172,8 @@ func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsL // List the organizations for a user. Passing the empty string will list // organizations for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organizations-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organizations-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-organizations-for-a-user func (s *OrganizationsService) List(ctx context.Context, user string, opts *ListOptions) ([]*Organization, *Response, error) { var u string if user != "" { @@ -185,7 +202,7 @@ func (s *OrganizationsService) List(ctx context.Context, user string, opts *List // Get fetches an organization by name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#get-an-organization func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error) { u := fmt.Sprintf("orgs/%v", org) req, err := s.client.NewRequest("GET", u, nil) @@ -226,7 +243,7 @@ func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organiza // Edit an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#update-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#update-an-organization func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error) { u := fmt.Sprintf("orgs/%v", name) req, err := s.client.NewRequest("PATCH", u, org) @@ -248,7 +265,7 @@ func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organ // ListInstallations lists installations for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-app-installations-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#list-app-installations-for-an-organization func (s *OrganizationsService) ListInstallations(ctx context.Context, org string, opts *ListOptions) (*OrganizationInstallations, *Response, error) { u := fmt.Sprintf("orgs/%v/installations", org) diff --git a/vendor/github.com/google/go-github/v43/github/orgs_actions_allowed.go b/vendor/github.com/google/go-github/v47/github/orgs_actions_allowed.go similarity index 76% rename from vendor/github.com/google/go-github/v43/github/orgs_actions_allowed.go rename to vendor/github.com/google/go-github/v47/github/orgs_actions_allowed.go index 9032d033..e3b35b1d 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_actions_allowed.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_actions_allowed.go @@ -10,9 +10,9 @@ import ( "fmt" ) -// ActionsAllowed represents selected actions that are allowed in an organization. +// ActionsAllowed represents selected actions that are allowed. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-allowed-actions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions type ActionsAllowed struct { GithubOwnedAllowed *bool `json:"github_owned_allowed,omitempty"` VerifiedAllowed *bool `json:"verified_allowed,omitempty"` @@ -25,7 +25,7 @@ func (a ActionsAllowed) String() string { // GetActionsAllowed gets the actions that are allowed in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-allowed-actions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization func (s *OrganizationsService) GetActionsAllowed(ctx context.Context, org string) (*ActionsAllowed, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org) @@ -45,14 +45,19 @@ func (s *OrganizationsService) GetActionsAllowed(ctx context.Context, org string // EditActionsAllowed sets the actions that are allowed in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-allowed-actions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-an-organization func (s *OrganizationsService) EditActionsAllowed(ctx context.Context, org string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions/selected-actions", org) req, err := s.client.NewRequest("PUT", u, actionsAllowed) if err != nil { return nil, nil, err } + p := new(ActionsAllowed) resp, err := s.client.Do(ctx, req, p) - return p, resp, err + if err != nil { + return nil, resp, err + } + + return p, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/orgs_actions_permissions.go b/vendor/github.com/google/go-github/v47/github/orgs_actions_permissions.go similarity index 81% rename from vendor/github.com/google/go-github/v43/github/orgs_actions_permissions.go rename to vendor/github.com/google/go-github/v47/github/orgs_actions_permissions.go index b8a10b25..6d1db2ee 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_actions_permissions.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_actions_permissions.go @@ -12,7 +12,7 @@ import ( // ActionsPermissions represents a policy for repositories and allowed actions in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#permissions +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions type ActionsPermissions struct { EnabledRepositories *string `json:"enabled_repositories,omitempty"` AllowedActions *string `json:"allowed_actions,omitempty"` @@ -25,7 +25,7 @@ func (a ActionsPermissions) String() string { // GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#get-github-actions-permissions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-github-actions-permissions-for-an-organization func (s *OrganizationsService) GetActionsPermissions(ctx context.Context, org string) (*ActionsPermissions, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions", org) @@ -45,14 +45,19 @@ func (s *OrganizationsService) GetActionsPermissions(ctx context.Context, org st // EditActionsPermissions sets the permissions policy for repositories and allowed actions in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/actions#set-github-actions-permissions-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-github-actions-permissions-for-an-organization func (s *OrganizationsService) EditActionsPermissions(ctx context.Context, org string, actionsPermissions ActionsPermissions) (*ActionsPermissions, *Response, error) { u := fmt.Sprintf("orgs/%v/actions/permissions", org) req, err := s.client.NewRequest("PUT", u, actionsPermissions) if err != nil { return nil, nil, err } + p := new(ActionsPermissions) resp, err := s.client.Do(ctx, req, p) - return p, resp, err + if err != nil { + return nil, resp, err + } + + return p, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/orgs_audit_log.go b/vendor/github.com/google/go-github/v47/github/orgs_audit_log.go similarity index 97% rename from vendor/github.com/google/go-github/v43/github/orgs_audit_log.go rename to vendor/github.com/google/go-github/v47/github/orgs_audit_log.go index ade57f54..be5fd24d 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_audit_log.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_audit_log.go @@ -70,6 +70,7 @@ type AuditEntry struct { Repo *string `json:"repo,omitempty"` Repository *string `json:"repository,omitempty"` RepositoryPublic *bool `json:"repository_public,omitempty"` + RunAttempt *int64 `json:"run_attempt,omitempty"` RunnerGroupID *int64 `json:"runner_group_id,omitempty"` RunnerGroupName *string `json:"runner_group_name,omitempty"` RunnerID *int64 `json:"runner_id,omitempty"` @@ -93,7 +94,7 @@ type AuditEntry struct { // GetAuditLog gets the audit-log entries for an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#get-the-audit-log-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/orgs#get-the-audit-log-for-an-organization func (s *OrganizationsService) GetAuditLog(ctx context.Context, org string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error) { u := fmt.Sprintf("orgs/%v/audit-log", org) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go b/vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go new file mode 100644 index 00000000..9904685b --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go @@ -0,0 +1,46 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// OrganizationCustomRepoRoles represents custom repository roles available in specified organization. +type OrganizationCustomRepoRoles struct { + TotalCount *int `json:"total_count,omitempty"` + CustomRepoRoles []*CustomRepoRoles `json:"custom_roles,omitempty"` +} + +// CustomRepoRoles represents custom repository roles for an organization. +// See https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization +// for more information. +type CustomRepoRoles struct { + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` +} + +// ListCustomRepoRoles lists the custom repository roles available in this organization. +// In order to see custom repository roles in an organization, the authenticated user must be an organization owner. +// +// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#list-custom-repository-roles-in-an-organization +func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org string) (*OrganizationCustomRepoRoles, *Response, error) { + u := fmt.Sprintf("orgs/%v/custom_roles", org) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + customRepoRoles := new(OrganizationCustomRepoRoles) + resp, err := s.client.Do(ctx, req, customRepoRoles) + if err != nil { + return nil, resp, err + } + + return customRepoRoles, resp, nil +} diff --git a/vendor/github.com/google/go-github/v43/github/orgs_hooks.go b/vendor/github.com/google/go-github/v47/github/orgs_hooks.go similarity index 78% rename from vendor/github.com/google/go-github/v43/github/orgs_hooks.go rename to vendor/github.com/google/go-github/v47/github/orgs_hooks.go index dc906568..c0dd51e2 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_hooks.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_hooks.go @@ -12,7 +12,7 @@ import ( // ListHooks lists all Hooks for the specified organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-webhooks +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#list-organization-webhooks func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opts *ListOptions) ([]*Hook, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks", org) u, err := addOptions(u, opts) @@ -36,16 +36,21 @@ func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opts * // GetHook returns a single specified Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#get-an-organization-webhook func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64) (*Hook, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } + hook := new(Hook) resp, err := s.client.Do(ctx, req, hook) - return hook, resp, err + if err != nil { + return nil, resp, err + } + + return hook, resp, nil } // CreateHook creates a Hook for the specified org. @@ -54,7 +59,7 @@ func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64 // Note that only a subset of the hook fields are used and hook must // not be nil. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#create-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#create-an-organization-webhook func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks", org) @@ -81,38 +86,45 @@ func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook // EditHook updates a specified Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#update-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#update-an-organization-webhook func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int64, hook *Hook) (*Hook, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) req, err := s.client.NewRequest("PATCH", u, hook) if err != nil { return nil, nil, err } + h := new(Hook) resp, err := s.client.Do(ctx, req, h) - return h, resp, err + if err != nil { + return nil, resp, err + } + + return h, resp, nil } // PingHook triggers a 'ping' event to be sent to the Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#ping-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#ping-an-organization-webhook func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%d/pings", org, id) req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } // DeleteHook deletes a specified Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#delete-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#delete-an-organization-webhook func (s *OrganizationsService) DeleteHook(ctx context.Context, org string, id int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%d", org, id) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } diff --git a/vendor/github.com/google/go-github/v43/github/orgs_hooks_deliveries.go b/vendor/github.com/google/go-github/v47/github/orgs_hooks_deliveries.go similarity index 84% rename from vendor/github.com/google/go-github/v43/github/orgs_hooks_deliveries.go rename to vendor/github.com/google/go-github/v47/github/orgs_hooks_deliveries.go index d1fb5c83..1bfad409 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_hooks_deliveries.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_hooks_deliveries.go @@ -12,7 +12,7 @@ import ( // ListHookDeliveries lists webhook deliveries for a webhook configured in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#list-deliveries-for-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#list-deliveries-for-an-organization-webhook func (s *OrganizationsService) ListHookDeliveries(ctx context.Context, org string, id int64, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%v/deliveries", org, id) u, err := addOptions(u, opts) @@ -36,7 +36,7 @@ func (s *OrganizationsService) ListHookDeliveries(ctx context.Context, org strin // GetHookDelivery returns a delivery for a webhook configured in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#get-a-webhook-delivery-for-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#get-a-webhook-delivery-for-an-organization-webhook func (s *OrganizationsService) GetHookDelivery(ctx context.Context, owner string, hookID, deliveryID int64) (*HookDelivery, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%v/deliveries/%v", owner, hookID, deliveryID) req, err := s.client.NewRequest("GET", u, nil) @@ -55,7 +55,7 @@ func (s *OrganizationsService) GetHookDelivery(ctx context.Context, owner string // RedeliverHookDelivery redelivers a delivery for a webhook configured in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#redeliver-a-delivery-for-an-organization-webhook +// GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks#redeliver-a-delivery-for-an-organization-webhook func (s *OrganizationsService) RedeliverHookDelivery(ctx context.Context, owner string, hookID, deliveryID int64) (*HookDelivery, *Response, error) { u := fmt.Sprintf("orgs/%v/hooks/%v/deliveries/%v/attempts", owner, hookID, deliveryID) req, err := s.client.NewRequest("POST", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/orgs_members.go b/vendor/github.com/google/go-github/v47/github/orgs_members.go similarity index 83% rename from vendor/github.com/google/go-github/v43/github/orgs_members.go rename to vendor/github.com/google/go-github/v47/github/orgs_members.go index f3a2f17c..38f43bad 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_members.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_members.go @@ -71,8 +71,8 @@ type ListMembersOptions struct { // user is an owner of the organization, this will return both concealed and // public members, otherwise it will only return public members. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-members -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-public-organization-members +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-organization-members +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-public-organization-members func (s *OrganizationsService) ListMembers(ctx context.Context, org string, opts *ListMembersOptions) ([]*User, *Response, error) { var u string if opts != nil && opts.PublicOnly { @@ -101,7 +101,7 @@ func (s *OrganizationsService) ListMembers(ctx context.Context, org string, opts // IsMember checks if a user is a member of an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#check-organization-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#check-organization-membership-for-a-user func (s *OrganizationsService) IsMember(ctx context.Context, org, user string) (bool, *Response, error) { u := fmt.Sprintf("orgs/%v/members/%v", org, user) req, err := s.client.NewRequest("GET", u, nil) @@ -116,7 +116,7 @@ func (s *OrganizationsService) IsMember(ctx context.Context, org, user string) ( // IsPublicMember checks if a user is a public member of an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#check-public-organization-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#check-public-organization-membership-for-a-user func (s *OrganizationsService) IsPublicMember(ctx context.Context, org, user string) (bool, *Response, error) { u := fmt.Sprintf("orgs/%v/public_members/%v", org, user) req, err := s.client.NewRequest("GET", u, nil) @@ -131,7 +131,7 @@ func (s *OrganizationsService) IsPublicMember(ctx context.Context, org, user str // RemoveMember removes a user from all teams of an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-an-organization-member +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#remove-an-organization-member func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/members/%v", org, user) req, err := s.client.NewRequest("DELETE", u, nil) @@ -145,7 +145,7 @@ func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user strin // PublicizeMembership publicizes a user's membership in an organization. (A // user cannot publicize the membership for another user.) // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#set-public-organization-membership-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#set-public-organization-membership-for-the-authenticated-user func (s *OrganizationsService) PublicizeMembership(ctx context.Context, org, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/public_members/%v", org, user) req, err := s.client.NewRequest("PUT", u, nil) @@ -158,7 +158,7 @@ func (s *OrganizationsService) PublicizeMembership(ctx context.Context, org, use // ConcealMembership conceals a user's membership in an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-public-organization-membership-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#remove-public-organization-membership-for-the-authenticated-user func (s *OrganizationsService) ConcealMembership(ctx context.Context, org, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/public_members/%v", org, user) req, err := s.client.NewRequest("DELETE", u, nil) @@ -181,7 +181,7 @@ type ListOrgMembershipsOptions struct { // ListOrgMemberships lists the organization memberships for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-memberships-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-organization-memberships-for-the-authenticated-user func (s *OrganizationsService) ListOrgMemberships(ctx context.Context, opts *ListOrgMembershipsOptions) ([]*Membership, *Response, error) { u := "user/memberships/orgs" u, err := addOptions(u, opts) @@ -207,8 +207,8 @@ func (s *OrganizationsService) ListOrgMemberships(ctx context.Context, opts *Lis // Passing an empty string for user will get the membership for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-an-organization-membership-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#get-organization-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#get-an-organization-membership-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#get-organization-membership-for-a-user func (s *OrganizationsService) GetOrgMembership(ctx context.Context, user, org string) (*Membership, *Response, error) { var u string if user != "" { @@ -235,8 +235,8 @@ func (s *OrganizationsService) GetOrgMembership(ctx context.Context, user, org s // Passing an empty string for user will edit the membership for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#update-an-organization-membership-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#set-organization-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#update-an-organization-membership-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#set-organization-membership-for-a-user func (s *OrganizationsService) EditOrgMembership(ctx context.Context, user, org string, membership *Membership) (*Membership, *Response, error) { var u, method string if user != "" { @@ -264,7 +264,7 @@ func (s *OrganizationsService) EditOrgMembership(ctx context.Context, user, org // RemoveOrgMembership removes user from the specified organization. If the // user has been invited to the organization, this will cancel their invitation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-organization-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#remove-organization-membership-for-a-user func (s *OrganizationsService) RemoveOrgMembership(ctx context.Context, user, org string) (*Response, error) { u := fmt.Sprintf("orgs/%v/memberships/%v", org, user) req, err := s.client.NewRequest("DELETE", u, nil) @@ -277,7 +277,7 @@ func (s *OrganizationsService) RemoveOrgMembership(ctx context.Context, user, or // ListPendingOrgInvitations returns a list of pending invitations. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-pending-organization-invitations +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-pending-organization-invitations func (s *OrganizationsService) ListPendingOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error) { u := fmt.Sprintf("orgs/%v/invitations", org) u, err := addOptions(u, opts) @@ -295,6 +295,7 @@ func (s *OrganizationsService) ListPendingOrgInvitations(ctx context.Context, or if err != nil { return nil, resp, err } + return pendingInvitations, resp, nil } @@ -322,7 +323,7 @@ type CreateOrgInvitationOptions struct { // In order to create invitations in an organization, // the authenticated user must be an organization owner. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#create-an-organization-invitation +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#create-an-organization-invitation func (s *OrganizationsService) CreateOrgInvitation(ctx context.Context, org string, opts *CreateOrgInvitationOptions) (*Invitation, *Response, error) { u := fmt.Sprintf("orgs/%v/invitations", org) @@ -336,13 +337,14 @@ func (s *OrganizationsService) CreateOrgInvitation(ctx context.Context, org stri if err != nil { return nil, resp, err } + return invitation, resp, nil } // ListOrgInvitationTeams lists all teams associated with an invitation. In order to see invitations in an organization, // the authenticated user must be an organization owner. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-organization-invitation-teams +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-organization-invitation-teams func (s *OrganizationsService) ListOrgInvitationTeams(ctx context.Context, org, invitationID string, opts *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/invitations/%v/teams", org, invitationID) u, err := addOptions(u, opts) @@ -360,12 +362,13 @@ func (s *OrganizationsService) ListOrgInvitationTeams(ctx context.Context, org, if err != nil { return nil, resp, err } + return orgInvitationTeams, resp, nil } // ListFailedOrgInvitations returns a list of failed inviatations. // -// GitHub API docs: https://docs.github.com/en/rest/reference/orgs#list-failed-organization-invitations +// GitHub API docs: https://docs.github.com/en/rest/orgs/members#list-failed-organization-invitations func (s *OrganizationsService) ListFailedOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error) { u := fmt.Sprintf("orgs/%v/failed_invitations", org) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/orgs_outside_collaborators.go b/vendor/github.com/google/go-github/v47/github/orgs_outside_collaborators.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/orgs_outside_collaborators.go rename to vendor/github.com/google/go-github/v47/github/orgs_outside_collaborators.go index d9ffd25a..506a4946 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_outside_collaborators.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_outside_collaborators.go @@ -27,7 +27,7 @@ type ListOutsideCollaboratorsOptions struct { // Warning: The API may change without advance notice during the preview period. // Preview features are not supported for production use. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-outside-collaborators-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/outside-collaborators#list-outside-collaborators-for-an-organization func (s *OrganizationsService) ListOutsideCollaborators(ctx context.Context, org string, opts *ListOutsideCollaboratorsOptions) ([]*User, *Response, error) { u := fmt.Sprintf("orgs/%v/outside_collaborators", org) u, err := addOptions(u, opts) @@ -52,7 +52,7 @@ func (s *OrganizationsService) ListOutsideCollaborators(ctx context.Context, org // RemoveOutsideCollaborator removes a user from the list of outside collaborators; // consequently, removing them from all the organization's repositories. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#remove-outside-collaborator-from-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/outside-collaborators#remove-outside-collaborator-from-an-organization func (s *OrganizationsService) RemoveOutsideCollaborator(ctx context.Context, org string, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/outside_collaborators/%v", org, user) req, err := s.client.NewRequest("DELETE", u, nil) @@ -69,7 +69,7 @@ func (s *OrganizationsService) RemoveOutsideCollaborator(ctx context.Context, or // Responses for converting a non-member or the last owner to an outside collaborator // are listed in GitHub API docs. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#convert-an-organization-member-to-outside-collaborator +// GitHub API docs: https://docs.github.com/en/rest/orgs/outside-collaborators#convert-an-organization-member-to-outside-collaborator func (s *OrganizationsService) ConvertMemberToOutsideCollaborator(ctx context.Context, org string, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/outside_collaborators/%v", org, user) req, err := s.client.NewRequest("PUT", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/orgs_packages.go b/vendor/github.com/google/go-github/v47/github/orgs_packages.go similarity index 81% rename from vendor/github.com/google/go-github/v43/github/orgs_packages.go rename to vendor/github.com/google/go-github/v47/github/orgs_packages.go index 0c36f21c..9fb11308 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_packages.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_packages.go @@ -12,7 +12,7 @@ import ( // List the packages for an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#list-packages-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#list-packages-for-an-organization func (s *OrganizationsService) ListPackages(ctx context.Context, org string, opts *PackageListOptions) ([]*Package, *Response, error) { u := fmt.Sprintf("orgs/%v/packages", org) u, err := addOptions(u, opts) @@ -36,7 +36,7 @@ func (s *OrganizationsService) ListPackages(ctx context.Context, org string, opt // Get a package by name from an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-for-an-organization func (s *OrganizationsService) GetPackage(ctx context.Context, org, packageType, packageName string) (*Package, *Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v", org, packageType, packageName) req, err := s.client.NewRequest("GET", u, nil) @@ -55,7 +55,7 @@ func (s *OrganizationsService) GetPackage(ctx context.Context, org, packageType, // Delete a package from an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-a-package-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#delete-a-package-for-an-organization func (s *OrganizationsService) DeletePackage(ctx context.Context, org, packageType, packageName string) (*Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v", org, packageType, packageName) req, err := s.client.NewRequest("DELETE", u, nil) @@ -68,7 +68,7 @@ func (s *OrganizationsService) DeletePackage(ctx context.Context, org, packageTy // Restore a package to an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-a-package-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#restore-a-package-for-an-organization func (s *OrganizationsService) RestorePackage(ctx context.Context, org, packageType, packageName string) (*Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v/restore", org, packageType, packageName) req, err := s.client.NewRequest("POST", u, nil) @@ -81,7 +81,7 @@ func (s *OrganizationsService) RestorePackage(ctx context.Context, org, packageT // Get all versions of a package in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-all-package-versions-for-a-package-owned-by-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#get-all-package-versions-for-a-package-owned-by-an-organization func (s *OrganizationsService) PackageGetAllVersions(ctx context.Context, org, packageType, packageName string, opts *PackageListOptions) ([]*PackageVersion, *Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions", org, packageType, packageName) u, err := addOptions(u, opts) @@ -105,7 +105,7 @@ func (s *OrganizationsService) PackageGetAllVersions(ctx context.Context, org, p // Get a specific version of a package in an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-version-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-version-for-an-organization func (s *OrganizationsService) PackageGetVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*PackageVersion, *Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions/%v", org, packageType, packageName, packageVersionID) req, err := s.client.NewRequest("GET", u, nil) @@ -124,7 +124,7 @@ func (s *OrganizationsService) PackageGetVersion(ctx context.Context, org, packa // Delete a package version from an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-package-version-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#delete-package-version-for-an-organization func (s *OrganizationsService) PackageDeleteVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions/%v", org, packageType, packageName, packageVersionID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -137,7 +137,7 @@ func (s *OrganizationsService) PackageDeleteVersion(ctx context.Context, org, pa // Restore a package version to an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-package-version-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/packages#restore-package-version-for-an-organization func (s *OrganizationsService) PackageRestoreVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/packages/%v/%v/versions/%v/restore", org, packageType, packageName, packageVersionID) req, err := s.client.NewRequest("POST", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/orgs_projects.go b/vendor/github.com/google/go-github/v47/github/orgs_projects.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/orgs_projects.go rename to vendor/github.com/google/go-github/v47/github/orgs_projects.go index b0c60ecb..d49eae54 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_projects.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_projects.go @@ -12,7 +12,7 @@ import ( // ListProjects lists the projects for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-organization-projects +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#list-organization-projects func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error) { u := fmt.Sprintf("orgs/%v/projects", org) u, err := addOptions(u, opts) @@ -39,7 +39,7 @@ func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opt // CreateProject creates a GitHub Project for the specified organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-an-organization-project +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#create-an-organization-project func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error) { u := fmt.Sprintf("orgs/%v/projects", org) req, err := s.client.NewRequest("POST", u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/orgs_users_blocking.go b/vendor/github.com/google/go-github/v47/github/orgs_users_blocking.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/orgs_users_blocking.go rename to vendor/github.com/google/go-github/v47/github/orgs_users_blocking.go index 2773344c..9c6cf602 100644 --- a/vendor/github.com/google/go-github/v43/github/orgs_users_blocking.go +++ b/vendor/github.com/google/go-github/v47/github/orgs_users_blocking.go @@ -12,7 +12,7 @@ import ( // ListBlockedUsers lists all the users blocked by an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#list-users-blocked-by-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#list-users-blocked-by-an-organization func (s *OrganizationsService) ListBlockedUsers(ctx context.Context, org string, opts *ListOptions) ([]*User, *Response, error) { u := fmt.Sprintf("orgs/%v/blocks", org) u, err := addOptions(u, opts) @@ -39,7 +39,7 @@ func (s *OrganizationsService) ListBlockedUsers(ctx context.Context, org string, // IsBlocked reports whether specified user is blocked from an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#check-if-a-user-is-blocked-by-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#check-if-a-user-is-blocked-by-an-organization func (s *OrganizationsService) IsBlocked(ctx context.Context, org string, user string) (bool, *Response, error) { u := fmt.Sprintf("orgs/%v/blocks/%v", org, user) @@ -58,7 +58,7 @@ func (s *OrganizationsService) IsBlocked(ctx context.Context, org string, user s // BlockUser blocks specified user from an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#block-a-user-from-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#block-a-user-from-an-organization func (s *OrganizationsService) BlockUser(ctx context.Context, org string, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/blocks/%v", org, user) @@ -75,7 +75,7 @@ func (s *OrganizationsService) BlockUser(ctx context.Context, org string, user s // UnblockUser unblocks specified user from an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/orgs/#unblock-a-user-from-an-organization +// GitHub API docs: https://docs.github.com/en/rest/orgs/blocking#unblock-a-user-from-an-organization func (s *OrganizationsService) UnblockUser(ctx context.Context, org string, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/blocks/%v", org, user) diff --git a/vendor/github.com/google/go-github/v43/github/packages.go b/vendor/github.com/google/go-github/v47/github/packages.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/packages.go rename to vendor/github.com/google/go-github/v47/github/packages.go diff --git a/vendor/github.com/google/go-github/v43/github/projects.go b/vendor/github.com/google/go-github/v47/github/projects.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/projects.go rename to vendor/github.com/google/go-github/v47/github/projects.go index 2886c3a3..df7ad6cd 100644 --- a/vendor/github.com/google/go-github/v43/github/projects.go +++ b/vendor/github.com/google/go-github/v47/github/projects.go @@ -13,7 +13,7 @@ import ( // ProjectsService provides access to the projects functions in the // GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/ +// GitHub API docs: https://docs.github.com/en/rest/projects type ProjectsService service // Project represents a GitHub Project. @@ -43,7 +43,7 @@ func (p Project) String() string { // GetProject gets a GitHub Project for a repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-a-project +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#get-a-project func (s *ProjectsService) GetProject(ctx context.Context, id int64) (*Project, *Response, error) { u := fmt.Sprintf("projects/%v", id) req, err := s.client.NewRequest("GET", u, nil) @@ -90,7 +90,7 @@ type ProjectOptions struct { // UpdateProject updates a repository project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#update-a-project +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#update-a-project func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opts *ProjectOptions) (*Project, *Response, error) { u := fmt.Sprintf("projects/%v", id) req, err := s.client.NewRequest("PATCH", u, opts) @@ -112,7 +112,7 @@ func (s *ProjectsService) UpdateProject(ctx context.Context, id int64, opts *Pro // DeleteProject deletes a GitHub Project from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#delete-a-project +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#delete-a-project func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Response, error) { u := fmt.Sprintf("projects/%v", id) req, err := s.client.NewRequest("DELETE", u, nil) @@ -128,7 +128,7 @@ func (s *ProjectsService) DeleteProject(ctx context.Context, id int64) (*Respons // ProjectColumn represents a column of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/projects/ +// GitHub API docs: https://docs.github.com/en/rest/repos/projects/ type ProjectColumn struct { ID *int64 `json:"id,omitempty"` Name *string `json:"name,omitempty"` @@ -142,7 +142,7 @@ type ProjectColumn struct { // ListProjectColumns lists the columns of a GitHub Project for a repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-project-columns +// GitHub API docs: https://docs.github.com/en/rest/projects/columns#list-project-columns func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int64, opts *ListOptions) ([]*ProjectColumn, *Response, error) { u := fmt.Sprintf("projects/%v/columns", projectID) u, err := addOptions(u, opts) @@ -169,7 +169,7 @@ func (s *ProjectsService) ListProjectColumns(ctx context.Context, projectID int6 // GetProjectColumn gets a column of a GitHub Project for a repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-a-project-column +// GitHub API docs: https://docs.github.com/en/rest/projects/columns#get-a-project-column func (s *ProjectsService) GetProjectColumn(ctx context.Context, id int64) (*ProjectColumn, *Response, error) { u := fmt.Sprintf("projects/columns/%v", id) req, err := s.client.NewRequest("GET", u, nil) @@ -199,7 +199,7 @@ type ProjectColumnOptions struct { // CreateProjectColumn creates a column for the specified (by number) project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-a-project-column +// GitHub API docs: https://docs.github.com/en/rest/projects/columns#create-a-project-column func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) { u := fmt.Sprintf("projects/%v/columns", projectID) req, err := s.client.NewRequest("POST", u, opts) @@ -221,7 +221,7 @@ func (s *ProjectsService) CreateProjectColumn(ctx context.Context, projectID int // UpdateProjectColumn updates a column of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#update-an-existing-project-column +// GitHub API docs: https://docs.github.com/en/rest/projects/columns#update-an-existing-project-column func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnOptions) (*ProjectColumn, *Response, error) { u := fmt.Sprintf("projects/columns/%v", columnID) req, err := s.client.NewRequest("PATCH", u, opts) @@ -243,7 +243,7 @@ func (s *ProjectsService) UpdateProjectColumn(ctx context.Context, columnID int6 // DeleteProjectColumn deletes a column from a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#delete-a-project-column +// GitHub API docs: https://docs.github.com/en/rest/projects/columns#delete-a-project-column func (s *ProjectsService) DeleteProjectColumn(ctx context.Context, columnID int64) (*Response, error) { u := fmt.Sprintf("projects/columns/%v", columnID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -267,7 +267,7 @@ type ProjectColumnMoveOptions struct { // MoveProjectColumn moves a column within a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#move-a-project-column +// GitHub API docs: https://docs.github.com/en/rest/projects/columns#move-a-project-column func (s *ProjectsService) MoveProjectColumn(ctx context.Context, columnID int64, opts *ProjectColumnMoveOptions) (*Response, error) { u := fmt.Sprintf("projects/columns/%v/moves", columnID) req, err := s.client.NewRequest("POST", u, opts) @@ -283,7 +283,7 @@ func (s *ProjectsService) MoveProjectColumn(ctx context.Context, columnID int64, // ProjectCard represents a card in a column of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/cards/#get-a-project-card +// GitHub API docs: https://docs.github.com/en/rest/projects/cards/#get-a-project-card type ProjectCard struct { URL *string `json:"url,omitempty"` ColumnURL *string `json:"column_url,omitempty"` @@ -318,7 +318,7 @@ type ProjectCardListOptions struct { // ListProjectCards lists the cards in a column of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-project-cards +// GitHub API docs: https://docs.github.com/en/rest/projects/cards#list-project-cards func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, opts *ProjectCardListOptions) ([]*ProjectCard, *Response, error) { u := fmt.Sprintf("projects/columns/%v/cards", columnID) u, err := addOptions(u, opts) @@ -345,7 +345,7 @@ func (s *ProjectsService) ListProjectCards(ctx context.Context, columnID int64, // GetProjectCard gets a card in a column of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-a-project-card +// GitHub API docs: https://docs.github.com/en/rest/projects/cards#get-a-project-card func (s *ProjectsService) GetProjectCard(ctx context.Context, cardID int64) (*ProjectCard, *Response, error) { u := fmt.Sprintf("projects/columns/cards/%v", cardID) req, err := s.client.NewRequest("GET", u, nil) @@ -383,7 +383,7 @@ type ProjectCardOptions struct { // CreateProjectCard creates a card in the specified column of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-a-project-card +// GitHub API docs: https://docs.github.com/en/rest/projects/cards#create-a-project-card func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) { u := fmt.Sprintf("projects/columns/%v/cards", columnID) req, err := s.client.NewRequest("POST", u, opts) @@ -405,7 +405,7 @@ func (s *ProjectsService) CreateProjectCard(ctx context.Context, columnID int64, // UpdateProjectCard updates a card of a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#update-an-existing-project-card +// GitHub API docs: https://docs.github.com/en/rest/projects/cards#update-an-existing-project-card func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, opts *ProjectCardOptions) (*ProjectCard, *Response, error) { u := fmt.Sprintf("projects/columns/cards/%v", cardID) req, err := s.client.NewRequest("PATCH", u, opts) @@ -427,7 +427,7 @@ func (s *ProjectsService) UpdateProjectCard(ctx context.Context, cardID int64, o // DeleteProjectCard deletes a card from a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#delete-a-project-card +// GitHub API docs: https://docs.github.com/en/rest/projects/cards#delete-a-project-card func (s *ProjectsService) DeleteProjectCard(ctx context.Context, cardID int64) (*Response, error) { u := fmt.Sprintf("projects/columns/cards/%v", cardID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -455,7 +455,7 @@ type ProjectCardMoveOptions struct { // MoveProjectCard moves a card within a GitHub Project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#move-a-project-card +// GitHub API docs: https://docs.github.com/en/rest/projects/cards#move-a-project-card func (s *ProjectsService) MoveProjectCard(ctx context.Context, cardID int64, opts *ProjectCardMoveOptions) (*Response, error) { u := fmt.Sprintf("projects/columns/cards/%v/moves", cardID) req, err := s.client.NewRequest("POST", u, opts) @@ -485,7 +485,7 @@ type ProjectCollaboratorOptions struct { // AddProjectCollaborator adds a collaborator to an organization project and sets // their permission level. You must be an organization owner or a project admin to add a collaborator. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#add-project-collaborator +// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#add-project-collaborator func (s *ProjectsService) AddProjectCollaborator(ctx context.Context, id int64, username string, opts *ProjectCollaboratorOptions) (*Response, error) { u := fmt.Sprintf("projects/%v/collaborators/%v", id, username) req, err := s.client.NewRequest("PUT", u, opts) @@ -502,7 +502,7 @@ func (s *ProjectsService) AddProjectCollaborator(ctx context.Context, id int64, // RemoveProjectCollaborator removes a collaborator from an organization project. // You must be an organization owner or a project admin to remove a collaborator. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#remove-user-as-a-collaborator +// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#remove-user-as-a-collaborator func (s *ProjectsService) RemoveProjectCollaborator(ctx context.Context, id int64, username string) (*Response, error) { u := fmt.Sprintf("projects/%v/collaborators/%v", id, username) req, err := s.client.NewRequest("DELETE", u, nil) @@ -538,7 +538,7 @@ type ListCollaboratorOptions struct { // with access through default organization permissions, and organization owners. You must be an // organization owner or a project admin to list collaborators. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-project-collaborators +// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#list-project-collaborators func (s *ProjectsService) ListProjectCollaborators(ctx context.Context, id int64, opts *ListCollaboratorOptions) ([]*User, *Response, error) { u := fmt.Sprintf("projects/%v/collaborators", id) u, err := addOptions(u, opts) @@ -576,7 +576,7 @@ type ProjectPermissionLevel struct { // project. Possible values for the permission key: "admin", "write", "read", "none". // You must be an organization owner or a project admin to review a user's permission level. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#get-project-permission-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/projects/collaborators#get-project-permission-for-a-user func (s *ProjectsService) ReviewProjectCollaboratorPermission(ctx context.Context, id int64, username string) (*ProjectPermissionLevel, *Response, error) { u := fmt.Sprintf("projects/%v/collaborators/%v/permission", id, username) req, err := s.client.NewRequest("GET", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/pulls.go b/vendor/github.com/google/go-github/v47/github/pulls.go similarity index 92% rename from vendor/github.com/google/go-github/v43/github/pulls.go rename to vendor/github.com/google/go-github/v47/github/pulls.go index 37fb7413..120a1d6f 100644 --- a/vendor/github.com/google/go-github/v43/github/pulls.go +++ b/vendor/github.com/google/go-github/v47/github/pulls.go @@ -15,7 +15,7 @@ import ( // PullRequestsService handles communication with the pull request related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/ +// GitHub API docs: https://docs.github.com/en/rest/pulls/ type PullRequestsService service // PullRequestAutoMerge represents the "auto_merge" response for a PullRequest. @@ -143,7 +143,7 @@ type PullRequestListOptions struct { // List the pull requests for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-pull-requests +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#list-pull-requests func (s *PullRequestsService) List(ctx context.Context, owner string, repo string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo) u, err := addOptions(u, opts) @@ -170,7 +170,7 @@ func (s *PullRequestsService) List(ctx context.Context, owner string, repo strin // The results may include open and closed pull requests. // By default, the PullRequestListOptions State filters for "open". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/commits/#list-pull-requests-associated-with-a-commit +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-pull-requests-associated-with-a-commit func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, owner, repo, sha string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/pulls", owner, repo, sha) u, err := addOptions(u, opts) @@ -196,7 +196,7 @@ func (s *PullRequestsService) ListPullRequestsWithCommit(ctx context.Context, ow // Get a single pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request func (s *PullRequestsService) Get(ctx context.Context, owner string, repo string, number int) (*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -215,7 +215,7 @@ func (s *PullRequestsService) Get(ctx context.Context, owner string, repo string // GetRaw gets a single pull request in raw (diff or patch) format. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#get-a-pull-request func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo string, number int, opts RawOptions) (string, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -254,7 +254,7 @@ type NewPullRequest struct { // Create a new pull request on the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#create-a-pull-request func (s *PullRequestsService) Create(ctx context.Context, owner string, repo string, pull *NewPullRequest) (*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo) req, err := s.client.NewRequest("POST", u, pull) @@ -293,7 +293,7 @@ type PullRequestBranchUpdateResponse struct { // A follow up request, after a delay of a second or so, should result // in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-pull-request-branch +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request-branch func (s *PullRequestsService) UpdateBranch(ctx context.Context, owner, repo string, number int, opts *PullRequestBranchUpdateOptions) (*PullRequestBranchUpdateResponse, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/update-branch", owner, repo, number) @@ -328,7 +328,7 @@ type pullRequestUpdate struct { // The following fields are editable: Title, Body, State, Base.Ref and MaintainerCanModify. // Base.Ref updates the base branch of the pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#update-a-pull-request func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error) { if pull == nil { return nil, nil, fmt.Errorf("pull must be provided") @@ -365,7 +365,7 @@ func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo strin // ListCommits lists the commits in a pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-commits-on-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#list-commits-on-a-pull-request func (s *PullRequestsService) ListCommits(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/commits", owner, repo, number) u, err := addOptions(u, opts) @@ -389,7 +389,7 @@ func (s *PullRequestsService) ListCommits(ctx context.Context, owner string, rep // ListFiles lists the files in a pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-pull-requests-files +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files func (s *PullRequestsService) ListFiles(ctx context.Context, owner string, repo string, number int, opts *ListOptions) ([]*CommitFile, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/files", owner, repo, number) u, err := addOptions(u, opts) @@ -413,7 +413,7 @@ func (s *PullRequestsService) ListFiles(ctx context.Context, owner string, repo // IsMerged checks if a pull request has been merged. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#check-if-a-pull-request-has-been-merged +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#check-if-a-pull-request-has-been-merged func (s *PullRequestsService) IsMerged(ctx context.Context, owner string, repo string, number int) (bool, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -455,7 +455,7 @@ type pullRequestMergeRequest struct { // Merge a pull request. // commitMessage is an extra detail to append to automatic commit message. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#merge-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/pulls#merge-a-pull-request func (s *PullRequestsService) Merge(ctx context.Context, owner string, repo string, number int, commitMessage string, options *PullRequestOptions) (*PullRequestMergeResult, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/merge", owner, repo, number) diff --git a/vendor/github.com/google/go-github/v43/github/pulls_comments.go b/vendor/github.com/google/go-github/v47/github/pulls_comments.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/pulls_comments.go rename to vendor/github.com/google/go-github/v47/github/pulls_comments.go index 5078bab1..83e7881e 100644 --- a/vendor/github.com/google/go-github/v43/github/pulls_comments.go +++ b/vendor/github.com/google/go-github/v47/github/pulls_comments.go @@ -66,8 +66,8 @@ type PullRequestListCommentsOptions struct { // pull request number of 0 will return all comments on all pull requests for // the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-review-comments-on-a-pull-request -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-review-comments-in-a-repository +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#list-review-comments-on-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#list-review-comments-in-a-repository func (s *PullRequestsService) ListComments(ctx context.Context, owner, repo string, number int, opts *PullRequestListCommentsOptions) ([]*PullRequestComment, *Response, error) { var u string if number == 0 { @@ -100,7 +100,7 @@ func (s *PullRequestsService) ListComments(ctx context.Context, owner, repo stri // GetComment fetches the specified pull request comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-review-comment-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#get-a-review-comment-for-a-pull-request func (s *PullRequestsService) GetComment(ctx context.Context, owner, repo string, commentID int64) (*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID) req, err := s.client.NewRequest("GET", u, nil) @@ -123,7 +123,7 @@ func (s *PullRequestsService) GetComment(ctx context.Context, owner, repo string // CreateComment creates a new comment on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-review-comment-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#create-a-review-comment-for-a-pull-request func (s *PullRequestsService) CreateComment(ctx context.Context, owner, repo string, number int, comment *PullRequestComment) (*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/comments", owner, repo, number) req, err := s.client.NewRequest("POST", u, comment) @@ -145,7 +145,7 @@ func (s *PullRequestsService) CreateComment(ctx context.Context, owner, repo str // CreateCommentInReplyTo creates a new comment as a reply to an existing pull request comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-review-comment-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#create-a-review-comment-for-a-pull-request func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner, repo string, number int, body string, commentID int64) (*PullRequestComment, *Response, error) { comment := &struct { Body string `json:"body,omitempty"` @@ -172,7 +172,7 @@ func (s *PullRequestsService) CreateCommentInReplyTo(ctx context.Context, owner, // EditComment updates a pull request comment. // A non-nil comment.Body must be provided. Other comment fields should be left nil. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-review-comment-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#update-a-review-comment-for-a-pull-request func (s *PullRequestsService) EditComment(ctx context.Context, owner, repo string, commentID int64, comment *PullRequestComment) (*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID) req, err := s.client.NewRequest("PATCH", u, comment) @@ -191,7 +191,7 @@ func (s *PullRequestsService) EditComment(ctx context.Context, owner, repo strin // DeleteComment deletes a pull request comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#delete-a-review-comment-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/comments#delete-a-review-comment-for-a-pull-request func (s *PullRequestsService) DeleteComment(ctx context.Context, owner, repo string, commentID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/pulls_reviewers.go b/vendor/github.com/google/go-github/v47/github/pulls_reviewers.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/pulls_reviewers.go rename to vendor/github.com/google/go-github/v47/github/pulls_reviewers.go index f901c2e8..1c336540 100644 --- a/vendor/github.com/google/go-github/v43/github/pulls_reviewers.go +++ b/vendor/github.com/google/go-github/v47/github/pulls_reviewers.go @@ -25,7 +25,7 @@ type Reviewers struct { // RequestReviewers creates a review request for the provided reviewers for the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#request-reviewers-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/review-requests#request-reviewers-for-a-pull-request func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*PullRequest, *Response, error) { u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) req, err := s.client.NewRequest("POST", u, &reviewers) @@ -44,7 +44,7 @@ func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo // ListReviewers lists reviewers whose reviews have been requested on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-requested-reviewers-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/review-requests#list-requested-reviewers-for-a-pull-request func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo string, number int, opts *ListOptions) (*Reviewers, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/requested_reviewers", owner, repo, number) u, err := addOptions(u, opts) @@ -68,7 +68,7 @@ func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo str // RemoveReviewers removes the review request for the provided reviewers for the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#remove-requested-reviewers-from-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/review-requests#remove-requested-reviewers-from-a-pull-request func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo string, number int, reviewers ReviewersRequest) (*Response, error) { u := fmt.Sprintf("repos/%s/%s/pulls/%d/requested_reviewers", owner, repo, number) req, err := s.client.NewRequest("DELETE", u, &reviewers) diff --git a/vendor/github.com/google/go-github/v43/github/pulls_reviews.go b/vendor/github.com/google/go-github/v47/github/pulls_reviews.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/pulls_reviews.go rename to vendor/github.com/google/go-github/v47/github/pulls_reviews.go index 437b0937..77bf60ce 100644 --- a/vendor/github.com/google/go-github/v43/github/pulls_reviews.go +++ b/vendor/github.com/google/go-github/v47/github/pulls_reviews.go @@ -101,7 +101,7 @@ func (r PullRequestReviewDismissalRequest) String() string { // ListReviews lists all reviews on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-reviews-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#list-reviews-for-a-pull-request func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) u, err := addOptions(u, opts) @@ -125,7 +125,7 @@ func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo strin // GetReview fetches the specified pull request review. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#get-a-review-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#get-a-review-for-a-pull-request func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) @@ -145,7 +145,7 @@ func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string, // DeletePendingReview deletes the specified pull request pending review. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#delete-a-pending-review-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#delete-a-pending-review-for-a-pull-request func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, repo string, number int, reviewID int64) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) @@ -165,7 +165,7 @@ func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, re // ListReviewComments lists all the comments for the specified review. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#list-comments-for-a-pull-request-review +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#list-comments-for-a-pull-request-review func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, repo string, number int, reviewID int64, opts *ListOptions) ([]*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID) u, err := addOptions(u, opts) @@ -189,39 +189,41 @@ func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, rep // CreateReview creates a new review on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#create-a-review-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request // // In order to use multi-line comments, you must use the "comfort fade" preview. // This replaces the use of the "Position" field in comments with 4 new fields: -// [Start]Side, and [Start]Line. +// +// [Start]Side, and [Start]Line. +// // These new fields must be used for ALL comments (including single-line), // with the following restrictions (empirically observed, so subject to change). // // For single-line "comfort fade" comments, you must use: // -// Path: &path, // as before -// Body: &body, // as before -// Side: &"RIGHT" (or "LEFT") -// Line: &123, // NOT THE SAME AS POSITION, this is an actual line number. +// Path: &path, // as before +// Body: &body, // as before +// Side: &"RIGHT" (or "LEFT") +// Line: &123, // NOT THE SAME AS POSITION, this is an actual line number. // // If StartSide or StartLine is used with single-line comments, a 422 is returned. // // For multi-line "comfort fade" comments, you must use: // -// Path: &path, // as before -// Body: &body, // as before -// StartSide: &"RIGHT" (or "LEFT") -// Side: &"RIGHT" (or "LEFT") -// StartLine: &120, -// Line: &125, +// Path: &path, // as before +// Body: &body, // as before +// StartSide: &"RIGHT" (or "LEFT") +// Side: &"RIGHT" (or "LEFT") +// StartLine: &120, +// Line: &125, // // Suggested edits are made by commenting on the lines to replace, and including the // suggested edit in a block like this (it may be surrounded in non-suggestion markdown): // -// ```suggestion -// Use this instead. -// It is waaaaaay better. -// ``` +// ```suggestion +// Use this instead. +// It is waaaaaay better. +// ``` func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) @@ -250,7 +252,7 @@ func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo stri // UpdateReview updates the review summary on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#update-a-review-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#update-a-review-for-a-pull-request func (s *PullRequestsService) UpdateReview(ctx context.Context, owner, repo string, number int, reviewID int64, body string) (*PullRequestReview, *Response, error) { opts := &struct { Body string `json:"body"` @@ -273,7 +275,7 @@ func (s *PullRequestsService) UpdateReview(ctx context.Context, owner, repo stri // SubmitReview submits a specified review on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#submit-a-review-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#submit-a-review-for-a-pull-request func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID) @@ -293,7 +295,7 @@ func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo stri // DismissReview dismisses a specified review on the specified pull request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/#dismiss-a-review-for-a-pull-request +// GitHub API docs: https://docs.github.com/en/rest/pulls/reviews#dismiss-a-review-for-a-pull-request func (s *PullRequestsService) DismissReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID) diff --git a/vendor/github.com/google/go-github/v47/github/pulls_threads.go b/vendor/github.com/google/go-github/v47/github/pulls_threads.go new file mode 100644 index 00000000..23e924d8 --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/pulls_threads.go @@ -0,0 +1,17 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +// PullRequestThread represents a thread of comments on a pull request. +type PullRequestThread struct { + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Comments []*PullRequestComment `json:"comments,omitempty"` +} + +func (p PullRequestThread) String() string { + return Stringify(p) +} diff --git a/vendor/github.com/google/go-github/v43/github/reactions.go b/vendor/github.com/google/go-github/v47/github/reactions.go similarity index 83% rename from vendor/github.com/google/go-github/v43/github/reactions.go rename to vendor/github.com/google/go-github/v47/github/reactions.go index ecfcf2e9..14d193ae 100644 --- a/vendor/github.com/google/go-github/v43/github/reactions.go +++ b/vendor/github.com/google/go-github/v47/github/reactions.go @@ -14,7 +14,7 @@ import ( // ReactionsService provides access to the reactions-related functions in the // GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/ +// GitHub API docs: https://docs.github.com/en/rest/reactions type ReactionsService service // Reaction represents a GitHub reaction. @@ -60,7 +60,7 @@ type ListCommentReactionOptions struct { // ListCommentReactions lists the reactions for a commit comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-commit-comment +// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-commit-comment func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListCommentReactionOptions) ([]*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id) u, err := addOptions(u, opts) @@ -90,7 +90,7 @@ func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo // previously created reaction will be returned with Status: 200 OK. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-commit-comment +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-commit-comment func (s *ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id) @@ -114,7 +114,7 @@ func (s *ReactionsService) CreateCommentReaction(ctx context.Context, owner, rep // DeleteCommentReaction deletes the reaction for a commit comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-commit-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction func (s *ReactionsService) DeleteCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions/%v", owner, repo, commentID, reactionID) @@ -123,7 +123,7 @@ func (s *ReactionsService) DeleteCommentReaction(ctx context.Context, owner, rep // DeleteCommentReactionByID deletes the reaction for a commit comment by repository ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-commit-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-commit-comment-reaction func (s *ReactionsService) DeleteCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) { u := fmt.Sprintf("repositories/%v/comments/%v/reactions/%v", repoID, commentID, reactionID) @@ -132,7 +132,7 @@ func (s *ReactionsService) DeleteCommentReactionByID(ctx context.Context, repoID // ListIssueReactions lists the reactions for an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-an-issue +// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-an-issue func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number) u, err := addOptions(u, opts) @@ -162,7 +162,7 @@ func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo s // previously created reaction will be returned with Status: 200 OK. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-an-issue +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-an-issue func (s *ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number) @@ -186,7 +186,7 @@ func (s *ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo // DeleteIssueReaction deletes the reaction to an issue. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-reaction func (s *ReactionsService) DeleteIssueReaction(ctx context.Context, owner, repo string, issueNumber int, reactionID int64) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/issues/%v/reactions/%v", owner, repo, issueNumber, reactionID) @@ -195,7 +195,7 @@ func (s *ReactionsService) DeleteIssueReaction(ctx context.Context, owner, repo // DeleteIssueReactionByID deletes the reaction to an issue by repository ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-reaction func (s *ReactionsService) DeleteIssueReactionByID(ctx context.Context, repoID, issueNumber int, reactionID int64) (*Response, error) { url := fmt.Sprintf("repositories/%v/issues/%v/reactions/%v", repoID, issueNumber, reactionID) @@ -204,7 +204,7 @@ func (s *ReactionsService) DeleteIssueReactionByID(ctx context.Context, repoID, // ListIssueCommentReactions lists the reactions for an issue comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-an-issue-comment +// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-an-issue-comment func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id) u, err := addOptions(u, opts) @@ -234,7 +234,7 @@ func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner, // previously created reaction will be returned with Status: 200 OK. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-an-issue-comment +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-an-issue-comment func (s *ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id) @@ -258,7 +258,7 @@ func (s *ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner // DeleteIssueCommentReaction deletes the reaction to an issue comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction func (s *ReactionsService) DeleteIssueCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions/%v", owner, repo, commentID, reactionID) @@ -267,7 +267,7 @@ func (s *ReactionsService) DeleteIssueCommentReaction(ctx context.Context, owner // DeleteIssueCommentReactionByID deletes the reaction to an issue comment by repository ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-an-issue-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-an-issue-comment-reaction func (s *ReactionsService) DeleteIssueCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) { url := fmt.Sprintf("repositories/%v/issues/comments/%v/reactions/%v", repoID, commentID, reactionID) @@ -276,7 +276,7 @@ func (s *ReactionsService) DeleteIssueCommentReactionByID(ctx context.Context, r // ListPullRequestCommentReactions lists the reactions for a pull request review comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-pull-request-review-comment +// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-pull-request-review-comment func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id) u, err := addOptions(u, opts) @@ -306,7 +306,7 @@ func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context, // previously created reaction will be returned with Status: 200 OK. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-pull-request-review-comment +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-pull-request-review-comment func (s *ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id) @@ -330,7 +330,7 @@ func (s *ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, // DeletePullRequestCommentReaction deletes the reaction to a pull request review comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-pull-request-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction func (s *ReactionsService) DeletePullRequestCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) { url := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions/%v", owner, repo, commentID, reactionID) @@ -339,7 +339,7 @@ func (s *ReactionsService) DeletePullRequestCommentReaction(ctx context.Context, // DeletePullRequestCommentReactionByID deletes the reaction to a pull request review comment by repository ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-a-pull-request-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-a-pull-request-comment-reaction func (s *ReactionsService) DeletePullRequestCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) { url := fmt.Sprintf("repositories/%v/pulls/comments/%v/reactions/%v", repoID, commentID, reactionID) @@ -348,7 +348,7 @@ func (s *ReactionsService) DeletePullRequestCommentReactionByID(ctx context.Cont // ListTeamDiscussionReactions lists the reactions for a team discussion. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-team-discussion-legacy +// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-team-discussion-legacy func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, teamID int64, discussionNumber int, opts *ListOptions) ([]*Reaction, *Response, error) { u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber) u, err := addOptions(u, opts) @@ -375,7 +375,7 @@ func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, team // CreateTeamDiscussionReaction creates a reaction for a team discussion. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-team-discussion-legacy +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion-legacy func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber) @@ -398,7 +398,7 @@ func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, tea // DeleteTeamDiscussionReaction deletes the reaction to a team discussion. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-team-discussion-reaction func (s *ReactionsService) DeleteTeamDiscussionReaction(ctx context.Context, org, teamSlug string, discussionNumber int, reactionID int64) (*Response, error) { url := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/reactions/%v", org, teamSlug, discussionNumber, reactionID) @@ -407,7 +407,7 @@ func (s *ReactionsService) DeleteTeamDiscussionReaction(ctx context.Context, org // DeleteTeamDiscussionReactionByOrgIDAndTeamID deletes the reaction to a team discussion by organization ID and team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion func (s *ReactionsService) DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber int, reactionID int64) (*Response, error) { url := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/reactions/%v", orgID, teamID, discussionNumber, reactionID) @@ -416,7 +416,7 @@ func (s *ReactionsService) DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx cont // ListTeamDiscussionCommentReactions lists the reactions for a team discussion comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#list-reactions-for-a-team-discussion-comment-legacy +// GitHub API docs: https://docs.github.com/en/rest/reactions#list-reactions-for-a-team-discussion-comment-legacy func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Context, teamID int64, discussionNumber, commentNumber int, opts *ListOptions) ([]*Reaction, *Response, error) { u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber) u, err := addOptions(u, opts) @@ -442,7 +442,7 @@ func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Contex // CreateTeamDiscussionCommentReaction creates a reaction for a team discussion comment. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-team-discussion-comment-legacy +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion-comment-legacy func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber) @@ -465,7 +465,7 @@ func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Conte // DeleteTeamDiscussionCommentReaction deletes the reaction to a team discussion comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#delete-team-discussion-comment-reaction func (s *ReactionsService) DeleteTeamDiscussionCommentReaction(ctx context.Context, org, teamSlug string, discussionNumber, commentNumber int, reactionID int64) (*Response, error) { url := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments/%v/reactions/%v", org, teamSlug, discussionNumber, commentNumber, reactionID) @@ -474,7 +474,7 @@ func (s *ReactionsService) DeleteTeamDiscussionCommentReaction(ctx context.Conte // DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID deletes the reaction to a team discussion comment by organization ID and team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#delete-team-discussion-comment-reaction +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-team-discussion-comment func (s *ReactionsService) DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber, commentNumber int, reactionID int64) (*Response, error) { url := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments/%v/reactions/%v", orgID, teamID, discussionNumber, commentNumber, reactionID) @@ -498,7 +498,7 @@ func (s *ReactionsService) deleteReaction(ctx context.Context, url string) (*Res // added the reaction type to this release. // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/reactions/#create-reaction-for-a-release +// GitHub API docs: https://docs.github.com/en/rest/reactions#create-reaction-for-a-release func (s *ReactionsService) CreateReleaseReaction(ctx context.Context, owner, repo string, releaseID int64, content string) (*Reaction, *Response, error) { u := fmt.Sprintf("repos/%v/%v/releases/%v/reactions", owner, repo, releaseID) diff --git a/vendor/github.com/google/go-github/v43/github/repos.go b/vendor/github.com/google/go-github/v47/github/repos.go similarity index 79% rename from vendor/github.com/google/go-github/v43/github/repos.go rename to vendor/github.com/google/go-github/v47/github/repos.go index 2b1139b6..45fd1888 100644 --- a/vendor/github.com/google/go-github/v43/github/repos.go +++ b/vendor/github.com/google/go-github/v47/github/repos.go @@ -21,56 +21,62 @@ var ErrBranchNotProtected = errors.New("branch is not protected") // RepositoriesService handles communication with the repository related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/ +// GitHub API docs: https://docs.github.com/en/rest/repos/ type RepositoriesService service // Repository represents a GitHub repository. type Repository struct { - ID *int64 `json:"id,omitempty"` - NodeID *string `json:"node_id,omitempty"` - Owner *User `json:"owner,omitempty"` - Name *string `json:"name,omitempty"` - FullName *string `json:"full_name,omitempty"` - Description *string `json:"description,omitempty"` - Homepage *string `json:"homepage,omitempty"` - CodeOfConduct *CodeOfConduct `json:"code_of_conduct,omitempty"` - DefaultBranch *string `json:"default_branch,omitempty"` - MasterBranch *string `json:"master_branch,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - PushedAt *Timestamp `json:"pushed_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - CloneURL *string `json:"clone_url,omitempty"` - GitURL *string `json:"git_url,omitempty"` - MirrorURL *string `json:"mirror_url,omitempty"` - SSHURL *string `json:"ssh_url,omitempty"` - SVNURL *string `json:"svn_url,omitempty"` - Language *string `json:"language,omitempty"` - Fork *bool `json:"fork,omitempty"` - ForksCount *int `json:"forks_count,omitempty"` - NetworkCount *int `json:"network_count,omitempty"` - OpenIssuesCount *int `json:"open_issues_count,omitempty"` - OpenIssues *int `json:"open_issues,omitempty"` // Deprecated: Replaced by OpenIssuesCount. For backward compatibility OpenIssues is still populated. - StargazersCount *int `json:"stargazers_count,omitempty"` - SubscribersCount *int `json:"subscribers_count,omitempty"` - WatchersCount *int `json:"watchers_count,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility WatchersCount is still populated. - Watchers *int `json:"watchers,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility Watchers is still populated. - Size *int `json:"size,omitempty"` - AutoInit *bool `json:"auto_init,omitempty"` - Parent *Repository `json:"parent,omitempty"` - Source *Repository `json:"source,omitempty"` - TemplateRepository *Repository `json:"template_repository,omitempty"` - Organization *Organization `json:"organization,omitempty"` - Permissions map[string]bool `json:"permissions,omitempty"` - AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` - AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` - AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` - AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` - AllowForking *bool `json:"allow_forking,omitempty"` - DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` - Topics []string `json:"topics,omitempty"` - Archived *bool `json:"archived,omitempty"` - Disabled *bool `json:"disabled,omitempty"` + ID *int64 `json:"id,omitempty"` + NodeID *string `json:"node_id,omitempty"` + Owner *User `json:"owner,omitempty"` + Name *string `json:"name,omitempty"` + FullName *string `json:"full_name,omitempty"` + Description *string `json:"description,omitempty"` + Homepage *string `json:"homepage,omitempty"` + CodeOfConduct *CodeOfConduct `json:"code_of_conduct,omitempty"` + DefaultBranch *string `json:"default_branch,omitempty"` + MasterBranch *string `json:"master_branch,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + PushedAt *Timestamp `json:"pushed_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + CloneURL *string `json:"clone_url,omitempty"` + GitURL *string `json:"git_url,omitempty"` + MirrorURL *string `json:"mirror_url,omitempty"` + SSHURL *string `json:"ssh_url,omitempty"` + SVNURL *string `json:"svn_url,omitempty"` + Language *string `json:"language,omitempty"` + Fork *bool `json:"fork,omitempty"` + ForksCount *int `json:"forks_count,omitempty"` + NetworkCount *int `json:"network_count,omitempty"` + OpenIssuesCount *int `json:"open_issues_count,omitempty"` + OpenIssues *int `json:"open_issues,omitempty"` // Deprecated: Replaced by OpenIssuesCount. For backward compatibility OpenIssues is still populated. + StargazersCount *int `json:"stargazers_count,omitempty"` + SubscribersCount *int `json:"subscribers_count,omitempty"` + WatchersCount *int `json:"watchers_count,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility WatchersCount is still populated. + Watchers *int `json:"watchers,omitempty"` // Deprecated: Replaced by StargazersCount. For backward compatibility Watchers is still populated. + Size *int `json:"size,omitempty"` + AutoInit *bool `json:"auto_init,omitempty"` + Parent *Repository `json:"parent,omitempty"` + Source *Repository `json:"source,omitempty"` + TemplateRepository *Repository `json:"template_repository,omitempty"` + Organization *Organization `json:"organization,omitempty"` + Permissions map[string]bool `json:"permissions,omitempty"` + AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` + AllowUpdateBranch *bool `json:"allow_update_branch,omitempty"` + AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` + AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` + AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` + AllowForking *bool `json:"allow_forking,omitempty"` + DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` + UseSquashPRTitleAsDefault *bool `json:"use_squash_pr_title_as_default,omitempty"` + SquashMergeCommitTitle *string `json:"squash_merge_commit_title,omitempty"` // Can be one of: "PR_TITLE", "COMMIT_OR_PR_TITLE" + SquashMergeCommitMessage *string `json:"squash_merge_commit_message,omitempty"` // Can be one of: "PR_BODY", "COMMIT_MESSAGES", "BLANK" + MergeCommitTitle *string `json:"merge_commit_title,omitempty"` // Can be one of: "PR_TITLE", "MERGE_MESSAGE" + MergeCommitMessage *string `json:"merge_commit_message,omitempty"` // Can be one of: "PR_BODY", "PR_TITLE", "BLANK" + Topics []string `json:"topics,omitempty"` + Archived *bool `json:"archived,omitempty"` + Disabled *bool `json:"disabled,omitempty"` // Only provided when using RepositoriesService.Get while in preview License *License `json:"license,omitempty"` @@ -132,13 +138,17 @@ type Repository struct { TeamsURL *string `json:"teams_url,omitempty"` // TextMatches is only populated from search results that request text matches - // See: search.go and https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#text-match-metadata + // See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata TextMatches []*TextMatch `json:"text_matches,omitempty"` // Visibility is only used for Create and Edit endpoints. The visibility field // overrides the field parameter when both are used. // Can be one of public, private or internal. Visibility *string `json:"visibility,omitempty"` + + // RoleName is only returned by the API 'check team permissions for a repository'. + // See: teams.go (IsTeamRepoByID) https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository + RoleName *string `json:"role_name,omitempty"` } func (r Repository) String() string { @@ -228,8 +238,8 @@ func (s SecretScanning) String() string { // List the repositories for a user. Passing the empty string will list // repositories for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repositories-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repositories-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repositories-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repositories-for-a-user func (s *RepositoriesService) List(ctx context.Context, user string, opts *RepositoryListOptions) ([]*Repository, *Response, error) { var u string if user != "" { @@ -280,7 +290,7 @@ type RepositoryListByOrgOptions struct { // ListByOrg lists the repositories for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-organization-repositories +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-organization-repositories func (s *RepositoriesService) ListByOrg(ctx context.Context, org string, opts *RepositoryListByOrgOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("orgs/%v/repos", org) u, err := addOptions(u, opts) @@ -315,7 +325,7 @@ type RepositoryListAllOptions struct { // ListAll lists all GitHub repositories in the order that they were created. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-public-repositories +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-public-repositories func (s *RepositoriesService) ListAll(ctx context.Context, opts *RepositoryListAllOptions) ([]*Repository, *Response, error) { u, err := addOptions("repositories", opts) if err != nil { @@ -357,15 +367,21 @@ type createRepoRequest struct { // Creating an organization repository. Required for non-owners. TeamID *int64 `json:"team_id,omitempty"` - AutoInit *bool `json:"auto_init,omitempty"` - GitignoreTemplate *string `json:"gitignore_template,omitempty"` - LicenseTemplate *string `json:"license_template,omitempty"` - AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` - AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` - AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` - AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` - AllowForking *bool `json:"allow_forking,omitempty"` - DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` + AutoInit *bool `json:"auto_init,omitempty"` + GitignoreTemplate *string `json:"gitignore_template,omitempty"` + LicenseTemplate *string `json:"license_template,omitempty"` + AllowSquashMerge *bool `json:"allow_squash_merge,omitempty"` + AllowMergeCommit *bool `json:"allow_merge_commit,omitempty"` + AllowRebaseMerge *bool `json:"allow_rebase_merge,omitempty"` + AllowUpdateBranch *bool `json:"allow_update_branch,omitempty"` + AllowAutoMerge *bool `json:"allow_auto_merge,omitempty"` + AllowForking *bool `json:"allow_forking,omitempty"` + DeleteBranchOnMerge *bool `json:"delete_branch_on_merge,omitempty"` + UseSquashPRTitleAsDefault *bool `json:"use_squash_pr_title_as_default,omitempty"` + SquashMergeCommitTitle *string `json:"squash_merge_commit_title,omitempty"` + SquashMergeCommitMessage *string `json:"squash_merge_commit_message,omitempty"` + MergeCommitTitle *string `json:"merge_commit_title,omitempty"` + MergeCommitMessage *string `json:"merge_commit_message,omitempty"` } // Create a new repository. If an organization is specified, the new @@ -380,8 +396,8 @@ type createRepoRequest struct { // changes propagate throughout its servers. You may set up a loop with // exponential back-off to verify repository's creation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-an-organization-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-a-repository-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-an-organization-repository func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error) { var u string if org != "" { @@ -391,25 +407,31 @@ func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repo } repoReq := &createRepoRequest{ - Name: repo.Name, - Description: repo.Description, - Homepage: repo.Homepage, - Private: repo.Private, - Visibility: repo.Visibility, - HasIssues: repo.HasIssues, - HasProjects: repo.HasProjects, - HasWiki: repo.HasWiki, - IsTemplate: repo.IsTemplate, - TeamID: repo.TeamID, - AutoInit: repo.AutoInit, - GitignoreTemplate: repo.GitignoreTemplate, - LicenseTemplate: repo.LicenseTemplate, - AllowSquashMerge: repo.AllowSquashMerge, - AllowMergeCommit: repo.AllowMergeCommit, - AllowRebaseMerge: repo.AllowRebaseMerge, - AllowAutoMerge: repo.AllowAutoMerge, - AllowForking: repo.AllowForking, - DeleteBranchOnMerge: repo.DeleteBranchOnMerge, + Name: repo.Name, + Description: repo.Description, + Homepage: repo.Homepage, + Private: repo.Private, + Visibility: repo.Visibility, + HasIssues: repo.HasIssues, + HasProjects: repo.HasProjects, + HasWiki: repo.HasWiki, + IsTemplate: repo.IsTemplate, + TeamID: repo.TeamID, + AutoInit: repo.AutoInit, + GitignoreTemplate: repo.GitignoreTemplate, + LicenseTemplate: repo.LicenseTemplate, + AllowSquashMerge: repo.AllowSquashMerge, + AllowMergeCommit: repo.AllowMergeCommit, + AllowRebaseMerge: repo.AllowRebaseMerge, + AllowUpdateBranch: repo.AllowUpdateBranch, + AllowAutoMerge: repo.AllowAutoMerge, + AllowForking: repo.AllowForking, + DeleteBranchOnMerge: repo.DeleteBranchOnMerge, + UseSquashPRTitleAsDefault: repo.UseSquashPRTitleAsDefault, + SquashMergeCommitTitle: repo.SquashMergeCommitTitle, + SquashMergeCommitMessage: repo.SquashMergeCommitMessage, + MergeCommitTitle: repo.MergeCommitTitle, + MergeCommitMessage: repo.MergeCommitMessage, } req, err := s.client.NewRequest("POST", u, repoReq) @@ -441,7 +463,7 @@ type TemplateRepoRequest struct { // CreateFromTemplate generates a repository from a template. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-using-a-template +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-a-repository-using-a-template func (s *RepositoriesService) CreateFromTemplate(ctx context.Context, templateOwner, templateRepo string, templateRepoReq *TemplateRepoRequest) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/generate", templateOwner, templateRepo) @@ -462,7 +484,7 @@ func (s *RepositoriesService) CreateFromTemplate(ctx context.Context, templateOw // Get fetches a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -471,7 +493,7 @@ func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Rep } // TODO: remove custom Accept header when the license support fully launches - // https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-a-repositorys-license + // https://docs.github.com/en/rest/licenses/#get-a-repositorys-license acceptHeaders := []string{ mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview, @@ -490,10 +512,12 @@ func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Rep } // GetCodeOfConduct gets the contents of a repository's code of conduct. +// Note that https://docs.github.com/en/rest/codes-of-conduct#about-the-codes-of-conduct-api +// says to use the GET /repos/{owner}/{repo} endpoint. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/codes-of-conduct/#get-the-code-of-conduct-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository func (s *RepositoriesService) GetCodeOfConduct(ctx context.Context, owner, repo string) (*CodeOfConduct, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/community/code_of_conduct", owner, repo) + u := fmt.Sprintf("repos/%v/%v", owner, repo) req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err @@ -502,13 +526,13 @@ func (s *RepositoriesService) GetCodeOfConduct(ctx context.Context, owner, repo // TODO: remove custom Accept header when this API fully launches. req.Header.Set("Accept", mediaTypeCodesOfConductPreview) - coc := new(CodeOfConduct) - resp, err := s.client.Do(ctx, req, coc) + r := new(Repository) + resp, err := s.client.Do(ctx, req, r) if err != nil { return nil, resp, err } - return coc, resp, nil + return r.GetCodeOfConduct(), resp, nil } // GetByID fetches a repository. @@ -532,7 +556,7 @@ func (s *RepositoriesService) GetByID(ctx context.Context, id int64) (*Repositor // Edit updates a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository func (s *RepositoriesService) Edit(ctx context.Context, owner, repo string, repository *Repository) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v", owner, repo) req, err := s.client.NewRequest("PATCH", u, repository) @@ -553,7 +577,7 @@ func (s *RepositoriesService) Edit(ctx context.Context, owner, repo string, repo // Delete a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#delete-a-repository func (s *RepositoriesService) Delete(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) @@ -600,7 +624,7 @@ type ListContributorsOptions struct { // GetVulnerabilityAlerts checks if vulnerability alerts are enabled for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#check-if-vulnerability-alerts-are-enabled-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository func (s *RepositoriesService) GetVulnerabilityAlerts(ctx context.Context, owner, repository string) (bool, *Response, error) { u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository) @@ -614,13 +638,12 @@ func (s *RepositoriesService) GetVulnerabilityAlerts(ctx context.Context, owner, resp, err := s.client.Do(ctx, req, nil) vulnerabilityAlertsEnabled, err := parseBoolResponse(err) - return vulnerabilityAlertsEnabled, resp, err } // EnableVulnerabilityAlerts enables vulnerability alerts and the dependency graph for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#enable-vulnerability-alerts +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#enable-vulnerability-alerts func (s *RepositoriesService) EnableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository) @@ -637,7 +660,7 @@ func (s *RepositoriesService) EnableVulnerabilityAlerts(ctx context.Context, own // DisableVulnerabilityAlerts disables vulnerability alerts and the dependency graph for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#disable-vulnerability-alerts +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#disable-vulnerability-alerts func (s *RepositoriesService) DisableVulnerabilityAlerts(ctx context.Context, owner, repository string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/vulnerability-alerts", owner, repository) @@ -654,7 +677,7 @@ func (s *RepositoriesService) DisableVulnerabilityAlerts(ctx context.Context, ow // EnableAutomatedSecurityFixes enables the automated security fixes for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#enable-automated-security-fixes +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#enable-automated-security-fixes func (s *RepositoriesService) EnableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository) @@ -671,7 +694,7 @@ func (s *RepositoriesService) EnableAutomatedSecurityFixes(ctx context.Context, // DisableAutomatedSecurityFixes disables vulnerability alerts and the dependency graph for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#disable-automated-security-fixes +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#disable-automated-security-fixes func (s *RepositoriesService) DisableAutomatedSecurityFixes(ctx context.Context, owner, repository string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/automated-security-fixes", owner, repository) @@ -688,7 +711,7 @@ func (s *RepositoriesService) DisableAutomatedSecurityFixes(ctx context.Context, // ListContributors lists contributors for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-contributors +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-contributors func (s *RepositoriesService) ListContributors(ctx context.Context, owner string, repository string, opts *ListContributorsOptions) ([]*Contributor, *Response, error) { u := fmt.Sprintf("repos/%v/%v/contributors", owner, repository) u, err := addOptions(u, opts) @@ -714,12 +737,12 @@ func (s *RepositoriesService) ListContributors(ctx context.Context, owner string // specifies the languages and the number of bytes of code written in that // language. For example: // -// { -// "C": 78769, -// "Python": 7769 -// } +// { +// "C": 78769, +// "Python": 7769 +// } // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-languages +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-languages func (s *RepositoriesService) ListLanguages(ctx context.Context, owner string, repo string) (map[string]int, *Response, error) { u := fmt.Sprintf("repos/%v/%v/languages", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -738,7 +761,7 @@ func (s *RepositoriesService) ListLanguages(ctx context.Context, owner string, r // ListTeams lists the teams for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-teams +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-teams func (s *RepositoriesService) ListTeams(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("repos/%v/%v/teams", owner, repo) u, err := addOptions(u, opts) @@ -770,7 +793,7 @@ type RepositoryTag struct { // ListTags lists tags for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-tags +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-repository-tags func (s *RepositoriesService) ListTags(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*RepositoryTag, *Response, error) { u := fmt.Sprintf("repos/%v/%v/tags", owner, repo) u, err := addOptions(u, opts) @@ -882,7 +905,7 @@ type RequiredStatusChecks struct { Contexts []string `json:"contexts,omitempty"` // The list of status checks to require in order to merge into this // branch. - Checks []*RequiredStatusCheck `json:"checks,omitempty"` + Checks []*RequiredStatusCheck `json:"checks"` } // RequiredStatusChecksRequest represents a request to edit a protected branch's status checks. @@ -908,6 +931,8 @@ type RequiredStatusCheck struct { // PullRequestReviewsEnforcement represents the pull request reviews enforcement of a protected branch. type PullRequestReviewsEnforcement struct { + // Allow specific users, teams, or apps to bypass pull request requirements. + BypassPullRequestAllowances *BypassPullRequestAllowances `json:"bypass_pull_request_allowances,omitempty"` // Specifies which users and teams can dismiss pull request reviews. DismissalRestrictions *DismissalRestrictions `json:"dismissal_restrictions,omitempty"` // Specifies if approved reviews are dismissed automatically, when a new commit is pushed. @@ -923,6 +948,8 @@ type PullRequestReviewsEnforcement struct { // enforcement of a protected branch. It is separate from PullRequestReviewsEnforcement above // because the request structure is different from the response structure. type PullRequestReviewsEnforcementRequest struct { + // Allow specific users, teams, or apps to bypass pull request requirements. + BypassPullRequestAllowancesRequest *BypassPullRequestAllowancesRequest `json:"bypass_pull_request_allowances,omitempty"` // Specifies which users and teams should be allowed to dismiss pull request reviews. // User and team dismissal restrictions are only available for // organization-owned repositories. Must be nil for personal repositories. @@ -940,6 +967,8 @@ type PullRequestReviewsEnforcementRequest struct { // enforcement of a protected branch. It is separate from PullRequestReviewsEnforcementRequest above // because the patch request does not require all fields to be initialized. type PullRequestReviewsEnforcementUpdate struct { + // Allow specific users, teams, or apps to bypass pull request requirements. + BypassPullRequestAllowancesRequest *BypassPullRequestAllowancesRequest `json:"bypass_pull_request_allowances,omitempty"` // Specifies which users and teams can dismiss pull request reviews. Can be omitted. DismissalRestrictionsRequest *DismissalRestrictionsRequest `json:"dismissal_restrictions,omitempty"` // Specifies if approved reviews can be dismissed automatically, when a new commit is pushed. Can be omitted. @@ -1001,6 +1030,29 @@ type BranchRestrictionsRequest struct { Apps []string `json:"apps,omitempty"` } +// BypassPullRequestAllowances represents the people, teams, or apps who are allowed to bypass required pull requests. +type BypassPullRequestAllowances struct { + // The list of users allowed to bypass pull request requirements. + Users []*User `json:"users"` + // The list of teams allowed to bypass pull request requirements. + Teams []*Team `json:"teams"` + // The list of apps allowed to bypass pull request requirements. + Apps []*App `json:"apps"` +} + +// BypassPullRequestAllowancesRequest represents the people, teams, or apps who are +// allowed to bypass required pull requests. +// It is separate from BypassPullRequestAllowances above because the request structure is +// different from the response structure. +type BypassPullRequestAllowancesRequest struct { + // The list of user logins allowed to bypass pull request requirements. + Users []string `json:"users"` + // The list of team slugs allowed to bypass pull request requirements. + Teams []string `json:"teams"` + // The list of app slugs allowed to bypass pull request requirements. + Apps []string `json:"apps"` +} + // DismissalRestrictions specifies which users and teams can dismiss pull request reviews. type DismissalRestrictions struct { // The list of users who can dimiss pull request reviews. @@ -1030,7 +1082,7 @@ type SignaturesProtectedBranch struct { // ListBranches lists branches for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-branches +// GitHub API docs: https://docs.github.com/en/rest/branches/branches#list-branches func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, repo string, opts *BranchListOptions) ([]*Branch, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches", owner, repo) u, err := addOptions(u, opts) @@ -1054,11 +1106,11 @@ func (s *RepositoriesService) ListBranches(ctx context.Context, owner string, re // GetBranch gets the specified branch for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-branch +// GitHub API docs: https://docs.github.com/en/rest/branches/branches#get-a-branch func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch string, followRedirects bool) (*Branch, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v", owner, repo, branch) - resp, err := s.getBranchFromURL(ctx, u, followRedirects) + resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) if err != nil { return nil, nil, err } @@ -1073,33 +1125,6 @@ func (s *RepositoriesService) GetBranch(ctx context.Context, owner, repo, branch return b, newResponse(resp), err } -func (s *RepositoriesService) getBranchFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) { - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, err - } - - var resp *http.Response - // Use http.DefaultTransport if no custom Transport is configured - req = withContext(ctx, req) - if s.client.client.Transport == nil { - resp, err = http.DefaultTransport.RoundTrip(req) - } else { - resp, err = s.client.client.Transport.RoundTrip(req) - } - if err != nil { - return nil, err - } - - // If redirect response is returned, follow it - if followRedirects && resp.StatusCode == http.StatusMovedPermanently { - resp.Body.Close() - u = resp.Header.Get("Location") - resp, err = s.getBranchFromURL(ctx, u, false) - } - return resp, err -} - // renameBranchRequest represents a request to rename a branch. type renameBranchRequest struct { NewName string `json:"new_name"` @@ -1110,7 +1135,7 @@ type renameBranchRequest struct { // To rename a non-default branch: Users must have push access. GitHub Apps must have the `contents:write` repository permission. // To rename the default branch: Users must have admin or owner permissions. GitHub Apps must have the `administration:write` repository permission. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#rename-a-branch +// GitHub API docs: https://docs.github.com/en/rest/branches/branches#rename-a-branch func (s *RepositoriesService) RenameBranch(ctx context.Context, owner, repo, branch, newName string) (*Branch, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/rename", owner, repo, branch) r := &renameBranchRequest{NewName: newName} @@ -1130,7 +1155,7 @@ func (s *RepositoriesService) RenameBranch(ctx context.Context, owner, repo, bra // GetBranchProtection gets the protection of a given branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-branch-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-branch-protection func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, repo, branch string) (*Protection, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1155,7 +1180,7 @@ func (s *RepositoriesService) GetBranchProtection(ctx context.Context, owner, re // GetRequiredStatusChecks gets the required status checks for a given protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-status-checks-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-status-checks-protection func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*RequiredStatusChecks, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1177,7 +1202,7 @@ func (s *RepositoriesService) GetRequiredStatusChecks(ctx context.Context, owner // ListRequiredStatusChecksContexts lists the required status checks contexts for a given protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-status-check-contexts +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-all-status-check-contexts func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Context, owner, repo, branch string) (contexts []string, resp *Response, err error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks/contexts", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1198,7 +1223,7 @@ func (s *RepositoriesService) ListRequiredStatusChecksContexts(ctx context.Conte // UpdateBranchProtection updates the protection of a given branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-branch-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner, repo, branch string, preq *ProtectionRequest) (*Protection, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch) req, err := s.client.NewRequest("PUT", u, preq) @@ -1220,7 +1245,7 @@ func (s *RepositoriesService) UpdateBranchProtection(ctx context.Context, owner, // RemoveBranchProtection removes the protection of a given branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-branch-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-branch-protection func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner, repo, branch string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection", owner, repo, branch) req, err := s.client.NewRequest("DELETE", u, nil) @@ -1233,7 +1258,7 @@ func (s *RepositoriesService) RemoveBranchProtection(ctx context.Context, owner, // GetSignaturesProtectedBranch gets required signatures of protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-commit-signature-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-commit-signature-protection func (s *RepositoriesService) GetSignaturesProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1256,7 +1281,7 @@ func (s *RepositoriesService) GetSignaturesProtectedBranch(ctx context.Context, // RequireSignaturesOnProtectedBranch makes signed commits required on a protected branch. // It requires admin access and branch protection to be enabled. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-commit-signature-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#create-commit-signature-protection func (s *RepositoriesService) RequireSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*SignaturesProtectedBranch, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch) req, err := s.client.NewRequest("POST", u, nil) @@ -1273,12 +1298,12 @@ func (s *RepositoriesService) RequireSignaturesOnProtectedBranch(ctx context.Con return nil, resp, err } - return r, resp, err + return r, resp, nil } // OptionalSignaturesOnProtectedBranch removes required signed commits on a given branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-commit-signature-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-commit-signature-protection func (s *RepositoriesService) OptionalSignaturesOnProtectedBranch(ctx context.Context, owner, repo, branch string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_signatures", owner, repo, branch) req, err := s.client.NewRequest("DELETE", u, nil) @@ -1294,7 +1319,7 @@ func (s *RepositoriesService) OptionalSignaturesOnProtectedBranch(ctx context.Co // UpdateRequiredStatusChecks updates the required status checks for a given protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-status-check-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-status-check-protection func (s *RepositoriesService) UpdateRequiredStatusChecks(ctx context.Context, owner, repo, branch string, sreq *RequiredStatusChecksRequest) (*RequiredStatusChecks, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch) req, err := s.client.NewRequest("PATCH", u, sreq) @@ -1313,7 +1338,7 @@ func (s *RepositoriesService) UpdateRequiredStatusChecks(ctx context.Context, ow // RemoveRequiredStatusChecks removes the required status checks for a given protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#remove-status-check-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-status-check-protection func (s *RepositoriesService) RemoveRequiredStatusChecks(ctx context.Context, owner, repo, branch string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_status_checks", owner, repo, branch) req, err := s.client.NewRequest("DELETE", u, nil) @@ -1326,7 +1351,7 @@ func (s *RepositoriesService) RemoveRequiredStatusChecks(ctx context.Context, ow // License gets the contents of a repository's license if one is detected. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/licenses/#get-the-license-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/licenses#get-the-license-for-a-repository func (s *RepositoriesService) License(ctx context.Context, owner, repo string) (*RepositoryLicense, *Response, error) { u := fmt.Sprintf("repos/%v/%v/license", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -1345,7 +1370,7 @@ func (s *RepositoriesService) License(ctx context.Context, owner, repo string) ( // GetPullRequestReviewEnforcement gets pull request review enforcement of a protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-pull-request-review-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-pull-request-review-protection func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1368,7 +1393,7 @@ func (s *RepositoriesService) GetPullRequestReviewEnforcement(ctx context.Contex // UpdatePullRequestReviewEnforcement patches pull request review enforcement of a protected branch. // It requires admin access and branch protection to be enabled. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-pull-request-review-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-pull-request-review-protection func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string, patch *PullRequestReviewsEnforcementUpdate) (*PullRequestReviewsEnforcement, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch) req, err := s.client.NewRequest("PATCH", u, patch) @@ -1385,13 +1410,13 @@ func (s *RepositoriesService) UpdatePullRequestReviewEnforcement(ctx context.Con return nil, resp, err } - return r, resp, err + return r, resp, nil } // DisableDismissalRestrictions disables dismissal restrictions of a protected branch. // It requires admin access and branch protection to be enabled. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-pull-request-review-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#update-pull-request-review-protection func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context, owner, repo, branch string) (*PullRequestReviewsEnforcement, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch) @@ -1413,12 +1438,12 @@ func (s *RepositoriesService) DisableDismissalRestrictions(ctx context.Context, return nil, resp, err } - return r, resp, err + return r, resp, nil } // RemovePullRequestReviewEnforcement removes pull request enforcement of a protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-pull-request-review-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-pull-request-review-protection func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/required_pull_request_reviews", owner, repo, branch) req, err := s.client.NewRequest("DELETE", u, nil) @@ -1431,7 +1456,7 @@ func (s *RepositoriesService) RemovePullRequestReviewEnforcement(ctx context.Con // GetAdminEnforcement gets admin enforcement information of a protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-admin-branch-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-admin-branch-protection func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1451,7 +1476,7 @@ func (s *RepositoriesService) GetAdminEnforcement(ctx context.Context, owner, re // AddAdminEnforcement adds admin enforcement to a protected branch. // It requires admin access and branch protection to be enabled. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#set-admin-branch-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-admin-branch-protection func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, repo, branch string) (*AdminEnforcement, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch) req, err := s.client.NewRequest("POST", u, nil) @@ -1465,12 +1490,12 @@ func (s *RepositoriesService) AddAdminEnforcement(ctx context.Context, owner, re return nil, resp, err } - return r, resp, err + return r, resp, nil } // RemoveAdminEnforcement removes admin enforcement from a protected branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-admin-branch-protection +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#delete-admin-branch-protection func (s *RepositoriesService) RemoveAdminEnforcement(ctx context.Context, owner, repo, branch string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/enforce_admins", owner, repo, branch) req, err := s.client.NewRequest("DELETE", u, nil) @@ -1488,7 +1513,7 @@ type repositoryTopics struct { // ListAllTopics lists topics for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-repository-topics +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#get-all-repository-topics func (s *RepositoriesService) ListAllTopics(ctx context.Context, owner, repo string) ([]string, *Response, error) { u := fmt.Sprintf("repos/%v/%v/topics", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -1508,9 +1533,9 @@ func (s *RepositoriesService) ListAllTopics(ctx context.Context, owner, repo str return topics.Names, resp, nil } -// ReplaceAllTopics replaces topics for a repository. +// ReplaceAllTopics replaces all repository topics. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#replace-all-repository-topics +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#replace-all-repository-topics func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo string, topics []string) ([]string, *Response, error) { u := fmt.Sprintf("repos/%v/%v/topics", owner, repo) t := &repositoryTopics{ @@ -1539,7 +1564,7 @@ func (s *RepositoriesService) ReplaceAllTopics(ctx context.Context, owner, repo // ListApps lists the GitHub apps that have push access to a given protected branch. // It requires the GitHub apps to have `write` access to the `content` permission. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-apps-with-access-to-the-protected-branch +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#get-apps-with-access-to-the-protected-branch func (s *RepositoriesService) ListApps(ctx context.Context, owner, repo, branch string) ([]*App, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch) req, err := s.client.NewRequest("GET", u, nil) @@ -1562,7 +1587,7 @@ func (s *RepositoriesService) ListApps(ctx context.Context, owner, repo, branch // // Note: The list of users, apps, and teams in total is limited to 100 items. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#set-app-access-restrictions +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#set-app-access-restrictions func (s *RepositoriesService) ReplaceAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch) req, err := s.client.NewRequest("PUT", u, slug) @@ -1584,7 +1609,7 @@ func (s *RepositoriesService) ReplaceAppRestrictions(ctx context.Context, owner, // // Note: The list of users, apps, and teams in total is limited to 100 items. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#add-app-access-restrictions +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#add-app-access-restrictions func (s *RepositoriesService) AddAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch) req, err := s.client.NewRequest("POST", u, slug) @@ -1606,7 +1631,7 @@ func (s *RepositoriesService) AddAppRestrictions(ctx context.Context, owner, rep // // Note: The list of users, apps, and teams in total is limited to 100 items. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#remove-app-access-restrictions +// GitHub API docs: https://docs.github.com/en/rest/branches/branch-protection#remove-app-access-restrictions func (s *RepositoriesService) RemoveAppRestrictions(ctx context.Context, owner, repo, branch string, slug []string) ([]*App, *Response, error) { u := fmt.Sprintf("repos/%v/%v/branches/%v/protection/restrictions/apps", owner, repo, branch) req, err := s.client.NewRequest("DELETE", u, slug) @@ -1637,7 +1662,7 @@ type TransferRequest struct { // A follow up request, after a delay of a second or so, should result // in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#transfer-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#transfer-a-repository func (s *RepositoriesService) Transfer(ctx context.Context, owner, repo string, transfer TransferRequest) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/transfer", owner, repo) @@ -1666,7 +1691,7 @@ type DispatchRequestOptions struct { // Dispatch triggers a repository_dispatch event in a GitHub Actions workflow. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-dispatch-event +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event func (s *RepositoriesService) Dispatch(ctx context.Context, owner, repo string, opts DispatchRequestOptions) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/dispatches", owner, repo) diff --git a/vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go b/vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go new file mode 100644 index 00000000..25a46905 --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go @@ -0,0 +1,49 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// GetActionsAllowed gets the allowed actions and reusable workflows for a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-a-repository +func (s *RepositoriesService) GetActionsAllowed(ctx context.Context, org, repo string) (*ActionsAllowed, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/permissions/selected-actions", org, repo) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + actionsAllowed := new(ActionsAllowed) + resp, err := s.client.Do(ctx, req, actionsAllowed) + if err != nil { + return nil, resp, err + } + + return actionsAllowed, resp, nil +} + +// EditActionsAllowed sets the allowed actions and reusable workflows for a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-allowed-actions-and-reusable-workflows-for-a-repository +func (s *RepositoriesService) EditActionsAllowed(ctx context.Context, org, repo string, actionsAllowed ActionsAllowed) (*ActionsAllowed, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/permissions/selected-actions", org, repo) + req, err := s.client.NewRequest("PUT", u, actionsAllowed) + if err != nil { + return nil, nil, err + } + + p := new(ActionsAllowed) + resp, err := s.client.Do(ctx, req, p) + if err != nil { + return nil, resp, err + } + + return p, resp, nil +} diff --git a/vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go b/vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go new file mode 100644 index 00000000..45f844ce --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go @@ -0,0 +1,62 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// ActionsPermissionsRepository represents a policy for repositories and allowed actions in a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions +type ActionsPermissionsRepository struct { + Enabled *bool `json:"enabled,omitempty"` + AllowedActions *string `json:"allowed_actions,omitempty"` + SelectedActionsURL *string `json:"selected_actions_url,omitempty"` +} + +func (a ActionsPermissionsRepository) String() string { + return Stringify(a) +} + +// GetActionsPermissions gets the GitHub Actions permissions policy for repositories and allowed actions in a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#get-github-actions-permissions-for-a-repository +func (s *RepositoriesService) GetActionsPermissions(ctx context.Context, owner, repo string) (*ActionsPermissionsRepository, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/permissions", owner, repo) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + permissions := new(ActionsPermissionsRepository) + resp, err := s.client.Do(ctx, req, permissions) + if err != nil { + return nil, resp, err + } + + return permissions, resp, nil +} + +// EditActionsPermissions sets the permissions policy for repositories and allowed actions in a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/actions/permissions#set-github-actions-permissions-for-a-repository +func (s *RepositoriesService) EditActionsPermissions(ctx context.Context, owner, repo string, actionsPermissionsRepository ActionsPermissionsRepository) (*ActionsPermissionsRepository, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/actions/permissions", owner, repo) + req, err := s.client.NewRequest("PUT", u, actionsPermissionsRepository) + if err != nil { + return nil, nil, err + } + + permissions := new(ActionsPermissionsRepository) + resp, err := s.client.Do(ctx, req, permissions) + if err != nil { + return nil, resp, err + } + + return permissions, resp, nil +} diff --git a/vendor/github.com/google/go-github/v43/github/repos_autolinks.go b/vendor/github.com/google/go-github/v47/github/repos_autolinks.go similarity index 77% rename from vendor/github.com/google/go-github/v43/github/repos_autolinks.go rename to vendor/github.com/google/go-github/v47/github/repos_autolinks.go index b6404783..0d2cec61 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_autolinks.go +++ b/vendor/github.com/google/go-github/v47/github/repos_autolinks.go @@ -12,21 +12,23 @@ import ( // AutolinkOptions specifies parameters for RepositoriesService.AddAutolink method. type AutolinkOptions struct { - KeyPrefix *string `json:"key_prefix,omitempty"` - URLTemplate *string `json:"url_template,omitempty"` + KeyPrefix *string `json:"key_prefix,omitempty"` + URLTemplate *string `json:"url_template,omitempty"` + IsAlphanumeric *bool `json:"is_alphanumeric,omitempty"` } // Autolink represents autolinks to external resources like JIRA issues and Zendesk tickets. type Autolink struct { - ID *int64 `json:"id,omitempty"` - KeyPrefix *string `json:"key_prefix,omitempty"` - URLTemplate *string `json:"url_template,omitempty"` + ID *int64 `json:"id,omitempty"` + KeyPrefix *string `json:"key_prefix,omitempty"` + URLTemplate *string `json:"url_template,omitempty"` + IsAlphanumeric *bool `json:"is_alphanumeric,omitempty"` } // ListAutolinks returns a list of autolinks configured for the given repository. // Information about autolinks are only available to repository administrators. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#list-all-autolinks-of-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#list-all-autolinks-of-a-repository func (s *RepositoriesService) ListAutolinks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Autolink, *Response, error) { u := fmt.Sprintf("repos/%v/%v/autolinks", owner, repo) u, err := addOptions(u, opts) @@ -51,7 +53,7 @@ func (s *RepositoriesService) ListAutolinks(ctx context.Context, owner, repo str // AddAutolink creates an autolink reference for a repository. // Users with admin access to the repository can create an autolink. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#create-an-autolink-reference-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#create-an-autolink-reference-for-a-repository func (s *RepositoriesService) AddAutolink(ctx context.Context, owner, repo string, opts *AutolinkOptions) (*Autolink, *Response, error) { u := fmt.Sprintf("repos/%v/%v/autolinks", owner, repo) req, err := s.client.NewRequest("POST", u, opts) @@ -70,7 +72,7 @@ func (s *RepositoriesService) AddAutolink(ctx context.Context, owner, repo strin // GetAutolink returns a single autolink reference by ID that was configured for the given repository. // Information about autolinks are only available to repository administrators. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-an-autolink-reference-of-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#get-an-autolink-reference-of-a-repository func (s *RepositoriesService) GetAutolink(ctx context.Context, owner, repo string, id int64) (*Autolink, *Response, error) { u := fmt.Sprintf("repos/%v/%v/autolinks/%v", owner, repo, id) @@ -91,7 +93,7 @@ func (s *RepositoriesService) GetAutolink(ctx context.Context, owner, repo strin // DeleteAutolink deletes a single autolink reference by ID that was configured for the given repository. // Information about autolinks are only available to repository administrators. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#delete-an-autolink-reference-from-a-repository +// GitHub API docs: https://docs.github.com/en/rest/repos/autolinks#delete-an-autolink-reference-from-a-repository func (s *RepositoriesService) DeleteAutolink(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/autolinks/%v", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v47/github/repos_codeowners.go b/vendor/github.com/google/go-github/v47/github/repos_codeowners.go new file mode 100644 index 00000000..835d56e1 --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/repos_codeowners.go @@ -0,0 +1,46 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// CodeownersErrors represents a list of syntax errors detected in the CODEOWNERS file. +type CodeownersErrors struct { + Errors []*CodeownersError `json:"errors"` +} + +// CodeownersError represents a syntax error detected in the CODEOWNERS file. +type CodeownersError struct { + Line int `json:"line"` + Column int `json:"column"` + Kind string `json:"kind"` + Source string `json:"source"` + Suggestion *string `json:"suggestion,omitempty"` + Message string `json:"message"` + Path string `json:"path"` +} + +// GetCodeownersErrors lists any syntax errors that are detected in the CODEOWNERS file. +// +// GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-codeowners-errors +func (s *RepositoriesService) GetCodeownersErrors(ctx context.Context, owner, repo string) (*CodeownersErrors, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/codeowners/errors", owner, repo) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + codeownersErrors := &CodeownersErrors{} + resp, err := s.client.Do(ctx, req, codeownersErrors) + if err != nil { + return nil, resp, err + } + + return codeownersErrors, resp, nil +} diff --git a/vendor/github.com/google/go-github/v43/github/repos_collaborators.go b/vendor/github.com/google/go-github/v47/github/repos_collaborators.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/repos_collaborators.go rename to vendor/github.com/google/go-github/v47/github/repos_collaborators.go index ccb97a19..abc4161c 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_collaborators.go +++ b/vendor/github.com/google/go-github/v47/github/repos_collaborators.go @@ -27,7 +27,7 @@ type ListCollaboratorsOptions struct { } // CollaboratorInvitation represents an invitation created when adding a collaborator. -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/collaborators/#response-when-a-new-invitation-is-created +// GitHub API docs: https://docs.github.com/en/rest/repos/collaborators/#response-when-a-new-invitation-is-created type CollaboratorInvitation struct { ID *int64 `json:"id,omitempty"` Repo *Repository `json:"repository,omitempty"` @@ -41,7 +41,7 @@ type CollaboratorInvitation struct { // ListCollaborators lists the GitHub users that have access to the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-collaborators +// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#list-repository-collaborators func (s *RepositoriesService) ListCollaborators(ctx context.Context, owner, repo string, opts *ListCollaboratorsOptions) ([]*User, *Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators", owner, repo) u, err := addOptions(u, opts) @@ -68,7 +68,7 @@ func (s *RepositoriesService) ListCollaborators(ctx context.Context, owner, repo // Note: This will return false if the user is not a collaborator OR the user // is not a GitHub user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#check-if-a-user-is-a-repository-collaborator +// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#check-if-a-user-is-a-repository-collaborator func (s *RepositoriesService) IsCollaborator(ctx context.Context, owner, repo, user string) (bool, *Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user) req, err := s.client.NewRequest("GET", u, nil) @@ -91,7 +91,8 @@ type RepositoryPermissionLevel struct { } // GetPermissionLevel retrieves the specific permission level a collaborator has for a given repository. -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-repository-permissions-for-a-user +// +// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user func (s *RepositoriesService) GetPermissionLevel(ctx context.Context, owner, repo, user string) (*RepositoryPermissionLevel, *Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators/%v/permission", owner, repo, user) req, err := s.client.NewRequest("GET", u, nil) @@ -104,6 +105,7 @@ func (s *RepositoriesService) GetPermissionLevel(ctx context.Context, owner, rep if err != nil { return nil, resp, err } + return rpl, resp, nil } @@ -125,30 +127,33 @@ type RepositoryAddCollaboratorOptions struct { // AddCollaborator sends an invitation to the specified GitHub user // to become a collaborator to the given repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#add-a-repository-collaborator +// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#add-a-repository-collaborator func (s *RepositoriesService) AddCollaborator(ctx context.Context, owner, repo, user string, opts *RepositoryAddCollaboratorOptions) (*CollaboratorInvitation, *Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, nil, err } + acr := new(CollaboratorInvitation) resp, err := s.client.Do(ctx, req, acr) if err != nil { return nil, resp, err } + return acr, resp, nil } // RemoveCollaborator removes the specified GitHub user as collaborator from the given repo. // Note: Does not return error if a valid user that is not a collaborator is removed. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#remove-a-repository-collaborator +// GitHub API docs: https://docs.github.com/en/rest/collaborators/collaborators#remove-a-repository-collaborator func (s *RepositoriesService) RemoveCollaborator(ctx context.Context, owner, repo, user string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/collaborators/%v", owner, repo, user) req, err := s.client.NewRequest("DELETE", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } diff --git a/vendor/github.com/google/go-github/v43/github/repos_comments.go b/vendor/github.com/google/go-github/v47/github/repos_comments.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/repos_comments.go rename to vendor/github.com/google/go-github/v47/github/repos_comments.go index 912eeba3..55a88d1f 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_comments.go +++ b/vendor/github.com/google/go-github/v47/github/repos_comments.go @@ -36,7 +36,7 @@ func (r RepositoryComment) String() string { // ListComments lists all the comments for the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commit-comments-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/commits/comments#list-commit-comments-for-a-repository func (s *RepositoriesService) ListComments(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/comments", owner, repo) u, err := addOptions(u, opts) @@ -63,7 +63,7 @@ func (s *RepositoriesService) ListComments(ctx context.Context, owner, repo stri // ListCommitComments lists all the comments for a given commit SHA. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commit-comments +// GitHub API docs: https://docs.github.com/en/rest/commits/comments#list-commit-comments func (s *RepositoriesService) ListCommitComments(ctx context.Context, owner, repo, sha string, opts *ListOptions) ([]*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/comments", owner, repo, sha) u, err := addOptions(u, opts) @@ -91,7 +91,7 @@ func (s *RepositoriesService) ListCommitComments(ctx context.Context, owner, rep // CreateComment creates a comment for the given commit. // Note: GitHub allows for comments to be created for non-existing files and positions. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-commit-comment +// GitHub API docs: https://docs.github.com/en/rest/commits/comments#create-a-commit-comment func (s *RepositoriesService) CreateComment(ctx context.Context, owner, repo, sha string, comment *RepositoryComment) (*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/comments", owner, repo, sha) req, err := s.client.NewRequest("POST", u, comment) @@ -110,7 +110,7 @@ func (s *RepositoriesService) CreateComment(ctx context.Context, owner, repo, sh // GetComment gets a single comment from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit-comment +// GitHub API docs: https://docs.github.com/en/rest/commits/comments#get-a-commit-comment func (s *RepositoriesService) GetComment(ctx context.Context, owner, repo string, id int64) (*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) @@ -132,7 +132,7 @@ func (s *RepositoriesService) GetComment(ctx context.Context, owner, repo string // UpdateComment updates the body of a single comment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-commit-comment +// GitHub API docs: https://docs.github.com/en/rest/commits/comments#update-a-commit-comment func (s *RepositoriesService) UpdateComment(ctx context.Context, owner, repo string, id int64, comment *RepositoryComment) (*RepositoryComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id) req, err := s.client.NewRequest("PATCH", u, comment) @@ -151,7 +151,7 @@ func (s *RepositoriesService) UpdateComment(ctx context.Context, owner, repo str // DeleteComment deletes a single comment from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-commit-comment +// GitHub API docs: https://docs.github.com/en/rest/commits/comments#delete-a-commit-comment func (s *RepositoriesService) DeleteComment(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/comments/%v", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/repos_commits.go b/vendor/github.com/google/go-github/v47/github/repos_commits.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/repos_commits.go rename to vendor/github.com/google/go-github/v47/github/repos_commits.go index ce3b48e3..d1fb577c 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_commits.go +++ b/vendor/github.com/google/go-github/v47/github/repos_commits.go @@ -124,7 +124,7 @@ type BranchCommit struct { // ListCommits lists the commits of a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commits +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-commits func (s *RepositoriesService) ListCommits(ctx context.Context, owner, repo string, opts *CommitsListOptions) ([]*RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits", owner, repo) u, err := addOptions(u, opts) @@ -148,8 +148,8 @@ func (s *RepositoriesService) ListCommits(ctx context.Context, owner, repo strin // GetCommit fetches the specified commit, including all details about it. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-single-commit -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-single-commit +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-commit func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha string, opts *ListOptions) (*RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha) u, err := addOptions(u, opts) @@ -173,7 +173,7 @@ func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha st // GetCommitRaw fetches the specified commit in raw (diff or patch) format. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-commit func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner string, repo string, sha string, opts RawOptions) (string, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha) req, err := s.client.NewRequest("GET", u, nil) @@ -202,7 +202,7 @@ func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner string, re // GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is // supplied and no new commits have occurred, a 304 Unmodified response is returned. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-commit +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#get-a-commit func (s *RepositoriesService) GetCommitSHA1(ctx context.Context, owner, repo, ref, lastSHA string) (string, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, refURLEscape(ref)) @@ -227,7 +227,7 @@ func (s *RepositoriesService) GetCommitSHA1(ctx context.Context, owner, repo, re // CompareCommits compares a range of commits with each other. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#compare-two-commits +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#compare-two-commits func (s *RepositoriesService) CompareCommits(ctx context.Context, owner, repo string, base, head string, opts *ListOptions) (*CommitsComparison, *Response, error) { escapedBase := url.QueryEscape(base) escapedHead := url.QueryEscape(head) @@ -258,7 +258,7 @@ func (s *RepositoriesService) CompareCommits(ctx context.Context, owner, repo st // To compare branches across other repositories in the same network as "repo", // use the format ":branch". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#compare-two-commits +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#compare-two-commits func (s *RepositoriesService) CompareCommitsRaw(ctx context.Context, owner, repo, base, head string, opts RawOptions) (string, *Response, error) { escapedBase := url.QueryEscape(base) escapedHead := url.QueryEscape(head) @@ -291,7 +291,7 @@ func (s *RepositoriesService) CompareCommitsRaw(ctx context.Context, owner, repo // ListBranchesHeadCommit gets all branches where the given commit SHA is the HEAD, // or latest commit for the branch. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-branches-for-head-commit +// GitHub API docs: https://docs.github.com/en/rest/commits/commits#list-branches-for-head-commit func (s *RepositoriesService) ListBranchesHeadCommit(ctx context.Context, owner, repo, sha string) ([]*BranchCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/branches-where-head", owner, repo, sha) diff --git a/vendor/github.com/google/go-github/v43/github/repos_community_health.go b/vendor/github.com/google/go-github/v47/github/repos_community_health.go similarity index 95% rename from vendor/github.com/google/go-github/v43/github/repos_community_health.go rename to vendor/github.com/google/go-github/v47/github/repos_community_health.go index 92e4d082..9de438b6 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_community_health.go +++ b/vendor/github.com/google/go-github/v47/github/repos_community_health.go @@ -44,7 +44,7 @@ type CommunityHealthMetrics struct { // GetCommunityHealthMetrics retrieves all the community health metrics for a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-community-profile-metrics +// GitHub API docs: https://docs.github.com/en/rest/metrics/community#get-community-profile-metrics func (s *RepositoriesService) GetCommunityHealthMetrics(ctx context.Context, owner, repo string) (*CommunityHealthMetrics, *Response, error) { u := fmt.Sprintf("repos/%v/%v/community/profile", owner, repo) req, err := s.client.NewRequest("GET", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/repos_contents.go b/vendor/github.com/google/go-github/v47/github/repos_contents.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/repos_contents.go rename to vendor/github.com/google/go-github/v47/github/repos_contents.go index 86e11c0a..be58fd52 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_contents.go +++ b/vendor/github.com/google/go-github/v47/github/repos_contents.go @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file. // Repository contents API methods. -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/contents/ +// GitHub API docs: https://docs.github.com/en/rest/repos/contents/ package github @@ -51,7 +51,7 @@ type RepositoryContentResponse struct { // RepositoryContentFileOptions specifies optional parameters for CreateFile, UpdateFile, and DeleteFile. type RepositoryContentFileOptions struct { Message *string `json:"message,omitempty"` - Content []byte `json:"content,omitempty"` // unencoded + Content []byte `json:"content"` // unencoded SHA *string `json:"sha,omitempty"` Branch *string `json:"branch,omitempty"` Author *CommitAuthor `json:"author,omitempty"` @@ -95,22 +95,25 @@ func (r *RepositoryContent) GetContent() (string, error) { // GetReadme gets the Readme file for the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository-readme +// GitHub API docs: https://docs.github.com/en/rest/repos/contents#get-a-repository-readme func (s *RepositoriesService) GetReadme(ctx context.Context, owner, repo string, opts *RepositoryContentGetOptions) (*RepositoryContent, *Response, error) { u := fmt.Sprintf("repos/%v/%v/readme", owner, repo) u, err := addOptions(u, opts) if err != nil { return nil, nil, err } + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, err } + readme := new(RepositoryContent) resp, err := s.client.Do(ctx, req, readme) if err != nil { return nil, resp, err } + return readme, resp, nil } @@ -129,18 +132,22 @@ func (s *RepositoriesService) DownloadContents(ctx context.Context, owner, repo, if err != nil { return nil, resp, err } + for _, contents := range dirContents { if *contents.Name == filename { if contents.DownloadURL == nil || *contents.DownloadURL == "" { return nil, resp, fmt.Errorf("no download link found for %s", filepath) } + dlResp, err := s.client.client.Get(*contents.DownloadURL) if err != nil { return nil, &Response{Response: dlResp}, err } + return dlResp.Body, &Response{Response: dlResp}, nil } } + return nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir) } @@ -159,18 +166,22 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne if err != nil { return nil, nil, resp, err } + for _, contents := range dirContents { if *contents.Name == filename { if contents.DownloadURL == nil || *contents.DownloadURL == "" { return nil, contents, resp, fmt.Errorf("no download link found for %s", filepath) } + dlResp, err := s.client.client.Get(*contents.DownloadURL) if err != nil { return nil, contents, &Response{Response: dlResp}, err } + return dlResp.Body, contents, &Response{Response: dlResp}, nil } } + return nil, nil, resp, fmt.Errorf("no file named %s found in %s", filename, dir) } @@ -181,7 +192,7 @@ func (s *RepositoriesService) DownloadContentsWithMeta(ctx context.Context, owne // as possible, both result types will be returned but only one will contain a // value and the other will be nil. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-repository-content +// GitHub API docs: https://docs.github.com/en/rest/repos/contents#get-repository-content func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path string, opts *RepositoryContentGetOptions) (fileContent *RepositoryContent, directoryContent []*RepositoryContent, resp *Response, err error) { escapedPath := (&url.URL{Path: strings.TrimSuffix(path, "/")}).String() u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, escapedPath) @@ -189,77 +200,88 @@ func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path if err != nil { return nil, nil, nil, err } + req, err := s.client.NewRequest("GET", u, nil) if err != nil { return nil, nil, nil, err } + var rawJSON json.RawMessage resp, err = s.client.Do(ctx, req, &rawJSON) if err != nil { return nil, nil, resp, err } + fileUnmarshalError := json.Unmarshal(rawJSON, &fileContent) if fileUnmarshalError == nil { return fileContent, nil, resp, nil } + directoryUnmarshalError := json.Unmarshal(rawJSON, &directoryContent) if directoryUnmarshalError == nil { return nil, directoryContent, resp, nil } + return nil, nil, resp, fmt.Errorf("unmarshalling failed for both file and directory content: %s and %s", fileUnmarshalError, directoryUnmarshalError) } // CreateFile creates a new file in a repository at the given path and returns // the commit and file metadata. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-or-update-file-contents +// GitHub API docs: https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, nil, err } + createResponse := new(RepositoryContentResponse) resp, err := s.client.Do(ctx, req, createResponse) if err != nil { return nil, resp, err } + return createResponse, resp, nil } // UpdateFile updates a file in a repository at the given path and returns the // commit and file metadata. Requires the blob SHA of the file being updated. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-or-update-file-contents +// GitHub API docs: https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents func (s *RepositoriesService) UpdateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path) req, err := s.client.NewRequest("PUT", u, opts) if err != nil { return nil, nil, err } + updateResponse := new(RepositoryContentResponse) resp, err := s.client.Do(ctx, req, updateResponse) if err != nil { return nil, resp, err } + return updateResponse, resp, nil } // DeleteFile deletes a file from a repository and returns the commit. // Requires the blob SHA of the file to be deleted. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-file +// GitHub API docs: https://docs.github.com/en/rest/repos/contents#delete-a-file func (s *RepositoriesService) DeleteFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { u := fmt.Sprintf("repos/%s/%s/contents/%s", owner, repo, path) req, err := s.client.NewRequest("DELETE", u, opts) if err != nil { return nil, nil, err } + deleteResponse := new(RepositoryContentResponse) resp, err := s.client.Do(ctx, req, deleteResponse) if err != nil { return nil, resp, err } + return deleteResponse, resp, nil } @@ -278,46 +300,26 @@ const ( // repository. The archiveFormat can be specified by either the github.Tarball // or github.Zipball constant. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/contents/#get-archive-link +// GitHub API docs: https://docs.github.com/en/rest/repos/contents/#get-archive-link func (s *RepositoriesService) GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, followRedirects bool) (*url.URL, *Response, error) { u := fmt.Sprintf("repos/%s/%s/%s", owner, repo, archiveformat) if opts != nil && opts.Ref != "" { u += fmt.Sprintf("/%s", opts.Ref) } - resp, err := s.getArchiveLinkFromURL(ctx, u, followRedirects) + resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, followRedirects) if err != nil { return nil, nil, err } + defer resp.Body.Close() + if resp.StatusCode != http.StatusFound { return nil, newResponse(resp), fmt.Errorf("unexpected status code: %s", resp.Status) } + parsedURL, err := url.Parse(resp.Header.Get("Location")) - return parsedURL, newResponse(resp), err -} - -func (s *RepositoriesService) getArchiveLinkFromURL(ctx context.Context, u string, followRedirects bool) (*http.Response, error) { - req, err := s.client.NewRequest("GET", u, nil) if err != nil { - return nil, err + return nil, newResponse(resp), err } - var resp *http.Response - // Use http.DefaultTransport if no custom Transport is configured - req = withContext(ctx, req) - if s.client.client.Transport == nil { - resp, err = http.DefaultTransport.RoundTrip(req) - } else { - resp, err = s.client.client.Transport.RoundTrip(req) - } - if err != nil { - return nil, err - } - resp.Body.Close() - - // If redirect response is returned, follow it - if followRedirects && resp.StatusCode == http.StatusMovedPermanently { - u = resp.Header.Get("Location") - resp, err = s.getArchiveLinkFromURL(ctx, u, false) - } - return resp, err + return parsedURL, newResponse(resp), nil } diff --git a/vendor/github.com/google/go-github/v43/github/repos_deployments.go b/vendor/github.com/google/go-github/v47/github/repos_deployments.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/repos_deployments.go rename to vendor/github.com/google/go-github/v47/github/repos_deployments.go index 7308bceb..36445f89 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_deployments.go +++ b/vendor/github.com/google/go-github/v47/github/repos_deployments.go @@ -63,7 +63,7 @@ type DeploymentsListOptions struct { // ListDeployments lists the deployments of a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-deployments +// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#list-deployments func (s *RepositoriesService) ListDeployments(ctx context.Context, owner, repo string, opts *DeploymentsListOptions) ([]*Deployment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo) u, err := addOptions(u, opts) @@ -87,7 +87,7 @@ func (s *RepositoriesService) ListDeployments(ctx context.Context, owner, repo s // GetDeployment returns a single deployment of a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-deployment +// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#get-a-deployment func (s *RepositoriesService) GetDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Deployment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments/%v", owner, repo, deploymentID) @@ -107,7 +107,7 @@ func (s *RepositoriesService) GetDeployment(ctx context.Context, owner, repo str // CreateDeployment creates a new deployment for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-deployment +// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#create-a-deployment func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo string, request *DeploymentRequest) (*Deployment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments", owner, repo) @@ -131,7 +131,7 @@ func (s *RepositoriesService) CreateDeployment(ctx context.Context, owner, repo // DeleteDeployment deletes an existing deployment for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-deployment +// GitHub API docs: https://docs.github.com/en/rest/deployments/deployments#delete-a-deployment func (s *RepositoriesService) DeleteDeployment(ctx context.Context, owner, repo string, deploymentID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments/%v", owner, repo, deploymentID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -175,7 +175,7 @@ type DeploymentStatusRequest struct { // ListDeploymentStatuses lists the statuses of a given deployment of a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-deployment-statuses +// GitHub API docs: https://docs.github.com/en/rest/deployments/statuses#list-deployment-statuses func (s *RepositoriesService) ListDeploymentStatuses(ctx context.Context, owner, repo string, deployment int64, opts *ListOptions) ([]*DeploymentStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment) u, err := addOptions(u, opts) @@ -203,7 +203,7 @@ func (s *RepositoriesService) ListDeploymentStatuses(ctx context.Context, owner, // GetDeploymentStatus returns a single deployment status of a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-deployment-status +// GitHub API docs: https://docs.github.com/en/rest/deployments/statuses#get-a-deployment-status func (s *RepositoriesService) GetDeploymentStatus(ctx context.Context, owner, repo string, deploymentID, deploymentStatusID int64) (*DeploymentStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses/%v", owner, repo, deploymentID, deploymentStatusID) @@ -227,7 +227,7 @@ func (s *RepositoriesService) GetDeploymentStatus(ctx context.Context, owner, re // CreateDeploymentStatus creates a new status for a deployment. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-deployment-status +// GitHub API docs: https://docs.github.com/en/rest/deployments/statuses#create-a-deployment-status func (s *RepositoriesService) CreateDeploymentStatus(ctx context.Context, owner, repo string, deployment int64, request *DeploymentStatusRequest) (*DeploymentStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/deployments/%v/statuses", owner, repo, deployment) diff --git a/vendor/github.com/google/go-github/v43/github/repos_environments.go b/vendor/github.com/google/go-github/v47/github/repos_environments.go similarity index 94% rename from vendor/github.com/google/go-github/v43/github/repos_environments.go rename to vendor/github.com/google/go-github/v47/github/repos_environments.go index 5dd45428..365f8d92 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_environments.go +++ b/vendor/github.com/google/go-github/v47/github/repos_environments.go @@ -104,7 +104,7 @@ func (r *RequiredReviewer) UnmarshalJSON(data []byte) error { // ListEnvironments lists all environments for a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-all-environments +// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#get-all-environments func (s *RepositoriesService) ListEnvironments(ctx context.Context, owner, repo string, opts *EnvironmentListOptions) (*EnvResponse, *Response, error) { u := fmt.Sprintf("repos/%s/%s/environments", owner, repo) u, err := addOptions(u, opts) @@ -127,7 +127,7 @@ func (s *RepositoriesService) ListEnvironments(ctx context.Context, owner, repo // GetEnvironment get a single environment for a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-an-environment +// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#get-an-environment func (s *RepositoriesService) GetEnvironment(ctx context.Context, owner, repo, name string) (*Environment, *Response, error) { u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name) @@ -170,7 +170,7 @@ type CreateUpdateEnvironment struct { // CreateUpdateEnvironment create or update a new environment for a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#create-or-update-an-environment +// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment func (s *RepositoriesService) CreateUpdateEnvironment(ctx context.Context, owner, repo, name string, environment *CreateUpdateEnvironment) (*Environment, *Response, error) { u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name) @@ -189,7 +189,7 @@ func (s *RepositoriesService) CreateUpdateEnvironment(ctx context.Context, owner // DeleteEnvironment delete an environment from a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#delete-an-environment +// GitHub API docs: https://docs.github.com/en/rest/deployments/environments#delete-an-environment func (s *RepositoriesService) DeleteEnvironment(ctx context.Context, owner, repo, name string) (*Response, error) { u := fmt.Sprintf("repos/%s/%s/environments/%s", owner, repo, name) diff --git a/vendor/github.com/google/go-github/v43/github/repos_forks.go b/vendor/github.com/google/go-github/v47/github/repos_forks.go similarity index 89% rename from vendor/github.com/google/go-github/v43/github/repos_forks.go rename to vendor/github.com/google/go-github/v47/github/repos_forks.go index 74b9b445..5c7d5dbd 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_forks.go +++ b/vendor/github.com/google/go-github/v47/github/repos_forks.go @@ -24,7 +24,7 @@ type RepositoryListForksOptions struct { // ListForks lists the forks of the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-forks +// GitHub API docs: https://docs.github.com/en/rest/repos/forks#list-forks func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, opts *RepositoryListForksOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) u, err := addOptions(u, opts) @@ -53,7 +53,9 @@ func (s *RepositoriesService) ListForks(ctx context.Context, owner, repo string, // RepositoriesService.CreateFork method. type RepositoryCreateForkOptions struct { // The organization to fork the repository into. - Organization string `url:"organization,omitempty"` + Organization string `url:"organization,omitempty"` + Name string `url:"name,omitempty"` + DefaultBranchOnly bool `url:"default_branch_only,omitempty"` } // CreateFork creates a fork of the specified repository. @@ -65,7 +67,7 @@ type RepositoryCreateForkOptions struct { // A follow up request, after a delay of a second or so, should result // in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-fork +// GitHub API docs: https://docs.github.com/en/rest/repos/forks#create-a-fork func (s *RepositoriesService) CreateFork(ctx context.Context, owner, repo string, opts *RepositoryCreateForkOptions) (*Repository, *Response, error) { u := fmt.Sprintf("repos/%v/%v/forks", owner, repo) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/repos_hooks.go b/vendor/github.com/google/go-github/v47/github/repos_hooks.go similarity index 67% rename from vendor/github.com/google/go-github/v43/github/repos_hooks.go rename to vendor/github.com/google/go-github/v47/github/repos_hooks.go index 6afec860..44eac8a4 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_hooks.go +++ b/vendor/github.com/google/go-github/v47/github/repos_hooks.go @@ -8,6 +8,9 @@ package github import ( "context" "fmt" + "net/http" + "net/url" + "strings" "time" ) @@ -18,57 +21,22 @@ import ( // here to account for these differences. // // GitHub API docs: https://help.github.com/articles/post-receive-hooks -type WebHookPayload struct { - Action *string `json:"action,omitempty"` - After *string `json:"after,omitempty"` - Before *string `json:"before,omitempty"` - Commits []*WebHookCommit `json:"commits,omitempty"` - Compare *string `json:"compare,omitempty"` - Created *bool `json:"created,omitempty"` - Deleted *bool `json:"deleted,omitempty"` - Forced *bool `json:"forced,omitempty"` - HeadCommit *WebHookCommit `json:"head_commit,omitempty"` - Installation *Installation `json:"installation,omitempty"` - Organization *Organization `json:"organization,omitempty"` - Pusher *User `json:"pusher,omitempty"` - Ref *string `json:"ref,omitempty"` - Repo *Repository `json:"repository,omitempty"` - Sender *User `json:"sender,omitempty"` -} - -func (w WebHookPayload) String() string { - return Stringify(w) -} +// +// Deprecated: Please use PushEvent instead. +type WebHookPayload = PushEvent // WebHookCommit represents the commit variant we receive from GitHub in a // WebHookPayload. -type WebHookCommit struct { - Added []string `json:"added,omitempty"` - Author *WebHookAuthor `json:"author,omitempty"` - Committer *WebHookAuthor `json:"committer,omitempty"` - Distinct *bool `json:"distinct,omitempty"` - ID *string `json:"id,omitempty"` - Message *string `json:"message,omitempty"` - Modified []string `json:"modified,omitempty"` - Removed []string `json:"removed,omitempty"` - Timestamp *time.Time `json:"timestamp,omitempty"` -} - -func (w WebHookCommit) String() string { - return Stringify(w) -} +// +// Deprecated: Please use HeadCommit instead. +type WebHookCommit = HeadCommit // WebHookAuthor represents the author or committer of a commit, as specified // in a WebHookCommit. The commit author may not correspond to a GitHub User. -type WebHookAuthor struct { - Email *string `json:"email,omitempty"` - Name *string `json:"name,omitempty"` - Username *string `json:"username,omitempty"` -} - -func (w WebHookAuthor) String() string { - return Stringify(w) -} +// +// Deprecated: Please use CommitAuthor instead. +// NOTE Breaking API change: the `Username` field is now called `Login`. +type WebHookAuthor = CommitAuthor // Hook represents a GitHub (web and service) hook for a repository. type Hook struct { @@ -112,7 +80,7 @@ type createHookRequest struct { // Note that only a subset of the hook fields are used and hook must // not be nil. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#create-a-repository-webhook func (s *RepositoriesService) CreateHook(ctx context.Context, owner, repo string, hook *Hook) (*Hook, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo) @@ -139,7 +107,7 @@ func (s *RepositoriesService) CreateHook(ctx context.Context, owner, repo string // ListHooks lists all Hooks for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-webhooks +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#list-repository-webhooks func (s *RepositoriesService) ListHooks(ctx context.Context, owner, repo string, opts *ListOptions) ([]*Hook, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks", owner, repo) u, err := addOptions(u, opts) @@ -163,7 +131,7 @@ func (s *RepositoriesService) ListHooks(ctx context.Context, owner, repo string, // GetHook returns a single specified Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#get-a-repository-webhook func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, id int64) (*Hook, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) @@ -181,7 +149,7 @@ func (s *RepositoriesService) GetHook(ctx context.Context, owner, repo string, i // EditHook updates a specified Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#update-a-repository-webhook func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string, id int64, hook *Hook) (*Hook, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id) req, err := s.client.NewRequest("PATCH", u, hook) @@ -199,7 +167,7 @@ func (s *RepositoriesService) EditHook(ctx context.Context, owner, repo string, // DeleteHook deletes a specified Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#delete-a-repository-webhook func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%d", owner, repo, id) req, err := s.client.NewRequest("DELETE", u, nil) @@ -211,7 +179,7 @@ func (s *RepositoriesService) DeleteHook(ctx context.Context, owner, repo string // PingHook triggers a 'ping' event to be sent to the Hook. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#ping-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#ping-a-repository-webhook func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%d/pings", owner, repo, id) req, err := s.client.NewRequest("POST", u, nil) @@ -223,7 +191,7 @@ func (s *RepositoriesService) PingHook(ctx context.Context, owner, repo string, // TestHook triggers a test Hook by github. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#test-the-push-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repos#test-the-push-repository-webhook func (s *RepositoriesService) TestHook(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%d/tests", owner, repo, id) req, err := s.client.NewRequest("POST", u, nil) @@ -232,3 +200,55 @@ func (s *RepositoriesService) TestHook(ctx context.Context, owner, repo string, } return s.client.Do(ctx, req, nil) } + +// Subscribe lets servers register to receive updates when a topic is updated. +// +// GitHub API docs: https://docs.github.com/en/rest/webhooks#pubsubhubbub +func (s *RepositoriesService) Subscribe(ctx context.Context, owner, repo, event, callback string, secret []byte) (*Response, error) { + req, err := s.createWebSubRequest("subscribe", owner, repo, event, callback, secret) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + +// Unsubscribe lets servers unregister to no longer receive updates when a topic is updated. +// +// GitHub API docs: https://docs.github.com/en/rest/webhooks#pubsubhubbub +func (s *RepositoriesService) Unsubscribe(ctx context.Context, owner, repo, event, callback string, secret []byte) (*Response, error) { + req, err := s.createWebSubRequest("unsubscribe", owner, repo, event, callback, secret) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} + +// createWebSubRequest returns a subscribe/unsubscribe request that implements +// the WebSub (formerly PubSubHubbub) protocol. +// +// See: https://www.w3.org/TR/websub/#subscriber-sends-subscription-request +func (s *RepositoriesService) createWebSubRequest(hubMode, owner, repo, event, callback string, secret []byte) (*http.Request, error) { + topic := fmt.Sprintf( + "https://github.com/%s/%s/events/%s", + owner, + repo, + event, + ) + form := url.Values{} + form.Add("hub.mode", hubMode) + form.Add("hub.topic", topic) + form.Add("hub.callback", callback) + if secret != nil { + form.Add("hub.secret", string(secret)) + } + body := strings.NewReader(form.Encode()) + + req, err := s.client.NewFormRequest("hub", body) + if err != nil { + return nil, err + } + + return req, nil +} diff --git a/vendor/github.com/google/go-github/v43/github/repos_hooks_deliveries.go b/vendor/github.com/google/go-github/v47/github/repos_hooks_deliveries.go similarity index 75% rename from vendor/github.com/google/go-github/v43/github/repos_hooks_deliveries.go rename to vendor/github.com/google/go-github/v47/github/repos_hooks_deliveries.go index 17132695..cbd2d381 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_hooks_deliveries.go +++ b/vendor/github.com/google/go-github/v47/github/repos_hooks_deliveries.go @@ -14,8 +14,8 @@ import ( // HookDelivery represents the data that is received from GitHub's Webhook Delivery API // // GitHub API docs: -// - https://docs.github.com/en/rest/reference/repos#list-deliveries-for-a-repository-webhook -// - https://docs.github.com/en/rest/reference/repos#get-a-delivery-for-a-repository-webhook +// - https://docs.github.com/en/rest/webhooks/repo-deliveries#list-deliveries-for-a-repository-webhook +// - https://docs.github.com/en/rest/webhooks/repo-deliveries#get-a-delivery-for-a-repository-webhook type HookDelivery struct { ID *int64 `json:"id,omitempty"` GUID *string `json:"guid,omitempty"` @@ -63,7 +63,7 @@ func (r HookResponse) String() string { // ListHookDeliveries lists webhook deliveries for a webhook configured in a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#list-deliveries-for-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repo-deliveries#list-deliveries-for-a-repository-webhook func (s *RepositoriesService) ListHookDeliveries(ctx context.Context, owner, repo string, id int64, opts *ListCursorOptions) ([]*HookDelivery, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%v/deliveries", owner, repo, id) u, err := addOptions(u, opts) @@ -87,7 +87,7 @@ func (s *RepositoriesService) ListHookDeliveries(ctx context.Context, owner, rep // GetHookDelivery returns a delivery for a webhook configured in a repository. // -// GitHub API docs: https://docs.github.com/en/rest/reference/repos#get-a-delivery-for-a-repository-webhook +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repo-deliveries#get-a-delivery-for-a-repository-webhook func (s *RepositoriesService) GetHookDelivery(ctx context.Context, owner, repo string, hookID, deliveryID int64) (*HookDelivery, *Response, error) { u := fmt.Sprintf("repos/%v/%v/hooks/%v/deliveries/%v", owner, repo, hookID, deliveryID) req, err := s.client.NewRequest("GET", u, nil) @@ -104,6 +104,25 @@ func (s *RepositoriesService) GetHookDelivery(ctx context.Context, owner, repo s return h, resp, nil } +// RedeliverHookDelivery redelivers a delivery for a webhook configured in a repository. +// +// GitHub API docs: https://docs.github.com/en/rest/webhooks/repo-deliveries#redeliver-a-delivery-for-a-repository-webhook +func (s *RepositoriesService) RedeliverHookDelivery(ctx context.Context, owner, repo string, hookID, deliveryID int64) (*HookDelivery, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/hooks/%v/deliveries/%v/attempts", owner, repo, hookID, deliveryID) + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, nil, err + } + + h := new(HookDelivery) + resp, err := s.client.Do(ctx, req, h) + if err != nil { + return nil, resp, err + } + + return h, resp, nil +} + // ParseRequestPayload parses the request payload. For recognized event types, // a value of the corresponding struct type will be returned. func (d *HookDelivery) ParseRequestPayload() (interface{}, error) { diff --git a/vendor/github.com/google/go-github/v43/github/repos_invitations.go b/vendor/github.com/google/go-github/v47/github/repos_invitations.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/repos_invitations.go rename to vendor/github.com/google/go-github/v47/github/repos_invitations.go index 79dd5788..81956cd4 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_invitations.go +++ b/vendor/github.com/google/go-github/v47/github/repos_invitations.go @@ -27,7 +27,7 @@ type RepositoryInvitation struct { // ListInvitations lists all currently-open repository invitations. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-invitations +// GitHub API docs: https://docs.github.com/en/rest/collaborators/invitations#list-repository-invitations func (s *RepositoriesService) ListInvitations(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryInvitation, *Response, error) { u := fmt.Sprintf("repos/%v/%v/invitations", owner, repo) u, err := addOptions(u, opts) @@ -51,7 +51,7 @@ func (s *RepositoriesService) ListInvitations(ctx context.Context, owner, repo s // DeleteInvitation deletes a repository invitation. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-repository-invitation +// GitHub API docs: https://docs.github.com/en/rest/collaborators/invitations#delete-a-repository-invitation func (s *RepositoriesService) DeleteInvitation(ctx context.Context, owner, repo string, invitationID int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/invitations/%v", owner, repo, invitationID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -68,7 +68,7 @@ func (s *RepositoriesService) DeleteInvitation(ctx context.Context, owner, repo // permissions represents the permissions that the associated user will have // on the repository. Possible values are: "read", "write", "admin". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-repository-invitation +// GitHub API docs: https://docs.github.com/en/rest/collaborators/invitations#update-a-repository-invitation func (s *RepositoriesService) UpdateInvitation(ctx context.Context, owner, repo string, invitationID int64, permissions string) (*RepositoryInvitation, *Response, error) { opts := &struct { Permissions string `json:"permissions"` diff --git a/vendor/github.com/google/go-github/v43/github/repos_keys.go b/vendor/github.com/google/go-github/v47/github/repos_keys.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/repos_keys.go rename to vendor/github.com/google/go-github/v47/github/repos_keys.go index 3e127ae4..42c5de49 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_keys.go +++ b/vendor/github.com/google/go-github/v47/github/repos_keys.go @@ -14,7 +14,7 @@ import ( // ListKeys lists the deploy keys for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-deploy-keys +// GitHub API docs: https://docs.github.com/en/rest/deploy-keys#list-deploy-keys func (s *RepositoriesService) ListKeys(ctx context.Context, owner string, repo string, opts *ListOptions) ([]*Key, *Response, error) { u := fmt.Sprintf("repos/%v/%v/keys", owner, repo) u, err := addOptions(u, opts) @@ -38,7 +38,7 @@ func (s *RepositoriesService) ListKeys(ctx context.Context, owner string, repo s // GetKey fetches a single deploy key. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-deploy-key +// GitHub API docs: https://docs.github.com/en/rest/deploy-keys#get-a-deploy-key func (s *RepositoriesService) GetKey(ctx context.Context, owner string, repo string, id int64) (*Key, *Response, error) { u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id) @@ -58,7 +58,7 @@ func (s *RepositoriesService) GetKey(ctx context.Context, owner string, repo str // CreateKey adds a deploy key for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-deploy-key +// GitHub API docs: https://docs.github.com/en/rest/deploy-keys#create-a-deploy-key func (s *RepositoriesService) CreateKey(ctx context.Context, owner string, repo string, key *Key) (*Key, *Response, error) { u := fmt.Sprintf("repos/%v/%v/keys", owner, repo) @@ -78,7 +78,7 @@ func (s *RepositoriesService) CreateKey(ctx context.Context, owner string, repo // DeleteKey deletes a deploy key. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-deploy-key +// GitHub API docs: https://docs.github.com/en/rest/deploy-keys#delete-a-deploy-key func (s *RepositoriesService) DeleteKey(ctx context.Context, owner string, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/keys/%v", owner, repo, id) diff --git a/vendor/github.com/google/go-github/v47/github/repos_lfs.go b/vendor/github.com/google/go-github/v47/github/repos_lfs.go new file mode 100644 index 00000000..6ac2e5a8 --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/repos_lfs.go @@ -0,0 +1,49 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// EnableLFS turns the LFS (Large File Storage) feature ON for the selected repo. +// +// GitHub API docs: https://docs.github.com/en/rest/repos/lfs#enable-git-lfs-for-a-repository +func (s *RepositoriesService) EnableLFS(ctx context.Context, owner, repo string) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/lfs", owner, repo) + + req, err := s.client.NewRequest("PUT", u, nil) + if err != nil { + return nil, err + } + + resp, err := s.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + + return resp, nil +} + +// DisableLFS turns the LFS (Large File Storage) feature OFF for the selected repo. +// +// GitHub API docs: https://docs.github.com/en/rest/repos/lfs#disable-git-lfs-for-a-repository +func (s *RepositoriesService) DisableLFS(ctx context.Context, owner, repo string) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/lfs", owner, repo) + + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + resp, err := s.client.Do(ctx, req, nil) + if err != nil { + return resp, err + } + + return resp, nil +} diff --git a/vendor/github.com/google/go-github/v47/github/repos_merging.go b/vendor/github.com/google/go-github/v47/github/repos_merging.go new file mode 100644 index 00000000..66e88452 --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/repos_merging.go @@ -0,0 +1,72 @@ +// Copyright 2014 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// RepositoryMergeRequest represents a request to merge a branch in a +// repository. +type RepositoryMergeRequest struct { + Base *string `json:"base,omitempty"` + Head *string `json:"head,omitempty"` + CommitMessage *string `json:"commit_message,omitempty"` +} + +// RepoMergeUpstreamRequest represents a request to sync a branch of +// a forked repository to keep it up-to-date with the upstream repository. +type RepoMergeUpstreamRequest struct { + Branch *string `json:"branch,omitempty"` +} + +// RepoMergeUpstreamResult represents the result of syncing a branch of +// a forked repository with the upstream repository. +type RepoMergeUpstreamResult struct { + Message *string `json:"message,omitempty"` + MergeType *string `json:"merge_type,omitempty"` + BaseBranch *string `json:"base_branch,omitempty"` +} + +// Merge a branch in the specified repository. +// +// GitHub API docs: https://docs.github.com/en/rest/branches/branches#merge-a-branch +func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, request *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/merges", owner, repo) + req, err := s.client.NewRequest("POST", u, request) + if err != nil { + return nil, nil, err + } + + commit := new(RepositoryCommit) + resp, err := s.client.Do(ctx, req, commit) + if err != nil { + return nil, resp, err + } + + return commit, resp, nil +} + +// MergeUpstream syncs a branch of a forked repository to keep it up-to-date +// with the upstream repository. +// +// GitHub API docs: https://docs.github.com/en/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository +func (s *RepositoriesService) MergeUpstream(ctx context.Context, owner, repo string, request *RepoMergeUpstreamRequest) (*RepoMergeUpstreamResult, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/merge-upstream", owner, repo) + req, err := s.client.NewRequest("POST", u, request) + if err != nil { + return nil, nil, err + } + + result := new(RepoMergeUpstreamResult) + resp, err := s.client.Do(ctx, req, result) + if err != nil { + return nil, resp, err + } + + return result, resp, nil +} diff --git a/vendor/github.com/google/go-github/v43/github/repos_pages.go b/vendor/github.com/google/go-github/v47/github/repos_pages.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/repos_pages.go rename to vendor/github.com/google/go-github/v47/github/repos_pages.go index 60a756b6..737cec0f 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_pages.go +++ b/vendor/github.com/google/go-github/v47/github/repos_pages.go @@ -63,7 +63,7 @@ type createPagesRequest struct { // EnablePages enables GitHub Pages for the named repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-github-pages-site +// GitHub API docs: https://docs.github.com/en/rest/pages#create-a-github-pages-site func (s *RepositoriesService) EnablePages(ctx context.Context, owner, repo string, pages *Pages) (*Pages, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages", owner, repo) @@ -93,8 +93,10 @@ type PagesUpdate struct { // Leaving CNAME empty will remove the custom domain. CNAME *string `json:"cname"` // Source must include the branch name, and may optionally specify the subdirectory "/docs". - // Possible values are: "gh-pages", "master", and "master /docs". - Source *string `json:"source,omitempty"` + // Possible values for Source.Branch are usually "gh-pages", "main", and "master", + // or any other existing branch name. + // Possible values for Source.Path are: "/", and "/docs". + Source *PagesSource `json:"source,omitempty"` // Public configures access controls for the site. // If "true", the site will be accessible to anyone on the internet. If "false", // the site will be accessible to anyone with read access to the repository that @@ -106,7 +108,7 @@ type PagesUpdate struct { // UpdatePages updates GitHub Pages for the named repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-information-about-a-github-pages-site +// GitHub API docs: https://docs.github.com/en/rest/pages#update-information-about-a-github-pages-site func (s *RepositoriesService) UpdatePages(ctx context.Context, owner, repo string, opts *PagesUpdate) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/pages", owner, repo) @@ -125,7 +127,7 @@ func (s *RepositoriesService) UpdatePages(ctx context.Context, owner, repo strin // DisablePages disables GitHub Pages for the named repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-github-pages-site +// GitHub API docs: https://docs.github.com/en/rest/pages#delete-a-github-pages-site func (s *RepositoriesService) DisablePages(ctx context.Context, owner, repo string) (*Response, error) { u := fmt.Sprintf("repos/%v/%v/pages", owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) @@ -141,7 +143,7 @@ func (s *RepositoriesService) DisablePages(ctx context.Context, owner, repo stri // GetPagesInfo fetches information about a GitHub Pages site. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-github-pages-site +// GitHub API docs: https://docs.github.com/en/rest/pages#get-a-github-pages-site func (s *RepositoriesService) GetPagesInfo(ctx context.Context, owner, repo string) (*Pages, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -160,7 +162,7 @@ func (s *RepositoriesService) GetPagesInfo(ctx context.Context, owner, repo stri // ListPagesBuilds lists the builds for a GitHub Pages site. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-github-pages-builds +// GitHub API docs: https://docs.github.com/en/rest/pages#list-github-pages-builds func (s *RepositoriesService) ListPagesBuilds(ctx context.Context, owner, repo string, opts *ListOptions) ([]*PagesBuild, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages/builds", owner, repo) u, err := addOptions(u, opts) @@ -184,7 +186,7 @@ func (s *RepositoriesService) ListPagesBuilds(ctx context.Context, owner, repo s // GetLatestPagesBuild fetches the latest build information for a GitHub pages site. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-latest-pages-build +// GitHub API docs: https://docs.github.com/en/rest/pages#get-latest-pages-build func (s *RepositoriesService) GetLatestPagesBuild(ctx context.Context, owner, repo string) (*PagesBuild, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages/builds/latest", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -203,7 +205,7 @@ func (s *RepositoriesService) GetLatestPagesBuild(ctx context.Context, owner, re // GetPageBuild fetches the specific build information for a GitHub pages site. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-github-pages-build +// GitHub API docs: https://docs.github.com/en/rest/pages#get-github-pages-build func (s *RepositoriesService) GetPageBuild(ctx context.Context, owner, repo string, id int64) (*PagesBuild, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages/builds/%v", owner, repo, id) req, err := s.client.NewRequest("GET", u, nil) @@ -222,7 +224,7 @@ func (s *RepositoriesService) GetPageBuild(ctx context.Context, owner, repo stri // RequestPageBuild requests a build of a GitHub Pages site without needing to push new commit. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#request-a-github-pages-build +// GitHub API docs: https://docs.github.com/en/rest/pages#request-a-github-pages-build func (s *RepositoriesService) RequestPageBuild(ctx context.Context, owner, repo string) (*PagesBuild, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pages/builds", owner, repo) req, err := s.client.NewRequest("POST", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/repos_prereceive_hooks.go b/vendor/github.com/google/go-github/v47/github/repos_prereceive_hooks.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/repos_prereceive_hooks.go rename to vendor/github.com/google/go-github/v47/github/repos_prereceive_hooks.go diff --git a/vendor/github.com/google/go-github/v43/github/repos_projects.go b/vendor/github.com/google/go-github/v47/github/repos_projects.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/repos_projects.go rename to vendor/github.com/google/go-github/v47/github/repos_projects.go index 1938d51b..a3001dee 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_projects.go +++ b/vendor/github.com/google/go-github/v47/github/repos_projects.go @@ -21,7 +21,7 @@ type ProjectListOptions struct { // ListProjects lists the projects for a repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-repository-projects +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#list-repository-projects func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo string, opts *ProjectListOptions) ([]*Project, *Response, error) { u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) u, err := addOptions(u, opts) @@ -48,7 +48,7 @@ func (s *RepositoriesService) ListProjects(ctx context.Context, owner, repo stri // CreateProject creates a GitHub Project for the specified repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-a-repository-project +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#create-a-repository-project func (s *RepositoriesService) CreateProject(ctx context.Context, owner, repo string, opts *ProjectOptions) (*Project, *Response, error) { u := fmt.Sprintf("repos/%v/%v/projects", owner, repo) req, err := s.client.NewRequest("POST", u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/repos_releases.go b/vendor/github.com/google/go-github/v47/github/repos_releases.go similarity index 89% rename from vendor/github.com/google/go-github/v43/github/repos_releases.go rename to vendor/github.com/google/go-github/v47/github/repos_releases.go index 1cd2fae6..c030f04d 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_releases.go +++ b/vendor/github.com/google/go-github/v47/github/repos_releases.go @@ -26,7 +26,9 @@ type RepositoryRelease struct { Draft *bool `json:"draft,omitempty"` Prerelease *bool `json:"prerelease,omitempty"` DiscussionCategoryName *string `json:"discussion_category_name,omitempty"` - GenerateReleaseNotes *bool `json:"generate_release_notes,omitempty"` + + // The following fields are not used in EditRelease: + GenerateReleaseNotes *bool `json:"generate_release_notes,omitempty"` // The following fields are not used in CreateRelease or EditRelease: ID *int64 `json:"id,omitempty"` @@ -83,7 +85,7 @@ func (r ReleaseAsset) String() string { // ListReleases lists the releases for a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-releases +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#list-releases func (s *RepositoriesService) ListReleases(ctx context.Context, owner, repo string, opts *ListOptions) ([]*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases", owner, repo) u, err := addOptions(u, opts) @@ -106,7 +108,7 @@ func (s *RepositoriesService) ListReleases(ctx context.Context, owner, repo stri // GetRelease fetches a single release. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-release +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#get-a-release func (s *RepositoriesService) GetRelease(ctx context.Context, owner, repo string, id int64) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) return s.getSingleRelease(ctx, u) @@ -114,7 +116,7 @@ func (s *RepositoriesService) GetRelease(ctx context.Context, owner, repo string // GetLatestRelease fetches the latest published release for the repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-the-latest-release +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#get-the-latest-release func (s *RepositoriesService) GetLatestRelease(ctx context.Context, owner, repo string) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/latest", owner, repo) return s.getSingleRelease(ctx, u) @@ -122,15 +124,15 @@ func (s *RepositoriesService) GetLatestRelease(ctx context.Context, owner, repo // GetReleaseByTag fetches a release with the specified tag. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-release-by-tag-name +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#get-a-release-by-tag-name func (s *RepositoriesService) GetReleaseByTag(ctx context.Context, owner, repo, tag string) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/tags/%s", owner, repo, tag) return s.getSingleRelease(ctx, u) } // GenerateReleaseNotes generates the release notes for the given tag. -// TODO: api docs -// GitHub API docs: +// +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#generate-release-notes-content-for-a-release func (s *RepositoriesService) GenerateReleaseNotes(ctx context.Context, owner, repo string, opts *GenerateNotesOptions) (*RepositoryReleaseNotes, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/generate-notes", owner, repo) req, err := s.client.NewRequest("POST", u, opts) @@ -183,7 +185,7 @@ type repositoryReleaseRequest struct { // Note that only a subset of the release fields are used. // See RepositoryRelease for more information. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-release +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#create-a-release func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, release *RepositoryRelease) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases", owner, repo) @@ -216,7 +218,7 @@ func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo str // Note that only a subset of the release fields are used. // See RepositoryRelease for more information. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-release +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#update-a-release func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo string, id int64, release *RepositoryRelease) (*RepositoryRelease, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) @@ -228,7 +230,6 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin Draft: release.Draft, Prerelease: release.Prerelease, DiscussionCategoryName: release.DiscussionCategoryName, - GenerateReleaseNotes: release.GenerateReleaseNotes, } req, err := s.client.NewRequest("PATCH", u, releaseReq) @@ -246,7 +247,7 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin // DeleteRelease delete a single release from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-release +// GitHub API docs: https://docs.github.com/en/rest/releases/releases#delete-a-release func (s *RepositoriesService) DeleteRelease(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id) @@ -259,7 +260,7 @@ func (s *RepositoriesService) DeleteRelease(ctx context.Context, owner, repo str // ListReleaseAssets lists the release's assets. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-release-assets +// GitHub API docs: https://docs.github.com/en/rest/releases/assets#list-release-assets func (s *RepositoriesService) ListReleaseAssets(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*ReleaseAsset, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id) u, err := addOptions(u, opts) @@ -282,7 +283,7 @@ func (s *RepositoriesService) ListReleaseAssets(ctx context.Context, owner, repo // GetReleaseAsset fetches a single release asset. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-release-asset +// GitHub API docs: https://docs.github.com/en/rest/releases/assets#get-a-release-asset func (s *RepositoriesService) GetReleaseAsset(ctx context.Context, owner, repo string, id int64) (*ReleaseAsset, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) @@ -311,7 +312,7 @@ func (s *RepositoriesService) GetReleaseAsset(ctx context.Context, owner, repo s // exist, but it's possible to pass any http.Client. If nil is passed the // redirectURL will be returned instead. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-a-release-asset +// GitHub API docs: https://docs.github.com/en/rest/releases/assets#get-a-release-asset func (s *RepositoriesService) DownloadReleaseAsset(ctx context.Context, owner, repo string, id int64, followRedirectsClient *http.Client) (rc io.ReadCloser, redirectURL string, err error) { u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) @@ -373,7 +374,7 @@ func (s *RepositoriesService) downloadReleaseAssetFromURL(ctx context.Context, f // EditReleaseAsset edits a repository release asset. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#update-a-release-asset +// GitHub API docs: https://docs.github.com/en/rest/releases/assets#update-a-release-asset func (s *RepositoriesService) EditReleaseAsset(ctx context.Context, owner, repo string, id int64, release *ReleaseAsset) (*ReleaseAsset, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) @@ -392,7 +393,7 @@ func (s *RepositoriesService) EditReleaseAsset(ctx context.Context, owner, repo // DeleteReleaseAsset delete a single release asset from a repository. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#delete-a-release-asset +// GitHub API docs: https://docs.github.com/en/rest/releases/assets#delete-a-release-asset func (s *RepositoriesService) DeleteReleaseAsset(ctx context.Context, owner, repo string, id int64) (*Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/assets/%d", owner, repo, id) @@ -406,7 +407,7 @@ func (s *RepositoriesService) DeleteReleaseAsset(ctx context.Context, owner, rep // UploadReleaseAsset creates an asset by uploading a file into a release repository. // To upload assets that cannot be represented by an os.File, call NewUploadRequest directly. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#upload-a-release-asset +// GitHub API docs: https://docs.github.com/en/rest/releases/assets#upload-a-release-asset func (s *RepositoriesService) UploadReleaseAsset(ctx context.Context, owner, repo string, id int64, opts *UploadOptions, file *os.File) (*ReleaseAsset, *Response, error) { u := fmt.Sprintf("repos/%s/%s/releases/%d/assets", owner, repo, id) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/repos_stats.go b/vendor/github.com/google/go-github/v47/github/repos_stats.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/repos_stats.go rename to vendor/github.com/google/go-github/v47/github/repos_stats.go index 73f0a676..3df0a8f6 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_stats.go +++ b/vendor/github.com/google/go-github/v47/github/repos_stats.go @@ -45,7 +45,7 @@ func (w WeeklyStats) String() string { // it is now computing the requested statistics. A follow up request, after a // delay of a second or so, should result in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-all-contributor-commit-activity +// GitHub API docs: https://docs.github.com/en/rest/metrics/statistics#get-all-contributor-commit-activity func (s *RepositoriesService) ListContributorsStats(ctx context.Context, owner, repo string) ([]*ContributorStats, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/contributors", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -84,7 +84,7 @@ func (w WeeklyCommitActivity) String() string { // it is now computing the requested statistics. A follow up request, after a // delay of a second or so, should result in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-the-last-year-of-commit-activity +// GitHub API docs: https://docs.github.com/en/rest/metrics/statistics#get-the-last-year-of-commit-activity func (s *RepositoriesService) ListCommitActivity(ctx context.Context, owner, repo string) ([]*WeeklyCommitActivity, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/commit_activity", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -111,7 +111,7 @@ func (s *RepositoriesService) ListCommitActivity(ctx context.Context, owner, rep // it is now computing the requested statistics. A follow up request, after a // delay of a second or so, should result in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-the-weekly-commit-activity +// GitHub API docs: https://docs.github.com/en/rest/metrics/statistics#get-the-weekly-commit-activity func (s *RepositoriesService) ListCodeFrequency(ctx context.Context, owner, repo string) ([]*WeeklyStats, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/code_frequency", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -121,6 +121,9 @@ func (s *RepositoriesService) ListCodeFrequency(ctx context.Context, owner, repo var weeks [][]int resp, err := s.client.Do(ctx, req, &weeks) + if err != nil { + return nil, resp, err + } // convert int slices into WeeklyStats var stats []*WeeklyStats @@ -136,7 +139,7 @@ func (s *RepositoriesService) ListCodeFrequency(ctx context.Context, owner, repo stats = append(stats, stat) } - return stats, resp, err + return stats, resp, nil } // RepositoryParticipation is the number of commits by everyone @@ -164,7 +167,7 @@ func (r RepositoryParticipation) String() string { // it is now computing the requested statistics. A follow up request, after a // delay of a second or so, should result in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-the-weekly-commit-count +// GitHub API docs: https://docs.github.com/en/rest/metrics/statistics#get-the-weekly-commit-count func (s *RepositoriesService) ListParticipation(ctx context.Context, owner, repo string) (*RepositoryParticipation, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/participation", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -197,7 +200,7 @@ type PunchCard struct { // it is now computing the requested statistics. A follow up request, after a // delay of a second or so, should result in a successful request. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-the-hourly-commit-count-for-each-day +// GitHub API docs: https://docs.github.com/en/rest/metrics/statistics#get-the-hourly-commit-count-for-each-day func (s *RepositoriesService) ListPunchCard(ctx context.Context, owner, repo string) ([]*PunchCard, *Response, error) { u := fmt.Sprintf("repos/%v/%v/stats/punch_card", owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -207,6 +210,9 @@ func (s *RepositoriesService) ListPunchCard(ctx context.Context, owner, repo str var results [][]int resp, err := s.client.Do(ctx, req, &results) + if err != nil { + return nil, resp, err + } // convert int slices into Punchcards var cards []*PunchCard @@ -222,5 +228,5 @@ func (s *RepositoriesService) ListPunchCard(ctx context.Context, owner, repo str cards = append(cards, card) } - return cards, resp, err + return cards, resp, nil } diff --git a/vendor/github.com/google/go-github/v43/github/repos_statuses.go b/vendor/github.com/google/go-github/v47/github/repos_statuses.go similarity index 91% rename from vendor/github.com/google/go-github/v43/github/repos_statuses.go rename to vendor/github.com/google/go-github/v47/github/repos_statuses.go index 347d856a..42238f3c 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_statuses.go +++ b/vendor/github.com/google/go-github/v47/github/repos_statuses.go @@ -46,7 +46,7 @@ func (r RepoStatus) String() string { // ListStatuses lists the statuses of a repository at the specified // reference. ref can be a SHA, a branch name, or a tag name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-commit-statuses-for-a-reference +// GitHub API docs: https://docs.github.com/en/rest/commits/statuses#list-commit-statuses-for-a-reference func (s *RepositoriesService) ListStatuses(ctx context.Context, owner, repo, ref string, opts *ListOptions) ([]*RepoStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/statuses", owner, repo, refURLEscape(ref)) u, err := addOptions(u, opts) @@ -71,7 +71,7 @@ func (s *RepositoriesService) ListStatuses(ctx context.Context, owner, repo, ref // CreateStatus creates a new status for a repository at the specified // reference. Ref can be a SHA, a branch name, or a tag name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#create-a-commit-status +// GitHub API docs: https://docs.github.com/en/rest/commits/statuses#create-a-commit-status func (s *RepositoriesService) CreateStatus(ctx context.Context, owner, repo, ref string, status *RepoStatus) (*RepoStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, refURLEscape(ref)) req, err := s.client.NewRequest("POST", u, status) @@ -110,7 +110,7 @@ func (s CombinedStatus) String() string { // GetCombinedStatus returns the combined status of a repository at the specified // reference. ref can be a SHA, a branch name, or a tag name. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-the-combined-status-for-a-specific-reference +// GitHub API docs: https://docs.github.com/en/rest/commits/statuses#get-the-combined-status-for-a-specific-reference func (s *RepositoriesService) GetCombinedStatus(ctx context.Context, owner, repo, ref string, opts *ListOptions) (*CombinedStatus, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v/status", owner, repo, refURLEscape(ref)) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v47/github/repos_tags.go b/vendor/github.com/google/go-github/v47/github/repos_tags.go new file mode 100644 index 00000000..ff46d90c --- /dev/null +++ b/vendor/github.com/google/go-github/v47/github/repos_tags.go @@ -0,0 +1,76 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// TagProtection represents a repository tag protection. +type TagProtection struct { + ID *int64 `json:"id"` + Pattern *string `json:"pattern"` +} + +// tagProtectionRequest represents a request to create tag protection. +type tagProtectionRequest struct { + // An optional glob pattern to match against when enforcing tag protection. + Pattern string `json:"pattern"` +} + +// ListTagProtection lists tag protection of the specified repository. +// +// GitHub API docs: https://docs.github.com/en/rest/repos/tags#list-tag-protection-states-for-a-repository +func (s *RepositoriesService) ListTagProtection(ctx context.Context, owner, repo string) ([]*TagProtection, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/tags/protection", owner, repo) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var tagProtections []*TagProtection + resp, err := s.client.Do(ctx, req, &tagProtections) + if err != nil { + return nil, resp, err + } + + return tagProtections, resp, nil +} + +// CreateTagProtection creates the tag protection of the specified repository. +// +// GitHub API docs: https://docs.github.com/en/rest/repos/tags#create-a-tag-protection-state-for-a-repository +func (s *RepositoriesService) CreateTagProtection(ctx context.Context, owner, repo, pattern string) (*TagProtection, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/tags/protection", owner, repo) + r := &tagProtectionRequest{Pattern: pattern} + req, err := s.client.NewRequest("POST", u, r) + if err != nil { + return nil, nil, err + } + + tagProtection := new(TagProtection) + resp, err := s.client.Do(ctx, req, tagProtection) + if err != nil { + return nil, resp, err + } + + return tagProtection, resp, nil +} + +// DeleteTagProtection deletes a tag protection from the specified repository. +// +// GitHub API docs: https://docs.github.com/en/rest/repos/tags#delete-a-tag-protection-state-for-a-repository +func (s *RepositoriesService) DeleteTagProtection(ctx context.Context, owner, repo string, tagProtectionID int64) (*Response, error) { + u := fmt.Sprintf("repos/%v/%v/tags/protection/%v", owner, repo, tagProtectionID) + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} diff --git a/vendor/github.com/google/go-github/v43/github/repos_traffic.go b/vendor/github.com/google/go-github/v47/github/repos_traffic.go similarity index 90% rename from vendor/github.com/google/go-github/v43/github/repos_traffic.go rename to vendor/github.com/google/go-github/v47/github/repos_traffic.go index e372fb5a..bf093c03 100644 --- a/vendor/github.com/google/go-github/v43/github/repos_traffic.go +++ b/vendor/github.com/google/go-github/v47/github/repos_traffic.go @@ -54,7 +54,7 @@ type TrafficBreakdownOptions struct { // ListTrafficReferrers list the top 10 referrers over the last 14 days. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-top-referral-sources +// GitHub API docs: https://docs.github.com/en/rest/metrics/traffic#get-top-referral-sources func (s *RepositoriesService) ListTrafficReferrers(ctx context.Context, owner, repo string) ([]*TrafficReferrer, *Response, error) { u := fmt.Sprintf("repos/%v/%v/traffic/popular/referrers", owner, repo) @@ -74,7 +74,7 @@ func (s *RepositoriesService) ListTrafficReferrers(ctx context.Context, owner, r // ListTrafficPaths list the top 10 popular content over the last 14 days. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-top-referral-paths +// GitHub API docs: https://docs.github.com/en/rest/metrics/traffic#get-top-referral-paths func (s *RepositoriesService) ListTrafficPaths(ctx context.Context, owner, repo string) ([]*TrafficPath, *Response, error) { u := fmt.Sprintf("repos/%v/%v/traffic/popular/paths", owner, repo) @@ -94,7 +94,7 @@ func (s *RepositoriesService) ListTrafficPaths(ctx context.Context, owner, repo // ListTrafficViews get total number of views for the last 14 days and breaks it down either per day or week. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-page-views +// GitHub API docs: https://docs.github.com/en/rest/metrics/traffic#get-page-views func (s *RepositoriesService) ListTrafficViews(ctx context.Context, owner, repo string, opts *TrafficBreakdownOptions) (*TrafficViews, *Response, error) { u := fmt.Sprintf("repos/%v/%v/traffic/views", owner, repo) u, err := addOptions(u, opts) @@ -118,7 +118,7 @@ func (s *RepositoriesService) ListTrafficViews(ctx context.Context, owner, repo // ListTrafficClones get total number of clones for the last 14 days and breaks it down either per day or week for the last 14 days. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#get-repository-clones +// GitHub API docs: https://docs.github.com/en/rest/metrics/traffic#get-repository-clones func (s *RepositoriesService) ListTrafficClones(ctx context.Context, owner, repo string, opts *TrafficBreakdownOptions) (*TrafficClones, *Response, error) { u := fmt.Sprintf("repos/%v/%v/traffic/clones", owner, repo) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/scim.go b/vendor/github.com/google/go-github/v47/github/scim.go similarity index 84% rename from vendor/github.com/google/go-github/v43/github/scim.go rename to vendor/github.com/google/go-github/v47/github/scim.go index 7a12d85b..9462fb6b 100644 --- a/vendor/github.com/google/go-github/v43/github/scim.go +++ b/vendor/github.com/google/go-github/v47/github/scim.go @@ -14,12 +14,12 @@ import ( // SCIMService provides access to SCIM related functions in the // GitHub API. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim +// GitHub API docs: https://docs.github.com/en/rest/scim type SCIMService service // SCIMUserAttributes represents supported SCIM User attributes. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#supported-scim-user-attributes +// GitHub API docs: https://docs.github.com/en/rest/scim#supported-scim-user-attributes type SCIMUserAttributes struct { UserName string `json:"userName"` // Configured by the admin. Could be an email, login, or username. (Required.) Name SCIMUserName `json:"name"` // (Required.) @@ -38,7 +38,7 @@ type SCIMUserName struct { Formatted *string `json:"formatted,omitempty"` // (Optional.) } -//SCIMUserEmail represents SCIM user email. +// SCIMUserEmail represents SCIM user email. type SCIMUserEmail struct { Value string `json:"value"` // (Required.) Primary *bool `json:"primary,omitempty"` // (Optional.) @@ -47,7 +47,7 @@ type SCIMUserEmail struct { // ListSCIMProvisionedIdentitiesOptions represents options for ListSCIMProvisionedIdentities. // -// Github API docs: https://docs.github.com/en/rest/reference/scim#list-scim-provisioned-identities--parameters +// Github API docs: https://docs.github.com/en/rest/scim#list-scim-provisioned-identities--parameters type ListSCIMProvisionedIdentitiesOptions struct { StartIndex *int `json:"startIndex,omitempty"` // Used for pagination: the index of the first result to return. (Optional.) Count *int `json:"count,omitempty"` // Used for pagination: the number of results to return. (Optional.) @@ -61,7 +61,7 @@ type ListSCIMProvisionedIdentitiesOptions struct { // ListSCIMProvisionedIdentities lists SCIM provisioned identities. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#list-scim-provisioned-identities +// GitHub API docs: https://docs.github.com/en/rest/scim#list-scim-provisioned-identities func (s *SCIMService) ListSCIMProvisionedIdentities(ctx context.Context, org string, opts *ListSCIMProvisionedIdentitiesOptions) (*Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users", org) u, err := addOptions(u, opts) @@ -77,7 +77,7 @@ func (s *SCIMService) ListSCIMProvisionedIdentities(ctx context.Context, org str // ProvisionAndInviteSCIMUser provisions organization membership for a user, and sends an activation email to the email address. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#provision-and-invite-a-scim-user +// GitHub API docs: https://docs.github.com/en/rest/scim#provision-and-invite-a-scim-user func (s *SCIMService) ProvisionAndInviteSCIMUser(ctx context.Context, org string, opts *SCIMUserAttributes) (*Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users", org) u, err := addOptions(u, opts) @@ -93,7 +93,7 @@ func (s *SCIMService) ProvisionAndInviteSCIMUser(ctx context.Context, org string // GetSCIMProvisioningInfoForUser returns SCIM provisioning information for a user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#get-scim-provisioning-information-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/scim#supported-scim-user-attributes func (s *SCIMService) GetSCIMProvisioningInfoForUser(ctx context.Context, org, scimUserID string) (*Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID) req, err := s.client.NewRequest("GET", u, nil) @@ -105,7 +105,7 @@ func (s *SCIMService) GetSCIMProvisioningInfoForUser(ctx context.Context, org, s // UpdateProvisionedOrgMembership updates a provisioned organization membership. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#update-a-provisioned-organization-membership +// GitHub API docs: https://docs.github.com/en/rest/scim#update-a-provisioned-organization-membership func (s *SCIMService) UpdateProvisionedOrgMembership(ctx context.Context, org, scimUserID string, opts *SCIMUserAttributes) (*Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID) u, err := addOptions(u, opts) @@ -121,7 +121,7 @@ func (s *SCIMService) UpdateProvisionedOrgMembership(ctx context.Context, org, s // UpdateAttributeForSCIMUserOptions represents options for UpdateAttributeForSCIMUser. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#update-an-attribute-for-a-scim-user--parameters +// GitHub API docs: https://docs.github.com/en/rest/scim#update-an-attribute-for-a-scim-user--parameters type UpdateAttributeForSCIMUserOptions struct { Schemas []string `json:"schemas,omitempty"` // (Optional.) Operations UpdateAttributeForSCIMUserOperations `json:"operations"` // Set of operations to be performed. (Required.) @@ -136,7 +136,7 @@ type UpdateAttributeForSCIMUserOperations struct { // UpdateAttributeForSCIMUser updates an attribute for an SCIM user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#update-an-attribute-for-a-scim-user +// GitHub API docs: https://docs.github.com/en/rest/scim#update-an-attribute-for-a-scim-user func (s *SCIMService) UpdateAttributeForSCIMUser(ctx context.Context, org, scimUserID string, opts *UpdateAttributeForSCIMUserOptions) (*Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID) u, err := addOptions(u, opts) @@ -152,7 +152,7 @@ func (s *SCIMService) UpdateAttributeForSCIMUser(ctx context.Context, org, scimU // DeleteSCIMUserFromOrg deletes SCIM user from an organization. // -// GitHub API docs: https://docs.github.com/en/rest/reference/scim#delete-a-scim-user-from-an-organization +// GitHub API docs: https://docs.github.com/en/rest/scim#delete-a-scim-user-from-an-organization func (s *SCIMService) DeleteSCIMUserFromOrg(ctx context.Context, org, scimUserID string) (*Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/search.go b/vendor/github.com/google/go-github/v47/github/search.go similarity index 84% rename from vendor/github.com/google/go-github/v43/github/search.go rename to vendor/github.com/google/go-github/v47/github/search.go index 19aa8927..adb832d0 100644 --- a/vendor/github.com/google/go-github/v43/github/search.go +++ b/vendor/github.com/google/go-github/v47/github/search.go @@ -9,6 +9,7 @@ import ( "context" "fmt" "strconv" + "strings" qs "github.com/google/go-querystring/query" ) @@ -19,8 +20,10 @@ import ( // Each method takes a query string defining the search keywords and any search qualifiers. // For example, when searching issues, the query "gopher is:issue language:go" will search // for issues containing the word "gopher" in Go repositories. The method call -// opts := &github.SearchOptions{Sort: "created", Order: "asc"} -// cl.Search.Issues(ctx, "gopher is:issue language:go", opts) +// +// opts := &github.SearchOptions{Sort: "created", Order: "asc"} +// cl.Search.Issues(ctx, "gopher is:issue language:go", opts) +// // will search for such issues, sorting by creation date in ascending order // (i.e., oldest first). // @@ -29,7 +32,7 @@ import ( // For example, querying with "language:c++" and "leveldb", then query should be // "language:c++ leveldb" but not "language:c+++leveldb". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/ +// GitHub API docs: https://docs.github.com/en/rest/search/ type SearchService service // SearchOptions specifies optional parameters to the SearchService methods. @@ -69,11 +72,15 @@ type RepositoriesSearchResult struct { // Repositories searches repositories via various criteria. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-repositories +// GitHub API docs: https://docs.github.com/en/rest/search#search-repositories func (s *SearchService) Repositories(ctx context.Context, query string, opts *SearchOptions) (*RepositoriesSearchResult, *Response, error) { result := new(RepositoriesSearchResult) resp, err := s.search(ctx, "repositories", &searchParameters{Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // TopicsSearchResult represents the result of a topics search. @@ -100,11 +107,15 @@ type TopicResult struct { // Please see https://help.github.com/en/articles/searching-topics for more // information about search qualifiers. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-topics +// GitHub API docs: https://docs.github.com/en/rest/search#search-topics func (s *SearchService) Topics(ctx context.Context, query string, opts *SearchOptions) (*TopicsSearchResult, *Response, error) { result := new(TopicsSearchResult) resp, err := s.search(ctx, "topics", &searchParameters{Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // CommitsSearchResult represents the result of a commits search. @@ -131,11 +142,15 @@ type CommitResult struct { // Commits searches commits via various criteria. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-commits +// GitHub API docs: https://docs.github.com/en/rest/search#search-commits func (s *SearchService) Commits(ctx context.Context, query string, opts *SearchOptions) (*CommitsSearchResult, *Response, error) { result := new(CommitsSearchResult) resp, err := s.search(ctx, "commits", &searchParameters{Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // IssuesSearchResult represents the result of an issues search. @@ -147,11 +162,15 @@ type IssuesSearchResult struct { // Issues searches issues via various criteria. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-issues-and-pull-requests +// GitHub API docs: https://docs.github.com/en/rest/search#search-issues-and-pull-requests func (s *SearchService) Issues(ctx context.Context, query string, opts *SearchOptions) (*IssuesSearchResult, *Response, error) { result := new(IssuesSearchResult) resp, err := s.search(ctx, "issues", &searchParameters{Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // UsersSearchResult represents the result of a users search. @@ -163,11 +182,15 @@ type UsersSearchResult struct { // Users searches users via various criteria. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-users +// GitHub API docs: https://docs.github.com/en/rest/search#search-users func (s *SearchService) Users(ctx context.Context, query string, opts *SearchOptions) (*UsersSearchResult, *Response, error) { result := new(UsersSearchResult) resp, err := s.search(ctx, "users", &searchParameters{Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // Match represents a single text match. @@ -212,11 +235,15 @@ func (c CodeResult) String() string { // Code searches code via various criteria. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-code +// GitHub API docs: https://docs.github.com/en/rest/search#search-code func (s *SearchService) Code(ctx context.Context, query string, opts *SearchOptions) (*CodeSearchResult, *Response, error) { result := new(CodeSearchResult) resp, err := s.search(ctx, "code", &searchParameters{Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // LabelsSearchResult represents the result of a code search. @@ -243,11 +270,15 @@ func (l LabelResult) String() string { // Labels searches labels in the repository with ID repoID via various criteria. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#search-labels +// GitHub API docs: https://docs.github.com/en/rest/search#search-labels func (s *SearchService) Labels(ctx context.Context, repoID int64, query string, opts *SearchOptions) (*LabelsSearchResult, *Response, error) { result := new(LabelsSearchResult) resp, err := s.search(ctx, "labels", &searchParameters{RepositoryID: &repoID, Query: query}, opts, result) - return result, resp, err + if err != nil { + return nil, resp, err + } + + return result, resp, nil } // Helper function that executes search queries against different @@ -260,6 +291,7 @@ func (s *SearchService) search(ctx context.Context, searchType string, parameter if err != nil { return nil, err } + if parameters.RepositoryID != nil { params.Set("repository_id", strconv.FormatInt(*parameters.RepositoryID, 10)) } @@ -270,29 +302,32 @@ func (s *SearchService) search(ctx context.Context, searchType string, parameter if err != nil { return nil, err } - + var acceptHeaders []string switch { case searchType == "commits": // Accept header for search commits preview endpoint // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeCommitSearchPreview) + acceptHeaders = append(acceptHeaders, mediaTypeCommitSearchPreview) case searchType == "topics": // Accept header for search repositories based on topics preview endpoint // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeTopicsPreview) + acceptHeaders = append(acceptHeaders, mediaTypeTopicsPreview) case searchType == "repositories": // Accept header for search repositories based on topics preview endpoint // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeTopicsPreview) + acceptHeaders = append(acceptHeaders, mediaTypeTopicsPreview) case searchType == "issues": // Accept header for search issues based on reactions preview endpoint // TODO: remove custom Accept header when this API fully launches. - req.Header.Set("Accept", mediaTypeReactionsPreview) - case opts != nil && opts.TextMatch: - // Accept header defaults to "application/vnd.github.v3+json" - // We change it here to fetch back text-match metadata - req.Header.Set("Accept", "application/vnd.github.v3.text-match+json") + acceptHeaders = append(acceptHeaders, mediaTypeReactionsPreview) } + // https://docs.github.com/en/rest/search#search-repositories + // Accept header defaults to "application/vnd.github.v3+json" + // We change it here to fetch back text-match metadata + if opts != nil && opts.TextMatch { + acceptHeaders = append(acceptHeaders, "application/vnd.github.v3.text-match+json") + } + req.Header.Set("Accept", strings.Join(acceptHeaders, ", ")) return s.client.Do(ctx, req, result) } diff --git a/vendor/github.com/google/go-github/v43/github/secret_scanning.go b/vendor/github.com/google/go-github/v47/github/secret_scanning.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/secret_scanning.go rename to vendor/github.com/google/go-github/v47/github/secret_scanning.go index f5061f3b..d512560d 100644 --- a/vendor/github.com/google/go-github/v43/github/secret_scanning.go +++ b/vendor/github.com/google/go-github/v47/github/secret_scanning.go @@ -12,8 +12,6 @@ import ( // SecretScanningService handles communication with the secret scanning related // methods of the GitHub API. -// -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning type SecretScanningService service // SecretScanningAlert represents a GitHub secret scanning alert. @@ -63,6 +61,14 @@ type SecretScanningAlertListOptions struct { Resolution string `url:"resolution,omitempty"` ListCursorOptions + + // List options can vary on the Enterprise type. + // On Enterprise Cloud, Secret Scan alerts support requesting by page number + // along with providing a cursor for an "after" param. + // See: https://docs.github.com/en/enterprise-cloud@latest/rest/secret-scanning#list-secret-scanning-alerts-for-an-organization + // Whereas on Enterprise Server, pagination is by index. + // See: https://docs.github.com/en/enterprise-server@3.6/rest/secret-scanning#list-secret-scanning-alerts-for-an-organization + ListOptions } // SecretScanningAlertUpdateOptions specifies optional parameters to the SecretScanningService.UpdateAlert method. @@ -84,7 +90,7 @@ type SecretScanningAlertUpdateOptions struct { // To use this endpoint, you must be a member of the enterprise, and you must use an access token with the repo scope or // security_events scope. Alerts are only returned for organizations in the enterprise for which you are an organization owner or a security manager. // -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning#list-secret-scanning-alerts-for-an-enterprise +// GitHub API docs: https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#list-secret-scanning-alerts-for-an-enterprise func (s *SecretScanningService) ListAlertsForEnterprise(ctx context.Context, enterprise string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) { u := fmt.Sprintf("enterprises/%v/secret-scanning/alerts", enterprise) u, err := addOptions(u, opts) @@ -111,7 +117,7 @@ func (s *SecretScanningService) ListAlertsForEnterprise(ctx context.Context, ent // To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with // the repo scope or security_events scope. // -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning#list-secret-scanning-alerts-for-an-organization +// GitHub API docs: https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#list-secret-scanning-alerts-for-an-organization func (s *SecretScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) { u := fmt.Sprintf("orgs/%v/secret-scanning/alerts", org) u, err := addOptions(u, opts) @@ -138,7 +144,7 @@ func (s *SecretScanningService) ListAlertsForOrg(ctx context.Context, org string // To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with // the repo scope or security_events scope. // -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning#list-secret-scanning-alerts-for-a-repository +// GitHub API docs: https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#list-secret-scanning-alerts-for-a-repository func (s *SecretScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) { u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts", owner, repo) u, err := addOptions(u, opts) @@ -165,7 +171,7 @@ func (s *SecretScanningService) ListAlertsForRepo(ctx context.Context, owner, re // To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with // the repo scope or security_events scope. // -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning#get-a-secret-scanning-alert +// GitHub API docs: https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#get-a-secret-scanning-alert func (s *SecretScanningService) GetAlert(ctx context.Context, owner, repo string, number int64) (*SecretScanningAlert, *Response, error) { u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v", owner, repo, number) @@ -188,7 +194,7 @@ func (s *SecretScanningService) GetAlert(ctx context.Context, owner, repo string // To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with // the repo scope or security_events scope. // -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning#update-a-secret-scanning-alert +// GitHub API docs: https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#update-a-secret-scanning-alert func (s *SecretScanningService) UpdateAlert(ctx context.Context, owner, repo string, number int64, opts *SecretScanningAlertUpdateOptions) (*SecretScanningAlert, *Response, error) { u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v", owner, repo, number) @@ -211,7 +217,7 @@ func (s *SecretScanningService) UpdateAlert(ctx context.Context, owner, repo str // To use this endpoint, you must be an administrator for the repository or organization, and you must use an access token with // the repo scope or security_events scope. // -// GitHub API docs: https://docs.github.com/en/rest/reference/secret-scanning#list-locations-for-a-secret-scanning-alert +// GitHub API docs: https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#list-locations-for-a-secret-scanning-alert func (s *SecretScanningService) ListLocationsForAlert(ctx context.Context, owner, repo string, number int64, opts *ListOptions) ([]*SecretScanningAlertLocation, *Response, error) { u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v/locations", owner, repo, number) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/strings.go b/vendor/github.com/google/go-github/v47/github/strings.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/strings.go rename to vendor/github.com/google/go-github/v47/github/strings.go diff --git a/vendor/github.com/google/go-github/v43/github/teams.go b/vendor/github.com/google/go-github/v47/github/teams.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/teams.go rename to vendor/github.com/google/go-github/v47/github/teams.go index 82d4093b..38845e09 100644 --- a/vendor/github.com/google/go-github/v43/github/teams.go +++ b/vendor/github.com/google/go-github/v47/github/teams.go @@ -16,7 +16,7 @@ import ( // TeamsService provides access to the team-related functions // in the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/ +// GitHub API docs: https://docs.github.com/en/rest/teams/ type TeamsService service // Team represents a team within a GitHub organization. Teams are used to @@ -82,7 +82,7 @@ func (i Invitation) String() string { // ListTeams lists all of the teams for an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-teams +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-teams func (s *TeamsService) ListTeams(ctx context.Context, org string, opts *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/teams", org) u, err := addOptions(u, opts) @@ -106,7 +106,7 @@ func (s *TeamsService) ListTeams(ctx context.Context, org string, opts *ListOpti // GetTeamByID fetches a team, given a specified organization ID, by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-a-team-by-name +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#get-a-team-by-name func (s *TeamsService) GetTeamByID(ctx context.Context, orgID, teamID int64) (*Team, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v", orgID, teamID) req, err := s.client.NewRequest("GET", u, nil) @@ -125,7 +125,7 @@ func (s *TeamsService) GetTeamByID(ctx context.Context, orgID, teamID int64) (*T // GetTeamBySlug fetches a team, given a specified organization name, by slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-a-team-by-name +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#get-a-team-by-name func (s *TeamsService) GetTeamBySlug(ctx context.Context, org, slug string) (*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v", org, slug) req, err := s.client.NewRequest("GET", u, nil) @@ -175,7 +175,7 @@ func (s NewTeam) String() string { // CreateTeam creates a new team within an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#create-a-team func (s *TeamsService) CreateTeam(ctx context.Context, org string, team NewTeam) (*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/teams", org) req, err := s.client.NewRequest("POST", u, team) @@ -221,7 +221,7 @@ func copyNewTeamWithoutParent(team *NewTeam) *newTeamNoParent { // EditTeamByID edits a team, given an organization ID, selected by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#update-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#update-a-team func (s *TeamsService) EditTeamByID(ctx context.Context, orgID, teamID int64, team NewTeam, removeParent bool) (*Team, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v", orgID, teamID) @@ -248,7 +248,7 @@ func (s *TeamsService) EditTeamByID(ctx context.Context, orgID, teamID int64, te // EditTeamBySlug edits a team, given an organization name, by slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#update-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#update-a-team func (s *TeamsService) EditTeamBySlug(ctx context.Context, org, slug string, team NewTeam, removeParent bool) (*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v", org, slug) @@ -275,7 +275,7 @@ func (s *TeamsService) EditTeamBySlug(ctx context.Context, org, slug string, tea // DeleteTeamByID deletes a team referenced by ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#delete-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#delete-a-team func (s *TeamsService) DeleteTeamByID(ctx context.Context, orgID, teamID int64) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v", orgID, teamID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -288,7 +288,7 @@ func (s *TeamsService) DeleteTeamByID(ctx context.Context, orgID, teamID int64) // DeleteTeamBySlug deletes a team reference by slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#delete-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#delete-a-team func (s *TeamsService) DeleteTeamBySlug(ctx context.Context, org, slug string) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v", org, slug) req, err := s.client.NewRequest("DELETE", u, nil) @@ -301,7 +301,7 @@ func (s *TeamsService) DeleteTeamBySlug(ctx context.Context, org, slug string) ( // ListChildTeamsByParentID lists child teams for a parent team given parent ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-child-teams +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-child-teams func (s *TeamsService) ListChildTeamsByParentID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/teams", orgID, teamID) u, err := addOptions(u, opts) @@ -325,7 +325,7 @@ func (s *TeamsService) ListChildTeamsByParentID(ctx context.Context, orgID, team // ListChildTeamsByParentSlug lists child teams for a parent team given parent slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-child-teams +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-child-teams func (s *TeamsService) ListChildTeamsByParentSlug(ctx context.Context, org, slug string, opts *ListOptions) ([]*Team, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/teams", org, slug) u, err := addOptions(u, opts) @@ -349,7 +349,7 @@ func (s *TeamsService) ListChildTeamsByParentSlug(ctx context.Context, org, slug // ListTeamReposByID lists the repositories given a team ID that the specified team has access to. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-team-repositories +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-team-repositories func (s *TeamsService) ListTeamReposByID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/repos", orgID, teamID) u, err := addOptions(u, opts) @@ -377,7 +377,7 @@ func (s *TeamsService) ListTeamReposByID(ctx context.Context, orgID, teamID int6 // ListTeamReposBySlug lists the repositories given a team slug that the specified team has access to. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-team-repositories +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-team-repositories func (s *TeamsService) ListTeamReposBySlug(ctx context.Context, org, slug string, opts *ListOptions) ([]*Repository, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/repos", org, slug) u, err := addOptions(u, opts) @@ -407,7 +407,7 @@ func (s *TeamsService) ListTeamReposBySlug(ctx context.Context, org, slug string // repository is managed by team, a Repository is returned which includes the // permissions team has for that repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#check-team-permissions-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository func (s *TeamsService) IsTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string) (*Repository, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/repos/%v/%v", orgID, teamID, owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -431,7 +431,7 @@ func (s *TeamsService) IsTeamRepoByID(ctx context.Context, orgID, teamID int64, // repository is managed by team, a Repository is returned which includes the // permissions team has for that repo. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#check-team-permissions-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-repository func (s *TeamsService) IsTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string) (*Repository, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/repos/%v/%v", org, slug, owner, repo) req, err := s.client.NewRequest("GET", u, nil) @@ -452,7 +452,7 @@ func (s *TeamsService) IsTeamRepoBySlug(ctx context.Context, org, slug, owner, r } // TeamAddTeamRepoOptions specifies the optional parameters to the -// TeamsService.AddTeamRepo method. +// TeamsService.AddTeamRepoByID and TeamsService.AddTeamRepoBySlug methods. type TeamAddTeamRepoOptions struct { // Permission specifies the permission to grant the team on this repository. // Possible values are: @@ -470,7 +470,7 @@ type TeamAddTeamRepoOptions struct { // The specified repository must be owned by the organization to which the team // belongs, or a direct fork of a repository owned by the organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#add-or-update-team-repository-permissions +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#add-or-update-team-repository-permissions func (s *TeamsService) AddTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string, opts *TeamAddTeamRepoOptions) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/repos/%v/%v", orgID, teamID, owner, repo) req, err := s.client.NewRequest("PUT", u, opts) @@ -485,7 +485,7 @@ func (s *TeamsService) AddTeamRepoByID(ctx context.Context, orgID, teamID int64, // The specified repository must be owned by the organization to which the team // belongs, or a direct fork of a repository owned by the organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#add-or-update-team-repository-permissions +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#add-or-update-team-repository-permissions func (s *TeamsService) AddTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string, opts *TeamAddTeamRepoOptions) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/repos/%v/%v", org, slug, owner, repo) req, err := s.client.NewRequest("PUT", u, opts) @@ -500,7 +500,7 @@ func (s *TeamsService) AddTeamRepoBySlug(ctx context.Context, org, slug, owner, // team given the team ID. Note that this does not delete the repository, it // just removes it from the team. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#remove-a-repository-from-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#remove-a-repository-from-a-team func (s *TeamsService) RemoveTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/repos/%v/%v", orgID, teamID, owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) @@ -515,7 +515,7 @@ func (s *TeamsService) RemoveTeamRepoByID(ctx context.Context, orgID, teamID int // team given the team slug. Note that this does not delete the repository, it // just removes it from the team. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#remove-a-repository-from-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#remove-a-repository-from-a-team func (s *TeamsService) RemoveTeamRepoBySlug(ctx context.Context, org, slug, owner, repo string) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/repos/%v/%v", org, slug, owner, repo) req, err := s.client.NewRequest("DELETE", u, nil) @@ -527,7 +527,7 @@ func (s *TeamsService) RemoveTeamRepoBySlug(ctx context.Context, org, slug, owne } // ListUserTeams lists a user's teams -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-teams-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-teams-for-the-authenticated-user func (s *TeamsService) ListUserTeams(ctx context.Context, opts *ListOptions) ([]*Team, *Response, error) { u := "user/teams" u, err := addOptions(u, opts) @@ -551,7 +551,7 @@ func (s *TeamsService) ListUserTeams(ctx context.Context, opts *ListOptions) ([] // ListTeamProjectsByID lists the organization projects for a team given the team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-team-projects +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-team-projects func (s *TeamsService) ListTeamProjectsByID(ctx context.Context, orgID, teamID int64) ([]*Project, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects", orgID, teamID) @@ -575,7 +575,7 @@ func (s *TeamsService) ListTeamProjectsByID(ctx context.Context, orgID, teamID i // ListTeamProjectsBySlug lists the organization projects for a team given the team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-team-projects +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#list-team-projects func (s *TeamsService) ListTeamProjectsBySlug(ctx context.Context, org, slug string) ([]*Project, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects", org, slug) @@ -600,7 +600,7 @@ func (s *TeamsService) ListTeamProjectsBySlug(ctx context.Context, org, slug str // ReviewTeamProjectsByID checks whether a team, given its ID, has read, write, or admin // permissions for an organization project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#check-team-permissions-for-a-project +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-project func (s *TeamsService) ReviewTeamProjectsByID(ctx context.Context, orgID, teamID, projectID int64) (*Project, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects/%v", orgID, teamID, projectID) req, err := s.client.NewRequest("GET", u, nil) @@ -624,7 +624,7 @@ func (s *TeamsService) ReviewTeamProjectsByID(ctx context.Context, orgID, teamID // ReviewTeamProjectsBySlug checks whether a team, given its slug, has read, write, or admin // permissions for an organization project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#check-team-permissions-for-a-project +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#check-team-permissions-for-a-project func (s *TeamsService) ReviewTeamProjectsBySlug(ctx context.Context, org, slug string, projectID int64) (*Project, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects/%v", org, slug, projectID) req, err := s.client.NewRequest("GET", u, nil) @@ -661,7 +661,7 @@ type TeamProjectOptions struct { // To add a project to a team or update the team's permission on a project, the // authenticated user must have admin permissions for the project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#add-or-update-team-project-permissions +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#add-or-update-team-project-permissions func (s *TeamsService) AddTeamProjectByID(ctx context.Context, orgID, teamID, projectID int64, opts *TeamProjectOptions) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects/%v", orgID, teamID, projectID) req, err := s.client.NewRequest("PUT", u, opts) @@ -680,7 +680,7 @@ func (s *TeamsService) AddTeamProjectByID(ctx context.Context, orgID, teamID, pr // To add a project to a team or update the team's permission on a project, the // authenticated user must have admin permissions for the project. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#add-or-update-team-project-permissions +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#add-or-update-team-project-permissions func (s *TeamsService) AddTeamProjectBySlug(ctx context.Context, org, slug string, projectID int64, opts *TeamProjectOptions) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects/%v", org, slug, projectID) req, err := s.client.NewRequest("PUT", u, opts) @@ -702,7 +702,7 @@ func (s *TeamsService) AddTeamProjectBySlug(ctx context.Context, org, slug strin // or project. // Note: This endpoint removes the project from the team, but does not delete it. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#remove-a-project-from-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#remove-a-project-from-a-team func (s *TeamsService) RemoveTeamProjectByID(ctx context.Context, orgID, teamID, projectID int64) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/projects/%v", orgID, teamID, projectID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -724,7 +724,7 @@ func (s *TeamsService) RemoveTeamProjectByID(ctx context.Context, orgID, teamID, // or project. // Note: This endpoint removes the project from the team, but does not delete it. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#remove-a-project-from-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/teams#remove-a-project-from-a-team func (s *TeamsService) RemoveTeamProjectBySlug(ctx context.Context, org, slug string, projectID int64) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/projects/%v", org, slug, projectID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -753,7 +753,7 @@ type IDPGroup struct { // ListIDPGroupsInOrganization lists IDP groups available in an organization. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-idp-groups-for-an-organization +// GitHub API docs: https://docs.github.com/en/rest/teams/team-sync#list-idp-groups-for-an-organization func (s *TeamsService) ListIDPGroupsInOrganization(ctx context.Context, org string, opts *ListCursorOptions) (*IDPGroupList, *Response, error) { u := fmt.Sprintf("orgs/%v/team-sync/groups", org) u, err := addOptions(u, opts) @@ -771,13 +771,14 @@ func (s *TeamsService) ListIDPGroupsInOrganization(ctx context.Context, org stri if err != nil { return nil, resp, err } + return groups, resp, nil } // ListIDPGroupsForTeamByID lists IDP groups connected to a team on GitHub // given organization and team IDs. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-idp-groups-for-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/team-sync#list-idp-groups-for-a-team func (s *TeamsService) ListIDPGroupsForTeamByID(ctx context.Context, orgID, teamID int64) (*IDPGroupList, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/team-sync/group-mappings", orgID, teamID) @@ -791,13 +792,14 @@ func (s *TeamsService) ListIDPGroupsForTeamByID(ctx context.Context, orgID, team if err != nil { return nil, resp, err } - return groups, resp, err + + return groups, resp, nil } // ListIDPGroupsForTeamBySlug lists IDP groups connected to a team on GitHub // given organization name and team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-idp-groups-for-a-team +// GitHub API docs: https://docs.github.com/en/rest/teams/team-sync#list-idp-groups-for-a-team func (s *TeamsService) ListIDPGroupsForTeamBySlug(ctx context.Context, org, slug string) (*IDPGroupList, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/team-sync/group-mappings", org, slug) @@ -811,13 +813,14 @@ func (s *TeamsService) ListIDPGroupsForTeamBySlug(ctx context.Context, org, slug if err != nil { return nil, resp, err } - return groups, resp, err + + return groups, resp, nil } // CreateOrUpdateIDPGroupConnectionsByID creates, updates, or removes a connection // between a team and an IDP group given organization and team IDs. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-or-update-idp-group-connections +// GitHub API docs: https://docs.github.com/en/rest/teams/team-sync#create-or-update-idp-group-connections func (s *TeamsService) CreateOrUpdateIDPGroupConnectionsByID(ctx context.Context, orgID, teamID int64, opts IDPGroupList) (*IDPGroupList, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/team-sync/group-mappings", orgID, teamID) @@ -838,7 +841,7 @@ func (s *TeamsService) CreateOrUpdateIDPGroupConnectionsByID(ctx context.Context // CreateOrUpdateIDPGroupConnectionsBySlug creates, updates, or removes a connection // between a team and an IDP group given organization name and team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-or-update-idp-group-connections +// GitHub API docs: https://docs.github.com/en/rest/teams/team-sync#create-or-update-idp-group-connections func (s *TeamsService) CreateOrUpdateIDPGroupConnectionsBySlug(ctx context.Context, org, slug string, opts IDPGroupList) (*IDPGroupList, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/team-sync/group-mappings", org, slug) @@ -886,7 +889,7 @@ type ExternalGroupList struct { // GetExternalGroup fetches an external group. // -// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/reference/teams#get-an-external-group +// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/teams/external-groups#get-an-external-group func (s *TeamsService) GetExternalGroup(ctx context.Context, org string, groupID int64) (*ExternalGroup, *Response, error) { u := fmt.Sprintf("orgs/%v/external-group/%v", org, groupID) req, err := s.client.NewRequest("GET", u, nil) @@ -913,7 +916,7 @@ type ListExternalGroupsOptions struct { // ListExternalGroups lists external groups connected to a team on GitHub. // -// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/reference/teams#list-external-groups-in-an-organization +// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/teams/external-groups#list-external-groups-in-an-organization func (s *TeamsService) ListExternalGroups(ctx context.Context, org string, opts *ListExternalGroupsOptions) (*ExternalGroupList, *Response, error) { u := fmt.Sprintf("orgs/%v/external-groups", org) u, err := addOptions(u, opts) @@ -937,7 +940,7 @@ func (s *TeamsService) ListExternalGroups(ctx context.Context, org string, opts // UpdateConnectedExternalGroup updates the connection between an external group and a team. // -// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/reference/teams#update-the-connection-between-an-external-group-and-a-team +// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/teams/external-groups#update-the-connection-between-an-external-group-and-a-team func (s *TeamsService) UpdateConnectedExternalGroup(ctx context.Context, org, slug string, eg *ExternalGroup) (*ExternalGroup, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/external-groups", org, slug) @@ -957,7 +960,7 @@ func (s *TeamsService) UpdateConnectedExternalGroup(ctx context.Context, org, sl // RemoveConnectedExternalGroup removes the connection between an external group and a team. // -// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/reference/teams#remove-the-connection-between-an-external-group-and-a-team +// GitHub API docs: https://docs.github.com/en/enterprise-cloud@latest/rest/teams/external-groups#remove-the-connection-between-an-external-group-and-a-team func (s *TeamsService) RemoveConnectedExternalGroup(ctx context.Context, org, slug string) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/external-groups", org, slug) diff --git a/vendor/github.com/google/go-github/v43/github/teams_discussion_comments.go b/vendor/github.com/google/go-github/v47/github/teams_discussion_comments.go similarity index 87% rename from vendor/github.com/google/go-github/v43/github/teams_discussion_comments.go rename to vendor/github.com/google/go-github/v47/github/teams_discussion_comments.go index b6c7e178..f3a1cc4d 100644 --- a/vendor/github.com/google/go-github/v43/github/teams_discussion_comments.go +++ b/vendor/github.com/google/go-github/v47/github/teams_discussion_comments.go @@ -43,7 +43,7 @@ type DiscussionCommentListOptions struct { // ListCommentsByID lists all comments on a team discussion by team ID. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-discussion-comments +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#list-discussion-comments func (s *TeamsService) ListCommentsByID(ctx context.Context, orgID, teamID int64, discussionNumber int, options *DiscussionCommentListOptions) ([]*DiscussionComment, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments", orgID, teamID, discussionNumber) u, err := addOptions(u, options) @@ -68,7 +68,7 @@ func (s *TeamsService) ListCommentsByID(ctx context.Context, orgID, teamID int64 // ListCommentsBySlug lists all comments on a team discussion by team slug. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-discussion-comments +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#list-discussion-comments func (s *TeamsService) ListCommentsBySlug(ctx context.Context, org, slug string, discussionNumber int, options *DiscussionCommentListOptions) ([]*DiscussionComment, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments", org, slug, discussionNumber) u, err := addOptions(u, options) @@ -93,7 +93,7 @@ func (s *TeamsService) ListCommentsBySlug(ctx context.Context, org, slug string, // GetCommentByID gets a specific comment on a team discussion by team ID. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#get-a-discussion-comment func (s *TeamsService) GetCommentByID(ctx context.Context, orgID, teamID int64, discussionNumber, commentNumber int) (*DiscussionComment, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments/%v", orgID, teamID, discussionNumber, commentNumber) req, err := s.client.NewRequest("GET", u, nil) @@ -113,7 +113,7 @@ func (s *TeamsService) GetCommentByID(ctx context.Context, orgID, teamID int64, // GetCommentBySlug gets a specific comment on a team discussion by team slug. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#get-a-discussion-comment func (s *TeamsService) GetCommentBySlug(ctx context.Context, org, slug string, discussionNumber, commentNumber int) (*DiscussionComment, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments/%v", org, slug, discussionNumber, commentNumber) @@ -134,7 +134,7 @@ func (s *TeamsService) GetCommentBySlug(ctx context.Context, org, slug string, d // CreateCommentByID creates a new comment on a team discussion by team ID. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#create-a-discussion-comment func (s *TeamsService) CreateCommentByID(ctx context.Context, orgID, teamID int64, discsusionNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments", orgID, teamID, discsusionNumber) req, err := s.client.NewRequest("POST", u, comment) @@ -154,7 +154,7 @@ func (s *TeamsService) CreateCommentByID(ctx context.Context, orgID, teamID int6 // CreateCommentBySlug creates a new comment on a team discussion by team slug. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#create-a-discussion-comment func (s *TeamsService) CreateCommentBySlug(ctx context.Context, org, slug string, discsusionNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments", org, slug, discsusionNumber) req, err := s.client.NewRequest("POST", u, comment) @@ -175,7 +175,7 @@ func (s *TeamsService) CreateCommentBySlug(ctx context.Context, org, slug string // Authenticated user must grant write:discussion scope. // User is allowed to edit body of a comment only. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#update-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#update-a-discussion-comment func (s *TeamsService) EditCommentByID(ctx context.Context, orgID, teamID int64, discussionNumber, commentNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments/%v", orgID, teamID, discussionNumber, commentNumber) req, err := s.client.NewRequest("PATCH", u, comment) @@ -196,7 +196,7 @@ func (s *TeamsService) EditCommentByID(ctx context.Context, orgID, teamID int64, // Authenticated user must grant write:discussion scope. // User is allowed to edit body of a comment only. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#update-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#update-a-discussion-comment func (s *TeamsService) EditCommentBySlug(ctx context.Context, org, slug string, discussionNumber, commentNumber int, comment DiscussionComment) (*DiscussionComment, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments/%v", org, slug, discussionNumber, commentNumber) req, err := s.client.NewRequest("PATCH", u, comment) @@ -216,7 +216,7 @@ func (s *TeamsService) EditCommentBySlug(ctx context.Context, org, slug string, // DeleteCommentByID deletes a comment on a team discussion by team ID. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#delete-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#delete-a-discussion-comment func (s *TeamsService) DeleteCommentByID(ctx context.Context, orgID, teamID int64, discussionNumber, commentNumber int) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments/%v", orgID, teamID, discussionNumber, commentNumber) req, err := s.client.NewRequest("DELETE", u, nil) @@ -230,7 +230,7 @@ func (s *TeamsService) DeleteCommentByID(ctx context.Context, orgID, teamID int6 // DeleteCommentBySlug deletes a comment on a team discussion by team slug. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#delete-a-discussion-comment +// GitHub API docs: https://docs.github.com/en/rest/teams/discussion-comments#delete-a-discussion-comment func (s *TeamsService) DeleteCommentBySlug(ctx context.Context, org, slug string, discussionNumber, commentNumber int) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments/%v", org, slug, discussionNumber, commentNumber) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/teams_discussions.go b/vendor/github.com/google/go-github/v47/github/teams_discussions.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/teams_discussions.go rename to vendor/github.com/google/go-github/v47/github/teams_discussions.go index 5678548e..69a3ebd5 100644 --- a/vendor/github.com/google/go-github/v43/github/teams_discussions.go +++ b/vendor/github.com/google/go-github/v47/github/teams_discussions.go @@ -49,7 +49,7 @@ type DiscussionListOptions struct { // ListDiscussionsByID lists all discussions on team's page given Organization and Team ID. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-discussions +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#list-discussions func (s *TeamsService) ListDiscussionsByID(ctx context.Context, orgID, teamID int64, opts *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions", orgID, teamID) u, err := addOptions(u, opts) @@ -74,7 +74,7 @@ func (s *TeamsService) ListDiscussionsByID(ctx context.Context, orgID, teamID in // ListDiscussionsBySlug lists all discussions on team's page given Organization name and Team's slug. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-discussions +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#list-discussions func (s *TeamsService) ListDiscussionsBySlug(ctx context.Context, org, slug string, opts *DiscussionListOptions) ([]*TeamDiscussion, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions", org, slug) u, err := addOptions(u, opts) @@ -99,7 +99,7 @@ func (s *TeamsService) ListDiscussionsBySlug(ctx context.Context, org, slug stri // GetDiscussionByID gets a specific discussion on a team's page given Organization and Team ID. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#get-a-discussion func (s *TeamsService) GetDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int) (*TeamDiscussion, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v", orgID, teamID, discussionNumber) req, err := s.client.NewRequest("GET", u, nil) @@ -119,7 +119,7 @@ func (s *TeamsService) GetDiscussionByID(ctx context.Context, orgID, teamID int6 // GetDiscussionBySlug gets a specific discussion on a team's page given Organization name and Team's slug. // Authenticated user must grant read:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#get-a-discussion func (s *TeamsService) GetDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int) (*TeamDiscussion, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v", org, slug, discussionNumber) req, err := s.client.NewRequest("GET", u, nil) @@ -139,7 +139,7 @@ func (s *TeamsService) GetDiscussionBySlug(ctx context.Context, org, slug string // CreateDiscussionByID creates a new discussion post on a team's page given Organization and Team ID. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#create-a-discussion func (s *TeamsService) CreateDiscussionByID(ctx context.Context, orgID, teamID int64, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions", orgID, teamID) req, err := s.client.NewRequest("POST", u, discussion) @@ -159,7 +159,7 @@ func (s *TeamsService) CreateDiscussionByID(ctx context.Context, orgID, teamID i // CreateDiscussionBySlug creates a new discussion post on a team's page given Organization name and Team's slug. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#create-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#create-a-discussion func (s *TeamsService) CreateDiscussionBySlug(ctx context.Context, org, slug string, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions", org, slug) req, err := s.client.NewRequest("POST", u, discussion) @@ -180,7 +180,7 @@ func (s *TeamsService) CreateDiscussionBySlug(ctx context.Context, org, slug str // Authenticated user must grant write:discussion scope. // User is allowed to change Title and Body of a discussion only. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#update-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#update-a-discussion func (s *TeamsService) EditDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v", orgID, teamID, discussionNumber) req, err := s.client.NewRequest("PATCH", u, discussion) @@ -201,7 +201,7 @@ func (s *TeamsService) EditDiscussionByID(ctx context.Context, orgID, teamID int // Authenticated user must grant write:discussion scope. // User is allowed to change Title and Body of a discussion only. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#update-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#update-a-discussion func (s *TeamsService) EditDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int, discussion TeamDiscussion) (*TeamDiscussion, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v", org, slug, discussionNumber) req, err := s.client.NewRequest("PATCH", u, discussion) @@ -221,7 +221,7 @@ func (s *TeamsService) EditDiscussionBySlug(ctx context.Context, org, slug strin // DeleteDiscussionByID deletes a discussion from team's page given Organization and Team ID. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#delete-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#delete-a-discussion func (s *TeamsService) DeleteDiscussionByID(ctx context.Context, orgID, teamID int64, discussionNumber int) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/discussions/%v", orgID, teamID, discussionNumber) req, err := s.client.NewRequest("DELETE", u, nil) @@ -235,7 +235,7 @@ func (s *TeamsService) DeleteDiscussionByID(ctx context.Context, orgID, teamID i // DeleteDiscussionBySlug deletes a discussion from team's page given Organization name and Team's slug. // Authenticated user must grant write:discussion scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#delete-a-discussion +// GitHub API docs: https://docs.github.com/en/rest/teams/discussions#delete-a-discussion func (s *TeamsService) DeleteDiscussionBySlug(ctx context.Context, org, slug string, discussionNumber int) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v", org, slug, discussionNumber) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/teams_members.go b/vendor/github.com/google/go-github/v47/github/teams_members.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/teams_members.go rename to vendor/github.com/google/go-github/v47/github/teams_members.go index e6ad448b..58cb7974 100644 --- a/vendor/github.com/google/go-github/v43/github/teams_members.go +++ b/vendor/github.com/google/go-github/v47/github/teams_members.go @@ -23,7 +23,7 @@ type TeamListTeamMembersOptions struct { // ListTeamMembersByID lists all of the users who are members of a team, given a specified // organization ID, by team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-team-members +// GitHub API docs: https://docs.github.com/en/rest/teams/members#list-team-members func (s *TeamsService) ListTeamMembersByID(ctx context.Context, orgID, teamID int64, opts *TeamListTeamMembersOptions) ([]*User, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/members", orgID, teamID) u, err := addOptions(u, opts) @@ -48,7 +48,7 @@ func (s *TeamsService) ListTeamMembersByID(ctx context.Context, orgID, teamID in // ListTeamMembersBySlug lists all of the users who are members of a team, given a specified // organization name, by team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-team-members +// GitHub API docs: https://docs.github.com/en/rest/teams/members#list-team-members func (s *TeamsService) ListTeamMembersBySlug(ctx context.Context, org, slug string, opts *TeamListTeamMembersOptions) ([]*User, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/members", org, slug) u, err := addOptions(u, opts) @@ -73,7 +73,7 @@ func (s *TeamsService) ListTeamMembersBySlug(ctx context.Context, org, slug stri // GetTeamMembershipByID returns the membership status for a user in a team, given a specified // organization ID, by team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-team-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/teams/members#list-team-members func (s *TeamsService) GetTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string) (*Membership, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/memberships/%v", orgID, teamID, user) req, err := s.client.NewRequest("GET", u, nil) @@ -93,7 +93,7 @@ func (s *TeamsService) GetTeamMembershipByID(ctx context.Context, orgID, teamID // GetTeamMembershipBySlug returns the membership status for a user in a team, given a specified // organization name, by team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#get-team-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/teams/members#get-team-membership-for-a-user func (s *TeamsService) GetTeamMembershipBySlug(ctx context.Context, org, slug, user string) (*Membership, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/memberships/%v", org, slug, user) req, err := s.client.NewRequest("GET", u, nil) @@ -127,7 +127,7 @@ type TeamAddTeamMembershipOptions struct { // AddTeamMembershipByID adds or invites a user to a team, given a specified // organization ID, by team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#add-or-update-team-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/teams/members#add-or-update-team-membership-for-a-user func (s *TeamsService) AddTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string, opts *TeamAddTeamMembershipOptions) (*Membership, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/memberships/%v", orgID, teamID, user) req, err := s.client.NewRequest("PUT", u, opts) @@ -147,7 +147,7 @@ func (s *TeamsService) AddTeamMembershipByID(ctx context.Context, orgID, teamID // AddTeamMembershipBySlug adds or invites a user to a team, given a specified // organization name, by team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#add-or-update-team-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/teams/members#add-or-update-team-membership-for-a-user func (s *TeamsService) AddTeamMembershipBySlug(ctx context.Context, org, slug, user string, opts *TeamAddTeamMembershipOptions) (*Membership, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/memberships/%v", org, slug, user) req, err := s.client.NewRequest("PUT", u, opts) @@ -167,7 +167,7 @@ func (s *TeamsService) AddTeamMembershipBySlug(ctx context.Context, org, slug, u // RemoveTeamMembershipByID removes a user from a team, given a specified // organization ID, by team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#remove-team-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/teams/members#remove-team-membership-for-a-user func (s *TeamsService) RemoveTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string) (*Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/memberships/%v", orgID, teamID, user) req, err := s.client.NewRequest("DELETE", u, nil) @@ -181,7 +181,7 @@ func (s *TeamsService) RemoveTeamMembershipByID(ctx context.Context, orgID, team // RemoveTeamMembershipBySlug removes a user from a team, given a specified // organization name, by team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#remove-team-membership-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/teams/members#remove-team-membership-for-a-user func (s *TeamsService) RemoveTeamMembershipBySlug(ctx context.Context, org, slug, user string) (*Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/memberships/%v", org, slug, user) req, err := s.client.NewRequest("DELETE", u, nil) @@ -195,7 +195,7 @@ func (s *TeamsService) RemoveTeamMembershipBySlug(ctx context.Context, org, slug // ListPendingTeamInvitationsByID gets pending invitation list of a team, given a specified // organization ID, by team ID. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-pending-team-invitations +// GitHub API docs: https://docs.github.com/en/rest/teams/members#list-pending-team-invitations func (s *TeamsService) ListPendingTeamInvitationsByID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Invitation, *Response, error) { u := fmt.Sprintf("organizations/%v/team/%v/invitations", orgID, teamID) u, err := addOptions(u, opts) @@ -220,7 +220,7 @@ func (s *TeamsService) ListPendingTeamInvitationsByID(ctx context.Context, orgID // ListPendingTeamInvitationsBySlug get pending invitation list of a team, given a specified // organization name, by team slug. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/teams/#list-pending-team-invitations +// GitHub API docs: https://docs.github.com/en/rest/teams/members#list-pending-team-invitations func (s *TeamsService) ListPendingTeamInvitationsBySlug(ctx context.Context, org, slug string, opts *ListOptions) ([]*Invitation, *Response, error) { u := fmt.Sprintf("orgs/%v/teams/%v/invitations", org, slug) u, err := addOptions(u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/timestamp.go b/vendor/github.com/google/go-github/v47/github/timestamp.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/timestamp.go rename to vendor/github.com/google/go-github/v47/github/timestamp.go diff --git a/vendor/github.com/google/go-github/v43/github/users.go b/vendor/github.com/google/go-github/v47/github/users.go similarity index 86% rename from vendor/github.com/google/go-github/v43/github/users.go rename to vendor/github.com/google/go-github/v47/github/users.go index f45b1f67..d40d23e9 100644 --- a/vendor/github.com/google/go-github/v43/github/users.go +++ b/vendor/github.com/google/go-github/v47/github/users.go @@ -13,7 +13,7 @@ import ( // UsersService handles communication with the user related // methods of the GitHub API. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/ +// GitHub API docs: https://docs.github.com/en/rest/users/ type UsersService service // User represents a GitHub user. @@ -63,12 +63,13 @@ type User struct { SubscriptionsURL *string `json:"subscriptions_url,omitempty"` // TextMatches is only populated from search results that request text matches - // See: search.go and https://docs.github.com/en/free-pro-team@latest/rest/reference/search/#text-match-metadata + // See: search.go and https://docs.github.com/en/rest/search/#text-match-metadata TextMatches []*TextMatch `json:"text_matches,omitempty"` - // Permissions identifies the permissions that a user has on a given - // repository. This is only populated when calling Repositories.ListCollaborators. + // Permissions and RoleName identify the permissions and role that a user has on a given + // repository. These are only populated when calling Repositories.ListCollaborators. Permissions map[string]bool `json:"permissions,omitempty"` + RoleName *string `json:"role_name,omitempty"` } func (u User) String() string { @@ -78,8 +79,8 @@ func (u User) String() string { // Get fetches a user. Passing the empty string will fetch the authenticated // user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#get-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#get-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/users#get-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/users#get-a-user func (s *UsersService) Get(ctx context.Context, user string) (*User, *Response, error) { var u string if user != "" { @@ -122,7 +123,7 @@ func (s *UsersService) GetByID(ctx context.Context, id int64) (*User, *Response, // Edit the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#update-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/users#update-the-authenticated-user func (s *UsersService) Edit(ctx context.Context, user *User) (*User, *Response, error) { u := "user" req, err := s.client.NewRequest("PATCH", u, user) @@ -164,7 +165,7 @@ type UserContext struct { // GetHovercard fetches contextual information about user. It requires authentication // via Basic Auth or via OAuth with the repo scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#get-contextual-information-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/users#get-contextual-information-for-a-user func (s *UsersService) GetHovercard(ctx context.Context, user string, opts *HovercardOptions) (*Hovercard, *Response, error) { u := fmt.Sprintf("users/%v/hovercard", user) u, err := addOptions(u, opts) @@ -202,7 +203,7 @@ type UserListOptions struct { // // To paginate through all users, populate 'Since' with the ID of the last user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-users +// GitHub API docs: https://docs.github.com/en/rest/users/users#list-users func (s *UsersService) ListAll(ctx context.Context, opts *UserListOptions) ([]*User, *Response, error) { u, err := addOptions("users", opts) if err != nil { @@ -226,7 +227,7 @@ func (s *UsersService) ListAll(ctx context.Context, opts *UserListOptions) ([]*U // ListInvitations lists all currently-open repository invitations for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#list-repository-invitations-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/collaborators/invitations#list-repository-invitations-for-the-authenticated-user func (s *UsersService) ListInvitations(ctx context.Context, opts *ListOptions) ([]*RepositoryInvitation, *Response, error) { u, err := addOptions("user/repository_invitations", opts) if err != nil { @@ -250,7 +251,7 @@ func (s *UsersService) ListInvitations(ctx context.Context, opts *ListOptions) ( // AcceptInvitation accepts the currently-open repository invitation for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#accept-a-repository-invitation +// GitHub API docs: https://docs.github.com/en/rest/collaborators/invitations#accept-a-repository-invitation func (s *UsersService) AcceptInvitation(ctx context.Context, invitationID int64) (*Response, error) { u := fmt.Sprintf("user/repository_invitations/%v", invitationID) req, err := s.client.NewRequest("PATCH", u, nil) @@ -264,7 +265,7 @@ func (s *UsersService) AcceptInvitation(ctx context.Context, invitationID int64) // DeclineInvitation declines the currently-open repository invitation for the // authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/repos/#decline-a-repository-invitation +// GitHub API docs: https://docs.github.com/en/rest/collaborators/invitations#decline-a-repository-invitation func (s *UsersService) DeclineInvitation(ctx context.Context, invitationID int64) (*Response, error) { u := fmt.Sprintf("user/repository_invitations/%v", invitationID) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/users_administration.go b/vendor/github.com/google/go-github/v47/github/users_administration.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/users_administration.go rename to vendor/github.com/google/go-github/v47/github/users_administration.go diff --git a/vendor/github.com/google/go-github/v43/github/users_blocking.go b/vendor/github.com/google/go-github/v47/github/users_blocking.go similarity index 82% rename from vendor/github.com/google/go-github/v43/github/users_blocking.go rename to vendor/github.com/google/go-github/v47/github/users_blocking.go index cdbc2c25..3d38d947 100644 --- a/vendor/github.com/google/go-github/v43/github/users_blocking.go +++ b/vendor/github.com/google/go-github/v47/github/users_blocking.go @@ -12,7 +12,7 @@ import ( // ListBlockedUsers lists all the blocked users by the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-users-blocked-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/blocking#list-users-blocked-by-the-authenticated-user func (s *UsersService) ListBlockedUsers(ctx context.Context, opts *ListOptions) ([]*User, *Response, error) { u := "user/blocks" u, err := addOptions(u, opts) @@ -39,7 +39,7 @@ func (s *UsersService) ListBlockedUsers(ctx context.Context, opts *ListOptions) // IsBlocked reports whether specified user is blocked by the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#check-if-a-user-is-blocked-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/blocking#check-if-a-user-is-blocked-by-the-authenticated-user func (s *UsersService) IsBlocked(ctx context.Context, user string) (bool, *Response, error) { u := fmt.Sprintf("user/blocks/%v", user) @@ -58,7 +58,7 @@ func (s *UsersService) IsBlocked(ctx context.Context, user string) (bool, *Respo // BlockUser blocks specified user for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#block-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/blocking#block-a-user func (s *UsersService) BlockUser(ctx context.Context, user string) (*Response, error) { u := fmt.Sprintf("user/blocks/%v", user) @@ -75,7 +75,7 @@ func (s *UsersService) BlockUser(ctx context.Context, user string) (*Response, e // UnblockUser unblocks specified user for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#unblock-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/blocking#unblock-a-user func (s *UsersService) UnblockUser(ctx context.Context, user string) (*Response, error) { u := fmt.Sprintf("user/blocks/%v", user) diff --git a/vendor/github.com/google/go-github/v43/github/users_emails.go b/vendor/github.com/google/go-github/v47/github/users_emails.go similarity index 80% rename from vendor/github.com/google/go-github/v43/github/users_emails.go rename to vendor/github.com/google/go-github/v47/github/users_emails.go index 94e7fb81..be7e0f81 100644 --- a/vendor/github.com/google/go-github/v43/github/users_emails.go +++ b/vendor/github.com/google/go-github/v47/github/users_emails.go @@ -17,7 +17,7 @@ type UserEmail struct { // ListEmails lists all email addresses for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-email-addresses-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/emails#list-email-addresses-for-the-authenticated-user func (s *UsersService) ListEmails(ctx context.Context, opts *ListOptions) ([]*UserEmail, *Response, error) { u := "user/emails" u, err := addOptions(u, opts) @@ -41,7 +41,7 @@ func (s *UsersService) ListEmails(ctx context.Context, opts *ListOptions) ([]*Us // AddEmails adds email addresses of the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#add-an-email-address-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/emails#add-an-email-address-for-the-authenticated-user func (s *UsersService) AddEmails(ctx context.Context, emails []string) ([]*UserEmail, *Response, error) { u := "user/emails" req, err := s.client.NewRequest("POST", u, emails) @@ -60,7 +60,7 @@ func (s *UsersService) AddEmails(ctx context.Context, emails []string) ([]*UserE // DeleteEmails deletes email addresses from authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#delete-an-email-address-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/emails#delete-an-email-address-for-the-authenticated-user func (s *UsersService) DeleteEmails(ctx context.Context, emails []string) (*Response, error) { u := "user/emails" req, err := s.client.NewRequest("DELETE", u, emails) diff --git a/vendor/github.com/google/go-github/v43/github/users_followers.go b/vendor/github.com/google/go-github/v47/github/users_followers.go similarity index 74% rename from vendor/github.com/google/go-github/v43/github/users_followers.go rename to vendor/github.com/google/go-github/v47/github/users_followers.go index f26392b6..1266e0e9 100644 --- a/vendor/github.com/google/go-github/v43/github/users_followers.go +++ b/vendor/github.com/google/go-github/v47/github/users_followers.go @@ -13,8 +13,8 @@ import ( // ListFollowers lists the followers for a user. Passing the empty string will // fetch followers for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-followers-of-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-followers-of-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/followers#list-followers-of-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/followers#list-followers-of-a-user func (s *UsersService) ListFollowers(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error) { var u string if user != "" { @@ -44,8 +44,8 @@ func (s *UsersService) ListFollowers(ctx context.Context, user string, opts *Lis // ListFollowing lists the people that a user is following. Passing the empty // string will list people the authenticated user is following. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-the-people-the-authenticated-user-follows -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-the-people-a-user-follows +// GitHub API docs: https://docs.github.com/en/rest/users/followers#list-the-people-the-authenticated-user-follows +// GitHub API docs: https://docs.github.com/en/rest/users/followers#list-the-people-a-user-follows func (s *UsersService) ListFollowing(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error) { var u string if user != "" { @@ -75,8 +75,8 @@ func (s *UsersService) ListFollowing(ctx context.Context, user string, opts *Lis // IsFollowing checks if "user" is following "target". Passing the empty // string for "user" will check if the authenticated user is following "target". // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#check-if-a-person-is-followed-by-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#check-if-a-user-follows-another-user +// GitHub API docs: https://docs.github.com/en/rest/users/followers#check-if-a-person-is-followed-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/followers#check-if-a-user-follows-another-user func (s *UsersService) IsFollowing(ctx context.Context, user, target string) (bool, *Response, error) { var u string if user != "" { @@ -97,7 +97,7 @@ func (s *UsersService) IsFollowing(ctx context.Context, user, target string) (bo // Follow will cause the authenticated user to follow the specified user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#follow-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/followers#follow-a-user func (s *UsersService) Follow(ctx context.Context, user string) (*Response, error) { u := fmt.Sprintf("user/following/%v", user) req, err := s.client.NewRequest("PUT", u, nil) @@ -110,7 +110,7 @@ func (s *UsersService) Follow(ctx context.Context, user string) (*Response, erro // Unfollow will cause the authenticated user to unfollow the specified user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#unfollow-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/followers#unfollow-a-user func (s *UsersService) Unfollow(ctx context.Context, user string) (*Response, error) { u := fmt.Sprintf("user/following/%v", user) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/users_gpg_keys.go b/vendor/github.com/google/go-github/v47/github/users_gpg_keys.go similarity index 85% rename from vendor/github.com/google/go-github/v43/github/users_gpg_keys.go rename to vendor/github.com/google/go-github/v47/github/users_gpg_keys.go index 387cc9b0..e9ce6222 100644 --- a/vendor/github.com/google/go-github/v43/github/users_gpg_keys.go +++ b/vendor/github.com/google/go-github/v47/github/users_gpg_keys.go @@ -45,8 +45,8 @@ type GPGEmail struct { // string will fetch keys for the authenticated user. It requires authentication // via Basic Auth or via OAuth with at least read:gpg_key scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-gpg-keys-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-gpg-keys-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/gpg-keys#list-gpg-keys-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/gpg-keys#list-gpg-keys-for-a-user func (s *UsersService) ListGPGKeys(ctx context.Context, user string, opts *ListOptions) ([]*GPGKey, *Response, error) { var u string if user != "" { @@ -76,7 +76,7 @@ func (s *UsersService) ListGPGKeys(ctx context.Context, user string, opts *ListO // GetGPGKey gets extended details for a single GPG key. It requires authentication // via Basic Auth or via OAuth with at least read:gpg_key scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#get-a-gpg-key-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/gpg-keys#get-a-gpg-key-for-the-authenticated-user func (s *UsersService) GetGPGKey(ctx context.Context, id int64) (*GPGKey, *Response, error) { u := fmt.Sprintf("user/gpg_keys/%v", id) req, err := s.client.NewRequest("GET", u, nil) @@ -96,7 +96,7 @@ func (s *UsersService) GetGPGKey(ctx context.Context, id int64) (*GPGKey, *Respo // CreateGPGKey creates a GPG key. It requires authenticatation via Basic Auth // or OAuth with at least write:gpg_key scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#create-a-gpg-key +// GitHub API docs: https://docs.github.com/en/rest/users/gpg-keys#create-a-gpg-key func (s *UsersService) CreateGPGKey(ctx context.Context, armoredPublicKey string) (*GPGKey, *Response, error) { gpgKey := &struct { ArmoredPublicKey string `json:"armored_public_key"` @@ -118,7 +118,7 @@ func (s *UsersService) CreateGPGKey(ctx context.Context, armoredPublicKey string // DeleteGPGKey deletes a GPG key. It requires authentication via Basic Auth or // via OAuth with at least admin:gpg_key scope. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#delete-a-gpg-key-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/gpg-keys#delete-a-gpg-key-for-the-authenticated-user func (s *UsersService) DeleteGPGKey(ctx context.Context, id int64) (*Response, error) { u := fmt.Sprintf("user/gpg_keys/%v", id) req, err := s.client.NewRequest("DELETE", u, nil) diff --git a/vendor/github.com/google/go-github/v43/github/users_keys.go b/vendor/github.com/google/go-github/v47/github/users_keys.go similarity index 78% rename from vendor/github.com/google/go-github/v43/github/users_keys.go rename to vendor/github.com/google/go-github/v47/github/users_keys.go index b5d4f79d..59d26cde 100644 --- a/vendor/github.com/google/go-github/v43/github/users_keys.go +++ b/vendor/github.com/google/go-github/v47/github/users_keys.go @@ -28,8 +28,8 @@ func (k Key) String() string { // ListKeys lists the verified public keys for a user. Passing the empty // string will fetch keys for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-public-ssh-keys-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#list-public-keys-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/users/keys#list-public-ssh-keys-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/keys#list-public-keys-for-a-user func (s *UsersService) ListKeys(ctx context.Context, user string, opts *ListOptions) ([]*Key, *Response, error) { var u string if user != "" { @@ -58,7 +58,7 @@ func (s *UsersService) ListKeys(ctx context.Context, user string, opts *ListOpti // GetKey fetches a single public key. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#get-a-public-ssh-key-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/keys#get-a-public-ssh-key-for-the-authenticated-user func (s *UsersService) GetKey(ctx context.Context, id int64) (*Key, *Response, error) { u := fmt.Sprintf("user/keys/%v", id) @@ -78,7 +78,7 @@ func (s *UsersService) GetKey(ctx context.Context, id int64) (*Key, *Response, e // CreateKey adds a public key for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#create-a-public-ssh-key-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/keys#create-a-public-ssh-key-for-the-authenticated-user func (s *UsersService) CreateKey(ctx context.Context, key *Key) (*Key, *Response, error) { u := "user/keys" @@ -98,7 +98,7 @@ func (s *UsersService) CreateKey(ctx context.Context, key *Key) (*Key, *Response // DeleteKey deletes a public key. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/users/#delete-a-public-ssh-key-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/keys#delete-a-public-ssh-key-for-the-authenticated-user func (s *UsersService) DeleteKey(ctx context.Context, id int64) (*Response, error) { u := fmt.Sprintf("user/keys/%v", id) diff --git a/vendor/github.com/google/go-github/v43/github/users_packages.go b/vendor/github.com/google/go-github/v47/github/users_packages.go similarity index 75% rename from vendor/github.com/google/go-github/v43/github/users_packages.go rename to vendor/github.com/google/go-github/v47/github/users_packages.go index cd20f8c1..da04919e 100644 --- a/vendor/github.com/google/go-github/v43/github/users_packages.go +++ b/vendor/github.com/google/go-github/v47/github/users_packages.go @@ -13,8 +13,8 @@ import ( // List the packages for a user. Passing the empty string for "user" will // list packages for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#list-packages-for-the-authenticated-users-namespace -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#list-packages-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#list-packages-for-the-authenticated-users-namespace +// GitHub API docs: https://docs.github.com/en/rest/packages#list-packages-for-a-user func (s *UsersService) ListPackages(ctx context.Context, user string, opts *PackageListOptions) ([]*Package, *Response, error) { var u string if user != "" { @@ -44,8 +44,8 @@ func (s *UsersService) ListPackages(ctx context.Context, user string, opts *Pack // Get a package by name for a user. Passing the empty string for "user" will // get the package for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-for-a-user func (s *UsersService) GetPackage(ctx context.Context, user, packageType, packageName string) (*Package, *Response, error) { var u string if user != "" { @@ -71,8 +71,8 @@ func (s *UsersService) GetPackage(ctx context.Context, user, packageType, packag // Delete a package from a user. Passing the empty string for "user" will // delete the package for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-a-package-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-a-package-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#delete-a-package-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#delete-a-package-for-a-user func (s *UsersService) DeletePackage(ctx context.Context, user, packageType, packageName string) (*Response, error) { var u string if user != "" { @@ -92,8 +92,8 @@ func (s *UsersService) DeletePackage(ctx context.Context, user, packageType, pac // Restore a package to a user. Passing the empty string for "user" will // restore the package for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-a-package-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-a-package-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#restore-a-package-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#restore-a-package-for-a-user func (s *UsersService) RestorePackage(ctx context.Context, user, packageType, packageName string) (*Response, error) { var u string if user != "" { @@ -113,8 +113,8 @@ func (s *UsersService) RestorePackage(ctx context.Context, user, packageType, pa // Get all versions of a package for a user. Passing the empty string for "user" will // get versions for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-all-package-versions-for-a-package-owned-by-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/users#delete-an-email-address-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#get-all-package-versions-for-a-package-owned-by-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#get-all-package-versions-for-a-package-owned-by-a-user func (s *UsersService) PackageGetAllVersions(ctx context.Context, user, packageType, packageName string, opts *PackageListOptions) ([]*PackageVersion, *Response, error) { var u string if user != "" { @@ -144,8 +144,8 @@ func (s *UsersService) PackageGetAllVersions(ctx context.Context, user, packageT // Get a specific version of a package for a user. Passing the empty string for "user" will // get the version for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-version-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#get-a-package-version-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-version-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#get-a-package-version-for-a-user func (s *UsersService) PackageGetVersion(ctx context.Context, user, packageType, packageName string, packageVersionID int64) (*PackageVersion, *Response, error) { var u string if user != "" { @@ -171,8 +171,8 @@ func (s *UsersService) PackageGetVersion(ctx context.Context, user, packageType, // Delete a package version for a user. Passing the empty string for "user" will // delete the version for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-a-package-version-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#delete-package-version-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#delete-a-package-version-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#delete-package-version-for-a-user func (s *UsersService) PackageDeleteVersion(ctx context.Context, user, packageType, packageName string, packageVersionID int64) (*Response, error) { var u string if user != "" { @@ -192,8 +192,8 @@ func (s *UsersService) PackageDeleteVersion(ctx context.Context, user, packageTy // Restore a package version to a user. Passing the empty string for "user" will // restore the version for the authenticated user. // -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-a-package-version-for-the-authenticated-user -// GitHub API docs: https://docs.github.com/en/rest/reference/packages#restore-package-version-for-a-user +// GitHub API docs: https://docs.github.com/en/rest/packages#restore-a-package-version-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/packages#restore-package-version-for-a-user func (s *UsersService) PackageRestoreVersion(ctx context.Context, user, packageType, packageName string, packageVersionID int64) (*Response, error) { var u string if user != "" { diff --git a/vendor/github.com/google/go-github/v43/github/users_projects.go b/vendor/github.com/google/go-github/v47/github/users_projects.go similarity index 88% rename from vendor/github.com/google/go-github/v43/github/users_projects.go rename to vendor/github.com/google/go-github/v47/github/users_projects.go index dd9ceaf2..0cbd61f9 100644 --- a/vendor/github.com/google/go-github/v43/github/users_projects.go +++ b/vendor/github.com/google/go-github/v47/github/users_projects.go @@ -12,7 +12,7 @@ import ( // ListProjects lists the projects for the specified user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#list-user-projects +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#list-user-projects func (s *UsersService) ListProjects(ctx context.Context, user string, opts *ProjectListOptions) ([]*Project, *Response, error) { u := fmt.Sprintf("users/%v/projects", user) u, err := addOptions(u, opts) @@ -47,7 +47,7 @@ type CreateUserProjectOptions struct { // CreateProject creates a GitHub Project for the current user. // -// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/projects/#create-a-user-project +// GitHub API docs: https://docs.github.com/en/rest/projects/projects#create-a-user-project func (s *UsersService) CreateProject(ctx context.Context, opts *CreateUserProjectOptions) (*Project, *Response, error) { u := "user/projects" req, err := s.client.NewRequest("POST", u, opts) diff --git a/vendor/github.com/google/go-github/v43/github/with_appengine.go b/vendor/github.com/google/go-github/v47/github/with_appengine.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/with_appengine.go rename to vendor/github.com/google/go-github/v47/github/with_appengine.go diff --git a/vendor/github.com/google/go-github/v43/github/without_appengine.go b/vendor/github.com/google/go-github/v47/github/without_appengine.go similarity index 100% rename from vendor/github.com/google/go-github/v43/github/without_appengine.go rename to vendor/github.com/google/go-github/v47/github/without_appengine.go diff --git a/vendor/modules.txt b/vendor/modules.txt index a479779f..ba5205cc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -29,9 +29,9 @@ github.com/golang-jwt/jwt # github.com/golang/protobuf v1.5.2 ## explicit; go 1.9 github.com/golang/protobuf/proto -# github.com/google/go-github/v43 v43.0.0 +# github.com/google/go-github/v47 v47.1.0 => github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 ## explicit; go 1.17 -github.com/google/go-github/v43/github +github.com/google/go-github/v47/github # github.com/google/go-querystring v1.1.0 ## explicit; go 1.10 github.com/google/go-querystring/query @@ -292,3 +292,4 @@ gorm.io/gorm/logger gorm.io/gorm/migrator gorm.io/gorm/schema gorm.io/gorm/utils +# github.com/google/go-github/v47 => github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 From 3e3b91ee59c64796fa0b33eaacb5f927bd8b19be Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 13 Oct 2022 18:32:21 +0000 Subject: [PATCH 04/12] Add enterprise support to garm-cli Signed-off-by: Gabriel Adrian Samfira --- apiserver/controllers/instances.go | 2 +- cmd/garm-cli/client/enterprises.go | 203 +++++++++++++++++++++++++++ cmd/garm-cli/client/organizations.go | 6 +- cmd/garm-cli/cmd/enterprise.go | 186 ++++++++++++++++++++++++ cmd/garm-cli/cmd/organization.go | 27 +--- cmd/garm-cli/cmd/pool.go | 14 +- cmd/garm-cli/cmd/repo_pool.go | 6 + cmd/garm-cli/cmd/repository.go | 23 --- cmd/garm-cli/cmd/runner.go | 12 +- database/sql/enterprise.go | 2 +- database/sql/pools.go | 1 + database/sql/util.go | 5 + params/params.go | 2 + runner/pool/pool.go | 3 +- runner/pools.go | 5 + runner/runner.go | 44 +++++- 16 files changed, 479 insertions(+), 62 deletions(-) create mode 100644 cmd/garm-cli/client/enterprises.go create mode 100644 cmd/garm-cli/cmd/enterprise.go diff --git a/apiserver/controllers/instances.go b/apiserver/controllers/instances.go index ee44dafe..a8d6fe2f 100644 --- a/apiserver/controllers/instances.go +++ b/apiserver/controllers/instances.go @@ -158,7 +158,7 @@ func (a *APIController) ListEnterpriseInstancesHandler(w http.ResponseWriter, r return } - instances, err := a.r.ListOrgInstances(ctx, enterpriseID) + instances, err := a.r.ListEnterpriseInstances(ctx, enterpriseID) if err != nil { log.Printf("listing instances: %s", err) handleError(w, err) diff --git a/cmd/garm-cli/client/enterprises.go b/cmd/garm-cli/client/enterprises.go new file mode 100644 index 00000000..f5d855b8 --- /dev/null +++ b/cmd/garm-cli/client/enterprises.go @@ -0,0 +1,203 @@ +// Copyright 2022 Cloudbase Solutions SRL +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package client + +import ( + "encoding/json" + "fmt" + + "garm/params" + + "github.com/pkg/errors" +) + +func (c *Client) ListEnterprises() ([]params.Enterprise, error) { + var enterprises []params.Enterprise + url := fmt.Sprintf("%s/api/v1/enterprises", c.Config.BaseURL) + resp, err := c.client.R(). + SetResult(&enterprises). + Get(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return nil, errors.Wrap(decErr, "sending request") + } + return nil, fmt.Errorf("error fetching enterprises: %s", apiErr.Details) + } + return enterprises, nil +} + +func (c *Client) CreateEnterprise(param params.CreateEnterpriseParams) (params.Enterprise, error) { + var response params.Enterprise + url := fmt.Sprintf("%s/api/v1/enterprises", c.Config.BaseURL) + + body, err := json.Marshal(param) + if err != nil { + return params.Enterprise{}, err + } + resp, err := c.client.R(). + SetBody(body). + SetResult(&response). + Post(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error creating enterprise: %s", apiErr.Details) + } + return response, nil +} + +func (c *Client) GetEnterprise(enterpriseID string) (params.Enterprise, error) { + var response params.Enterprise + url := fmt.Sprintf("%s/api/v1/enterprises/%s", c.Config.BaseURL, enterpriseID) + resp, err := c.client.R(). + SetResult(&response). + Get(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error fetching enterprise: %s", apiErr.Details) + } + return response, nil +} + +func (c *Client) DeleteEnterprise(enterpriseID string) error { + url := fmt.Sprintf("%s/api/v1/enterprises/%s", c.Config.BaseURL, enterpriseID) + resp, err := c.client.R(). + Delete(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return errors.Wrap(decErr, "sending request") + } + return fmt.Errorf("error fetching removing enterprise: %s", apiErr.Details) + } + return nil +} + +func (c *Client) CreateEnterprisePool(enterpriseID string, param params.CreatePoolParams) (params.Pool, error) { + url := fmt.Sprintf("%s/api/v1/enterprises/%s/pools", c.Config.BaseURL, enterpriseID) + + var response params.Pool + body, err := json.Marshal(param) + if err != nil { + return response, err + } + resp, err := c.client.R(). + SetBody(body). + SetResult(&response). + Post(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error creating enterprise pool: %s", apiErr.Details) + } + return response, nil +} + +func (c *Client) ListEnterprisePools(enterpriseID string) ([]params.Pool, error) { + url := fmt.Sprintf("%s/api/v1/enterprises/%s/pools", c.Config.BaseURL, enterpriseID) + + var response []params.Pool + resp, err := c.client.R(). + SetResult(&response). + Get(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error listing enterprise pools: %s", apiErr.Details) + } + return response, nil +} + +func (c *Client) GetEnterprisePool(enterpriseID, poolID string) (params.Pool, error) { + url := fmt.Sprintf("%s/api/v1/enterprises/%s/pools/%s", c.Config.BaseURL, enterpriseID, poolID) + + var response params.Pool + resp, err := c.client.R(). + SetResult(&response). + Get(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error fetching enterprise pool: %s", apiErr.Details) + } + return response, nil +} + +func (c *Client) DeleteEnterprisePool(enterpriseID, poolID string) error { + url := fmt.Sprintf("%s/api/v1/enterprises/%s/pools/%s", c.Config.BaseURL, enterpriseID, poolID) + + resp, err := c.client.R(). + Delete(url) + + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return errors.Wrap(decErr, "sending request") + } + return fmt.Errorf("error deleting enterprise pool: %s", apiErr.Details) + } + return nil +} + +func (c *Client) UpdateEnterprisePool(enterpriseID, poolID string, param params.UpdatePoolParams) (params.Pool, error) { + url := fmt.Sprintf("%s/api/v1/enterprises/%s/pools/%s", c.Config.BaseURL, enterpriseID, poolID) + + var response params.Pool + body, err := json.Marshal(param) + if err != nil { + return response, err + } + resp, err := c.client.R(). + SetBody(body). + SetResult(&response). + Put(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error updating enterprise pool: %s", apiErr.Details) + } + return response, nil +} + +func (c *Client) ListEnterpriseInstances(enterpriseID string) ([]params.Instance, error) { + url := fmt.Sprintf("%s/api/v1/enterprises/%s/instances", c.Config.BaseURL, enterpriseID) + + var response []params.Instance + resp, err := c.client.R(). + SetResult(&response). + Get(url) + if err != nil || resp.IsError() { + apiErr, decErr := c.decodeAPIError(resp.Body()) + if decErr != nil { + return response, errors.Wrap(decErr, "sending request") + } + return response, fmt.Errorf("error listing enterprise instances: %s", apiErr.Details) + } + return response, nil +} diff --git a/cmd/garm-cli/client/organizations.go b/cmd/garm-cli/client/organizations.go index b20df34b..64425c7a 100644 --- a/cmd/garm-cli/client/organizations.go +++ b/cmd/garm-cli/client/organizations.go @@ -56,7 +56,7 @@ func (c *Client) CreateOrganization(param params.CreateOrgParams) (params.Organi if decErr != nil { return response, errors.Wrap(decErr, "sending request") } - return response, fmt.Errorf("error performing login: %s", apiErr.Details) + return response, fmt.Errorf("error creating org: %s", apiErr.Details) } return response, nil } @@ -72,7 +72,7 @@ func (c *Client) GetOrganization(orgID string) (params.Organization, error) { if decErr != nil { return response, errors.Wrap(decErr, "sending request") } - return response, fmt.Errorf("error fetching orgs: %s", apiErr.Details) + return response, fmt.Errorf("error fetching org: %s", apiErr.Details) } return response, nil } @@ -86,7 +86,7 @@ func (c *Client) DeleteOrganization(orgID string) error { if decErr != nil { return errors.Wrap(decErr, "sending request") } - return fmt.Errorf("error fetching orgs: %s", apiErr.Details) + return fmt.Errorf("error removing org: %s", apiErr.Details) } return nil } diff --git a/cmd/garm-cli/cmd/enterprise.go b/cmd/garm-cli/cmd/enterprise.go new file mode 100644 index 00000000..82c0b6fe --- /dev/null +++ b/cmd/garm-cli/cmd/enterprise.go @@ -0,0 +1,186 @@ +// Copyright 2022 Cloudbase Solutions SRL +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. You may obtain +// a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations +// under the License. + +package cmd + +import ( + "fmt" + "garm/params" + + "github.com/jedib0t/go-pretty/v6/table" + "github.com/spf13/cobra" +) + +var ( + enterpriseName string + enterpriseWebhookSecret string + enterpriseCreds string +) + +// enterpriseCmd represents the enterprise command +var enterpriseCmd = &cobra.Command{ + Use: "enterprise", + Aliases: []string{"ent"}, + SilenceUsage: true, + Short: "Manage enterprise", + Long: `Add, remove or update enterprise for which we manage +self hosted runners. + +This command allows you to define a new enterprise or manage an existing +enterprise for which garm maintains pools of self hosted runners.`, + Run: nil, +} + +var enterpriseAddCmd = &cobra.Command{ + Use: "add", + Aliases: []string{"create"}, + Short: "Add enterprise", + Long: `Add a new enterprise to the manager.`, + SilenceUsage: true, + RunE: func(cmd *cobra.Command, args []string) error { + if needsInit { + return needsInitError + } + + newEnterpriseReq := params.CreateEnterpriseParams{ + Name: enterpriseName, + WebhookSecret: enterpriseWebhookSecret, + CredentialsName: enterpriseCreds, + } + enterprise, err := cli.CreateEnterprise(newEnterpriseReq) + if err != nil { + return err + } + formatOneEnterprise(enterprise) + return nil + }, +} + +var enterpriseListCmd = &cobra.Command{ + Use: "list", + Aliases: []string{"ls"}, + Short: "List enterprises", + Long: `List all configured enterprises that are currently managed.`, + SilenceUsage: true, + RunE: func(cmd *cobra.Command, args []string) error { + if needsInit { + return needsInitError + } + + enterprises, err := cli.ListEnterprises() + if err != nil { + return err + } + formatEnterprises(enterprises) + return nil + }, +} + +var enterpriseShowCmd = &cobra.Command{ + Use: "show", + Short: "Show details for one enterprise", + Long: `Displays detailed information about a single enterprise.`, + SilenceUsage: true, + RunE: func(cmd *cobra.Command, args []string) error { + if needsInit { + return needsInitError + } + if len(args) == 0 { + return fmt.Errorf("requires a enterprise ID") + } + if len(args) > 1 { + return fmt.Errorf("too many arguments") + } + enterprise, err := cli.GetEnterprise(args[0]) + if err != nil { + return err + } + formatOneEnterprise(enterprise) + return nil + }, +} + +var enterpriseDeleteCmd = &cobra.Command{ + Use: "delete", + Aliases: []string{"remove", "rm", "del"}, + Short: "Removes one enterprise", + Long: `Delete one enterprise from the manager.`, + SilenceUsage: true, + RunE: func(cmd *cobra.Command, args []string) error { + if needsInit { + return needsInitError + } + if len(args) == 0 { + return fmt.Errorf("requires a enterprise ID") + } + if len(args) > 1 { + return fmt.Errorf("too many arguments") + } + if err := cli.DeleteEnterprise(args[0]); err != nil { + return err + } + return nil + }, +} + +func init() { + + enterpriseAddCmd.Flags().StringVar(&enterpriseName, "name", "", "The name of the enterprise") + enterpriseAddCmd.Flags().StringVar(&enterpriseWebhookSecret, "webhook-secret", "", "The webhook secret for this enterprise") + enterpriseAddCmd.Flags().StringVar(&enterpriseCreds, "credentials", "", "Credentials name. See credentials list.") + enterpriseAddCmd.MarkFlagRequired("credentials") + enterpriseAddCmd.MarkFlagRequired("name") + + enterpriseCmd.AddCommand( + enterpriseListCmd, + enterpriseAddCmd, + enterpriseShowCmd, + enterpriseDeleteCmd, + ) + + rootCmd.AddCommand(enterpriseCmd) +} + +func formatEnterprises(enterprises []params.Enterprise) { + t := table.NewWriter() + header := table.Row{"ID", "Name", "Credentials name"} + t.AppendHeader(header) + for _, val := range enterprises { + t.AppendRow(table.Row{val.ID, val.Name, val.CredentialsName}) + t.AppendSeparator() + } + fmt.Println(t.Render()) +} + +func formatOneEnterprise(enterprise params.Enterprise) { + t := table.NewWriter() + rowConfigAutoMerge := table.RowConfig{AutoMerge: true} + header := table.Row{"Field", "Value"} + t.AppendHeader(header) + t.AppendRow(table.Row{"ID", enterprise.ID}) + t.AppendRow(table.Row{"Name", enterprise.Name}) + t.AppendRow(table.Row{"Credentials", enterprise.CredentialsName}) + + if len(enterprise.Pools) > 0 { + for _, pool := range enterprise.Pools { + t.AppendRow(table.Row{"Pools", pool.ID}, rowConfigAutoMerge) + } + } + t.SetColumnConfigs([]table.ColumnConfig{ + {Number: 1, AutoMerge: true}, + {Number: 2, AutoMerge: true}, + }) + + fmt.Println(t.Render()) +} diff --git a/cmd/garm-cli/cmd/organization.go b/cmd/garm-cli/cmd/organization.go index f2f629c0..432d3263 100644 --- a/cmd/garm-cli/cmd/organization.go +++ b/cmd/garm-cli/cmd/organization.go @@ -38,7 +38,7 @@ var organizationCmd = &cobra.Command{ self hosted runners. This command allows you to define a new organization or manage an existing -organization for which the garm maintains pools of self hosted runners.`, +organization for which garm maintains pools of self hosted runners.`, Run: nil, } @@ -71,7 +71,7 @@ var orgListCmd = &cobra.Command{ Use: "list", Aliases: []string{"ls"}, Short: "List organizations", - Long: `List all configured respositories that are currently managed.`, + Long: `List all configured organizations that are currently managed.`, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { @@ -134,29 +134,6 @@ var orgDeleteCmd = &cobra.Command{ }, } -var orgInstanceListCmd = &cobra.Command{ - Use: "delete", - Aliases: []string{"remove", "rm", "del"}, - Short: "Removes one organization", - Long: `Delete one organization from the manager.`, - SilenceUsage: true, - RunE: func(cmd *cobra.Command, args []string) error { - if needsInit { - return needsInitError - } - if len(args) == 0 { - return fmt.Errorf("requires a organization ID") - } - if len(args) > 1 { - return fmt.Errorf("too many arguments") - } - if err := cli.DeleteOrganization(args[0]); err != nil { - return err - } - return nil - }, -} - func init() { orgAddCmd.Flags().StringVar(&orgName, "name", "", "The name of the organization") diff --git a/cmd/garm-cli/cmd/pool.go b/cmd/garm-cli/cmd/pool.go index 4eb4687a..2d0c8802 100644 --- a/cmd/garm-cli/cmd/pool.go +++ b/cmd/garm-cli/cmd/pool.go @@ -27,6 +27,7 @@ import ( var ( poolRepository string poolOrganization string + poolEnterprise string poolAll bool ) @@ -57,6 +58,9 @@ Example: List pools from one org: garm-cli pool list --org=5493e51f-3170-4ce3-9f05-3fe690fc6ec6 + List pools from one enterprise: + garm-cli pool list --org=a8ee4c66-e762-4cbe-a35d-175dba2c9e62 + List all pools from all repos and orgs: garm-cli pool list --all @@ -76,6 +80,8 @@ Example: pools, err = cli.ListRepoPools(poolRepository) } else if cmd.Flags().Changed("org") { pools, err = cli.ListOrgPools(poolOrganization) + } else if cmd.Flags().Changed("enterprise") { + pools, err = cli.ListEnterprisePools(poolEnterprise) } else if cmd.Flags().Changed("all") { pools, err = cli.ListAllPools() } else { @@ -183,6 +189,8 @@ var poolAddCmd = &cobra.Command{ pool, err = cli.CreateRepoPool(poolRepository, newPoolParams) } else if cmd.Flags().Changed("org") { pool, err = cli.CreateOrgPool(poolOrganization, newPoolParams) + } else if cmd.Flags().Changed("enterprise") { + pool, err = cli.CreateEnterprisePool(poolEnterprise, newPoolParams) } else { cmd.Help() os.Exit(0) @@ -270,8 +278,9 @@ explicitly remove them using the runner delete command. func init() { poolListCmd.Flags().StringVarP(&poolRepository, "repo", "r", "", "List all pools within this repository.") poolListCmd.Flags().StringVarP(&poolOrganization, "org", "o", "", "List all pools withing this organization.") + poolListCmd.Flags().StringVarP(&poolEnterprise, "enterprise", "e", "", "List all pools withing this enterprise.") poolListCmd.Flags().BoolVarP(&poolAll, "all", "a", false, "List all pools, regardless of org or repo.") - poolListCmd.MarkFlagsMutuallyExclusive("repo", "org", "all") + poolListCmd.MarkFlagsMutuallyExclusive("repo", "org", "all", "enterprise") poolUpdateCmd.Flags().StringVar(&poolImage, "image", "", "The provider-specific image name to use for runners in this pool.") poolUpdateCmd.Flags().StringVar(&poolFlavor, "flavor", "", "The flavor to use for this runner.") @@ -300,7 +309,8 @@ func init() { poolAddCmd.Flags().StringVarP(&poolRepository, "repo", "r", "", "Add the new pool within this repository.") poolAddCmd.Flags().StringVarP(&poolOrganization, "org", "o", "", "Add the new pool withing this organization.") - poolAddCmd.MarkFlagsMutuallyExclusive("repo", "org") + poolAddCmd.Flags().StringVarP(&poolEnterprise, "enterprise", "e", "", "Add the new pool withing this enterprise.") + poolAddCmd.MarkFlagsMutuallyExclusive("repo", "org", "enterprise") poolCmd.AddCommand( poolListCmd, diff --git a/cmd/garm-cli/cmd/repo_pool.go b/cmd/garm-cli/cmd/repo_pool.go index 8e430ab6..30d64b99 100644 --- a/cmd/garm-cli/cmd/repo_pool.go +++ b/cmd/garm-cli/cmd/repo_pool.go @@ -286,6 +286,9 @@ func formatPools(pools []params.Pool) { } else if pool.OrgID != "" && pool.OrgName != "" { belongsTo = pool.OrgName level = "org" + } else if pool.EnterpriseID != "" && pool.EnterpriseName != "" { + belongsTo = pool.EnterpriseName + level = "enterprise" } t.AppendRow(table.Row{pool.ID, pool.Image, pool.Flavor, strings.Join(tags, " "), belongsTo, level, pool.Enabled}) t.AppendSeparator() @@ -313,6 +316,9 @@ func formatOnePool(pool params.Pool) { } else if pool.OrgID != "" && pool.OrgName != "" { belongsTo = pool.OrgName level = "org" + } else if pool.EnterpriseID != "" && pool.EnterpriseName != "" { + belongsTo = pool.EnterpriseName + level = "enterprise" } t.AppendHeader(header) diff --git a/cmd/garm-cli/cmd/repository.go b/cmd/garm-cli/cmd/repository.go index 02d3543b..bcb33db9 100644 --- a/cmd/garm-cli/cmd/repository.go +++ b/cmd/garm-cli/cmd/repository.go @@ -136,29 +136,6 @@ var repoDeleteCmd = &cobra.Command{ }, } -var repoInstanceListCmd = &cobra.Command{ - Use: "delete", - Aliases: []string{"remove", "rm", "del"}, - Short: "Removes one repository", - Long: `Delete one repository from the manager.`, - SilenceUsage: true, - RunE: func(cmd *cobra.Command, args []string) error { - if needsInit { - return needsInitError - } - if len(args) == 0 { - return fmt.Errorf("requires a repository ID") - } - if len(args) > 1 { - return fmt.Errorf("too many arguments") - } - if err := cli.DeleteRepository(args[0]); err != nil { - return err - } - return nil - }, -} - func init() { repoAddCmd.Flags().StringVar(&repoOwner, "owner", "", "The owner of this repository") diff --git a/cmd/garm-cli/cmd/runner.go b/cmd/garm-cli/cmd/runner.go index 06c8cc21..f509d641 100644 --- a/cmd/garm-cli/cmd/runner.go +++ b/cmd/garm-cli/cmd/runner.go @@ -26,6 +26,7 @@ import ( var ( runnerRepository string runnerOrganization string + runnerEnterprise string runnerAll bool forceRemove bool ) @@ -61,6 +62,9 @@ Example: List runners from one org: garm-cli runner list --org=5493e51f-3170-4ce3-9f05-3fe690fc6ec6 + List runners from one enterprise: + garm-cli runner list --enterprise=a966188b-0e05-4edc-9b82-bc81a1fd38ed + List all runners from all pools belonging to all repos and orgs: garm-cli runner list --all @@ -78,9 +82,10 @@ Example: case 1: if cmd.Flags().Changed("repo") || cmd.Flags().Changed("org") || + cmd.Flags().Changed("enterprise") || cmd.Flags().Changed("all") { - return fmt.Errorf("specifying a pool ID and any of [all org repo] are mutually exclusive") + return fmt.Errorf("specifying a pool ID and any of [all org repo enterprise] are mutually exclusive") } instances, err = cli.ListPoolInstances(args[0]) case 0: @@ -88,6 +93,8 @@ Example: instances, err = cli.ListRepoInstances(runnerRepository) } else if cmd.Flags().Changed("org") { instances, err = cli.ListOrgInstances(runnerOrganization) + } else if cmd.Flags().Changed("enterprise") { + instances, err = cli.ListEnterpriseInstances(runnerEnterprise) } else if cmd.Flags().Changed("all") { instances, err = cli.ListAllInstances() } else { @@ -172,8 +179,9 @@ to either cancel the workflow or wait for it to finish. func init() { runnerListCmd.Flags().StringVarP(&runnerRepository, "repo", "r", "", "List all runners from all pools within this repository.") runnerListCmd.Flags().StringVarP(&runnerOrganization, "org", "o", "", "List all runners from all pools withing this organization.") + runnerListCmd.Flags().StringVarP(&runnerEnterprise, "enterprise", "e", "", "List all runners from all pools withing this enterprise.") runnerListCmd.Flags().BoolVarP(&runnerAll, "all", "a", false, "List all runners, regardless of org or repo.") - runnerListCmd.MarkFlagsMutuallyExclusive("repo", "org", "all") + runnerListCmd.MarkFlagsMutuallyExclusive("repo", "org", "enterprise", "all") runnerDeleteCmd.Flags().BoolVarP(&forceRemove, "force-remove-runner", "f", false, "Confirm you want to delete a runner") runnerDeleteCmd.MarkFlagsMutuallyExclusive("force-remove-runner") diff --git a/database/sql/enterprise.go b/database/sql/enterprise.go index b41cf35b..9d8eb1ca 100644 --- a/database/sql/enterprise.go +++ b/database/sql/enterprise.go @@ -229,7 +229,7 @@ func (s *sqlDatabase) FindEnterprisePoolByTags(ctx context.Context, enterpriseID } func (s *sqlDatabase) ListEnterprisePools(ctx context.Context, enterpriseID string) ([]params.Pool, error) { - pools, err := s.getEnterprisePools(ctx, enterpriseID, "Tags") + pools, err := s.getEnterprisePools(ctx, enterpriseID, "Tags", "Enterprise") if err != nil { return nil, errors.Wrap(err, "fetching pools") } diff --git a/database/sql/pools.go b/database/sql/pools.go index ae9f10ca..40be0531 100644 --- a/database/sql/pools.go +++ b/database/sql/pools.go @@ -29,6 +29,7 @@ func (s *sqlDatabase) ListAllPools(ctx context.Context) ([]params.Pool, error) { Preload("Tags"). Preload("Organization"). Preload("Repository"). + Preload("Enterprise"). Find(&pools) if q.Error != nil { return nil, errors.Wrap(q.Error, "fetching all pools") diff --git a/database/sql/util.go b/database/sql/util.go index 484fcb8d..e8ff2f54 100644 --- a/database/sql/util.go +++ b/database/sql/util.go @@ -128,6 +128,11 @@ func (s *sqlDatabase) sqlToCommonPool(pool Pool) params.Pool { ret.OrgName = pool.Organization.Name } + if pool.EnterpriseID != uuid.Nil && pool.Enterprise.Name != "" { + ret.EnterpriseID = pool.EnterpriseID.String() + ret.EnterpriseName = pool.Enterprise.Name + } + for idx, val := range pool.Tags { ret.Tags[idx] = s.sqlToCommonTags(*val) } diff --git a/params/params.go b/params/params.go index ae24ac78..ed0f3105 100644 --- a/params/params.go +++ b/params/params.go @@ -128,6 +128,8 @@ type Pool struct { RepoName string `json:"repo_name,omitempty"` OrgID string `json:"org_id,omitempty"` OrgName string `json:"org_name,omitempty"` + EnterpriseID string `json:"enterprise_id,omitempty"` + EnterpriseName string `json:"enterprise_name,omitempty"` RunnerBootstrapTimeout uint `json:"runner_bootstrap_timeout"` } diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 6c39b3f2..9a39f28f 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -353,7 +353,7 @@ func (r *basePool) loop() { reapTimer := time.NewTicker(common.PoolReapTimeoutInterval) toolUpdateTimer := time.NewTicker(common.PoolToolUpdateInterval) defer func() { - log.Printf("repository %s loop exited", r.helper.String()) + log.Printf("%s loop exited", r.helper.String()) consolidateTimer.Stop() reapTimer.Stop() toolUpdateTimer.Stop() @@ -896,6 +896,7 @@ func (r *basePool) ForceDeleteRunner(runner params.Instance) error { } } } + log.Printf("setting instance status for: %v", runner.Name) if err := r.setInstanceStatus(runner.Name, providerCommon.InstancePendingDelete, nil); err != nil { log.Printf("failed to update runner %s status", runner.Name) diff --git a/runner/pools.go b/runner/pools.go index 060f7cbd..92f6e286 100644 --- a/runner/pools.go +++ b/runner/pools.go @@ -16,6 +16,7 @@ package runner import ( "context" + "fmt" "garm/auth" runnerErrors "garm/errors" @@ -112,6 +113,10 @@ func (r *Runner) UpdatePoolByID(ctx context.Context, poolID string, param params newPool, err = r.store.UpdateRepositoryPool(ctx, pool.RepoID, poolID, param) } else if pool.OrgID != "" { newPool, err = r.store.UpdateOrganizationPool(ctx, pool.OrgID, poolID, param) + } else if pool.EnterpriseID != "" { + newPool, err = r.store.UpdateEnterprisePool(ctx, pool.EnterpriseID, poolID, param) + } else { + return params.Pool{}, fmt.Errorf("pool not bound to a repo, org or enterprise") } if err != nil { diff --git a/runner/runner.go b/runner/runner.go index ca25f29e..fde59c2c 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -71,6 +71,7 @@ func NewRunner(ctx context.Context, cfg config.Config) (*Runner, error) { credentials: creds, repositories: map[string]common.PoolManager{}, organizations: map[string]common.PoolManager{}, + enterprises: map[string]common.PoolManager{}, } runner := &Runner{ ctx: ctx, @@ -81,7 +82,7 @@ func NewRunner(ctx context.Context, cfg config.Config) (*Runner, error) { credentials: creds, } - if err := runner.loadReposAndOrgs(); err != nil { + if err := runner.loadReposOrgsAndEnterprises(); err != nil { return nil, errors.Wrap(err, "loading pool managers") } @@ -293,7 +294,7 @@ func (r *Runner) ListProviders(ctx context.Context) ([]params.Provider, error) { return ret, nil } -func (r *Runner) loadReposAndOrgs() error { +func (r *Runner) loadReposOrgsAndEnterprises() error { r.mux.Lock() defer r.mux.Unlock() @@ -307,7 +308,12 @@ func (r *Runner) loadReposAndOrgs() error { return errors.Wrap(err, "fetching organizations") } - expectedReplies := len(repos) + len(orgs) + enterprises, err := r.store.ListEnterprises(r.ctx) + if err != nil { + return errors.Wrap(err, "fetching enterprises") + } + + expectedReplies := len(repos) + len(orgs) + len(enterprises) errChan := make(chan error, expectedReplies) for _, repo := range repos { @@ -326,6 +332,14 @@ func (r *Runner) loadReposAndOrgs() error { }(org) } + for _, enterprise := range enterprises { + go func(enterprise params.Enterprise) { + log.Printf("creating pool manager for enterprise %s", enterprise.Name) + _, err := r.poolManagerCtrl.CreateEnterprisePoolManager(r.ctx, enterprise, r.providers, r.store) + errChan <- err + }(enterprise) + } + for i := 0; i < expectedReplies; i++ { select { case err := <-errChan: @@ -354,7 +368,12 @@ func (r *Runner) Start() error { return errors.Wrap(err, "fetch org pool managers") } - expectedReplies := len(repositories) + len(organizations) + enterprises, err := r.poolManagerCtrl.GetEnterprisePoolManagers() + if err != nil { + return errors.Wrap(err, "fetch enterprise pool managers") + } + + expectedReplies := len(repositories) + len(organizations) + len(enterprises) errChan := make(chan error, expectedReplies) for _, repo := range repositories { @@ -373,6 +392,14 @@ func (r *Runner) Start() error { } + for _, enterprise := range enterprises { + go func(org common.PoolManager) { + err := org.Start() + errChan <- err + }(enterprise) + + } + for i := 0; i < expectedReplies; i++ { select { case err := <-errChan: @@ -688,6 +715,15 @@ func (r *Runner) ForceDeleteRunner(ctx context.Context, instanceName string) err if err != nil { return errors.Wrapf(err, "fetching pool manager for org %s", pool.OrgName) } + } else if pool.EnterpriseID != "" { + enterprise, err := r.store.GetEnterpriseByID(ctx, pool.EnterpriseID) + if err != nil { + return errors.Wrap(err, "fetching enterprise") + } + poolMgr, err = r.findEnterprisePoolManager(enterprise.Name) + if err != nil { + return errors.Wrapf(err, "fetching pool manager for enterprise %s", pool.EnterpriseName) + } } if err := poolMgr.ForceDeleteRunner(instance); err != nil { From afb2bd9ab866c1f0726a5acc9648e93405ec7704 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 13 Oct 2022 18:53:56 +0000 Subject: [PATCH 05/12] Fix internal config credentials Signed-off-by: Gabriel Adrian Samfira --- runner/runner.go | 6 +++--- util/util.go | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/runner/runner.go b/runner/runner.go index fde59c2c..42b33119 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -243,9 +243,9 @@ func (p *poolManagerCtrl) getInternalConfig(credsName string) (params.Internal, GithubCredentialsDetails: params.GithubCredentials{ Name: creds.Name, Description: creds.Description, - BaseURL: creds.BaseURL, - APIBaseURL: creds.APIBaseURL, - UploadBaseURL: creds.UploadBaseURL, + BaseURL: creds.BaseEndpoint(), + APIBaseURL: creds.APIEndpoint(), + UploadBaseURL: creds.UploadEndpoint(), CABundle: caBundle, }, }, nil diff --git a/util/util.go b/util/util.go index 58e5626e..3d7065c7 100644 --- a/util/util.go +++ b/util/util.go @@ -196,10 +196,23 @@ func GithubClient(ctx context.Context, token string, credsDetails params.GithubC func GetCloudConfig(bootstrapParams params.BootstrapInstance, tools github.RunnerApplicationDownload, runnerName string) (string, error) { cloudCfg := cloudconfig.NewDefaultCloudInitConfig() + if tools.Filename == nil { + return "", fmt.Errorf("missing tools filename") + } + + if tools.DownloadURL == nil { + return "", fmt.Errorf("missing tools download URL") + } + + var tempToken string + if tools.TempDownloadToken != nil { + tempToken = *tools.TempDownloadToken + } + installRunnerParams := cloudconfig.InstallRunnerParams{ FileName: *tools.Filename, DownloadURL: *tools.DownloadURL, - TempDownloadToken: *tools.TempDownloadToken, + TempDownloadToken: tempToken, GithubToken: bootstrapParams.GithubRunnerAccessToken, RunnerUsername: config.DefaultUser, RunnerGroup: config.DefaultUser, From 95379b81bc10f9992ca9f4f8f5d1fd5e62b7c1e0 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 13 Oct 2022 19:06:25 +0000 Subject: [PATCH 06/12] Update docs --- database/sql/organizations_test.go | 2 +- doc/github_credentials.md | 24 +++++++++++++++++++++++- doc/running_garm.md | 2 +- testdata/config.toml | 15 +++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/database/sql/organizations_test.go b/database/sql/organizations_test.go index 1ad6dc49..2f431875 100644 --- a/database/sql/organizations_test.go +++ b/database/sql/organizations_test.go @@ -288,7 +288,7 @@ func (s *OrgTestSuite) TestListOrganizationsDBFetchErr() { s.assertSQLMockExpectations() s.Require().NotNil(err) - s.Require().Equal("fetching user from database: fetching user from database mock error", err.Error()) + s.Require().Equal("fetching org from database: fetching user from database mock error", err.Error()) } func (s *OrgTestSuite) TestDeleteOrganization() { diff --git a/doc/github_credentials.md b/doc/github_credentials.md index d1b854ed..1d7c2c81 100644 --- a/doc/github_credentials.md +++ b/doc/github_credentials.md @@ -1,12 +1,19 @@ # Configuring github credentials -Garm needs a [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to create runner registration tokens, list current self hosted runners and potentially remove them if they become orphaned (the VM was manually removed on the provider). +The ```github``` config section holds credentials and API endpoint information for accessing the GitHub APIs. Credentials are tied to the instance of GitHub you're using. Whether you're using [github.com](https://github.com) or your own deployment of GitHub Enterprise server, this section is how ```garm``` knows where it should create the runners. + +Tying the API endpoint info to the credentials allows us to use the same ```garm``` installation with both [github.com](https://github.com) and private deployments. All you have to do is to add the needed endpoint info (see bellow). + + +Garm uses a [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) to create runner registration tokens, list current self hosted runners and potentially remove them if they become orphaned (the VM was manually removed on the provider). + From the list of scopes, you will need to select: * ```public_repo``` - for access to a repository * ```repo``` - for access to a private repository * ```admin:org``` - if you plan on using this with an organization to which you have access + * ```manage_runners:enterprise``` - if you plan to use garm at the enterprise level The resulting token must be configured in the ```[[github]]``` section of the config. Sample as follows: @@ -24,6 +31,21 @@ The resulting token must be configured in the ```[[github]]``` section of the co # to work with repositories, and the admin:org needs to be set if you plan on # adding an organization. oauth2_token = "super secret token" + # base_url (optional) is the URL at which your GitHub Enterprise Server can be accessed. + # If these credentials are for github.com, leave this setting blank + base_url = "https://ghe.example.com" + # api_base_url (optional) is the base URL where the GitHub Enterprise Server API can be accessed. + # Leave this blank if these credentials are for github.com. + api_base_url = "https://ghe.example.com" + # upload_base_url (optional) is the base URL where the GitHub Enterprise Server upload API can be accessed. + # Leave this blank if these credentials are for github.com, or if you don't have a separate URL + # for the upload API. + upload_base_url = "https://api.ghe.example.com" + # ca_cert_bundle (optional) is the CA certificate bundle in PEM format that will be used by the github + # client to talk to the API. This bundle will also be sent to all runners as bootstrap params. + # Use this option if you're using a self signed certificate. + # Leave this blank if you're using github.com or if your certificare is signed by a valid CA. + ca_cert_bundle = "/etc/garm/ghe.crt" ``` The double paranthesis means that this is an array. You can specify the ```[[github]]``` section multiple times, with different tokens from different users, or with different access levels. You will then be able to list the available credentials using the API, and reference these credentials when adding repositories or organizations. diff --git a/doc/running_garm.md b/doc/running_garm.md index 983cc6d5..dbfe60a8 100644 --- a/doc/running_garm.md +++ b/doc/running_garm.md @@ -135,7 +135,7 @@ Pools are objects that define one type of worker and rules by which that pool of Before we can create a pool, we need to list the available providers. Providers are defined in the config (see above), but we need to reference them by name in the pool. ```bash -ubuntu@experiments:~$ garm-cli provider list +ubuntu@experiments:~$ garm-cli provider list +-----------+------------------------+------+ | NAME | DESCRIPTION | TYPE | +-----------+------------------------+------+ diff --git a/testdata/config.toml b/testdata/config.toml index 455fc278..7f1c0d42 100644 --- a/testdata/config.toml +++ b/testdata/config.toml @@ -192,3 +192,18 @@ provider_type = "external" # to work with repositories, and the admin:org needs to be set if you plan on # adding an organization. oauth2_token = "super secret token" + # base_url (optional) is the URL at which your GitHub Enterprise Server can be accessed. + # If these credentials are for github.com, leave this setting blank + base_url = "https://ghe.example.com" + # api_base_url (optional) is the base URL where the GitHub Enterprise Server API can be accessed. + # Leave this blank if these credentials are for github.com. + api_base_url = "https://ghe.example.com" + # upload_base_url (optional) is the base URL where the GitHub Enterprise Server upload API can be accessed. + # Leave this blank if these credentials are for github.com, or if you don't have a separate URL + # for the upload API. + upload_base_url = "https://api.ghe.example.com" + # ca_cert_bundle (optional) is the CA certificate bundle in PEM format that will be used by the github + # client to talk to the API. This bundle will also be sent to all runners as bootstrap params. + # Use this option if you're using a self signed certificate. + # Leave this blank if you're using github.com or if your certificare is signed by a valid CA. + ca_cert_bundle = "/etc/garm/ghe.crt" From b8e3303e541a1ae4736a1831813c52afee70902f Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 13 Oct 2022 20:23:59 +0000 Subject: [PATCH 07/12] Lower tools update interval --- runner/common/pool.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/runner/common/pool.go b/runner/common/pool.go index f4cba170..73dc54cd 100644 --- a/runner/common/pool.go +++ b/runner/common/pool.go @@ -28,8 +28,9 @@ const ( PoolConsilitationInterval = 5 * time.Second PoolReapTimeoutInterval = 5 * time.Minute // Temporary tools download token is valid for 1 hour by default. - // Set this to less than an hour so as not to run into 401 errors. - PoolToolUpdateInterval = 50 * time.Minute + // Set this to 15 minutes. This should allow enough time even on slow + // clouds for the instance to spin up, download the tools and join gh. + PoolToolUpdateInterval = 15 * time.Minute ) //go:generate mockery --all From adaeaa48f882e8f64d95564fb0fb5e3fe6c05df0 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 20 Oct 2022 11:43:14 +0300 Subject: [PATCH 08/12] Properly paginate Signed-off-by: Gabriel Adrian Samfira --- runner/pool/enterprise.go | 33 +++++++++++++-------------------- runner/pool/organization.go | 29 +++++++++++------------------ runner/pool/repository.go | 34 ++++++++++++++-------------------- 3 files changed, 38 insertions(+), 58 deletions(-) diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go index e829d2a8..8fe57b4d 100644 --- a/runner/pool/enterprise.go +++ b/runner/pool/enterprise.go @@ -3,7 +3,6 @@ package pool import ( "context" "fmt" - "math" "strings" "sync" @@ -94,27 +93,21 @@ func (r *enterprise) GetGithubToken() string { func (r *enterprise) GetGithubRunners() ([]*github.Runner, error) { opts := github.ListOptions{ PerPage: 100, - Page: 1, - } - runners, _, err := r.ghcEnterpriseCli.ListRunners(r.ctx, r.cfg.Name, &opts) - if err != nil { - return nil, errors.Wrap(err, "fetching runners") - } - ret := []*github.Runner{} - ret = append(ret, runners.Runners...) - pages := math.Ceil(float64(runners.TotalCount) / float64(100)) - if pages > 1 { - for i := 2; i <= int(pages); i++ { - opts.Page = i - runners, _, err = r.ghcEnterpriseCli.ListRunners(r.ctx, r.cfg.Name, &opts) - if err != nil { - return nil, errors.Wrap(err, "fetching runners") - } - ret = append(ret, runners.Runners...) - } } - return ret, nil + var allRunners []*github.Runner + for { + runners, ghResp, err := r.ghcEnterpriseCli.ListRunners(r.ctx, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") + } + allRunners = append(allRunners, runners.Runners...) + if ghResp.NextPage == 0 { + break + } + opts.Page = ghResp.NextPage + } + return allRunners, nil } func (r *enterprise) FetchTools() ([]*github.RunnerApplicationDownload, error) { diff --git a/runner/pool/organization.go b/runner/pool/organization.go index b2fe6d6e..25b5d692 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -17,7 +17,6 @@ package pool import ( "context" "fmt" - "math" "strings" "sync" @@ -105,28 +104,22 @@ func (r *organization) GetGithubToken() string { func (r *organization) GetGithubRunners() ([]*github.Runner, error) { opts := github.ListOptions{ PerPage: 100, - Page: 1, - } - runners, _, err := r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, &opts) - if err != nil { - return nil, errors.Wrap(err, "fetching runners") } - ret := []*github.Runner{} - ret = append(ret, runners.Runners...) - pages := math.Ceil(float64(runners.TotalCount) / float64(100)) - if pages > 1 { - for i := 2; i <= int(pages); i++ { - opts.Page = i - runners, _, err = r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, &opts) - if err != nil { - return nil, errors.Wrap(err, "fetching runners") - } - ret = append(ret, runners.Runners...) + var allRunners []*github.Runner + for { + runners, ghResp, err := r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") } + allRunners = append(allRunners, runners.Runners...) + if ghResp.NextPage == 0 { + break + } + opts.Page = ghResp.NextPage } - return ret, nil + return allRunners, nil } func (r *organization) FetchTools() ([]*github.RunnerApplicationDownload, error) { diff --git a/runner/pool/repository.go b/runner/pool/repository.go index ebbf76e1..8fd9b8e6 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -17,7 +17,6 @@ package pool import ( "context" "fmt" - "math" "strings" "sync" @@ -107,27 +106,22 @@ func (r *repository) GetGithubToken() string { func (r *repository) GetGithubRunners() ([]*github.Runner, error) { opts := github.ListOptions{ PerPage: 100, - Page: 1, - } - runners, _, err := r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, &opts) - if err != nil { - return nil, errors.Wrap(err, "fetching runners") - } - ret := []*github.Runner{} - ret = append(ret, runners.Runners...) - pages := math.Ceil(float64(runners.TotalCount) / float64(100)) - if pages > 1 { - for i := 2; i <= int(pages); i++ { - opts.Page = i - runners, _, err = r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, &opts) - if err != nil { - return nil, errors.Wrap(err, "fetching runners") - } - ret = append(ret, runners.Runners...) - } } - return ret, nil + var allRunners []*github.Runner + for { + runners, ghResp, err := r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, &opts) + if err != nil { + return nil, errors.Wrap(err, "fetching runners") + } + allRunners = append(allRunners, runners.Runners...) + if ghResp.NextPage == 0 { + break + } + opts.Page = ghResp.NextPage + } + + return allRunners, nil } func (r *repository) FetchTools() ([]*github.RunnerApplicationDownload, error) { From 80452aac39179fb488446528612f47aaf96561d6 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 20 Oct 2022 12:07:56 +0300 Subject: [PATCH 09/12] Update go-github and remove redirect --- go.mod | 4 +- go.sum | 4 +- params/params.go | 2 +- runner/common/mocks/GithubClient.go | 2 +- runner/common/mocks/GithubEnterpriseClient.go | 2 +- runner/common/util.go | 2 +- runner/pool/enterprise.go | 2 +- runner/pool/interfaces.go | 2 +- runner/pool/organization.go | 2 +- runner/pool/pool.go | 2 +- runner/pool/repository.go | 2 +- runner/providers/lxd/lxd.go | 2 +- util/util.go | 2 +- .../go-github/v47/github/orgs_custom_roles.go | 46 --- .../google/go-github/{v47 => v48}/AUTHORS | 1 + .../google/go-github/{v47 => v48}/LICENSE | 0 .../go-github/{v47 => v48}/github/actions.go | 0 .../{v47 => v48}/github/actions_artifacts.go | 0 .../github/actions_runner_groups.go | 0 .../{v47 => v48}/github/actions_runners.go | 0 .../{v47 => v48}/github/actions_secrets.go | 0 .../github/actions_workflow_jobs.go | 0 .../github/actions_workflow_runs.go | 0 .../{v47 => v48}/github/actions_workflows.go | 0 .../go-github/{v47 => v48}/github/activity.go | 0 .../{v47 => v48}/github/activity_events.go | 0 .../github/activity_notifications.go | 0 .../{v47 => v48}/github/activity_star.go | 0 .../{v47 => v48}/github/activity_watching.go | 0 .../go-github/{v47 => v48}/github/admin.go | 0 .../{v47 => v48}/github/admin_orgs.go | 0 .../{v47 => v48}/github/admin_stats.go | 0 .../{v47 => v48}/github/admin_users.go | 0 .../go-github/{v47 => v48}/github/apps.go | 0 .../{v47 => v48}/github/apps_hooks.go | 0 .../github/apps_hooks_deliveries.go | 0 .../{v47 => v48}/github/apps_installation.go | 0 .../{v47 => v48}/github/apps_manifest.go | 0 .../{v47 => v48}/github/apps_marketplace.go | 0 .../{v47 => v48}/github/authorizations.go | 0 .../go-github/{v47 => v48}/github/billing.go | 0 .../go-github/{v47 => v48}/github/checks.go | 0 .../{v47 => v48}/github/code-scanning.go | 0 .../{v47 => v48}/github/dependabot.go | 0 .../{v47 => v48}/github/dependabot_secrets.go | 0 .../go-github/{v47 => v48}/github/doc.go | 2 +- .../{v47 => v48}/github/enterprise.go | 0 .../github/enterprise_actions_runners.go | 2 +- .../github/enterprise_audit_log.go | 0 .../go-github/{v47 => v48}/github/event.go | 0 .../{v47 => v48}/github/event_types.go | 0 .../go-github/{v47 => v48}/github/gists.go | 0 .../{v47 => v48}/github/gists_comments.go | 0 .../go-github/{v47 => v48}/github/git.go | 0 .../{v47 => v48}/github/git_blobs.go | 0 .../{v47 => v48}/github/git_commits.go | 0 .../go-github/{v47 => v48}/github/git_refs.go | 0 .../go-github/{v47 => v48}/github/git_tags.go | 0 .../{v47 => v48}/github/git_trees.go | 0 .../{v47 => v48}/github/github-accessors.go | 360 ++++++++++++++++++ .../go-github/{v47 => v48}/github/github.go | 2 +- .../{v47 => v48}/github/gitignore.go | 0 .../{v47 => v48}/github/interactions.go | 0 .../{v47 => v48}/github/interactions_orgs.go | 0 .../{v47 => v48}/github/interactions_repos.go | 0 .../{v47 => v48}/github/issue_import.go | 0 .../go-github/{v47 => v48}/github/issues.go | 0 .../{v47 => v48}/github/issues_assignees.go | 0 .../{v47 => v48}/github/issues_comments.go | 0 .../{v47 => v48}/github/issues_events.go | 0 .../{v47 => v48}/github/issues_labels.go | 0 .../{v47 => v48}/github/issues_milestones.go | 0 .../{v47 => v48}/github/issues_timeline.go | 0 .../go-github/{v47 => v48}/github/licenses.go | 0 .../go-github/{v47 => v48}/github/messages.go | 0 .../{v47 => v48}/github/migrations.go | 0 .../github/migrations_source_import.go | 0 .../{v47 => v48}/github/migrations_user.go | 0 .../go-github/{v47 => v48}/github/misc.go | 0 .../go-github/{v47 => v48}/github/orgs.go | 0 .../github/orgs_actions_allowed.go | 0 .../github/orgs_actions_permissions.go | 0 .../{v47 => v48}/github/orgs_audit_log.go | 0 .../go-github/v48/github/orgs_custom_roles.go | 120 ++++++ .../{v47 => v48}/github/orgs_hooks.go | 0 .../github/orgs_hooks_deliveries.go | 0 .../{v47 => v48}/github/orgs_members.go | 0 .../github/orgs_outside_collaborators.go | 0 .../{v47 => v48}/github/orgs_packages.go | 0 .../{v47 => v48}/github/orgs_projects.go | 0 .../github/orgs_users_blocking.go | 0 .../go-github/{v47 => v48}/github/packages.go | 0 .../go-github/{v47 => v48}/github/projects.go | 0 .../go-github/{v47 => v48}/github/pulls.go | 0 .../{v47 => v48}/github/pulls_comments.go | 0 .../{v47 => v48}/github/pulls_reviewers.go | 0 .../{v47 => v48}/github/pulls_reviews.go | 0 .../{v47 => v48}/github/pulls_threads.go | 0 .../{v47 => v48}/github/reactions.go | 0 .../go-github/{v47 => v48}/github/repos.go | 96 ++++- .../github/repos_actions_allowed.go | 0 .../github/repos_actions_permissions.go | 0 .../{v47 => v48}/github/repos_autolinks.go | 0 .../{v47 => v48}/github/repos_codeowners.go | 0 .../github/repos_collaborators.go | 0 .../{v47 => v48}/github/repos_comments.go | 0 .../{v47 => v48}/github/repos_commits.go | 0 .../github/repos_community_health.go | 0 .../{v47 => v48}/github/repos_contents.go | 0 .../{v47 => v48}/github/repos_deployments.go | 0 .../{v47 => v48}/github/repos_environments.go | 0 .../{v47 => v48}/github/repos_forks.go | 0 .../{v47 => v48}/github/repos_hooks.go | 0 .../github/repos_hooks_deliveries.go | 0 .../{v47 => v48}/github/repos_invitations.go | 0 .../{v47 => v48}/github/repos_keys.go | 0 .../{v47 => v48}/github/repos_lfs.go | 0 .../{v47 => v48}/github/repos_merging.go | 0 .../{v47 => v48}/github/repos_pages.go | 0 .../github/repos_prereceive_hooks.go | 0 .../{v47 => v48}/github/repos_projects.go | 0 .../{v47 => v48}/github/repos_releases.go | 0 .../{v47 => v48}/github/repos_stats.go | 0 .../{v47 => v48}/github/repos_statuses.go | 0 .../{v47 => v48}/github/repos_tags.go | 0 .../{v47 => v48}/github/repos_traffic.go | 0 .../go-github/{v47 => v48}/github/scim.go | 56 ++- .../go-github/{v47 => v48}/github/search.go | 0 .../{v47 => v48}/github/secret_scanning.go | 0 .../go-github/{v47 => v48}/github/strings.go | 0 .../go-github/{v47 => v48}/github/teams.go | 0 .../github/teams_discussion_comments.go | 0 .../{v47 => v48}/github/teams_discussions.go | 0 .../{v47 => v48}/github/teams_members.go | 0 .../{v47 => v48}/github/timestamp.go | 0 .../go-github/{v47 => v48}/github/users.go | 0 .../github/users_administration.go | 0 .../{v47 => v48}/github/users_blocking.go | 0 .../{v47 => v48}/github/users_emails.go | 0 .../{v47 => v48}/github/users_followers.go | 0 .../{v47 => v48}/github/users_gpg_keys.go | 0 .../{v47 => v48}/github/users_keys.go | 0 .../{v47 => v48}/github/users_packages.go | 0 .../{v47 => v48}/github/users_projects.go | 0 .../v48/github/users_ssh_signing_keys.go | 108 ++++++ .../{v47 => v48}/github/with_appengine.go | 0 .../{v47 => v48}/github/without_appengine.go | 0 vendor/modules.txt | 5 +- 148 files changed, 748 insertions(+), 80 deletions(-) delete mode 100644 vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go rename vendor/github.com/google/go-github/{v47 => v48}/AUTHORS (99%) rename vendor/github.com/google/go-github/{v47 => v48}/LICENSE (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_artifacts.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_runner_groups.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_runners.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_secrets.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_workflow_jobs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_workflow_runs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/actions_workflows.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/activity.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/activity_events.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/activity_notifications.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/activity_star.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/activity_watching.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/admin.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/admin_orgs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/admin_stats.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/admin_users.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/apps.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/apps_hooks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/apps_hooks_deliveries.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/apps_installation.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/apps_manifest.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/apps_marketplace.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/authorizations.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/billing.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/checks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/code-scanning.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/dependabot.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/dependabot_secrets.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/doc.go (99%) rename vendor/github.com/google/go-github/{v47 => v48}/github/enterprise.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/enterprise_actions_runners.go (97%) rename vendor/github.com/google/go-github/{v47 => v48}/github/enterprise_audit_log.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/event.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/event_types.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/gists.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/gists_comments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/git.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/git_blobs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/git_commits.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/git_refs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/git_tags.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/git_trees.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/github-accessors.go (98%) rename vendor/github.com/google/go-github/{v47 => v48}/github/github.go (99%) rename vendor/github.com/google/go-github/{v47 => v48}/github/gitignore.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/interactions.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/interactions_orgs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/interactions_repos.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issue_import.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues_assignees.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues_comments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues_events.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues_labels.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues_milestones.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/issues_timeline.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/licenses.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/messages.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/migrations.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/migrations_source_import.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/migrations_user.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/misc.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_actions_allowed.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_actions_permissions.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_audit_log.go (100%) create mode 100644 vendor/github.com/google/go-github/v48/github/orgs_custom_roles.go rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_hooks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_hooks_deliveries.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_members.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_outside_collaborators.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_packages.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_projects.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/orgs_users_blocking.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/packages.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/projects.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/pulls.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/pulls_comments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/pulls_reviewers.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/pulls_reviews.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/pulls_threads.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/reactions.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos.go (92%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_actions_allowed.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_actions_permissions.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_autolinks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_codeowners.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_collaborators.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_comments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_commits.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_community_health.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_contents.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_deployments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_environments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_forks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_hooks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_hooks_deliveries.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_invitations.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_keys.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_lfs.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_merging.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_pages.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_prereceive_hooks.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_projects.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_releases.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_stats.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_statuses.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_tags.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/repos_traffic.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/scim.go (82%) rename vendor/github.com/google/go-github/{v47 => v48}/github/search.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/secret_scanning.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/strings.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/teams.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/teams_discussion_comments.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/teams_discussions.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/teams_members.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/timestamp.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_administration.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_blocking.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_emails.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_followers.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_gpg_keys.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_keys.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_packages.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/users_projects.go (100%) create mode 100644 vendor/github.com/google/go-github/v48/github/users_ssh_signing_keys.go rename vendor/github.com/google/go-github/{v47 => v48}/github/with_appengine.go (100%) rename vendor/github.com/google/go-github/{v47 => v48}/github/without_appengine.go (100%) diff --git a/go.mod b/go.mod index 745a51a0..e2ca6abf 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/BurntSushi/toml v0.4.1 github.com/go-resty/resty/v2 v2.7.0 github.com/golang-jwt/jwt v3.2.2+incompatible - github.com/google/go-github/v47 v47.1.0 + github.com/google/go-github/v48 v48.0.0 github.com/google/uuid v1.3.0 github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 @@ -71,5 +71,3 @@ require ( gopkg.in/macaroon-bakery.v2 v2.3.0 // indirect gopkg.in/macaroon.v2 v2.1.0 // indirect ) - -replace github.com/google/go-github/v47 => github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 diff --git a/go.sum b/go.sum index 09a99715..5813b8f0 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,6 @@ github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03D github.com/frankban/quicktest v1.10.0/go.mod h1:ui7WezCLWMWxVWr1GETZY3smRy0G4KWq9vcPtJmFl7Y= github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= -github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 h1:CNZ1asZM2ABO6DLFPS86CkGMEp5nFSQnpAECOOhYBGo= -github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1/go.mod h1:VPZBXNbFSJGjyjFRUKo9vZGawTajnWzC/YjGw/oFKi0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -119,6 +117,8 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-github/v48 v48.0.0 h1:9H5fWVXFK6ZsRriyPbjtnFAkJnoj0WKFtTYfpCRrTm8= +github.com/google/go-github/v48 v48.0.0/go.mod h1:dDlehKBDo850ZPvCTK0sEqTCVWcrGl2LcDiajkYi89Y= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= diff --git a/params/params.go b/params/params.go index ed0f3105..b2807db0 100644 --- a/params/params.go +++ b/params/params.go @@ -19,7 +19,7 @@ import ( "garm/runner/providers/common" "time" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" uuid "github.com/satori/go.uuid" ) diff --git a/runner/common/mocks/GithubClient.go b/runner/common/mocks/GithubClient.go index 4f1ae8dc..b8db134a 100644 --- a/runner/common/mocks/GithubClient.go +++ b/runner/common/mocks/GithubClient.go @@ -5,7 +5,7 @@ package mocks import ( context "context" - github "github.com/google/go-github/v47/github" + github "github.com/google/go-github/v48/github" mock "github.com/stretchr/testify/mock" ) diff --git a/runner/common/mocks/GithubEnterpriseClient.go b/runner/common/mocks/GithubEnterpriseClient.go index c7cea9c4..741d139c 100644 --- a/runner/common/mocks/GithubEnterpriseClient.go +++ b/runner/common/mocks/GithubEnterpriseClient.go @@ -5,7 +5,7 @@ package mocks import ( context "context" - github "github.com/google/go-github/v47/github" + github "github.com/google/go-github/v48/github" mock "github.com/stretchr/testify/mock" ) diff --git a/runner/common/util.go b/runner/common/util.go index 16ee2133..554da767 100644 --- a/runner/common/util.go +++ b/runner/common/util.go @@ -3,7 +3,7 @@ package common import ( "context" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" ) // GithubClient that describes the minimum list of functions we need to interact with github. diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go index 8fe57b4d..c2de3cd8 100644 --- a/runner/pool/enterprise.go +++ b/runner/pool/enterprise.go @@ -12,7 +12,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" "github.com/pkg/errors" ) diff --git a/runner/pool/interfaces.go b/runner/pool/interfaces.go index 7e5a87ee..4ccece01 100644 --- a/runner/pool/interfaces.go +++ b/runner/pool/interfaces.go @@ -17,7 +17,7 @@ package pool import ( "garm/params" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" ) type poolHelper interface { diff --git a/runner/pool/organization.go b/runner/pool/organization.go index 25b5d692..3ab36c62 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -26,7 +26,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" "github.com/pkg/errors" ) diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 9a39f28f..8898d51d 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -30,7 +30,7 @@ import ( "garm/runner/common" providerCommon "garm/runner/providers/common" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" "github.com/google/uuid" "github.com/pkg/errors" ) diff --git a/runner/pool/repository.go b/runner/pool/repository.go index 8fd9b8e6..864bcab3 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -26,7 +26,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" "github.com/pkg/errors" ) diff --git a/runner/providers/lxd/lxd.go b/runner/providers/lxd/lxd.go index 6d19cb3f..32bf794a 100644 --- a/runner/providers/lxd/lxd.go +++ b/runner/providers/lxd/lxd.go @@ -25,7 +25,7 @@ import ( "garm/runner/common" "garm/util" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" lxd "github.com/lxc/lxd/client" "github.com/lxc/lxd/shared/api" "github.com/pkg/errors" diff --git a/util/util.go b/util/util.go index 3d7065c7..8658f6a5 100644 --- a/util/util.go +++ b/util/util.go @@ -38,7 +38,7 @@ import ( "garm/params" "garm/runner/common" - "github.com/google/go-github/v47/github" + "github.com/google/go-github/v48/github" "github.com/pkg/errors" "golang.org/x/crypto/bcrypt" "golang.org/x/oauth2" diff --git a/vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go b/vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go deleted file mode 100644 index 9904685b..00000000 --- a/vendor/github.com/google/go-github/v47/github/orgs_custom_roles.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2022 The go-github AUTHORS. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package github - -import ( - "context" - "fmt" -) - -// OrganizationCustomRepoRoles represents custom repository roles available in specified organization. -type OrganizationCustomRepoRoles struct { - TotalCount *int `json:"total_count,omitempty"` - CustomRepoRoles []*CustomRepoRoles `json:"custom_roles,omitempty"` -} - -// CustomRepoRoles represents custom repository roles for an organization. -// See https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization -// for more information. -type CustomRepoRoles struct { - ID *int64 `json:"id,omitempty"` - Name *string `json:"name,omitempty"` -} - -// ListCustomRepoRoles lists the custom repository roles available in this organization. -// In order to see custom repository roles in an organization, the authenticated user must be an organization owner. -// -// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#list-custom-repository-roles-in-an-organization -func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org string) (*OrganizationCustomRepoRoles, *Response, error) { - u := fmt.Sprintf("orgs/%v/custom_roles", org) - - req, err := s.client.NewRequest("GET", u, nil) - if err != nil { - return nil, nil, err - } - - customRepoRoles := new(OrganizationCustomRepoRoles) - resp, err := s.client.Do(ctx, req, customRepoRoles) - if err != nil { - return nil, resp, err - } - - return customRepoRoles, resp, nil -} diff --git a/vendor/github.com/google/go-github/v47/AUTHORS b/vendor/github.com/google/go-github/v48/AUTHORS similarity index 99% rename from vendor/github.com/google/go-github/v47/AUTHORS rename to vendor/github.com/google/go-github/v48/AUTHORS index 80bd26dd..1ee400fe 100644 --- a/vendor/github.com/google/go-github/v47/AUTHORS +++ b/vendor/github.com/google/go-github/v48/AUTHORS @@ -59,6 +59,7 @@ Beyang Liu Billy Keyes Billy Lynch Björn Häuser +Bjorn Neergaard boljen Brad Harris Brad Moylan diff --git a/vendor/github.com/google/go-github/v47/LICENSE b/vendor/github.com/google/go-github/v48/LICENSE similarity index 100% rename from vendor/github.com/google/go-github/v47/LICENSE rename to vendor/github.com/google/go-github/v48/LICENSE diff --git a/vendor/github.com/google/go-github/v47/github/actions.go b/vendor/github.com/google/go-github/v48/github/actions.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions.go rename to vendor/github.com/google/go-github/v48/github/actions.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_artifacts.go b/vendor/github.com/google/go-github/v48/github/actions_artifacts.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_artifacts.go rename to vendor/github.com/google/go-github/v48/github/actions_artifacts.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_runner_groups.go b/vendor/github.com/google/go-github/v48/github/actions_runner_groups.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_runner_groups.go rename to vendor/github.com/google/go-github/v48/github/actions_runner_groups.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_runners.go b/vendor/github.com/google/go-github/v48/github/actions_runners.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_runners.go rename to vendor/github.com/google/go-github/v48/github/actions_runners.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_secrets.go b/vendor/github.com/google/go-github/v48/github/actions_secrets.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_secrets.go rename to vendor/github.com/google/go-github/v48/github/actions_secrets.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_workflow_jobs.go b/vendor/github.com/google/go-github/v48/github/actions_workflow_jobs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_workflow_jobs.go rename to vendor/github.com/google/go-github/v48/github/actions_workflow_jobs.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_workflow_runs.go b/vendor/github.com/google/go-github/v48/github/actions_workflow_runs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_workflow_runs.go rename to vendor/github.com/google/go-github/v48/github/actions_workflow_runs.go diff --git a/vendor/github.com/google/go-github/v47/github/actions_workflows.go b/vendor/github.com/google/go-github/v48/github/actions_workflows.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/actions_workflows.go rename to vendor/github.com/google/go-github/v48/github/actions_workflows.go diff --git a/vendor/github.com/google/go-github/v47/github/activity.go b/vendor/github.com/google/go-github/v48/github/activity.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/activity.go rename to vendor/github.com/google/go-github/v48/github/activity.go diff --git a/vendor/github.com/google/go-github/v47/github/activity_events.go b/vendor/github.com/google/go-github/v48/github/activity_events.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/activity_events.go rename to vendor/github.com/google/go-github/v48/github/activity_events.go diff --git a/vendor/github.com/google/go-github/v47/github/activity_notifications.go b/vendor/github.com/google/go-github/v48/github/activity_notifications.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/activity_notifications.go rename to vendor/github.com/google/go-github/v48/github/activity_notifications.go diff --git a/vendor/github.com/google/go-github/v47/github/activity_star.go b/vendor/github.com/google/go-github/v48/github/activity_star.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/activity_star.go rename to vendor/github.com/google/go-github/v48/github/activity_star.go diff --git a/vendor/github.com/google/go-github/v47/github/activity_watching.go b/vendor/github.com/google/go-github/v48/github/activity_watching.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/activity_watching.go rename to vendor/github.com/google/go-github/v48/github/activity_watching.go diff --git a/vendor/github.com/google/go-github/v47/github/admin.go b/vendor/github.com/google/go-github/v48/github/admin.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/admin.go rename to vendor/github.com/google/go-github/v48/github/admin.go diff --git a/vendor/github.com/google/go-github/v47/github/admin_orgs.go b/vendor/github.com/google/go-github/v48/github/admin_orgs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/admin_orgs.go rename to vendor/github.com/google/go-github/v48/github/admin_orgs.go diff --git a/vendor/github.com/google/go-github/v47/github/admin_stats.go b/vendor/github.com/google/go-github/v48/github/admin_stats.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/admin_stats.go rename to vendor/github.com/google/go-github/v48/github/admin_stats.go diff --git a/vendor/github.com/google/go-github/v47/github/admin_users.go b/vendor/github.com/google/go-github/v48/github/admin_users.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/admin_users.go rename to vendor/github.com/google/go-github/v48/github/admin_users.go diff --git a/vendor/github.com/google/go-github/v47/github/apps.go b/vendor/github.com/google/go-github/v48/github/apps.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/apps.go rename to vendor/github.com/google/go-github/v48/github/apps.go diff --git a/vendor/github.com/google/go-github/v47/github/apps_hooks.go b/vendor/github.com/google/go-github/v48/github/apps_hooks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/apps_hooks.go rename to vendor/github.com/google/go-github/v48/github/apps_hooks.go diff --git a/vendor/github.com/google/go-github/v47/github/apps_hooks_deliveries.go b/vendor/github.com/google/go-github/v48/github/apps_hooks_deliveries.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/apps_hooks_deliveries.go rename to vendor/github.com/google/go-github/v48/github/apps_hooks_deliveries.go diff --git a/vendor/github.com/google/go-github/v47/github/apps_installation.go b/vendor/github.com/google/go-github/v48/github/apps_installation.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/apps_installation.go rename to vendor/github.com/google/go-github/v48/github/apps_installation.go diff --git a/vendor/github.com/google/go-github/v47/github/apps_manifest.go b/vendor/github.com/google/go-github/v48/github/apps_manifest.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/apps_manifest.go rename to vendor/github.com/google/go-github/v48/github/apps_manifest.go diff --git a/vendor/github.com/google/go-github/v47/github/apps_marketplace.go b/vendor/github.com/google/go-github/v48/github/apps_marketplace.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/apps_marketplace.go rename to vendor/github.com/google/go-github/v48/github/apps_marketplace.go diff --git a/vendor/github.com/google/go-github/v47/github/authorizations.go b/vendor/github.com/google/go-github/v48/github/authorizations.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/authorizations.go rename to vendor/github.com/google/go-github/v48/github/authorizations.go diff --git a/vendor/github.com/google/go-github/v47/github/billing.go b/vendor/github.com/google/go-github/v48/github/billing.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/billing.go rename to vendor/github.com/google/go-github/v48/github/billing.go diff --git a/vendor/github.com/google/go-github/v47/github/checks.go b/vendor/github.com/google/go-github/v48/github/checks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/checks.go rename to vendor/github.com/google/go-github/v48/github/checks.go diff --git a/vendor/github.com/google/go-github/v47/github/code-scanning.go b/vendor/github.com/google/go-github/v48/github/code-scanning.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/code-scanning.go rename to vendor/github.com/google/go-github/v48/github/code-scanning.go diff --git a/vendor/github.com/google/go-github/v47/github/dependabot.go b/vendor/github.com/google/go-github/v48/github/dependabot.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/dependabot.go rename to vendor/github.com/google/go-github/v48/github/dependabot.go diff --git a/vendor/github.com/google/go-github/v47/github/dependabot_secrets.go b/vendor/github.com/google/go-github/v48/github/dependabot_secrets.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/dependabot_secrets.go rename to vendor/github.com/google/go-github/v48/github/dependabot_secrets.go diff --git a/vendor/github.com/google/go-github/v47/github/doc.go b/vendor/github.com/google/go-github/v48/github/doc.go similarity index 99% rename from vendor/github.com/google/go-github/v47/github/doc.go rename to vendor/github.com/google/go-github/v48/github/doc.go index 9ab7f558..0c4afaa3 100644 --- a/vendor/github.com/google/go-github/v47/github/doc.go +++ b/vendor/github.com/google/go-github/v48/github/doc.go @@ -8,7 +8,7 @@ Package github provides a client for using the GitHub API. Usage: - import "github.com/google/go-github/v47/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) + import "github.com/google/go-github/v48/github" // with go modules enabled (GO111MODULE=on or outside GOPATH) import "github.com/google/go-github/github" // with go modules disabled Construct a new GitHub client, then use the various services on the client to diff --git a/vendor/github.com/google/go-github/v47/github/enterprise.go b/vendor/github.com/google/go-github/v48/github/enterprise.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/enterprise.go rename to vendor/github.com/google/go-github/v48/github/enterprise.go diff --git a/vendor/github.com/google/go-github/v47/github/enterprise_actions_runners.go b/vendor/github.com/google/go-github/v48/github/enterprise_actions_runners.go similarity index 97% rename from vendor/github.com/google/go-github/v47/github/enterprise_actions_runners.go rename to vendor/github.com/google/go-github/v48/github/enterprise_actions_runners.go index 935f1897..daafc5e6 100644 --- a/vendor/github.com/google/go-github/v47/github/enterprise_actions_runners.go +++ b/vendor/github.com/google/go-github/v48/github/enterprise_actions_runners.go @@ -12,7 +12,7 @@ import ( // ListRunnerApplicationDownloads lists self-hosted runner application binaries that can be downloaded and run. // -// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-a-repository +// GitHub API docs: https://docs.github.com/en/rest/actions/self-hosted-runners#list-runner-applications-for-an-enterprise func (s *EnterpriseService) ListRunnerApplicationDownloads(ctx context.Context, enterprise string) ([]*RunnerApplicationDownload, *Response, error) { u := fmt.Sprintf("enterprises/%v/actions/runners/downloads", enterprise) req, err := s.client.NewRequest("GET", u, nil) diff --git a/vendor/github.com/google/go-github/v47/github/enterprise_audit_log.go b/vendor/github.com/google/go-github/v48/github/enterprise_audit_log.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/enterprise_audit_log.go rename to vendor/github.com/google/go-github/v48/github/enterprise_audit_log.go diff --git a/vendor/github.com/google/go-github/v47/github/event.go b/vendor/github.com/google/go-github/v48/github/event.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/event.go rename to vendor/github.com/google/go-github/v48/github/event.go diff --git a/vendor/github.com/google/go-github/v47/github/event_types.go b/vendor/github.com/google/go-github/v48/github/event_types.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/event_types.go rename to vendor/github.com/google/go-github/v48/github/event_types.go diff --git a/vendor/github.com/google/go-github/v47/github/gists.go b/vendor/github.com/google/go-github/v48/github/gists.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/gists.go rename to vendor/github.com/google/go-github/v48/github/gists.go diff --git a/vendor/github.com/google/go-github/v47/github/gists_comments.go b/vendor/github.com/google/go-github/v48/github/gists_comments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/gists_comments.go rename to vendor/github.com/google/go-github/v48/github/gists_comments.go diff --git a/vendor/github.com/google/go-github/v47/github/git.go b/vendor/github.com/google/go-github/v48/github/git.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/git.go rename to vendor/github.com/google/go-github/v48/github/git.go diff --git a/vendor/github.com/google/go-github/v47/github/git_blobs.go b/vendor/github.com/google/go-github/v48/github/git_blobs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/git_blobs.go rename to vendor/github.com/google/go-github/v48/github/git_blobs.go diff --git a/vendor/github.com/google/go-github/v47/github/git_commits.go b/vendor/github.com/google/go-github/v48/github/git_commits.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/git_commits.go rename to vendor/github.com/google/go-github/v48/github/git_commits.go diff --git a/vendor/github.com/google/go-github/v47/github/git_refs.go b/vendor/github.com/google/go-github/v48/github/git_refs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/git_refs.go rename to vendor/github.com/google/go-github/v48/github/git_refs.go diff --git a/vendor/github.com/google/go-github/v47/github/git_tags.go b/vendor/github.com/google/go-github/v48/github/git_tags.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/git_tags.go rename to vendor/github.com/google/go-github/v48/github/git_tags.go diff --git a/vendor/github.com/google/go-github/v47/github/git_trees.go b/vendor/github.com/google/go-github/v48/github/git_trees.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/git_trees.go rename to vendor/github.com/google/go-github/v48/github/git_trees.go diff --git a/vendor/github.com/google/go-github/v47/github/github-accessors.go b/vendor/github.com/google/go-github/v48/github/github-accessors.go similarity index 98% rename from vendor/github.com/google/go-github/v47/github/github-accessors.go rename to vendor/github.com/google/go-github/v48/github/github-accessors.go index 398ed7a3..42b1abc8 100644 --- a/vendor/github.com/google/go-github/v47/github/github-accessors.go +++ b/vendor/github.com/google/go-github/v48/github/github-accessors.go @@ -86,6 +86,14 @@ func (a *ActionsPermissionsRepository) GetSelectedActionsURL() string { return *a.SelectedActionsURL } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (a *AdminEnforcedChanges) GetFrom() bool { + if a == nil || a.From == nil { + return false + } + return *a.From +} + // GetURL returns the URL field if it's non-nil, zero value otherwise. func (a *AdminEnforcement) GetURL() string { if a == nil || a.URL == nil { @@ -414,6 +422,14 @@ func (a *Alert) GetURL() string { return *a.URL } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (a *AllowDeletionsEnforcementLevelChanges) GetFrom() string { + if a == nil || a.From == nil { + return "" + } + return *a.From +} + // GetRef returns the Ref field if it's non-nil, zero value otherwise. func (a *AnalysesListOptions) GetRef() string { if a == nil || a.Ref == nil { @@ -1366,6 +1382,14 @@ func (a *AuthorizedActorsOnly) GetFrom() bool { return *a.From } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (a *AuthorizedDismissalActorsOnlyChanges) GetFrom() bool { + if a == nil || a.From == nil { + return false + } + return *a.From +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (a *Autolink) GetID() int64 { if a == nil || a.ID == nil { @@ -3542,6 +3566,38 @@ func (c *CreateOrgInvitationOptions) GetRole() string { return *c.Role } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CreateOrUpdateCustomRoleOptions) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CreateOrUpdateCustomRoleOptions) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CreateOrUpdateCustomRoleOptions) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (c *CreateProtectedChanges) GetFrom() bool { + if c == nil || c.From == nil { + return false + } + return *c.From +} + // GetAllowsPublicRepositories returns the AllowsPublicRepositories field if it's non-nil, zero value otherwise. func (c *CreateRunnerGroupRequest) GetAllowsPublicRepositories() bool { if c == nil || c.AllowsPublicRepositories == nil { @@ -3590,6 +3646,22 @@ func (c *CreateUserProjectOptions) GetBody() string { return *c.Body } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CustomRepoRoles) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CustomRepoRoles) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (c *CustomRepoRoles) GetID() int64 { if c == nil || c.ID == nil { @@ -4534,6 +4606,14 @@ func (d *DismissedReview) GetState() string { return *d.State } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (d *DismissStaleReviewsOnPushChanges) GetFrom() bool { + if d == nil || d.From == nil { + return false + } + return *d.From +} + // GetClientPayload returns the ClientPayload field if it's non-nil, zero value otherwise. func (d *DispatchRequestOptions) GetClientPayload() json.RawMessage { if d == nil || d.ClientPayload == nil { @@ -8174,6 +8254,14 @@ func (l *License) GetURL() string { return *l.URL } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (l *LinearHistoryRequirementEnforcementLevelChanges) GetFrom() string { + if l == nil || l.From == nil { + return "" + } + return *l.From +} + // GetAppID returns the AppID field if it's non-nil, zero value otherwise. func (l *ListCheckRunsOptions) GetAppID() int64 { if l == nil || l.AppID == nil { @@ -11806,6 +11894,22 @@ func (p *Protection) GetRestrictions() *BranchRestrictions { return p.Restrictions } +// GetAdminEnforced returns the AdminEnforced field. +func (p *ProtectionChanges) GetAdminEnforced() *AdminEnforcedChanges { + if p == nil { + return nil + } + return p.AdminEnforced +} + +// GetAllowDeletionsEnforcementLevel returns the AllowDeletionsEnforcementLevel field. +func (p *ProtectionChanges) GetAllowDeletionsEnforcementLevel() *AllowDeletionsEnforcementLevelChanges { + if p == nil { + return nil + } + return p.AllowDeletionsEnforcementLevel +} + // GetAuthorizedActorNames returns the AuthorizedActorNames field. func (p *ProtectionChanges) GetAuthorizedActorNames() *AuthorizedActorNames { if p == nil { @@ -11822,6 +11926,94 @@ func (p *ProtectionChanges) GetAuthorizedActorsOnly() *AuthorizedActorsOnly { return p.AuthorizedActorsOnly } +// GetAuthorizedDismissalActorsOnly returns the AuthorizedDismissalActorsOnly field. +func (p *ProtectionChanges) GetAuthorizedDismissalActorsOnly() *AuthorizedDismissalActorsOnlyChanges { + if p == nil { + return nil + } + return p.AuthorizedDismissalActorsOnly +} + +// GetCreateProtected returns the CreateProtected field. +func (p *ProtectionChanges) GetCreateProtected() *CreateProtectedChanges { + if p == nil { + return nil + } + return p.CreateProtected +} + +// GetDismissStaleReviewsOnPush returns the DismissStaleReviewsOnPush field. +func (p *ProtectionChanges) GetDismissStaleReviewsOnPush() *DismissStaleReviewsOnPushChanges { + if p == nil { + return nil + } + return p.DismissStaleReviewsOnPush +} + +// GetLinearHistoryRequirementEnforcementLevel returns the LinearHistoryRequirementEnforcementLevel field. +func (p *ProtectionChanges) GetLinearHistoryRequirementEnforcementLevel() *LinearHistoryRequirementEnforcementLevelChanges { + if p == nil { + return nil + } + return p.LinearHistoryRequirementEnforcementLevel +} + +// GetPullRequestReviewsEnforcementLevel returns the PullRequestReviewsEnforcementLevel field. +func (p *ProtectionChanges) GetPullRequestReviewsEnforcementLevel() *PullRequestReviewsEnforcementLevelChanges { + if p == nil { + return nil + } + return p.PullRequestReviewsEnforcementLevel +} + +// GetRequireCodeOwnerReview returns the RequireCodeOwnerReview field. +func (p *ProtectionChanges) GetRequireCodeOwnerReview() *RequireCodeOwnerReviewChanges { + if p == nil { + return nil + } + return p.RequireCodeOwnerReview +} + +// GetRequiredConversationResolutionLevel returns the RequiredConversationResolutionLevel field. +func (p *ProtectionChanges) GetRequiredConversationResolutionLevel() *RequiredConversationResolutionLevelChanges { + if p == nil { + return nil + } + return p.RequiredConversationResolutionLevel +} + +// GetRequiredDeploymentsEnforcementLevel returns the RequiredDeploymentsEnforcementLevel field. +func (p *ProtectionChanges) GetRequiredDeploymentsEnforcementLevel() *RequiredDeploymentsEnforcementLevelChanges { + if p == nil { + return nil + } + return p.RequiredDeploymentsEnforcementLevel +} + +// GetRequiredStatusChecks returns the RequiredStatusChecks field. +func (p *ProtectionChanges) GetRequiredStatusChecks() *RequiredStatusChecksChanges { + if p == nil { + return nil + } + return p.RequiredStatusChecks +} + +// GetRequiredStatusChecksEnforcementLevel returns the RequiredStatusChecksEnforcementLevel field. +func (p *ProtectionChanges) GetRequiredStatusChecksEnforcementLevel() *RequiredStatusChecksEnforcementLevelChanges { + if p == nil { + return nil + } + return p.RequiredStatusChecksEnforcementLevel +} + +// GetSignatureRequirementEnforcementLevel returns the SignatureRequirementEnforcementLevel field. +func (p *ProtectionChanges) GetSignatureRequirementEnforcementLevel() *SignatureRequirementEnforcementLevelChanges { + if p == nil { + return nil + } + return p.SignatureRequirementEnforcementLevel +} + // GetAllowDeletions returns the AllowDeletions field if it's non-nil, zero value otherwise. func (p *ProtectionRequest) GetAllowDeletions() bool { if p == nil || p.AllowDeletions == nil { @@ -13014,6 +13206,14 @@ func (p *PullRequestReviewsEnforcement) GetDismissalRestrictions() *DismissalRes return p.DismissalRestrictions } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (p *PullRequestReviewsEnforcementLevelChanges) GetFrom() string { + if p == nil || p.From == nil { + return "" + } + return *p.From +} + // GetBypassPullRequestAllowancesRequest returns the BypassPullRequestAllowancesRequest field. func (p *PullRequestReviewsEnforcementRequest) GetBypassPullRequestAllowancesRequest() *BypassPullRequestAllowancesRequest { if p == nil { @@ -16134,6 +16334,30 @@ func (r *RepoStatus) GetURL() string { return *r.URL } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (r *RequireCodeOwnerReviewChanges) GetFrom() bool { + if r == nil || r.From == nil { + return false + } + return *r.From +} + +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (r *RequiredConversationResolutionLevelChanges) GetFrom() string { + if r == nil || r.From == nil { + return "" + } + return *r.From +} + +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (r *RequiredDeploymentsEnforcementLevelChanges) GetFrom() string { + if r == nil || r.From == nil { + return "" + } + return *r.From +} + // GetType returns the Type field if it's non-nil, zero value otherwise. func (r *RequiredReviewer) GetType() string { if r == nil || r.Type == nil { @@ -16150,6 +16374,14 @@ func (r *RequiredStatusCheck) GetAppID() int64 { return *r.AppID } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (r *RequiredStatusChecksEnforcementLevelChanges) GetFrom() string { + if r == nil || r.From == nil { + return "" + } + return *r.From +} + // GetStrict returns the Strict field if it's non-nil, zero value otherwise. func (r *RequiredStatusChecksRequest) GetStrict() bool { if r == nil || r.Strict == nil { @@ -16582,6 +16814,62 @@ func (s *ScanningAnalysis) GetWarning() string { return *s.Warning } +// GetCreated returns the Created field if it's non-nil, zero value otherwise. +func (s *SCIMMeta) GetCreated() Timestamp { + if s == nil || s.Created == nil { + return Timestamp{} + } + return *s.Created +} + +// GetLastModified returns the LastModified field if it's non-nil, zero value otherwise. +func (s *SCIMMeta) GetLastModified() Timestamp { + if s == nil || s.LastModified == nil { + return Timestamp{} + } + return *s.LastModified +} + +// GetLocation returns the Location field if it's non-nil, zero value otherwise. +func (s *SCIMMeta) GetLocation() string { + if s == nil || s.Location == nil { + return "" + } + return *s.Location +} + +// GetResourceType returns the ResourceType field if it's non-nil, zero value otherwise. +func (s *SCIMMeta) GetResourceType() string { + if s == nil || s.ResourceType == nil { + return "" + } + return *s.ResourceType +} + +// GetItemsPerPage returns the ItemsPerPage field if it's non-nil, zero value otherwise. +func (s *SCIMProvisionedIdentities) GetItemsPerPage() int { + if s == nil || s.ItemsPerPage == nil { + return 0 + } + return *s.ItemsPerPage +} + +// GetStartIndex returns the StartIndex field if it's non-nil, zero value otherwise. +func (s *SCIMProvisionedIdentities) GetStartIndex() int { + if s == nil || s.StartIndex == nil { + return 0 + } + return *s.StartIndex +} + +// GetTotalResults returns the TotalResults field if it's non-nil, zero value otherwise. +func (s *SCIMProvisionedIdentities) GetTotalResults() int { + if s == nil || s.TotalResults == nil { + return 0 + } + return *s.TotalResults +} + // GetActive returns the Active field if it's non-nil, zero value otherwise. func (s *SCIMUserAttributes) GetActive() bool { if s == nil || s.Active == nil { @@ -16606,6 +16894,22 @@ func (s *SCIMUserAttributes) GetExternalID() string { return *s.ExternalID } +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (s *SCIMUserAttributes) GetID() string { + if s == nil || s.ID == nil { + return "" + } + return *s.ID +} + +// GetMeta returns the Meta field. +func (s *SCIMUserAttributes) GetMeta() *SCIMMeta { + if s == nil { + return nil + } + return s.Meta +} + // GetPrimary returns the Primary field if it's non-nil, zero value otherwise. func (s *SCIMUserEmail) GetPrimary() bool { if s == nil || s.Primary == nil { @@ -16894,6 +17198,14 @@ func (s *SecretScanningAlertUpdateOptions) GetState() string { return *s.State } +// GetStatus returns the Status field if it's non-nil, zero value otherwise. +func (s *SecretScanningPushProtection) GetStatus() string { + if s == nil || s.Status == nil { + return "" + } + return *s.Status +} + // GetDescription returns the Description field if it's non-nil, zero value otherwise. func (s *SecurityAdvisory) GetDescription() string { if s == nil || s.Description == nil { @@ -16982,6 +17294,14 @@ func (s *SecurityAndAnalysis) GetSecretScanning() *SecretScanning { return s.SecretScanning } +// GetSecretScanningPushProtection returns the SecretScanningPushProtection field. +func (s *SecurityAndAnalysis) GetSecretScanningPushProtection() *SecretScanningPushProtection { + if s == nil { + return nil + } + return s.SecretScanningPushProtection +} + // GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. func (s *SelectedReposList) GetTotalCount() int { if s == nil || s.TotalCount == nil { @@ -16998,6 +17318,14 @@ func (s *ServiceHook) GetName() string { return *s.Name } +// GetFrom returns the From field if it's non-nil, zero value otherwise. +func (s *SignatureRequirementEnforcementLevelChanges) GetFrom() string { + if s == nil || s.From == nil { + return "" + } + return *s.From +} + // GetEnabled returns the Enabled field if it's non-nil, zero value otherwise. func (s *SignaturesProtectedBranch) GetEnabled() bool { if s == nil || s.Enabled == nil { @@ -17142,6 +17470,38 @@ func (s *SourceImportAuthor) GetURL() string { return *s.URL } +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (s *SSHSigningKey) GetCreatedAt() Timestamp { + if s == nil || s.CreatedAt == nil { + return Timestamp{} + } + return *s.CreatedAt +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (s *SSHSigningKey) GetID() int64 { + if s == nil || s.ID == nil { + return 0 + } + return *s.ID +} + +// GetKey returns the Key field if it's non-nil, zero value otherwise. +func (s *SSHSigningKey) GetKey() string { + if s == nil || s.Key == nil { + return "" + } + return *s.Key +} + +// GetTitle returns the Title field if it's non-nil, zero value otherwise. +func (s *SSHSigningKey) GetTitle() string { + if s == nil || s.Title == nil { + return "" + } + return *s.Title +} + // GetAction returns the Action field if it's non-nil, zero value otherwise. func (s *StarEvent) GetAction() string { if s == nil || s.Action == nil { diff --git a/vendor/github.com/google/go-github/v47/github/github.go b/vendor/github.com/google/go-github/v48/github/github.go similarity index 99% rename from vendor/github.com/google/go-github/v47/github/github.go rename to vendor/github.com/google/go-github/v48/github/github.go index da923dbb..2883c380 100644 --- a/vendor/github.com/google/go-github/v47/github/github.go +++ b/vendor/github.com/google/go-github/v48/github/github.go @@ -28,7 +28,7 @@ import ( ) const ( - Version = "v47.0.0" + Version = "v48.0.0" defaultBaseURL = "https://api.github.com/" defaultUserAgent = "go-github" + "/" + Version diff --git a/vendor/github.com/google/go-github/v47/github/gitignore.go b/vendor/github.com/google/go-github/v48/github/gitignore.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/gitignore.go rename to vendor/github.com/google/go-github/v48/github/gitignore.go diff --git a/vendor/github.com/google/go-github/v47/github/interactions.go b/vendor/github.com/google/go-github/v48/github/interactions.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/interactions.go rename to vendor/github.com/google/go-github/v48/github/interactions.go diff --git a/vendor/github.com/google/go-github/v47/github/interactions_orgs.go b/vendor/github.com/google/go-github/v48/github/interactions_orgs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/interactions_orgs.go rename to vendor/github.com/google/go-github/v48/github/interactions_orgs.go diff --git a/vendor/github.com/google/go-github/v47/github/interactions_repos.go b/vendor/github.com/google/go-github/v48/github/interactions_repos.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/interactions_repos.go rename to vendor/github.com/google/go-github/v48/github/interactions_repos.go diff --git a/vendor/github.com/google/go-github/v47/github/issue_import.go b/vendor/github.com/google/go-github/v48/github/issue_import.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issue_import.go rename to vendor/github.com/google/go-github/v48/github/issue_import.go diff --git a/vendor/github.com/google/go-github/v47/github/issues.go b/vendor/github.com/google/go-github/v48/github/issues.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues.go rename to vendor/github.com/google/go-github/v48/github/issues.go diff --git a/vendor/github.com/google/go-github/v47/github/issues_assignees.go b/vendor/github.com/google/go-github/v48/github/issues_assignees.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues_assignees.go rename to vendor/github.com/google/go-github/v48/github/issues_assignees.go diff --git a/vendor/github.com/google/go-github/v47/github/issues_comments.go b/vendor/github.com/google/go-github/v48/github/issues_comments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues_comments.go rename to vendor/github.com/google/go-github/v48/github/issues_comments.go diff --git a/vendor/github.com/google/go-github/v47/github/issues_events.go b/vendor/github.com/google/go-github/v48/github/issues_events.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues_events.go rename to vendor/github.com/google/go-github/v48/github/issues_events.go diff --git a/vendor/github.com/google/go-github/v47/github/issues_labels.go b/vendor/github.com/google/go-github/v48/github/issues_labels.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues_labels.go rename to vendor/github.com/google/go-github/v48/github/issues_labels.go diff --git a/vendor/github.com/google/go-github/v47/github/issues_milestones.go b/vendor/github.com/google/go-github/v48/github/issues_milestones.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues_milestones.go rename to vendor/github.com/google/go-github/v48/github/issues_milestones.go diff --git a/vendor/github.com/google/go-github/v47/github/issues_timeline.go b/vendor/github.com/google/go-github/v48/github/issues_timeline.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/issues_timeline.go rename to vendor/github.com/google/go-github/v48/github/issues_timeline.go diff --git a/vendor/github.com/google/go-github/v47/github/licenses.go b/vendor/github.com/google/go-github/v48/github/licenses.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/licenses.go rename to vendor/github.com/google/go-github/v48/github/licenses.go diff --git a/vendor/github.com/google/go-github/v47/github/messages.go b/vendor/github.com/google/go-github/v48/github/messages.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/messages.go rename to vendor/github.com/google/go-github/v48/github/messages.go diff --git a/vendor/github.com/google/go-github/v47/github/migrations.go b/vendor/github.com/google/go-github/v48/github/migrations.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/migrations.go rename to vendor/github.com/google/go-github/v48/github/migrations.go diff --git a/vendor/github.com/google/go-github/v47/github/migrations_source_import.go b/vendor/github.com/google/go-github/v48/github/migrations_source_import.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/migrations_source_import.go rename to vendor/github.com/google/go-github/v48/github/migrations_source_import.go diff --git a/vendor/github.com/google/go-github/v47/github/migrations_user.go b/vendor/github.com/google/go-github/v48/github/migrations_user.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/migrations_user.go rename to vendor/github.com/google/go-github/v48/github/migrations_user.go diff --git a/vendor/github.com/google/go-github/v47/github/misc.go b/vendor/github.com/google/go-github/v48/github/misc.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/misc.go rename to vendor/github.com/google/go-github/v48/github/misc.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs.go b/vendor/github.com/google/go-github/v48/github/orgs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs.go rename to vendor/github.com/google/go-github/v48/github/orgs.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_actions_allowed.go b/vendor/github.com/google/go-github/v48/github/orgs_actions_allowed.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_actions_allowed.go rename to vendor/github.com/google/go-github/v48/github/orgs_actions_allowed.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_actions_permissions.go b/vendor/github.com/google/go-github/v48/github/orgs_actions_permissions.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_actions_permissions.go rename to vendor/github.com/google/go-github/v48/github/orgs_actions_permissions.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_audit_log.go b/vendor/github.com/google/go-github/v48/github/orgs_audit_log.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_audit_log.go rename to vendor/github.com/google/go-github/v48/github/orgs_audit_log.go diff --git a/vendor/github.com/google/go-github/v48/github/orgs_custom_roles.go b/vendor/github.com/google/go-github/v48/github/orgs_custom_roles.go new file mode 100644 index 00000000..41270b32 --- /dev/null +++ b/vendor/github.com/google/go-github/v48/github/orgs_custom_roles.go @@ -0,0 +1,120 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// OrganizationCustomRepoRoles represents custom repository roles available in specified organization. +type OrganizationCustomRepoRoles struct { + TotalCount *int `json:"total_count,omitempty"` + CustomRepoRoles []*CustomRepoRoles `json:"custom_roles,omitempty"` +} + +// CustomRepoRoles represents custom repository roles for an organization. +// See https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-peoples-access-to-your-organization-with-roles/managing-custom-repository-roles-for-an-organization +// for more information. +type CustomRepoRoles struct { + ID *int64 `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + Permissions []string `json:"permissions,omitempty"` +} + +// ListCustomRepoRoles lists the custom repository roles available in this organization. +// In order to see custom repository roles in an organization, the authenticated user must be an organization owner. +// +// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#list-custom-repository-roles-in-an-organization +func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org string) (*OrganizationCustomRepoRoles, *Response, error) { + u := fmt.Sprintf("orgs/%v/custom_roles", org) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + customRepoRoles := new(OrganizationCustomRepoRoles) + resp, err := s.client.Do(ctx, req, customRepoRoles) + if err != nil { + return nil, resp, err + } + + return customRepoRoles, resp, nil +} + +// CreateOrUpdateCustomRoleOptions represents options required to create or update a custom repository role. +type CreateOrUpdateCustomRoleOptions struct { + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + Permissions []string `json:"permissions,omitempty"` +} + +// CreateCustomRepoRole creates a custom repository role in this organization. +// In order to create custom repository roles in an organization, the authenticated user must be an organization owner. +// +// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#create-a-custom-role +func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org string, opts *CreateOrUpdateCustomRoleOptions) (*CustomRepoRoles, *Response, error) { + u := fmt.Sprintf("orgs/%v/custom_roles", org) + + req, err := s.client.NewRequest("POST", u, opts) + if err != nil { + return nil, nil, err + } + + resultingRole := new(CustomRepoRoles) + resp, err := s.client.Do(ctx, req, resultingRole) + if err != nil { + return nil, resp, err + } + + return resultingRole, resp, err +} + +// UpdateCustomRepoRole updates a custom repository role in this organization. +// In order to update custom repository roles in an organization, the authenticated user must be an organization owner. +// +// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#update-a-custom-role +func (s *OrganizationsService) UpdateCustomRepoRole(ctx context.Context, org, roleID string, opts *CreateOrUpdateCustomRoleOptions) (*CustomRepoRoles, *Response, error) { + u := fmt.Sprintf("orgs/%v/custom_roles/%v", org, roleID) + + req, err := s.client.NewRequest("PATCH", u, opts) + if err != nil { + return nil, nil, err + } + + resultingRole := new(CustomRepoRoles) + resp, err := s.client.Do(ctx, req, resultingRole) + if err != nil { + return nil, resp, err + } + + return resultingRole, resp, err +} + +// DeleteCustomRepoRole deletes an existing custom repository role in this organization. +// In order to delete custom repository roles in an organization, the authenticated user must be an organization owner. +// +// GitHub API docs: https://docs.github.com/en/rest/orgs/custom-roles#delete-a-custom-role +func (s *OrganizationsService) DeleteCustomRepoRole(ctx context.Context, org, roleID string) (*Response, error) { + u := fmt.Sprintf("orgs/%v/custom_roles/%v", org, roleID) + + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + resultingRole := new(CustomRepoRoles) + resp, err := s.client.Do(ctx, req, resultingRole) + if err != nil { + return resp, err + } + + return resp, nil +} diff --git a/vendor/github.com/google/go-github/v47/github/orgs_hooks.go b/vendor/github.com/google/go-github/v48/github/orgs_hooks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_hooks.go rename to vendor/github.com/google/go-github/v48/github/orgs_hooks.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_hooks_deliveries.go b/vendor/github.com/google/go-github/v48/github/orgs_hooks_deliveries.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_hooks_deliveries.go rename to vendor/github.com/google/go-github/v48/github/orgs_hooks_deliveries.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_members.go b/vendor/github.com/google/go-github/v48/github/orgs_members.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_members.go rename to vendor/github.com/google/go-github/v48/github/orgs_members.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_outside_collaborators.go b/vendor/github.com/google/go-github/v48/github/orgs_outside_collaborators.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_outside_collaborators.go rename to vendor/github.com/google/go-github/v48/github/orgs_outside_collaborators.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_packages.go b/vendor/github.com/google/go-github/v48/github/orgs_packages.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_packages.go rename to vendor/github.com/google/go-github/v48/github/orgs_packages.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_projects.go b/vendor/github.com/google/go-github/v48/github/orgs_projects.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_projects.go rename to vendor/github.com/google/go-github/v48/github/orgs_projects.go diff --git a/vendor/github.com/google/go-github/v47/github/orgs_users_blocking.go b/vendor/github.com/google/go-github/v48/github/orgs_users_blocking.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/orgs_users_blocking.go rename to vendor/github.com/google/go-github/v48/github/orgs_users_blocking.go diff --git a/vendor/github.com/google/go-github/v47/github/packages.go b/vendor/github.com/google/go-github/v48/github/packages.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/packages.go rename to vendor/github.com/google/go-github/v48/github/packages.go diff --git a/vendor/github.com/google/go-github/v47/github/projects.go b/vendor/github.com/google/go-github/v48/github/projects.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/projects.go rename to vendor/github.com/google/go-github/v48/github/projects.go diff --git a/vendor/github.com/google/go-github/v47/github/pulls.go b/vendor/github.com/google/go-github/v48/github/pulls.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/pulls.go rename to vendor/github.com/google/go-github/v48/github/pulls.go diff --git a/vendor/github.com/google/go-github/v47/github/pulls_comments.go b/vendor/github.com/google/go-github/v48/github/pulls_comments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/pulls_comments.go rename to vendor/github.com/google/go-github/v48/github/pulls_comments.go diff --git a/vendor/github.com/google/go-github/v47/github/pulls_reviewers.go b/vendor/github.com/google/go-github/v48/github/pulls_reviewers.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/pulls_reviewers.go rename to vendor/github.com/google/go-github/v48/github/pulls_reviewers.go diff --git a/vendor/github.com/google/go-github/v47/github/pulls_reviews.go b/vendor/github.com/google/go-github/v48/github/pulls_reviews.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/pulls_reviews.go rename to vendor/github.com/google/go-github/v48/github/pulls_reviews.go diff --git a/vendor/github.com/google/go-github/v47/github/pulls_threads.go b/vendor/github.com/google/go-github/v48/github/pulls_threads.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/pulls_threads.go rename to vendor/github.com/google/go-github/v48/github/pulls_threads.go diff --git a/vendor/github.com/google/go-github/v47/github/reactions.go b/vendor/github.com/google/go-github/v48/github/reactions.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/reactions.go rename to vendor/github.com/google/go-github/v48/github/reactions.go diff --git a/vendor/github.com/google/go-github/v47/github/repos.go b/vendor/github.com/google/go-github/v48/github/repos.go similarity index 92% rename from vendor/github.com/google/go-github/v47/github/repos.go rename to vendor/github.com/google/go-github/v48/github/repos.go index 45fd1888..8f5bbea9 100644 --- a/vendor/github.com/google/go-github/v47/github/repos.go +++ b/vendor/github.com/google/go-github/v48/github/repos.go @@ -205,8 +205,9 @@ type RepositoryListOptions struct { // SecurityAndAnalysis specifies the optional advanced security features // that are enabled on a given repository. type SecurityAndAnalysis struct { - AdvancedSecurity *AdvancedSecurity `json:"advanced_security,omitempty"` - SecretScanning *SecretScanning `json:"secret_scanning,omitempty"` + AdvancedSecurity *AdvancedSecurity `json:"advanced_security,omitempty"` + SecretScanning *SecretScanning `json:"secret_scanning,omitempty"` + SecretScanningPushProtection *SecretScanningPushProtection `json:"secret_scanning_push_protection,omitempty"` } func (s SecurityAndAnalysis) String() string { @@ -235,6 +236,13 @@ func (s SecretScanning) String() string { return Stringify(s) } +// SecretScanningPushProtection specifies the state of secret scanning push protection on a repository. +// +// GitHub API docs: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning#about-secret-scanning-for-partner-patterns +type SecretScanningPushProtection struct { + Status *string `json:"status,omitempty"` +} + // List the repositories for a user. Passing the empty string will list // repositories for the authenticated user. // @@ -864,8 +872,31 @@ type BranchProtectionRule struct { // ProtectionChanges represents the changes to the rule if the BranchProtection was edited. type ProtectionChanges struct { - AuthorizedActorsOnly *AuthorizedActorsOnly `json:"authorized_actors_only,omitempty"` - AuthorizedActorNames *AuthorizedActorNames `json:"authorized_actor_names,omitempty"` + AdminEnforced *AdminEnforcedChanges `json:"admin_enforced,omitempty"` + AllowDeletionsEnforcementLevel *AllowDeletionsEnforcementLevelChanges `json:"allow_deletions_enforcement_level,omitempty"` + AuthorizedActorNames *AuthorizedActorNames `json:"authorized_actor_names,omitempty"` + AuthorizedActorsOnly *AuthorizedActorsOnly `json:"authorized_actors_only,omitempty"` + AuthorizedDismissalActorsOnly *AuthorizedDismissalActorsOnlyChanges `json:"authorized_dismissal_actors_only,omitempty"` + CreateProtected *CreateProtectedChanges `json:"create_protected,omitempty"` + DismissStaleReviewsOnPush *DismissStaleReviewsOnPushChanges `json:"dismiss_stale_reviews_on_push,omitempty"` + LinearHistoryRequirementEnforcementLevel *LinearHistoryRequirementEnforcementLevelChanges `json:"linear_history_requirement_enforcement_level,omitempty"` + PullRequestReviewsEnforcementLevel *PullRequestReviewsEnforcementLevelChanges `json:"pull_request_reviews_enforcement_level,omitempty"` + RequireCodeOwnerReview *RequireCodeOwnerReviewChanges `json:"require_code_owner_review,omitempty"` + RequiredConversationResolutionLevel *RequiredConversationResolutionLevelChanges `json:"required_conversation_resolution_level,omitempty"` + RequiredDeploymentsEnforcementLevel *RequiredDeploymentsEnforcementLevelChanges `json:"required_deployments_enforcement_level,omitempty"` + RequiredStatusChecks *RequiredStatusChecksChanges `json:"required_status_checks,omitempty"` + RequiredStatusChecksEnforcementLevel *RequiredStatusChecksEnforcementLevelChanges `json:"required_status_checks_enforcement_level,omitempty"` + SignatureRequirementEnforcementLevel *SignatureRequirementEnforcementLevelChanges `json:"signature_requirement_enforcement_level,omitempty"` +} + +// AdminEnforcedChanges represents the changes made to the AdminEnforced policy. +type AdminEnforcedChanges struct { + From *bool `json:"from,omitempty"` +} + +// AllowDeletionsEnforcementLevelChanges represents the changes made to the AllowDeletionsEnforcementLevel policy. +type AllowDeletionsEnforcementLevelChanges struct { + From *string `json:"from,omitempty"` } // AuthorizedActorNames represents who are authorized to edit the branch protection rules. @@ -873,11 +904,66 @@ type AuthorizedActorNames struct { From []string `json:"from,omitempty"` } -// AuthorizedActorsOnly represents if the branche rule can be edited by authorized actors only. +// AuthorizedActorsOnly represents if the branch rule can be edited by authorized actors only. type AuthorizedActorsOnly struct { From *bool `json:"from,omitempty"` } +// AuthorizedDismissalActorsOnlyChanges represents the changes made to the AuthorizedDismissalActorsOnly policy. +type AuthorizedDismissalActorsOnlyChanges struct { + From *bool `json:"from,omitempty"` +} + +// CreateProtectedChanges represents the changes made to the CreateProtected policy. +type CreateProtectedChanges struct { + From *bool `json:"from,omitempty"` +} + +// DismissStaleReviewsOnPushChanges represents the changes made to the DismissStaleReviewsOnPushChanges policy. +type DismissStaleReviewsOnPushChanges struct { + From *bool `json:"from,omitempty"` +} + +// LinearHistoryRequirementEnforcementLevelChanges represents the changes made to the LinearHistoryRequirementEnforcementLevel policy. +type LinearHistoryRequirementEnforcementLevelChanges struct { + From *string `json:"from,omitempty"` +} + +// PullRequestReviewsEnforcementLevelChanges represents the changes made to the PullRequestReviewsEnforcementLevel policy. +type PullRequestReviewsEnforcementLevelChanges struct { + From *string `json:"from,omitempty"` +} + +// RequireCodeOwnerReviewChanges represents the changes made to the RequireCodeOwnerReview policy. +type RequireCodeOwnerReviewChanges struct { + From *bool `json:"from,omitempty"` +} + +// RequiredConversationResolutionLevelChanges represents the changes made to the RequiredConversationResolutionLevel policy. +type RequiredConversationResolutionLevelChanges struct { + From *string `json:"from,omitempty"` +} + +// RequiredDeploymentsEnforcementLevelChanges represents the changes made to the RequiredDeploymentsEnforcementLevel policy. +type RequiredDeploymentsEnforcementLevelChanges struct { + From *string `json:"from,omitempty"` +} + +// RequiredStatusChecksChanges represents the changes made to the RequiredStatusChecks policy. +type RequiredStatusChecksChanges struct { + From []string `json:"from,omitempty"` +} + +// RequiredStatusChecksEnforcementLevelChanges represents the changes made to the RequiredStatusChecksEnforcementLevel policy. +type RequiredStatusChecksEnforcementLevelChanges struct { + From *string `json:"from,omitempty"` +} + +// SignatureRequirementEnforcementLevelChanges represents the changes made to the SignatureRequirementEnforcementLevel policy. +type SignatureRequirementEnforcementLevelChanges struct { + From *string `json:"from,omitempty"` +} + // ProtectionRequest represents a request to create/edit a branch's protection. type ProtectionRequest struct { RequiredStatusChecks *RequiredStatusChecks `json:"required_status_checks"` diff --git a/vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go b/vendor/github.com/google/go-github/v48/github/repos_actions_allowed.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_actions_allowed.go rename to vendor/github.com/google/go-github/v48/github/repos_actions_allowed.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go b/vendor/github.com/google/go-github/v48/github/repos_actions_permissions.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_actions_permissions.go rename to vendor/github.com/google/go-github/v48/github/repos_actions_permissions.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_autolinks.go b/vendor/github.com/google/go-github/v48/github/repos_autolinks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_autolinks.go rename to vendor/github.com/google/go-github/v48/github/repos_autolinks.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_codeowners.go b/vendor/github.com/google/go-github/v48/github/repos_codeowners.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_codeowners.go rename to vendor/github.com/google/go-github/v48/github/repos_codeowners.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_collaborators.go b/vendor/github.com/google/go-github/v48/github/repos_collaborators.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_collaborators.go rename to vendor/github.com/google/go-github/v48/github/repos_collaborators.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_comments.go b/vendor/github.com/google/go-github/v48/github/repos_comments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_comments.go rename to vendor/github.com/google/go-github/v48/github/repos_comments.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_commits.go b/vendor/github.com/google/go-github/v48/github/repos_commits.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_commits.go rename to vendor/github.com/google/go-github/v48/github/repos_commits.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_community_health.go b/vendor/github.com/google/go-github/v48/github/repos_community_health.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_community_health.go rename to vendor/github.com/google/go-github/v48/github/repos_community_health.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_contents.go b/vendor/github.com/google/go-github/v48/github/repos_contents.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_contents.go rename to vendor/github.com/google/go-github/v48/github/repos_contents.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_deployments.go b/vendor/github.com/google/go-github/v48/github/repos_deployments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_deployments.go rename to vendor/github.com/google/go-github/v48/github/repos_deployments.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_environments.go b/vendor/github.com/google/go-github/v48/github/repos_environments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_environments.go rename to vendor/github.com/google/go-github/v48/github/repos_environments.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_forks.go b/vendor/github.com/google/go-github/v48/github/repos_forks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_forks.go rename to vendor/github.com/google/go-github/v48/github/repos_forks.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_hooks.go b/vendor/github.com/google/go-github/v48/github/repos_hooks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_hooks.go rename to vendor/github.com/google/go-github/v48/github/repos_hooks.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_hooks_deliveries.go b/vendor/github.com/google/go-github/v48/github/repos_hooks_deliveries.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_hooks_deliveries.go rename to vendor/github.com/google/go-github/v48/github/repos_hooks_deliveries.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_invitations.go b/vendor/github.com/google/go-github/v48/github/repos_invitations.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_invitations.go rename to vendor/github.com/google/go-github/v48/github/repos_invitations.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_keys.go b/vendor/github.com/google/go-github/v48/github/repos_keys.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_keys.go rename to vendor/github.com/google/go-github/v48/github/repos_keys.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_lfs.go b/vendor/github.com/google/go-github/v48/github/repos_lfs.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_lfs.go rename to vendor/github.com/google/go-github/v48/github/repos_lfs.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_merging.go b/vendor/github.com/google/go-github/v48/github/repos_merging.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_merging.go rename to vendor/github.com/google/go-github/v48/github/repos_merging.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_pages.go b/vendor/github.com/google/go-github/v48/github/repos_pages.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_pages.go rename to vendor/github.com/google/go-github/v48/github/repos_pages.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_prereceive_hooks.go b/vendor/github.com/google/go-github/v48/github/repos_prereceive_hooks.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_prereceive_hooks.go rename to vendor/github.com/google/go-github/v48/github/repos_prereceive_hooks.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_projects.go b/vendor/github.com/google/go-github/v48/github/repos_projects.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_projects.go rename to vendor/github.com/google/go-github/v48/github/repos_projects.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_releases.go b/vendor/github.com/google/go-github/v48/github/repos_releases.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_releases.go rename to vendor/github.com/google/go-github/v48/github/repos_releases.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_stats.go b/vendor/github.com/google/go-github/v48/github/repos_stats.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_stats.go rename to vendor/github.com/google/go-github/v48/github/repos_stats.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_statuses.go b/vendor/github.com/google/go-github/v48/github/repos_statuses.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_statuses.go rename to vendor/github.com/google/go-github/v48/github/repos_statuses.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_tags.go b/vendor/github.com/google/go-github/v48/github/repos_tags.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_tags.go rename to vendor/github.com/google/go-github/v48/github/repos_tags.go diff --git a/vendor/github.com/google/go-github/v47/github/repos_traffic.go b/vendor/github.com/google/go-github/v48/github/repos_traffic.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/repos_traffic.go rename to vendor/github.com/google/go-github/v48/github/repos_traffic.go diff --git a/vendor/github.com/google/go-github/v47/github/scim.go b/vendor/github.com/google/go-github/v48/github/scim.go similarity index 82% rename from vendor/github.com/google/go-github/v47/github/scim.go rename to vendor/github.com/google/go-github/v48/github/scim.go index 9462fb6b..70f81ed1 100644 --- a/vendor/github.com/google/go-github/v47/github/scim.go +++ b/vendor/github.com/google/go-github/v48/github/scim.go @@ -29,6 +29,9 @@ type SCIMUserAttributes struct { ExternalID *string `json:"externalId,omitempty"` // (Optional.) Groups []string `json:"groups,omitempty"` // (Optional.) Active *bool `json:"active,omitempty"` // (Optional.) + // Only populated as a result of calling ListSCIMProvisionedIdentitiesOptions or GetSCIMProvisioningInfoForUser: + ID *string `json:"id,omitempty"` + Meta *SCIMMeta `json:"meta,omitempty"` } // SCIMUserName represents SCIM user information. @@ -45,6 +48,23 @@ type SCIMUserEmail struct { Type *string `json:"type,omitempty"` // (Optional.) } +// SCIMMeta represents metadata about the SCIM resource. +type SCIMMeta struct { + ResourceType *string `json:"resourceType,omitempty"` + Created *Timestamp `json:"created,omitempty"` + LastModified *Timestamp `json:"lastModified,omitempty"` + Location *string `json:"location,omitempty"` +} + +// SCIMProvisionedIdentities represents the result of calling ListSCIMProvisionedIdentities. +type SCIMProvisionedIdentities struct { + Schemas []string `json:"schemas,omitempty"` + TotalResults *int `json:"totalResults,omitempty"` + ItemsPerPage *int `json:"itemsPerPage,omitempty"` + StartIndex *int `json:"startIndex,omitempty"` + Resources []*SCIMUserAttributes `json:"Resources,omitempty"` +} + // ListSCIMProvisionedIdentitiesOptions represents options for ListSCIMProvisionedIdentities. // // Github API docs: https://docs.github.com/en/rest/scim#list-scim-provisioned-identities--parameters @@ -62,17 +82,25 @@ type ListSCIMProvisionedIdentitiesOptions struct { // ListSCIMProvisionedIdentities lists SCIM provisioned identities. // // GitHub API docs: https://docs.github.com/en/rest/scim#list-scim-provisioned-identities -func (s *SCIMService) ListSCIMProvisionedIdentities(ctx context.Context, org string, opts *ListSCIMProvisionedIdentitiesOptions) (*Response, error) { +func (s *SCIMService) ListSCIMProvisionedIdentities(ctx context.Context, org string, opts *ListSCIMProvisionedIdentitiesOptions) (*SCIMProvisionedIdentities, *Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users", org) u, err := addOptions(u, opts) if err != nil { - return nil, err + return nil, nil, err } + req, err := s.client.NewRequest("GET", u, nil) if err != nil { - return nil, err + return nil, nil, err } - return s.client.Do(ctx, req, nil) + + identities := new(SCIMProvisionedIdentities) + resp, err := s.client.Do(ctx, req, identities) + if err != nil { + return nil, resp, err + } + + return identities, resp, nil } // ProvisionAndInviteSCIMUser provisions organization membership for a user, and sends an activation email to the email address. @@ -84,23 +112,32 @@ func (s *SCIMService) ProvisionAndInviteSCIMUser(ctx context.Context, org string if err != nil { return nil, err } + req, err := s.client.NewRequest("POST", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } // GetSCIMProvisioningInfoForUser returns SCIM provisioning information for a user. // // GitHub API docs: https://docs.github.com/en/rest/scim#supported-scim-user-attributes -func (s *SCIMService) GetSCIMProvisioningInfoForUser(ctx context.Context, org, scimUserID string) (*Response, error) { +func (s *SCIMService) GetSCIMProvisioningInfoForUser(ctx context.Context, org, scimUserID string) (*SCIMUserAttributes, *Response, error) { u := fmt.Sprintf("scim/v2/organizations/%v/Users/%v", org, scimUserID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { - return nil, err + return nil, nil, err } - return s.client.Do(ctx, req, nil) + + user := new(SCIMUserAttributes) + resp, err := s.client.Do(ctx, req, &user) + if err != nil { + return nil, resp, err + } + + return user, resp, nil } // UpdateProvisionedOrgMembership updates a provisioned organization membership. @@ -112,10 +149,12 @@ func (s *SCIMService) UpdateProvisionedOrgMembership(ctx context.Context, org, s if err != nil { return nil, err } + req, err := s.client.NewRequest("PUT", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } @@ -143,10 +182,12 @@ func (s *SCIMService) UpdateAttributeForSCIMUser(ctx context.Context, org, scimU if err != nil { return nil, err } + req, err := s.client.NewRequest("PATCH", u, nil) if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } @@ -159,5 +200,6 @@ func (s *SCIMService) DeleteSCIMUserFromOrg(ctx context.Context, org, scimUserID if err != nil { return nil, err } + return s.client.Do(ctx, req, nil) } diff --git a/vendor/github.com/google/go-github/v47/github/search.go b/vendor/github.com/google/go-github/v48/github/search.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/search.go rename to vendor/github.com/google/go-github/v48/github/search.go diff --git a/vendor/github.com/google/go-github/v47/github/secret_scanning.go b/vendor/github.com/google/go-github/v48/github/secret_scanning.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/secret_scanning.go rename to vendor/github.com/google/go-github/v48/github/secret_scanning.go diff --git a/vendor/github.com/google/go-github/v47/github/strings.go b/vendor/github.com/google/go-github/v48/github/strings.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/strings.go rename to vendor/github.com/google/go-github/v48/github/strings.go diff --git a/vendor/github.com/google/go-github/v47/github/teams.go b/vendor/github.com/google/go-github/v48/github/teams.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/teams.go rename to vendor/github.com/google/go-github/v48/github/teams.go diff --git a/vendor/github.com/google/go-github/v47/github/teams_discussion_comments.go b/vendor/github.com/google/go-github/v48/github/teams_discussion_comments.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/teams_discussion_comments.go rename to vendor/github.com/google/go-github/v48/github/teams_discussion_comments.go diff --git a/vendor/github.com/google/go-github/v47/github/teams_discussions.go b/vendor/github.com/google/go-github/v48/github/teams_discussions.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/teams_discussions.go rename to vendor/github.com/google/go-github/v48/github/teams_discussions.go diff --git a/vendor/github.com/google/go-github/v47/github/teams_members.go b/vendor/github.com/google/go-github/v48/github/teams_members.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/teams_members.go rename to vendor/github.com/google/go-github/v48/github/teams_members.go diff --git a/vendor/github.com/google/go-github/v47/github/timestamp.go b/vendor/github.com/google/go-github/v48/github/timestamp.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/timestamp.go rename to vendor/github.com/google/go-github/v48/github/timestamp.go diff --git a/vendor/github.com/google/go-github/v47/github/users.go b/vendor/github.com/google/go-github/v48/github/users.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users.go rename to vendor/github.com/google/go-github/v48/github/users.go diff --git a/vendor/github.com/google/go-github/v47/github/users_administration.go b/vendor/github.com/google/go-github/v48/github/users_administration.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_administration.go rename to vendor/github.com/google/go-github/v48/github/users_administration.go diff --git a/vendor/github.com/google/go-github/v47/github/users_blocking.go b/vendor/github.com/google/go-github/v48/github/users_blocking.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_blocking.go rename to vendor/github.com/google/go-github/v48/github/users_blocking.go diff --git a/vendor/github.com/google/go-github/v47/github/users_emails.go b/vendor/github.com/google/go-github/v48/github/users_emails.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_emails.go rename to vendor/github.com/google/go-github/v48/github/users_emails.go diff --git a/vendor/github.com/google/go-github/v47/github/users_followers.go b/vendor/github.com/google/go-github/v48/github/users_followers.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_followers.go rename to vendor/github.com/google/go-github/v48/github/users_followers.go diff --git a/vendor/github.com/google/go-github/v47/github/users_gpg_keys.go b/vendor/github.com/google/go-github/v48/github/users_gpg_keys.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_gpg_keys.go rename to vendor/github.com/google/go-github/v48/github/users_gpg_keys.go diff --git a/vendor/github.com/google/go-github/v47/github/users_keys.go b/vendor/github.com/google/go-github/v48/github/users_keys.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_keys.go rename to vendor/github.com/google/go-github/v48/github/users_keys.go diff --git a/vendor/github.com/google/go-github/v47/github/users_packages.go b/vendor/github.com/google/go-github/v48/github/users_packages.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_packages.go rename to vendor/github.com/google/go-github/v48/github/users_packages.go diff --git a/vendor/github.com/google/go-github/v47/github/users_projects.go b/vendor/github.com/google/go-github/v48/github/users_projects.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/users_projects.go rename to vendor/github.com/google/go-github/v48/github/users_projects.go diff --git a/vendor/github.com/google/go-github/v48/github/users_ssh_signing_keys.go b/vendor/github.com/google/go-github/v48/github/users_ssh_signing_keys.go new file mode 100644 index 00000000..567623f8 --- /dev/null +++ b/vendor/github.com/google/go-github/v48/github/users_ssh_signing_keys.go @@ -0,0 +1,108 @@ +// Copyright 2022 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "context" + "fmt" +) + +// SSHSigningKey represents a public SSH key used to sign git commits. +type SSHSigningKey struct { + ID *int64 `json:"id,omitempty"` + Key *string `json:"key,omitempty"` + Title *string `json:"title,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` +} + +func (k SSHSigningKey) String() string { + return Stringify(k) +} + +// ListSSHSigningKeys lists the SSH signing keys for a user. Passing an empty +// username string will fetch SSH signing keys for the authenticated user. +// +// GitHub API docs: https://docs.github.com/en/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-the-authenticated-user +// GitHub API docs: https://docs.github.com/en/rest/users/ssh-signing-keys#list-ssh-signing-keys-for-a-user +func (s *UsersService) ListSSHSigningKeys(ctx context.Context, user string, opts *ListOptions) ([]*SSHSigningKey, *Response, error) { + var u string + if user != "" { + u = fmt.Sprintf("users/%v/ssh_signing_keys", user) + } else { + u = "user/ssh_signing_keys" + } + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var keys []*SSHSigningKey + resp, err := s.client.Do(ctx, req, &keys) + if err != nil { + return nil, resp, err + } + + return keys, resp, nil +} + +// GetSSHSigningKey fetches a single SSH signing key for the authenticated user. +// +// GitHub API docs: https://docs.github.com/en/rest/users/ssh-signing-keys#get-an-ssh-signing-key-for-the-authenticated-user +func (s *UsersService) GetSSHSigningKey(ctx context.Context, id int64) (*SSHSigningKey, *Response, error) { + u := fmt.Sprintf("user/ssh_signing_keys/%v", id) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + key := new(SSHSigningKey) + resp, err := s.client.Do(ctx, req, key) + if err != nil { + return nil, resp, err + } + + return key, resp, nil +} + +// CreateSSHSigningKey adds a SSH signing key for the authenticated user. +// +// GitHub API docs: https://docs.github.com/en/rest/users/ssh-signing-keys#create-a-ssh-signing-key-for-the-authenticated-user +func (s *UsersService) CreateSSHSigningKey(ctx context.Context, key *Key) (*SSHSigningKey, *Response, error) { + u := "user/ssh_signing_keys" + + req, err := s.client.NewRequest("POST", u, key) + if err != nil { + return nil, nil, err + } + + k := new(SSHSigningKey) + resp, err := s.client.Do(ctx, req, k) + if err != nil { + return nil, resp, err + } + + return k, resp, nil +} + +// DeleteKey deletes a SSH signing key for the authenticated user. +// +// GitHub API docs: https://docs.github.com/en/rest/users/ssh-signing-keys#delete-an-ssh-signing-key-for-the-authenticated-user +func (s *UsersService) DeleteSSHSigningKey(ctx context.Context, id int64) (*Response, error) { + u := fmt.Sprintf("user/ssh_signing_keys/%v", id) + + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(ctx, req, nil) +} diff --git a/vendor/github.com/google/go-github/v47/github/with_appengine.go b/vendor/github.com/google/go-github/v48/github/with_appengine.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/with_appengine.go rename to vendor/github.com/google/go-github/v48/github/with_appengine.go diff --git a/vendor/github.com/google/go-github/v47/github/without_appengine.go b/vendor/github.com/google/go-github/v48/github/without_appengine.go similarity index 100% rename from vendor/github.com/google/go-github/v47/github/without_appengine.go rename to vendor/github.com/google/go-github/v48/github/without_appengine.go diff --git a/vendor/modules.txt b/vendor/modules.txt index ba5205cc..876154bd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -29,9 +29,9 @@ github.com/golang-jwt/jwt # github.com/golang/protobuf v1.5.2 ## explicit; go 1.9 github.com/golang/protobuf/proto -# github.com/google/go-github/v47 v47.1.0 => github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 +# github.com/google/go-github/v48 v48.0.0 ## explicit; go 1.17 -github.com/google/go-github/v47/github +github.com/google/go-github/v48/github # github.com/google/go-querystring v1.1.0 ## explicit; go 1.10 github.com/google/go-querystring/query @@ -292,4 +292,3 @@ gorm.io/gorm/logger gorm.io/gorm/migrator gorm.io/gorm/schema gorm.io/gorm/utils -# github.com/google/go-github/v47 => github.com/gabriel-samfira/go-github/v47 v47.1.1-0.20221013145953-21e3b4d7b0c1 From 05057e37fd4c848671b030b440019aaaba3abee6 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Thu, 20 Oct 2022 17:22:47 +0300 Subject: [PATCH 10/12] Start pool managers in the background Garm no longer fails on startup if a pool manager cannot be started. It will attempt to start the pool manager in the background. If it fails due to an unauthorized error, it will sleep for 3 hours. It is unlikely it will work a second time if credentials are not updated in the config and garm is restarted, so no point in getting rate limited. Signed-off-by: Gabriel Adrian Samfira --- cmd/garm-cli/cmd/credentials.go | 2 +- cmd/garm-cli/cmd/enterprise.go | 16 ++- cmd/garm-cli/cmd/org_instances.go | 2 +- cmd/garm-cli/cmd/org_pool.go | 10 +- cmd/garm-cli/cmd/organization.go | 17 ++- cmd/garm-cli/cmd/pool.go | 10 +- cmd/garm-cli/cmd/profile.go | 8 +- cmd/garm-cli/cmd/provider.go | 2 +- cmd/garm-cli/cmd/repo_instances.go | 2 +- cmd/garm-cli/cmd/repo_pool.go | 36 +---- cmd/garm-cli/cmd/repository.go | 16 ++- cmd/garm-cli/cmd/root.go | 14 +- cmd/garm-cli/cmd/runner.go | 6 +- params/params.go | 34 +++-- runner/common/mocks/PoolManager.go | 14 ++ runner/common/pool.go | 7 + runner/enterprises.go | 22 ++- runner/organizations.go | 24 +++- runner/organizations_test.go | 4 + runner/pool/enterprise.go | 11 +- runner/pool/organization.go | 11 +- runner/pool/pool.go | 212 ++++++++++++++++++++--------- runner/pool/repository.go | 11 +- runner/repositories.go | 23 +++- runner/repositories_test.go | 4 + runner/runner.go | 70 ++++++++-- 26 files changed, 408 insertions(+), 180 deletions(-) diff --git a/cmd/garm-cli/cmd/credentials.go b/cmd/garm-cli/cmd/credentials.go index a4986b8b..447d2957 100644 --- a/cmd/garm-cli/cmd/credentials.go +++ b/cmd/garm-cli/cmd/credentials.go @@ -46,7 +46,7 @@ func init() { SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } creds, err := cli.ListCredentials() diff --git a/cmd/garm-cli/cmd/enterprise.go b/cmd/garm-cli/cmd/enterprise.go index 82c0b6fe..0a58519b 100644 --- a/cmd/garm-cli/cmd/enterprise.go +++ b/cmd/garm-cli/cmd/enterprise.go @@ -50,7 +50,7 @@ var enterpriseAddCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } newEnterpriseReq := params.CreateEnterpriseParams{ @@ -75,7 +75,7 @@ var enterpriseListCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } enterprises, err := cli.ListEnterprises() @@ -94,7 +94,7 @@ var enterpriseShowCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { return fmt.Errorf("requires a enterprise ID") @@ -119,7 +119,7 @@ var enterpriseDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { return fmt.Errorf("requires a enterprise ID") @@ -154,10 +154,10 @@ func init() { func formatEnterprises(enterprises []params.Enterprise) { t := table.NewWriter() - header := table.Row{"ID", "Name", "Credentials name"} + header := table.Row{"ID", "Name", "Credentials name", "Pool mgr running"} t.AppendHeader(header) for _, val := range enterprises { - t.AppendRow(table.Row{val.ID, val.Name, val.CredentialsName}) + t.AppendRow(table.Row{val.ID, val.Name, val.CredentialsName, val.PoolManagerStatus.IsRunning}) t.AppendSeparator() } fmt.Println(t.Render()) @@ -171,6 +171,10 @@ func formatOneEnterprise(enterprise params.Enterprise) { t.AppendRow(table.Row{"ID", enterprise.ID}) t.AppendRow(table.Row{"Name", enterprise.Name}) t.AppendRow(table.Row{"Credentials", enterprise.CredentialsName}) + t.AppendRow(table.Row{"Pool manager running", enterprise.PoolManagerStatus.IsRunning}) + if !enterprise.PoolManagerStatus.IsRunning { + t.AppendRow(table.Row{"Failure reason", enterprise.PoolManagerStatus.FailureReason}) + } if len(enterprise.Pools) > 0 { for _, pool := range enterprise.Pools { diff --git a/cmd/garm-cli/cmd/org_instances.go b/cmd/garm-cli/cmd/org_instances.go index 4c8445d7..002b022c 100644 --- a/cmd/garm-cli/cmd/org_instances.go +++ b/cmd/garm-cli/cmd/org_instances.go @@ -37,7 +37,7 @@ var orgRunnerListCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { diff --git a/cmd/garm-cli/cmd/org_pool.go b/cmd/garm-cli/cmd/org_pool.go index 976f5c79..1ad3ac1b 100644 --- a/cmd/garm-cli/cmd/org_pool.go +++ b/cmd/garm-cli/cmd/org_pool.go @@ -48,7 +48,7 @@ var orgPoolAddCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -91,7 +91,7 @@ var orgPoolListCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -117,7 +117,7 @@ var orgPoolShowCmd = &cobra.Command{ Long: `Displays detailed information about a single pool.`, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) < 2 || len(args) > 2 { @@ -142,7 +142,7 @@ var orgPoolDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) < 2 || len(args) > 2 { return fmt.Errorf("command requires orgID and poolID") @@ -167,7 +167,7 @@ explicitly remove them using the runner delete command. SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) < 2 || len(args) > 2 { diff --git a/cmd/garm-cli/cmd/organization.go b/cmd/garm-cli/cmd/organization.go index 432d3263..184a9a18 100644 --- a/cmd/garm-cli/cmd/organization.go +++ b/cmd/garm-cli/cmd/organization.go @@ -50,7 +50,7 @@ var orgAddCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } newOrgReq := params.CreateOrgParams{ @@ -75,7 +75,7 @@ var orgListCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } orgs, err := cli.ListOrganizations() @@ -94,7 +94,7 @@ var orgShowCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { return fmt.Errorf("requires a organization ID") @@ -119,7 +119,7 @@ var orgDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { return fmt.Errorf("requires a organization ID") @@ -154,10 +154,10 @@ func init() { func formatOrganizations(orgs []params.Organization) { t := table.NewWriter() - header := table.Row{"ID", "Name", "Credentials name"} + header := table.Row{"ID", "Name", "Credentials name", "Pool mgr running"} t.AppendHeader(header) for _, val := range orgs { - t.AppendRow(table.Row{val.ID, val.Name, val.CredentialsName}) + t.AppendRow(table.Row{val.ID, val.Name, val.CredentialsName, val.PoolManagerStatus.IsRunning}) t.AppendSeparator() } fmt.Println(t.Render()) @@ -171,7 +171,10 @@ func formatOneOrganization(org params.Organization) { t.AppendRow(table.Row{"ID", org.ID}) t.AppendRow(table.Row{"Name", org.Name}) t.AppendRow(table.Row{"Credentials", org.CredentialsName}) - + t.AppendRow(table.Row{"Pool manager running", org.PoolManagerStatus.IsRunning}) + if !org.PoolManagerStatus.IsRunning { + t.AppendRow(table.Row{"Failure reason", org.PoolManagerStatus.FailureReason}) + } if len(org.Pools) > 0 { for _, pool := range org.Pools { t.AppendRow(table.Row{"Pools", pool.ID}, rowConfigAutoMerge) diff --git a/cmd/garm-cli/cmd/pool.go b/cmd/garm-cli/cmd/pool.go index 2d0c8802..ec5f3964 100644 --- a/cmd/garm-cli/cmd/pool.go +++ b/cmd/garm-cli/cmd/pool.go @@ -68,7 +68,7 @@ Example: SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } var pools []params.Pool @@ -108,7 +108,7 @@ var poolShowCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -136,7 +136,7 @@ var poolDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -162,7 +162,7 @@ var poolAddCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } tags := strings.Split(poolTags, ",") @@ -216,7 +216,7 @@ explicitly remove them using the runner delete command. SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { diff --git a/cmd/garm-cli/cmd/profile.go b/cmd/garm-cli/cmd/profile.go index ca9b6689..64ca54f7 100644 --- a/cmd/garm-cli/cmd/profile.go +++ b/cmd/garm-cli/cmd/profile.go @@ -55,7 +55,7 @@ file of the garm client. SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if cfg == nil { @@ -76,7 +76,7 @@ var profileDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -101,7 +101,7 @@ var poolSwitchCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -177,7 +177,7 @@ installation, by performing a login. SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if cfg == nil { diff --git a/cmd/garm-cli/cmd/provider.go b/cmd/garm-cli/cmd/provider.go index 562f9462..95404364 100644 --- a/cmd/garm-cli/cmd/provider.go +++ b/cmd/garm-cli/cmd/provider.go @@ -45,7 +45,7 @@ func init() { SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } providers, err := cli.ListProviders() diff --git a/cmd/garm-cli/cmd/repo_instances.go b/cmd/garm-cli/cmd/repo_instances.go index ee3c513a..9094bc2b 100644 --- a/cmd/garm-cli/cmd/repo_instances.go +++ b/cmd/garm-cli/cmd/repo_instances.go @@ -37,7 +37,7 @@ var repoRunnerListCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { diff --git a/cmd/garm-cli/cmd/repo_pool.go b/cmd/garm-cli/cmd/repo_pool.go index 30d64b99..d09bf106 100644 --- a/cmd/garm-cli/cmd/repo_pool.go +++ b/cmd/garm-cli/cmd/repo_pool.go @@ -62,7 +62,7 @@ var repoPoolAddCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -97,41 +97,13 @@ var repoPoolAddCmd = &cobra.Command{ }, } -var repoPoolListCmd = &cobra.Command{ - Use: "list", - Aliases: []string{"ls"}, - Short: "List repository pools", - Long: `List all configured pools for a given repository.`, - SilenceUsage: true, - RunE: func(cmd *cobra.Command, args []string) error { - if needsInit { - return needsInitError - } - - if len(args) == 0 { - return fmt.Errorf("requires a repository ID") - } - - if len(args) > 1 { - return fmt.Errorf("too many arguments") - } - - pools, err := cli.ListRepoPools(args[0]) - if err != nil { - return err - } - formatPools(pools) - return nil - }, -} - var repoPoolShowCmd = &cobra.Command{ Use: "show", Short: "Show details for one pool", Long: `Displays detailed information about a single pool.`, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) < 2 || len(args) > 2 { @@ -156,7 +128,7 @@ var repoPoolDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) < 2 || len(args) > 2 { return fmt.Errorf("command requires repoID and poolID") @@ -181,7 +153,7 @@ explicitly remove them using the runner delete command. SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) < 2 || len(args) > 2 { diff --git a/cmd/garm-cli/cmd/repository.go b/cmd/garm-cli/cmd/repository.go index bcb33db9..52896ced 100644 --- a/cmd/garm-cli/cmd/repository.go +++ b/cmd/garm-cli/cmd/repository.go @@ -51,7 +51,7 @@ var repoAddCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } newRepoReq := params.CreateRepoParams{ @@ -77,7 +77,7 @@ var repoListCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } repos, err := cli.ListRepositories() @@ -96,7 +96,7 @@ var repoShowCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { return fmt.Errorf("requires a repository ID") @@ -121,7 +121,7 @@ var repoDeleteCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { return fmt.Errorf("requires a repository ID") @@ -158,10 +158,10 @@ func init() { func formatRepositories(repos []params.Repository) { t := table.NewWriter() - header := table.Row{"ID", "Owner", "Name", "Credentials name"} + header := table.Row{"ID", "Owner", "Name", "Credentials name", "Pool mgr running"} t.AppendHeader(header) for _, val := range repos { - t.AppendRow(table.Row{val.ID, val.Owner, val.Name, val.CredentialsName}) + t.AppendRow(table.Row{val.ID, val.Owner, val.Name, val.CredentialsName, val.PoolManagerStatus.IsRunning}) t.AppendSeparator() } fmt.Println(t.Render()) @@ -176,6 +176,10 @@ func formatOneRepository(repo params.Repository) { t.AppendRow(table.Row{"Owner", repo.Owner}) t.AppendRow(table.Row{"Name", repo.Name}) t.AppendRow(table.Row{"Credentials", repo.CredentialsName}) + t.AppendRow(table.Row{"Pool manager running", repo.PoolManagerStatus.IsRunning}) + if !repo.PoolManagerStatus.IsRunning { + t.AppendRow(table.Row{"Failure reason", repo.PoolManagerStatus.FailureReason}) + } if len(repo.Pools) > 0 { for _, pool := range repo.Pools { diff --git a/cmd/garm-cli/cmd/root.go b/cmd/garm-cli/cmd/root.go index a8b24321..a3fb0197 100644 --- a/cmd/garm-cli/cmd/root.go +++ b/cmd/garm-cli/cmd/root.go @@ -26,13 +26,13 @@ import ( var Version string var ( - cfg *config.Config - mgr config.Manager - cli *client.Client - active string - needsInit bool - debug bool - needsInitError = fmt.Errorf("Please log into a garm installation first") + cfg *config.Config + mgr config.Manager + cli *client.Client + active string + needsInit bool + debug bool + errNeedsInitError = fmt.Errorf("please log into a garm installation first") ) // rootCmd represents the base command when called without any subcommands diff --git a/cmd/garm-cli/cmd/runner.go b/cmd/garm-cli/cmd/runner.go index f509d641..2f36233b 100644 --- a/cmd/garm-cli/cmd/runner.go +++ b/cmd/garm-cli/cmd/runner.go @@ -72,7 +72,7 @@ Example: SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } var instances []params.Instance @@ -121,7 +121,7 @@ var runnerShowCmd = &cobra.Command{ SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { @@ -158,7 +158,7 @@ to either cancel the workflow or wait for it to finish. SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { - return needsInitError + return errNeedsInitError } if len(args) == 0 { diff --git a/params/params.go b/params/params.go index b2807db0..b0a07450 100644 --- a/params/params.go +++ b/params/params.go @@ -151,29 +151,32 @@ type Internal struct { } type Repository struct { - ID string `json:"id"` - Owner string `json:"owner"` - Name string `json:"name"` - Pools []Pool `json:"pool,omitempty"` - CredentialsName string `json:"credentials_name"` + ID string `json:"id"` + Owner string `json:"owner"` + Name string `json:"name"` + Pools []Pool `json:"pool,omitempty"` + CredentialsName string `json:"credentials_name"` + PoolManagerStatus PoolManagerStatus `json:"pool_manager_status,omitempty"` // Do not serialize sensitive info. WebhookSecret string `json:"-"` } type Organization struct { - ID string `json:"id"` - Name string `json:"name"` - Pools []Pool `json:"pool,omitempty"` - CredentialsName string `json:"credentials_name"` + ID string `json:"id"` + Name string `json:"name"` + Pools []Pool `json:"pool,omitempty"` + CredentialsName string `json:"credentials_name"` + PoolManagerStatus PoolManagerStatus `json:"pool_manager_status,omitempty"` // Do not serialize sensitive info. WebhookSecret string `json:"-"` } type Enterprise struct { - ID string `json:"id"` - Name string `json:"name"` - Pools []Pool `json:"pool,omitempty"` - CredentialsName string `json:"credentials_name"` + ID string `json:"id"` + Name string `json:"name"` + Pools []Pool `json:"pool,omitempty"` + CredentialsName string `json:"credentials_name"` + PoolManagerStatus PoolManagerStatus `json:"pool_manager_status,omitempty"` // Do not serialize sensitive info. WebhookSecret string `json:"-"` } @@ -219,3 +222,8 @@ type Provider struct { type UpdatePoolStateParams struct { WebhookSecret string } + +type PoolManagerStatus struct { + IsRunning bool `json:"running"` + FailureReason string `json:"failure_reason,omitempty"` +} diff --git a/runner/common/mocks/PoolManager.go b/runner/common/mocks/PoolManager.go index be95d2cb..4d55c339 100644 --- a/runner/common/mocks/PoolManager.go +++ b/runner/common/mocks/PoolManager.go @@ -83,6 +83,20 @@ func (_m *PoolManager) Start() error { return r0 } +// Status provides a mock function with given fields: +func (_m *PoolManager) Status() params.PoolManagerStatus { + ret := _m.Called() + + var r0 params.PoolManagerStatus + if rf, ok := ret.Get(0).(func() params.PoolManagerStatus); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(params.PoolManagerStatus) + } + + return r0 +} + // Stop provides a mock function with given fields: func (_m *PoolManager) Stop() error { ret := _m.Called() diff --git a/runner/common/pool.go b/runner/common/pool.go index 73dc54cd..113125e9 100644 --- a/runner/common/pool.go +++ b/runner/common/pool.go @@ -31,6 +31,12 @@ const ( // Set this to 15 minutes. This should allow enough time even on slow // clouds for the instance to spin up, download the tools and join gh. PoolToolUpdateInterval = 15 * time.Minute + + // UnauthorizedBackoffTimer is the time we wait before making another request + // after getting an unauthorized error from github. It is unlikely that a second + // request will not receive the same error, unless the config is changed with new + // credentials and garm is restarted. + UnauthorizedBackoffTimer = 3 * time.Hour ) //go:generate mockery --all @@ -45,5 +51,6 @@ type PoolManager interface { // PoolManager lifecycle functions. Start/stop pool. Start() error Stop() error + Status() params.PoolManagerStatus Wait() error } diff --git a/runner/enterprises.go b/runner/enterprises.go index 7750b91e..4fdd4b0c 100644 --- a/runner/enterprises.go +++ b/runner/enterprises.go @@ -2,6 +2,7 @@ package runner import ( "context" + "fmt" "garm/auth" "garm/config" runnerErrors "garm/errors" @@ -72,7 +73,20 @@ func (r *Runner) ListEnterprises(ctx context.Context) ([]params.Enterprise, erro return nil, errors.Wrap(err, "listing enterprises") } - return enterprises, nil + var allEnterprises []params.Enterprise + + for _, enterprise := range enterprises { + poolMgr, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise) + if err != nil { + enterprise.PoolManagerStatus.IsRunning = false + enterprise.PoolManagerStatus.FailureReason = fmt.Sprintf("failed to get pool manager: %q", err) + } else { + enterprise.PoolManagerStatus = poolMgr.Status() + } + allEnterprises = append(allEnterprises, enterprise) + } + + return allEnterprises, nil } func (r *Runner) GetEnterpriseByID(ctx context.Context, enterpriseID string) (params.Enterprise, error) { @@ -84,6 +98,12 @@ func (r *Runner) GetEnterpriseByID(ctx context.Context, enterpriseID string) (pa if err != nil { return params.Enterprise{}, errors.Wrap(err, "fetching enterprise") } + poolMgr, err := r.poolManagerCtrl.GetEnterprisePoolManager(enterprise) + if err != nil { + enterprise.PoolManagerStatus.IsRunning = false + enterprise.PoolManagerStatus.FailureReason = fmt.Sprintf("failed to get pool manager: %q", err) + } + enterprise.PoolManagerStatus = poolMgr.Status() return enterprise, nil } diff --git a/runner/organizations.go b/runner/organizations.go index e9f7e264..eef1e65f 100644 --- a/runner/organizations.go +++ b/runner/organizations.go @@ -16,6 +16,7 @@ package runner import ( "context" + "fmt" "log" "strings" @@ -85,7 +86,21 @@ func (r *Runner) ListOrganizations(ctx context.Context) ([]params.Organization, return nil, errors.Wrap(err, "listing organizations") } - return orgs, nil + var allOrgs []params.Organization + + for _, org := range orgs { + poolMgr, err := r.poolManagerCtrl.GetOrgPoolManager(org) + if err != nil { + org.PoolManagerStatus.IsRunning = false + org.PoolManagerStatus.FailureReason = fmt.Sprintf("failed to get pool manager: %q", err) + } else { + org.PoolManagerStatus = poolMgr.Status() + } + + allOrgs = append(allOrgs, org) + } + + return allOrgs, nil } func (r *Runner) GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error) { @@ -97,6 +112,13 @@ func (r *Runner) GetOrganizationByID(ctx context.Context, orgID string) (params. if err != nil { return params.Organization{}, errors.Wrap(err, "fetching organization") } + + poolMgr, err := r.poolManagerCtrl.GetOrgPoolManager(org) + if err != nil { + org.PoolManagerStatus.IsRunning = false + org.PoolManagerStatus.FailureReason = fmt.Sprintf("failed to get pool manager: %q", err) + } + org.PoolManagerStatus = poolMgr.Status() return org, nil } diff --git a/runner/organizations_test.go b/runner/organizations_test.go index 6a28d190..e87cc255 100644 --- a/runner/organizations_test.go +++ b/runner/organizations_test.go @@ -262,6 +262,8 @@ func (s *OrgTestSuite) TestCreateOrganizationStartPoolMgrFailed() { } func (s *OrgTestSuite) TestListOrganizations() { + s.Fixtures.PoolMgrCtrlMock.On("GetOrgPoolManager", mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, nil) + s.Fixtures.PoolMgrMock.On("Status").Return(params.PoolManagerStatus{IsRunning: true}, nil) orgs, err := s.Runner.ListOrganizations(s.Fixtures.AdminContext) s.Require().Nil(err) @@ -275,6 +277,8 @@ func (s *OrgTestSuite) TestListOrganizationsErrUnauthorized() { } func (s *OrgTestSuite) TestGetOrganizationByID() { + s.Fixtures.PoolMgrCtrlMock.On("GetOrgPoolManager", mock.AnythingOfType("params.Organization")).Return(s.Fixtures.PoolMgrMock, nil) + s.Fixtures.PoolMgrMock.On("Status").Return(params.PoolManagerStatus{IsRunning: true}, nil) org, err := s.Runner.GetOrganizationByID(s.Fixtures.AdminContext, s.Fixtures.StoreOrgs["test-org-1"].ID) s.Require().Nil(err) diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go index c2de3cd8..6bf8f789 100644 --- a/runner/pool/enterprise.go +++ b/runner/pool/enterprise.go @@ -3,6 +3,7 @@ package pool import ( "context" "fmt" + "net/http" "strings" "sync" @@ -35,7 +36,7 @@ func NewEnterprisePoolManager(ctx context.Context, cfg params.Enterprise, cfgInt store: store, } - repo := &basePool{ + repo := &basePoolManager{ ctx: ctx, store: store, providers: providers, @@ -99,6 +100,9 @@ func (r *enterprise) GetGithubRunners() ([]*github.Runner, error) { for { runners, ghResp, err := r.ghcEnterpriseCli.ListRunners(r.ctx, r.cfg.Name, &opts) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return nil, errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runners") + } return nil, errors.Wrap(err, "fetching runners") } allRunners = append(allRunners, runners.Runners...) @@ -113,8 +117,11 @@ func (r *enterprise) GetGithubRunners() ([]*github.Runner, error) { func (r *enterprise) FetchTools() ([]*github.RunnerApplicationDownload, error) { r.mux.Lock() defer r.mux.Unlock() - tools, _, err := r.ghcEnterpriseCli.ListRunnerApplicationDownloads(r.ctx, r.cfg.Name) + tools, ghResp, err := r.ghcEnterpriseCli.ListRunnerApplicationDownloads(r.ctx, r.cfg.Name) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return nil, errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runners") + } return nil, errors.Wrap(err, "fetching runner tools") } diff --git a/runner/pool/organization.go b/runner/pool/organization.go index 3ab36c62..e3cd2ebd 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -17,6 +17,7 @@ package pool import ( "context" "fmt" + "net/http" "strings" "sync" @@ -48,7 +49,7 @@ func NewOrganizationPoolManager(ctx context.Context, cfg params.Organization, cf store: store, } - repo := &basePool{ + repo := &basePoolManager{ ctx: ctx, store: store, providers: providers, @@ -110,6 +111,9 @@ func (r *organization) GetGithubRunners() ([]*github.Runner, error) { for { runners, ghResp, err := r.ghcli.ListOrganizationRunners(r.ctx, r.cfg.Name, &opts) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return nil, errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runners") + } return nil, errors.Wrap(err, "fetching runners") } allRunners = append(allRunners, runners.Runners...) @@ -125,8 +129,11 @@ func (r *organization) GetGithubRunners() ([]*github.Runner, error) { func (r *organization) FetchTools() ([]*github.RunnerApplicationDownload, error) { r.mux.Lock() defer r.mux.Unlock() - tools, _, err := r.ghcli.ListOrganizationRunnerApplicationDownloads(r.ctx, r.cfg.Name) + tools, ghResp, err := r.ghcli.ListOrganizationRunnerApplicationDownloads(r.ctx, r.cfg.Name) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return nil, errors.Wrap(runnerErrors.ErrUnauthorized, "fetching tools") + } return nil, errors.Wrap(err, "fetching runner tools") } diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 8898d51d..385908b0 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -47,7 +47,7 @@ const ( maxCreateAttempts = 5 ) -type basePool struct { +type basePoolManager struct { ctx context.Context controllerID string @@ -61,6 +61,9 @@ type basePool struct { helper poolHelper credsDetails params.GithubCredentials + managerIsRunning bool + managerErrorReason string + mux sync.Mutex } @@ -81,7 +84,7 @@ func controllerIDFromLabels(labels []*github.RunnerLabels) string { // happens, github will remove the ephemeral worker and send a webhook our way. // If we were offline and did not process the webhook, the instance will linger. // We need to remove it from the provider and database. -func (r *basePool) cleanupOrphanedProviderRunners(runners []*github.Runner) error { +func (r *basePoolManager) cleanupOrphanedProviderRunners(runners []*github.Runner) error { dbInstances, err := r.helper.FetchDbInstances() if err != nil { return errors.Wrap(err, "fetching instances from db") @@ -116,7 +119,7 @@ func (r *basePool) cleanupOrphanedProviderRunners(runners []*github.Runner) erro // reapTimedOutRunners will mark as pending_delete any runner that has a status // of "running" in the provider, but that has not registered with Github, and has // received no new updates in the configured timeout interval. -func (r *basePool) reapTimedOutRunners(runners []*github.Runner) error { +func (r *basePoolManager) reapTimedOutRunners(runners []*github.Runner) error { dbInstances, err := r.helper.FetchDbInstances() if err != nil { return errors.Wrap(err, "fetching instances from db") @@ -152,7 +155,7 @@ func (r *basePool) reapTimedOutRunners(runners []*github.Runner) error { // as offline and for which we no longer have a local instance. // This may happen if someone manually deletes the instance in the provider. We need to // first remove the instance from github, and then from our database. -func (r *basePool) cleanupOrphanedGithubRunners(runners []*github.Runner) error { +func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner) error { for _, runner := range runners { runnerControllerID := controllerIDFromLabels(runner.Labels) if runnerControllerID != r.controllerID { @@ -243,7 +246,7 @@ func (r *basePool) cleanupOrphanedGithubRunners(runners []*github.Runner) error return nil } -func (r *basePool) fetchInstance(runnerName string) (params.Instance, error) { +func (r *basePoolManager) fetchInstance(runnerName string) (params.Instance, error) { runner, err := r.store.GetInstanceByName(r.ctx, runnerName) if err != nil { return params.Instance{}, errors.Wrap(err, "fetching instance") @@ -252,7 +255,7 @@ func (r *basePool) fetchInstance(runnerName string) (params.Instance, error) { return runner, nil } -func (r *basePool) setInstanceRunnerStatus(runnerName string, status providerCommon.RunnerStatus) error { +func (r *basePoolManager) setInstanceRunnerStatus(runnerName string, status providerCommon.RunnerStatus) error { updateParams := params.UpdateInstanceParams{ RunnerStatus: status, } @@ -263,7 +266,7 @@ func (r *basePool) setInstanceRunnerStatus(runnerName string, status providerCom return nil } -func (r *basePool) updateInstance(runnerName string, update params.UpdateInstanceParams) error { +func (r *basePoolManager) updateInstance(runnerName string, update params.UpdateInstanceParams) error { runner, err := r.fetchInstance(runnerName) if err != nil { return errors.Wrap(err, "fetching instance") @@ -275,7 +278,7 @@ func (r *basePool) updateInstance(runnerName string, update params.UpdateInstanc return nil } -func (r *basePool) setInstanceStatus(runnerName string, status providerCommon.InstanceStatus, providerFault []byte) error { +func (r *basePoolManager) setInstanceStatus(runnerName string, status providerCommon.InstanceStatus, providerFault []byte) error { updateParams := params.UpdateInstanceParams{ Status: status, ProviderFault: providerFault, @@ -287,7 +290,7 @@ func (r *basePool) setInstanceStatus(runnerName string, status providerCommon.In return nil } -func (r *basePool) acquireNewInstance(job params.WorkflowJob) error { +func (r *basePoolManager) acquireNewInstance(job params.WorkflowJob) error { requestedLabels := job.WorkflowJob.Labels if len(requestedLabels) == 0 { // no labels were requested. @@ -322,7 +325,7 @@ func (r *basePool) acquireNewInstance(job params.WorkflowJob) error { return nil } -func (r *basePool) AddRunner(ctx context.Context, poolID string) error { +func (r *basePoolManager) AddRunner(ctx context.Context, poolID string) error { pool, err := r.helper.GetPoolByID(poolID) if err != nil { return errors.Wrap(err, "fetching pool") @@ -348,7 +351,7 @@ func (r *basePool) AddRunner(ctx context.Context, poolID string) error { return nil } -func (r *basePool) loop() { +func (r *basePoolManager) loop() { consolidateTimer := time.NewTicker(common.PoolConsilitationInterval) reapTimer := time.NewTicker(common.PoolReapTimeoutInterval) toolUpdateTimer := time.NewTicker(common.PoolToolUpdateInterval) @@ -360,7 +363,8 @@ func (r *basePool) loop() { close(r.done) }() log.Printf("starting loop for %s", r.helper.String()) - // TODO: Consolidate runners on loop start. Provider runners must match runners + + // Consolidate runners on loop start. Provider runners must match runners // in github and DB. When a Workflow job is received, we will first create/update // an entity in the database, before sending the request to the provider to create/delete // an instance. If a "queued" job is received, we create an entity in the db with @@ -370,45 +374,118 @@ func (r *basePool) loop() { // in the database. // We also ensure we have runners created based on pool characteristics. This is where // we spin up "MinWorkers" for each runner type. - for { - select { - case <-reapTimer.C: - runners, err := r.helper.GetGithubRunners() - if err != nil { - log.Printf("error fetching github runners: %s", err) - continue - } - if err := r.reapTimedOutRunners(runners); err != nil { - log.Printf("failed to reap timed out runners: %q", err) - } + switch r.managerIsRunning { + case true: + select { + case <-reapTimer.C: + runners, err := r.helper.GetGithubRunners() + if err != nil { + failureReason := fmt.Sprintf("error fetching github runners for %s: %s", r.helper.String(), err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + if errors.Is(err, runnerErrors.ErrUnauthorized) { + r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer) + } else { + r.waitForTimeoutOrCanceled(60 * time.Second) + } + continue + } + if err := r.reapTimedOutRunners(runners); err != nil { + log.Printf("failed to reap timed out runners: %q", err) + } - if err := r.cleanupOrphanedGithubRunners(runners); err != nil { - log.Printf("failed to clean orphaned github runners: %q", err) + if err := r.cleanupOrphanedGithubRunners(runners); err != nil { + log.Printf("failed to clean orphaned github runners: %q", err) + } + case <-consolidateTimer.C: + // consolidate. + r.consolidate() + case <-toolUpdateTimer.C: + // Update tools cache. + tools, err := r.helper.FetchTools() + if err != nil { + failureReason := fmt.Sprintf("failed to update tools for repo %s: %s", r.helper.String(), err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + if errors.Is(err, runnerErrors.ErrUnauthorized) { + r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer) + } else { + r.waitForTimeoutOrCanceled(60 * time.Second) + } + continue + } + r.mux.Lock() + r.tools = tools + r.mux.Unlock() + case <-r.ctx.Done(): + // daemon is shutting down. + return + case <-r.quit: + // this worker was stopped. + return } - case <-consolidateTimer.C: - // consolidate. - r.consolidate() - case <-toolUpdateTimer.C: - // Update tools cache. + default: + log.Printf("attempting to start pool manager for %s", r.helper.String()) tools, err := r.helper.FetchTools() + var failureReason string if err != nil { - log.Printf("failed to update tools for repo %s: %s", r.helper.String(), err) + failureReason = fmt.Sprintf("failed to fetch tools from github for %s: %q", r.helper.String(), err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + if errors.Is(err, runnerErrors.ErrUnauthorized) { + r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer) + } else { + r.waitForTimeoutOrCanceled(60 * time.Second) + } + continue } r.mux.Lock() r.tools = tools r.mux.Unlock() - case <-r.ctx.Done(): - // daemon is shutting down. - return - case <-r.quit: - // this worker was stopped. - return + + if err := r.runnerCleanup(); err != nil { + failureReason = fmt.Sprintf("failed to clean runners for %s: %q", r.helper.String(), err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + if errors.Is(err, runnerErrors.ErrUnauthorized) { + r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer) + } else { + r.waitForTimeoutOrCanceled(60 * time.Second) + } + continue + } + r.setPoolRunningState(true, "") } } } -func (r *basePool) addInstanceToProvider(instance params.Instance) error { +func (r *basePoolManager) Status() params.PoolManagerStatus { + r.mux.Lock() + defer r.mux.Unlock() + return params.PoolManagerStatus{ + IsRunning: r.managerIsRunning, + FailureReason: r.managerErrorReason, + } +} + +func (r *basePoolManager) waitForTimeoutOrCanceled(timeout time.Duration) { + log.Printf("sleeping for %.2f minutes", timeout.Minutes()) + select { + case <-time.After(timeout): + case <-r.ctx.Done(): + case <-r.quit: + } +} + +func (r *basePoolManager) setPoolRunningState(isRunning bool, failureReason string) { + r.mux.Lock() + r.managerErrorReason = failureReason + r.managerIsRunning = isRunning + r.mux.Unlock() +} + +func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error { pool, err := r.helper.GetPoolByID(instance.PoolID) if err != nil { return errors.Wrap(err, "fetching pool") @@ -416,7 +493,7 @@ func (r *basePool) addInstanceToProvider(instance params.Instance) error { provider, ok := r.providers[pool.ProviderName] if !ok { - return runnerErrors.NewNotFoundError("invalid provider ID") + return fmt.Errorf("unknown provider %s for pool %s", pool.ProviderName, pool.ID) } labels := []string{} @@ -490,7 +567,7 @@ func (r *basePool) addInstanceToProvider(instance params.Instance) error { return nil } -func (r *basePool) getRunnerNameFromJob(job params.WorkflowJob) (string, error) { +func (r *basePoolManager) getRunnerNameFromJob(job params.WorkflowJob) (string, error) { if job.WorkflowJob.RunnerName != "" { return job.WorkflowJob.RunnerName, nil } @@ -506,7 +583,7 @@ func (r *basePool) getRunnerNameFromJob(job params.WorkflowJob) (string, error) return runnerName, nil } -func (r *basePool) HandleWorkflowJob(job params.WorkflowJob) error { +func (r *basePoolManager) HandleWorkflowJob(job params.WorkflowJob) error { if err := r.helper.ValidateOwner(job); err != nil { return errors.Wrap(err, "validating owner") } @@ -559,15 +636,15 @@ func (r *basePool) HandleWorkflowJob(job params.WorkflowJob) error { return nil } -func (r *basePool) poolLabel(poolID string) string { +func (r *basePoolManager) poolLabel(poolID string) string { return fmt.Sprintf("%s%s", poolIDLabelprefix, poolID) } -func (r *basePool) controllerLabel() string { +func (r *basePoolManager) controllerLabel() string { return fmt.Sprintf("%s%s", controllerLabelPrefix, r.controllerID) } -func (r *basePool) updateArgsFromProviderInstance(providerInstance params.Instance) params.UpdateInstanceParams { +func (r *basePoolManager) updateArgsFromProviderInstance(providerInstance params.Instance) params.UpdateInstanceParams { return params.UpdateInstanceParams{ ProviderID: providerInstance.ProviderID, OSName: providerInstance.OSName, @@ -579,7 +656,7 @@ func (r *basePool) updateArgsFromProviderInstance(providerInstance params.Instan } } -func (r *basePool) ensureIdleRunnersForOnePool(pool params.Pool) { +func (r *basePoolManager) ensureIdleRunnersForOnePool(pool params.Pool) { if !pool.Enabled { return } @@ -622,7 +699,7 @@ func (r *basePool) ensureIdleRunnersForOnePool(pool params.Pool) { } } -func (r *basePool) retryFailedInstancesForOnePool(pool params.Pool) { +func (r *basePoolManager) retryFailedInstancesForOnePool(pool params.Pool) { if !pool.Enabled { return } @@ -664,7 +741,7 @@ func (r *basePool) retryFailedInstancesForOnePool(pool params.Pool) { } } -func (r *basePool) retryFailedInstances() { +func (r *basePoolManager) retryFailedInstances() { pools, err := r.helper.ListPools() if err != nil { log.Printf("error listing pools: %s", err) @@ -681,7 +758,7 @@ func (r *basePool) retryFailedInstances() { wg.Wait() } -func (r *basePool) ensureMinIdleRunners() { +func (r *basePoolManager) ensureMinIdleRunners() { pools, err := r.helper.ListPools() if err != nil { log.Printf("error listing pools: %s", err) @@ -698,7 +775,7 @@ func (r *basePool) ensureMinIdleRunners() { wg.Wait() } -func (r *basePool) deleteInstanceFromProvider(instance params.Instance) error { +func (r *basePoolManager) deleteInstanceFromProvider(instance params.Instance) error { pool, err := r.helper.GetPoolByID(instance.PoolID) if err != nil { return errors.Wrap(err, "fetching pool") @@ -706,7 +783,7 @@ func (r *basePool) deleteInstanceFromProvider(instance params.Instance) error { provider, ok := r.providers[pool.ProviderName] if !ok { - return runnerErrors.NewNotFoundError("invalid provider ID") + return fmt.Errorf("unknown provider %s for pool %s", pool.ProviderName, pool.ID) } identifier := instance.ProviderID @@ -726,7 +803,7 @@ func (r *basePool) deleteInstanceFromProvider(instance params.Instance) error { return nil } -func (r *basePool) deletePendingInstances() { +func (r *basePoolManager) deletePendingInstances() { instances, err := r.helper.FetchDbInstances() if err != nil { log.Printf("failed to fetch instances from store: %s", err) @@ -764,7 +841,7 @@ func (r *basePool) deletePendingInstances() { } } -func (r *basePool) addPendingInstances() { +func (r *basePoolManager) addPendingInstances() { // TODO: filter instances by status. instances, err := r.helper.FetchDbInstances() if err != nil { @@ -796,7 +873,7 @@ func (r *basePool) addPendingInstances() { } } -func (r *basePool) consolidate() { +func (r *basePoolManager) consolidate() { // TODO(gabriel-samfira): replace this with something more efficient. r.mux.Lock() defer r.mux.Unlock() @@ -826,7 +903,7 @@ func (r *basePool) consolidate() { wg.Wait() } -func (r *basePool) Wait() error { +func (r *basePoolManager) Wait() error { select { case <-r.done: case <-time.After(20 * time.Second): @@ -835,15 +912,7 @@ func (r *basePool) Wait() error { return nil } -func (r *basePool) Start() error { - tools, err := r.helper.FetchTools() - if err != nil { - return errors.Wrap(err, "initializing tools") - } - r.mux.Lock() - r.tools = tools - r.mux.Unlock() - +func (r *basePoolManager) runnerCleanup() error { runners, err := r.helper.GetGithubRunners() if err != nil { return errors.Wrap(err, "fetching github runners") @@ -855,28 +924,35 @@ func (r *basePool) Start() error { if err := r.cleanupOrphanedGithubRunners(runners); err != nil { return errors.Wrap(err, "cleaning orphaned github runners") } + return nil +} + +func (r *basePoolManager) Start() error { go r.loop() return nil } -func (r *basePool) Stop() error { +func (r *basePoolManager) Stop() error { close(r.quit) return nil } -func (r *basePool) RefreshState(param params.UpdatePoolStateParams) error { +func (r *basePoolManager) RefreshState(param params.UpdatePoolStateParams) error { return r.helper.UpdateState(param) } -func (r *basePool) WebhookSecret() string { +func (r *basePoolManager) WebhookSecret() string { return r.helper.WebhookSecret() } -func (r *basePool) ID() string { +func (r *basePoolManager) ID() string { return r.helper.ID() } -func (r *basePool) ForceDeleteRunner(runner params.Instance) error { +func (r *basePoolManager) ForceDeleteRunner(runner params.Instance) error { + if !r.managerIsRunning { + return runnerErrors.NewConflictError("pool manager is not running for %s", r.helper.String()) + } if runner.AgentID != 0 { resp, err := r.helper.RemoveGithubRunner(runner.AgentID) if err != nil { diff --git a/runner/pool/repository.go b/runner/pool/repository.go index 864bcab3..597bbf05 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -17,6 +17,7 @@ package pool import ( "context" "fmt" + "net/http" "strings" "sync" @@ -48,7 +49,7 @@ func NewRepositoryPoolManager(ctx context.Context, cfg params.Repository, cfgInt store: store, } - repo := &basePool{ + repo := &basePoolManager{ ctx: ctx, store: store, providers: providers, @@ -112,6 +113,9 @@ func (r *repository) GetGithubRunners() ([]*github.Runner, error) { for { runners, ghResp, err := r.ghcli.ListRunners(r.ctx, r.cfg.Owner, r.cfg.Name, &opts) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return nil, errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runners") + } return nil, errors.Wrap(err, "fetching runners") } allRunners = append(allRunners, runners.Runners...) @@ -127,8 +131,11 @@ func (r *repository) GetGithubRunners() ([]*github.Runner, error) { func (r *repository) FetchTools() ([]*github.RunnerApplicationDownload, error) { r.mux.Lock() defer r.mux.Unlock() - tools, _, err := r.ghcli.ListRunnerApplicationDownloads(r.ctx, r.cfg.Owner, r.cfg.Name) + tools, ghResp, err := r.ghcli.ListRunnerApplicationDownloads(r.ctx, r.cfg.Owner, r.cfg.Name) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return nil, errors.Wrap(runnerErrors.ErrUnauthorized, "fetching tools") + } return nil, errors.Wrap(err, "fetching runner tools") } diff --git a/runner/repositories.go b/runner/repositories.go index 3cc11aad..f9a33137 100644 --- a/runner/repositories.go +++ b/runner/repositories.go @@ -16,6 +16,7 @@ package runner import ( "context" + "fmt" "log" "strings" @@ -85,7 +86,20 @@ func (r *Runner) ListRepositories(ctx context.Context) ([]params.Repository, err return nil, errors.Wrap(err, "listing repositories") } - return repos, nil + var allRepos []params.Repository + + for _, repo := range repos { + poolMgr, err := r.poolManagerCtrl.GetRepoPoolManager(repo) + if err != nil { + repo.PoolManagerStatus.IsRunning = false + repo.PoolManagerStatus.FailureReason = fmt.Sprintf("failed to get pool manager: %q", err) + } else { + repo.PoolManagerStatus = poolMgr.Status() + } + allRepos = append(allRepos, repo) + } + + return allRepos, nil } func (r *Runner) GetRepositoryByID(ctx context.Context, repoID string) (params.Repository, error) { @@ -97,6 +111,13 @@ func (r *Runner) GetRepositoryByID(ctx context.Context, repoID string) (params.R if err != nil { return params.Repository{}, errors.Wrap(err, "fetching repository") } + + poolMgr, err := r.poolManagerCtrl.GetRepoPoolManager(repo) + if err != nil { + repo.PoolManagerStatus.IsRunning = false + repo.PoolManagerStatus.FailureReason = fmt.Sprintf("failed to get pool manager: %q", err) + } + repo.PoolManagerStatus = poolMgr.Status() return repo, nil } diff --git a/runner/repositories_test.go b/runner/repositories_test.go index 93eaa8ba..2466d006 100644 --- a/runner/repositories_test.go +++ b/runner/repositories_test.go @@ -265,6 +265,8 @@ func (s *RepoTestSuite) TestCreateRepositoryStartPoolMgrFailed() { } func (s *RepoTestSuite) TestListRepositories() { + s.Fixtures.PoolMgrCtrlMock.On("GetRepoPoolManager", mock.AnythingOfType("params.Repository")).Return(s.Fixtures.PoolMgrMock, nil) + s.Fixtures.PoolMgrMock.On("Status").Return(params.PoolManagerStatus{IsRunning: true}, nil) repos, err := s.Runner.ListRepositories(s.Fixtures.AdminContext) s.Require().Nil(err) @@ -278,6 +280,8 @@ func (s *RepoTestSuite) TestListRepositoriesErrUnauthorized() { } func (s *RepoTestSuite) TestGetRepositoryByID() { + s.Fixtures.PoolMgrCtrlMock.On("GetRepoPoolManager", mock.AnythingOfType("params.Repository")).Return(s.Fixtures.PoolMgrMock, nil) + s.Fixtures.PoolMgrMock.On("Status").Return(params.PoolManagerStatus{IsRunning: true}, nil) repo, err := s.Runner.GetRepositoryByID(s.Fixtures.AdminContext, s.Fixtures.StoreRepos["test-repo-1"].ID) s.Require().Nil(err) diff --git a/runner/runner.go b/runner/runner.go index 42b33119..3c7b00ba 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -421,19 +421,49 @@ func (r *Runner) Stop() error { if err != nil { return errors.Wrap(err, "fetch repo pool managers") } - for _, repo := range repos { - if err := repo.Stop(); err != nil { - return errors.Wrap(err, "stopping repo pool manager") - } - } orgs, err := r.poolManagerCtrl.GetOrgPoolManagers() if err != nil { return errors.Wrap(err, "fetch org pool managers") } + + enterprises, err := r.poolManagerCtrl.GetEnterprisePoolManagers() + if err != nil { + return errors.Wrap(err, "fetch enterprise pool managers") + } + + expectedReplies := len(repos) + len(orgs) + len(enterprises) + errChan := make(chan error, expectedReplies) + + for _, repo := range repos { + go func(poolMgr common.PoolManager) { + err := poolMgr.Stop() + errChan <- err + }(repo) + } + for _, org := range orgs { - if err := org.Stop(); err != nil { - return errors.Wrap(err, "stopping org pool manager") + go func(poolMgr common.PoolManager) { + err := poolMgr.Stop() + errChan <- err + }(org) + } + + for _, enterprise := range enterprises { + go func(poolMgr common.PoolManager) { + err := poolMgr.Stop() + errChan <- err + }(enterprise) + } + + for i := 0; i < expectedReplies; i++ { + select { + case err := <-errChan: + if err != nil { + return errors.Wrap(err, "stopping pool manager") + } + case <-time.After(60 * time.Second): + return fmt.Errorf("timed out waiting for pool mamager stop") } } return nil @@ -449,6 +479,17 @@ func (r *Runner) Wait() error { if err != nil { return errors.Wrap(err, "fetch repo pool managers") } + + orgs, err := r.poolManagerCtrl.GetOrgPoolManagers() + if err != nil { + return errors.Wrap(err, "fetch org pool managers") + } + + enterprises, err := r.poolManagerCtrl.GetEnterprisePoolManagers() + if err != nil { + return errors.Wrap(err, "fetch enterprise pool managers") + } + for poolId, repo := range repos { wg.Add(1) go func(id string, poolMgr common.PoolManager) { @@ -459,10 +500,6 @@ func (r *Runner) Wait() error { }(poolId, repo) } - orgs, err := r.poolManagerCtrl.GetOrgPoolManagers() - if err != nil { - return errors.Wrap(err, "fetch org pool managers") - } for poolId, org := range orgs { wg.Add(1) go func(id string, poolMgr common.PoolManager) { @@ -472,6 +509,17 @@ func (r *Runner) Wait() error { } }(poolId, org) } + + for poolId, enterprise := range enterprises { + wg.Add(1) + go func(id string, poolMgr common.PoolManager) { + defer wg.Done() + if err := poolMgr.Wait(); err != nil { + log.Printf("timed out waiting for pool manager %s to exit", id) + } + }(poolId, enterprise) + } + wg.Wait() return nil } From 970ffb608e92f631846e7020a82ab28ebeca8d3d Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Fri, 21 Oct 2022 00:23:04 +0300 Subject: [PATCH 11/12] Mark pool manager as offline in case of 403 Signed-off-by: Gabriel Adrian Samfira --- runner/pool/enterprise.go | 10 +++++++-- runner/pool/interfaces.go | 9 ++++---- runner/pool/organization.go | 11 ++++++++-- runner/pool/pool.go | 43 +++++++++++++++++++++++++++++++------ runner/pool/repository.go | 10 +++++++-- 5 files changed, 67 insertions(+), 16 deletions(-) diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go index 6bf8f789..0cc99d97 100644 --- a/runner/pool/enterprise.go +++ b/runner/pool/enterprise.go @@ -62,8 +62,11 @@ type enterprise struct { } func (r *enterprise) GetRunnerNameFromWorkflow(job params.WorkflowJob) (string, error) { - workflow, _, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Repository.Owner.Login, job.Repository.Name, job.WorkflowJob.ID) + workflow, ghResp, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Repository.Owner.Login, job.Repository.Name, job.WorkflowJob.ID) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runners") + } return "", errors.Wrap(err, "fetching workflow info") } if workflow.RunnerName != nil { @@ -153,9 +156,12 @@ func (r *enterprise) JwtToken() string { } func (r *enterprise) GetGithubRegistrationToken() (string, error) { - tk, _, err := r.ghcEnterpriseCli.CreateRegistrationToken(r.ctx, r.cfg.Name) + tk, ghResp, err := r.ghcEnterpriseCli.CreateRegistrationToken(r.ctx, r.cfg.Name) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching registration token") + } return "", errors.Wrap(err, "creating runner token") } return *tk.Token, nil diff --git a/runner/pool/interfaces.go b/runner/pool/interfaces.go index 4ccece01..9f1f7b85 100644 --- a/runner/pool/interfaces.go +++ b/runner/pool/interfaces.go @@ -23,13 +23,15 @@ import ( type poolHelper interface { GetGithubToken() string GetGithubRunners() ([]*github.Runner, error) - FetchTools() ([]*github.RunnerApplicationDownload, error) - FetchDbInstances() ([]params.Instance, error) + GetGithubRegistrationToken() (string, error) + GetRunnerNameFromWorkflow(job params.WorkflowJob) (string, error) RemoveGithubRunner(runnerID int64) (*github.Response, error) + FetchTools() ([]*github.RunnerApplicationDownload, error) + + FetchDbInstances() ([]params.Instance, error) ListPools() ([]params.Pool, error) GithubURL() string JwtToken() string - GetGithubRegistrationToken() (string, error) String() string GetCallbackURL() string FindPoolByTags(labels []string) (params.Pool, error) @@ -37,6 +39,5 @@ type poolHelper interface { ValidateOwner(job params.WorkflowJob) error UpdateState(param params.UpdatePoolStateParams) error WebhookSecret() string - GetRunnerNameFromWorkflow(job params.WorkflowJob) (string, error) ID() string } diff --git a/runner/pool/organization.go b/runner/pool/organization.go index e3cd2ebd..b8efba72 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -74,8 +74,11 @@ type organization struct { } func (r *organization) GetRunnerNameFromWorkflow(job params.WorkflowJob) (string, error) { - workflow, _, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Organization.Login, job.Repository.Name, job.WorkflowJob.ID) + workflow, ghResp, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Organization.Login, job.Repository.Name, job.WorkflowJob.ID) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runner name") + } return "", errors.Wrap(err, "fetching workflow info") } if workflow.RunnerName != nil { @@ -165,9 +168,13 @@ func (r *organization) JwtToken() string { } func (r *organization) GetGithubRegistrationToken() (string, error) { - tk, _, err := r.ghcli.CreateOrganizationRegistrationToken(r.ctx, r.cfg.Name) + tk, ghResp, err := r.ghcli.CreateOrganizationRegistrationToken(r.ctx, r.cfg.Name) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching token") + } + return "", errors.Wrap(err, "creating runner token") } return *tk.Token, nil diff --git a/runner/pool/pool.go b/runner/pool/pool.go index 385908b0..1eac96c2 100644 --- a/runner/pool/pool.go +++ b/runner/pool/pool.go @@ -183,6 +183,13 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner) if resp != nil && resp.StatusCode == http.StatusNotFound { continue } + + if errors.Is(err, runnerErrors.ErrUnauthorized) { + failureReason := fmt.Sprintf("failed to remove github runner: %q", err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + } + return errors.Wrap(err, "removing runner") } continue @@ -220,6 +227,12 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner) if resp != nil && resp.StatusCode == http.StatusNotFound { log.Printf("runner dissapeared from github") } else { + if errors.Is(err, runnerErrors.ErrUnauthorized) { + failureReason := fmt.Sprintf("failed to remove github runner: %q", err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + } + return errors.Wrap(err, "removing runner from github") } } @@ -385,9 +398,7 @@ func (r *basePoolManager) loop() { r.setPoolRunningState(false, failureReason) log.Print(failureReason) if errors.Is(err, runnerErrors.ErrUnauthorized) { - r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer) - } else { - r.waitForTimeoutOrCanceled(60 * time.Second) + break } continue } @@ -409,9 +420,7 @@ func (r *basePoolManager) loop() { r.setPoolRunningState(false, failureReason) log.Print(failureReason) if errors.Is(err, runnerErrors.ErrUnauthorized) { - r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer) - } else { - r.waitForTimeoutOrCanceled(60 * time.Second) + break } continue } @@ -505,6 +514,11 @@ func (r *basePoolManager) addInstanceToProvider(instance params.Instance) error tk, err := r.helper.GetGithubRegistrationToken() if err != nil { + if errors.Is(err, runnerErrors.ErrUnauthorized) { + failureReason := fmt.Sprintf("failed to fetch registration token: %q", err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + } return errors.Wrap(err, "fetching registration token") } @@ -577,6 +591,11 @@ func (r *basePoolManager) getRunnerNameFromJob(job params.WorkflowJob) (string, log.Printf("runner name not found in workflow job, attempting to fetch from API") runnerName, err := r.helper.GetRunnerNameFromWorkflow(job) if err != nil { + if errors.Is(err, runnerErrors.ErrUnauthorized) { + failureReason := fmt.Sprintf("failed to fetch runner name from API: %q", err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + } return "", errors.Wrap(err, "fetching runner name from API") } @@ -915,6 +934,11 @@ func (r *basePoolManager) Wait() error { func (r *basePoolManager) runnerCleanup() error { runners, err := r.helper.GetGithubRunners() if err != nil { + if errors.Is(err, runnerErrors.ErrUnauthorized) { + failureReason := fmt.Sprintf("failed to fetch runners: %q", err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + } return errors.Wrap(err, "fetching github runners") } if err := r.cleanupOrphanedProviderRunners(runners); err != nil { @@ -963,6 +987,13 @@ func (r *basePoolManager) ForceDeleteRunner(runner params.Instance) error { case http.StatusNotFound: // Runner may have been deleted by a finished job, or manually by the user. log.Printf("runner with agent id %d was not found in github", runner.AgentID) + case http.StatusUnauthorized: + // Mark the pool as offline from this point forward + failureReason := fmt.Sprintf("failed to remove runner: %q", err) + r.setPoolRunningState(false, failureReason) + log.Print(failureReason) + // evaluate the next switch case. + fallthrough default: return errors.Wrap(err, "removing runner") } diff --git a/runner/pool/repository.go b/runner/pool/repository.go index 597bbf05..598ac939 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -76,8 +76,11 @@ type repository struct { } func (r *repository) GetRunnerNameFromWorkflow(job params.WorkflowJob) (string, error) { - workflow, _, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Repository.Owner.Login, job.Repository.Name, job.WorkflowJob.ID) + workflow, ghResp, err := r.ghcli.GetWorkflowJobByID(r.ctx, job.Repository.Owner.Login, job.Repository.Name, job.WorkflowJob.ID) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching runner name") + } return "", errors.Wrap(err, "fetching workflow info") } if workflow.RunnerName != nil { @@ -167,9 +170,12 @@ func (r *repository) JwtToken() string { } func (r *repository) GetGithubRegistrationToken() (string, error) { - tk, _, err := r.ghcli.CreateRegistrationToken(r.ctx, r.cfg.Owner, r.cfg.Name) + tk, ghResp, err := r.ghcli.CreateRegistrationToken(r.ctx, r.cfg.Owner, r.cfg.Name) if err != nil { + if ghResp.StatusCode == http.StatusUnauthorized { + return "", errors.Wrap(runnerErrors.ErrUnauthorized, "fetching token") + } return "", errors.Wrap(err, "creating runner token") } return *tk.Token, nil From f13d63b2e4c5c78c9e637607ad7a560ad97d78a6 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Fri, 21 Oct 2022 11:39:03 +0300 Subject: [PATCH 12/12] Use logWriter instead of os.Stdout --- apiserver/routers/routers.go | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/apiserver/routers/routers.go b/apiserver/routers/routers.go index 818c28e0..87d7d471 100644 --- a/apiserver/routers/routers.go +++ b/apiserver/routers/routers.go @@ -169,40 +169,40 @@ func NewAPIRouter(han *controllers.APIController, logWriter io.Writer, authMiddl // Enterprises and pools // ///////////////////////////// // Get pool - apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(os.Stdout, http.HandlerFunc(han.GetEnterprisePoolHandler))).Methods("GET", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(os.Stdout, http.HandlerFunc(han.GetEnterprisePoolHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(logWriter, http.HandlerFunc(han.GetEnterprisePoolHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(logWriter, http.HandlerFunc(han.GetEnterprisePoolHandler))).Methods("GET", "OPTIONS") // Delete pool - apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(os.Stdout, http.HandlerFunc(han.DeleteEnterprisePoolHandler))).Methods("DELETE", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(os.Stdout, http.HandlerFunc(han.DeleteEnterprisePoolHandler))).Methods("DELETE", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(logWriter, http.HandlerFunc(han.DeleteEnterprisePoolHandler))).Methods("DELETE", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(logWriter, http.HandlerFunc(han.DeleteEnterprisePoolHandler))).Methods("DELETE", "OPTIONS") // Update pool - apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(os.Stdout, http.HandlerFunc(han.UpdateEnterprisePoolHandler))).Methods("PUT", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(os.Stdout, http.HandlerFunc(han.UpdateEnterprisePoolHandler))).Methods("PUT", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}/", log(logWriter, http.HandlerFunc(han.UpdateEnterprisePoolHandler))).Methods("PUT", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/{poolID}", log(logWriter, http.HandlerFunc(han.UpdateEnterprisePoolHandler))).Methods("PUT", "OPTIONS") // List pools - apiRouter.Handle("/enterprises/{enterpriseID}/pools/", log(os.Stdout, http.HandlerFunc(han.ListEnterprisePoolsHandler))).Methods("GET", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}/pools", log(os.Stdout, http.HandlerFunc(han.ListEnterprisePoolsHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/", log(logWriter, http.HandlerFunc(han.ListEnterprisePoolsHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools", log(logWriter, http.HandlerFunc(han.ListEnterprisePoolsHandler))).Methods("GET", "OPTIONS") // Create pool - apiRouter.Handle("/enterprises/{enterpriseID}/pools/", log(os.Stdout, http.HandlerFunc(han.CreateEnterprisePoolHandler))).Methods("POST", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}/pools", log(os.Stdout, http.HandlerFunc(han.CreateEnterprisePoolHandler))).Methods("POST", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools/", log(logWriter, http.HandlerFunc(han.CreateEnterprisePoolHandler))).Methods("POST", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/pools", log(logWriter, http.HandlerFunc(han.CreateEnterprisePoolHandler))).Methods("POST", "OPTIONS") // Repo instances list - apiRouter.Handle("/enterprises/{enterpriseID}/instances/", log(os.Stdout, http.HandlerFunc(han.ListEnterpriseInstancesHandler))).Methods("GET", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}/instances", log(os.Stdout, http.HandlerFunc(han.ListEnterpriseInstancesHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/instances/", log(logWriter, http.HandlerFunc(han.ListEnterpriseInstancesHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/instances", log(logWriter, http.HandlerFunc(han.ListEnterpriseInstancesHandler))).Methods("GET", "OPTIONS") // Get org - apiRouter.Handle("/enterprises/{enterpriseID}/", log(os.Stdout, http.HandlerFunc(han.GetEnterpriseByIDHandler))).Methods("GET", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}", log(os.Stdout, http.HandlerFunc(han.GetEnterpriseByIDHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/", log(logWriter, http.HandlerFunc(han.GetEnterpriseByIDHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}", log(logWriter, http.HandlerFunc(han.GetEnterpriseByIDHandler))).Methods("GET", "OPTIONS") // Update org - apiRouter.Handle("/enterprises/{enterpriseID}/", log(os.Stdout, http.HandlerFunc(han.UpdateEnterpriseHandler))).Methods("PUT", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}", log(os.Stdout, http.HandlerFunc(han.UpdateEnterpriseHandler))).Methods("PUT", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/", log(logWriter, http.HandlerFunc(han.UpdateEnterpriseHandler))).Methods("PUT", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}", log(logWriter, http.HandlerFunc(han.UpdateEnterpriseHandler))).Methods("PUT", "OPTIONS") // Delete org - apiRouter.Handle("/enterprises/{enterpriseID}/", log(os.Stdout, http.HandlerFunc(han.DeleteEnterpriseHandler))).Methods("DELETE", "OPTIONS") - apiRouter.Handle("/enterprises/{enterpriseID}", log(os.Stdout, http.HandlerFunc(han.DeleteEnterpriseHandler))).Methods("DELETE", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}/", log(logWriter, http.HandlerFunc(han.DeleteEnterpriseHandler))).Methods("DELETE", "OPTIONS") + apiRouter.Handle("/enterprises/{enterpriseID}", log(logWriter, http.HandlerFunc(han.DeleteEnterpriseHandler))).Methods("DELETE", "OPTIONS") // List orgs - apiRouter.Handle("/enterprises/", log(os.Stdout, http.HandlerFunc(han.ListEnterprisesHandler))).Methods("GET", "OPTIONS") - apiRouter.Handle("/enterprises", log(os.Stdout, http.HandlerFunc(han.ListEnterprisesHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises/", log(logWriter, http.HandlerFunc(han.ListEnterprisesHandler))).Methods("GET", "OPTIONS") + apiRouter.Handle("/enterprises", log(logWriter, http.HandlerFunc(han.ListEnterprisesHandler))).Methods("GET", "OPTIONS") // Create org - apiRouter.Handle("/enterprises/", log(os.Stdout, http.HandlerFunc(han.CreateEnterpriseHandler))).Methods("POST", "OPTIONS") - apiRouter.Handle("/enterprises", log(os.Stdout, http.HandlerFunc(han.CreateEnterpriseHandler))).Methods("POST", "OPTIONS") + apiRouter.Handle("/enterprises/", log(logWriter, http.HandlerFunc(han.CreateEnterpriseHandler))).Methods("POST", "OPTIONS") + apiRouter.Handle("/enterprises", log(logWriter, http.HandlerFunc(han.CreateEnterpriseHandler))).Methods("POST", "OPTIONS") // Credentials and providers apiRouter.Handle("/credentials/", log(logWriter, http.HandlerFunc(han.ListCredentials))).Methods("GET", "OPTIONS")