diff --git a/go.mod b/go.mod index b771e50..81b576a 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.14.0 - github.com/xanzy/go-gitlab v0.74.0 + github.com/xanzy/go-gitlab v0.76.0 golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 05001db..7f62fe1 100644 --- a/go.sum +++ b/go.sum @@ -216,8 +216,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/xanzy/go-gitlab v0.74.0 h1:Ha1cokbjn0PXy6B19t3W324dwM4AOT52fuHr7nERPrc= -github.com/xanzy/go-gitlab v0.74.0/go.mod h1:d/a0vswScO7Agg1CZNz15Ic6SSvBG9vfw8egL99t4kA= +github.com/xanzy/go-gitlab v0.76.0 h1:mkmuB27RDVZY/iXR61pEUfIqJ15Iivfu1kc3KZtBICI= +github.com/xanzy/go-gitlab v0.76.0/go.mod h1:d/a0vswScO7Agg1CZNz15Ic6SSvBG9vfw8egL99t4kA= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/vendor/github.com/xanzy/go-gitlab/gitlab.go b/vendor/github.com/xanzy/go-gitlab/gitlab.go index 50e084c..d9001eb 100644 --- a/vendor/github.com/xanzy/go-gitlab/gitlab.go +++ b/vendor/github.com/xanzy/go-gitlab/gitlab.go @@ -156,6 +156,7 @@ type Client struct { Markdown *MarkdownService MergeRequestApprovals *MergeRequestApprovalsService MergeRequests *MergeRequestsService + Metadata *MetadataService Milestones *MilestonesService Namespaces *NamespacesService Notes *NotesService @@ -361,6 +362,7 @@ func newClient(options ...ClientOptionFunc) (*Client, error) { c.Markdown = &MarkdownService{client: c} c.MergeRequestApprovals = &MergeRequestApprovalsService{client: c} c.MergeRequests = &MergeRequestsService{client: c, timeStats: timeStats} + c.Metadata = &MetadataService{client: c} c.Milestones = &MilestonesService{client: c} c.Namespaces = &NamespacesService{client: c} c.Notes = &NotesService{client: c} diff --git a/vendor/github.com/xanzy/go-gitlab/groups.go b/vendor/github.com/xanzy/go-gitlab/groups.go index 96a1e3a..2f3de16 100644 --- a/vendor/github.com/xanzy/go-gitlab/groups.go +++ b/vendor/github.com/xanzy/go-gitlab/groups.go @@ -18,10 +18,13 @@ package gitlab import ( "bytes" + "encoding/json" "fmt" "io" "net/http" "time" + + retryablehttp "github.com/hashicorp/go-retryablehttp" ) // GroupsService handles communication with the group related methods of @@ -91,6 +94,15 @@ type GroupAvatar struct { Image io.Reader } +// MarshalJSON implements the json.Marshaler interface. +func (a *GroupAvatar) MarshalJSON() ([]byte, error) { + if a.Filename == "" && a.Image == nil { + return []byte(`""`), nil + } + type alias GroupAvatar + return json.Marshal((*alias)(a)) +} + // LDAPGroupLink represents a GitLab LDAP group link. // // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#ldap-group-links @@ -321,6 +333,7 @@ func (s *GroupsService) DownloadAvatar(gid interface{}, options ...RequestOption type CreateGroupOptions struct { Name *string `url:"name,omitempty" json:"name,omitempty"` Path *string `url:"path,omitempty" json:"path,omitempty"` + Avatar *GroupAvatar `url:"-" json:"-"` Description *string `url:"description,omitempty" json:"description,omitempty"` MembershipLock *bool `url:"membership_lock,omitempty" json:"membership_lock,omitempty"` Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"` @@ -345,7 +358,22 @@ type CreateGroupOptions struct { // // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#new-group func (s *GroupsService) CreateGroup(opt *CreateGroupOptions, options ...RequestOptionFunc) (*Group, *Response, error) { - req, err := s.client.NewRequest(http.MethodPost, "groups", opt, options) + var err error + var req *retryablehttp.Request + + if opt.Avatar == nil { + req, err = s.client.NewRequest(http.MethodPost, "groups", opt, options) + } else { + req, err = s.client.UploadRequest( + http.MethodPost, + "groups", + opt.Avatar.Image, + opt.Avatar.Filename, + UploadAvatar, + opt, + options, + ) + } if err != nil { return nil, nil, err } @@ -429,6 +457,7 @@ func (s *GroupsService) TransferSubGroup(gid interface{}, opt *TransferSubGroupO type UpdateGroupOptions struct { Name *string `url:"name,omitempty" json:"name,omitempty"` Path *string `url:"path,omitempty" json:"path,omitempty"` + Avatar *GroupAvatar `url:"-" json:"avatar,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"` MembershipLock *bool `url:"membership_lock,omitempty" json:"membership_lock,omitempty"` Visibility *VisibilityValue `url:"visibility,omitempty" json:"visibility,omitempty"` @@ -462,7 +491,21 @@ func (s *GroupsService) UpdateGroup(gid interface{}, opt *UpdateGroupOptions, op } u := fmt.Sprintf("groups/%s", PathEscape(group)) - req, err := s.client.NewRequest(http.MethodPut, u, opt, options) + var req *retryablehttp.Request + + if opt.Avatar == nil || (opt.Avatar.Filename == "" && opt.Avatar.Image == nil) { + req, err = s.client.NewRequest(http.MethodPut, u, opt, options) + } else { + req, err = s.client.UploadRequest( + http.MethodPut, + u, + opt.Avatar.Image, + opt.Avatar.Filename, + UploadAvatar, + opt, + options, + ) + } if err != nil { return nil, nil, err } diff --git a/vendor/github.com/xanzy/go-gitlab/metadata.go b/vendor/github.com/xanzy/go-gitlab/metadata.go new file mode 100644 index 0000000..29436fd --- /dev/null +++ b/vendor/github.com/xanzy/go-gitlab/metadata.go @@ -0,0 +1,63 @@ +// +// Copyright 2022, Timo Furrer +// +// 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 gitlab + +import "net/http" + +// MetadataService handles communication with the GitLab server instance to +// retrieve its metadata information via the GitLab API. +// +// GitLab API docs: https://docs.gitlab.com/ce/api/version.md +type MetadataService struct { + client *Client +} + +// Metadata represents a GitLab instance version. +// +// GitLab API docs: https://docs.gitlab.com/ce/api/metadata.md +type Metadata struct { + Version string `json:"version"` + Revision string `json:"revision"` + KAS struct { + Enabled bool `json:"enabled"` + ExternalURL string `json:"externalUrl"` + Version string `json:"version"` + } `json:"kas"` +} + +func (s Metadata) String() string { + return Stringify(s) +} + +// GetMetadata gets a GitLab server instance meteadata. +// +// GitLab API docs: https://docs.gitlab.com/ce/api/metadata.md +func (s *MetadataService) GetMetadata(options ...RequestOptionFunc) (*Metadata, *Response, error) { + req, err := s.client.NewRequest(http.MethodGet, "metadata", nil, options) + if err != nil { + return nil, nil, err + } + + v := new(Metadata) + resp, err := s.client.Do(req, v) + if err != nil { + return nil, resp, err + } + + return v, resp, err +} + diff --git a/vendor/github.com/xanzy/go-gitlab/project_feature_flags.go b/vendor/github.com/xanzy/go-gitlab/project_feature_flags.go index c01a17e..79aaf8b 100644 --- a/vendor/github.com/xanzy/go-gitlab/project_feature_flags.go +++ b/vendor/github.com/xanzy/go-gitlab/project_feature_flags.go @@ -137,6 +137,7 @@ type CreateProjectFeatureFlagOptions struct { // Gitlab API docs: // https://docs.gitlab.com/ee/api/feature_flags.html#create-a-feature-flag type FeatureFlagStrategyOptions struct { + ID *int `url:"id,omitempty" json:"id,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"` Parameters *ProjectFeatureFlagStrategyParameter `url:"parameters,omitempty" json:"parameters,omitempty"` Scopes *[]*ProjectFeatureFlagScope `url:"scopes,omitempty" json:"scopes,omitempty"` diff --git a/vendor/github.com/xanzy/go-gitlab/projects.go b/vendor/github.com/xanzy/go-gitlab/projects.go index 6afc4c6..676a4b7 100644 --- a/vendor/github.com/xanzy/go-gitlab/projects.go +++ b/vendor/github.com/xanzy/go-gitlab/projects.go @@ -17,6 +17,7 @@ package gitlab import ( + "encoding/json" "fmt" "io" "net/http" @@ -120,6 +121,7 @@ type Project struct { SharedWithGroups []struct { GroupID int `json:"group_id"` GroupName string `json:"group_name"` + GroupFullPath string `json:"group_full_path"` GroupAccessLevel int `json:"group_access_level"` } `json:"shared_with_groups"` Statistics *Statistics `json:"statistics"` @@ -710,6 +712,15 @@ type ProjectAvatar struct { Image io.Reader } +// MarshalJSON implements the json.Marshaler interface. +func (a *ProjectAvatar) MarshalJSON() ([]byte, error) { + if a.Filename == "" && a.Image == nil { + return []byte(`""`), nil + } + type alias ProjectAvatar + return json.Marshal((*alias)(a)) +} + // CreateProject creates a new project owned by the authenticated user. // // GitLab API docs: https://docs.gitlab.com/ce/api/projects.html#create-project @@ -811,7 +822,7 @@ type EditProjectOptions struct { AutoDevopsDeployStrategy *string `url:"auto_devops_deploy_strategy,omitempty" json:"auto_devops_deploy_strategy,omitempty"` AutoDevopsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"` AutocloseReferencedIssues *bool `url:"autoclose_referenced_issues,omitempty" json:"autoclose_referenced_issues,omitempty"` - Avatar *ProjectAvatar `url:"-" json:"-"` + Avatar *ProjectAvatar `url:"-" json:"avatar,omitempty"` BuildCoverageRegex *string `url:"build_coverage_regex,omitempty" json:"build_coverage_regex,omitempty"` BuildGitStrategy *string `url:"build_git_strategy,omitempty" json:"build_git_strategy,omitempty"` BuildTimeout *int `url:"build_timeout,omitempty" json:"build_timeout,omitempty"` @@ -901,11 +912,11 @@ func (s *ProjectsService) EditProject(pid interface{}, opt *EditProjectOptions, var req *retryablehttp.Request - if opt.Avatar == nil { + if opt.Avatar == nil || (opt.Avatar.Filename == "" && opt.Avatar.Image == nil) { req, err = s.client.NewRequest(http.MethodPut, u, opt, options) } else { req, err = s.client.UploadRequest( - http.MethodPost, + http.MethodPut, u, opt.Avatar.Image, opt.Avatar.Filename, diff --git a/vendor/github.com/xanzy/go-gitlab/settings.go b/vendor/github.com/xanzy/go-gitlab/settings.go index 6ac05ae..5905307 100644 --- a/vendor/github.com/xanzy/go-gitlab/settings.go +++ b/vendor/github.com/xanzy/go-gitlab/settings.go @@ -64,6 +64,7 @@ type Settings struct { AutoDevOpsDomain string `json:"auto_devops_domain"` AutoDevOpsEnabled bool `json:"auto_devops_enabled"` AutomaticPurchasedStorageAllocation bool `json:"automatic_purchased_storage_allocation"` + CanCreateGroup bool `json:"can_create_group"` CheckNamespacePlan bool `json:"check_namespace_plan"` CommitEmailHostname string `json:"commit_email_hostname"` ContainerExpirationPoliciesEnableHistoricEntries bool `json:"container_expiration_policies_enable_historic_entries"` @@ -431,6 +432,7 @@ type UpdateSettingsOptions struct { AutoDevOpsDomain *string `url:"auto_devops_domain,omitempty" json:"auto_devops_domain,omitempty"` AutoDevOpsEnabled *bool `url:"auto_devops_enabled,omitempty" json:"auto_devops_enabled,omitempty"` AutomaticPurchasedStorageAllocation *bool `url:"automatic_purchased_storage_allocation,omitempty" json:"automatic_purchased_storage_allocation,omitempty"` + CanCreateGroup *bool `url:"can_create_group,omitempty" json:"can_create_group,omitempty"` CheckNamespacePlan *bool `url:"check_namespace_plan,omitempty" json:"check_namespace_plan,omitempty"` CommitEmailHostname *string `url:"commit_email_hostname,omitempty" json:"commit_email_hostname,omitempty"` ContainerExpirationPoliciesEnableHistoricEntries *bool `url:"container_expiration_policies_enable_historic_entries,omitempty" json:"container_expiration_policies_enable_historic_entries,omitempty"` diff --git a/vendor/github.com/xanzy/go-gitlab/users.go b/vendor/github.com/xanzy/go-gitlab/users.go index f04acfb..61973a9 100644 --- a/vendor/github.com/xanzy/go-gitlab/users.go +++ b/vendor/github.com/xanzy/go-gitlab/users.go @@ -745,8 +745,9 @@ func (s *UsersService) DeleteGPGKeyForUser(user, key int, options ...RequestOpti // // GitLab API docs: https://docs.gitlab.com/ce/api/users.html#list-emails type Email struct { - ID int `json:"id"` - Email string `json:"email"` + ID int `json:"id"` + Email string `json:"email"` + ConfirmedAt *time.Time `json:"confirmed_at"` } // ListEmails gets a list of currently authenticated user's Emails. diff --git a/vendor/modules.txt b/vendor/modules.txt index c88322f..b8260e2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -104,7 +104,7 @@ github.com/spf13/viper/internal/encoding/yaml # github.com/subosito/gotenv v1.4.1 ## explicit; go 1.18 github.com/subosito/gotenv -# github.com/xanzy/go-gitlab v0.74.0 +# github.com/xanzy/go-gitlab v0.76.0 ## explicit; go 1.18 github.com/xanzy/go-gitlab # golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa