diff --git a/.mise.toml b/.mise.toml index d794749..c2dd072 100644 --- a/.mise.toml +++ b/.mise.toml @@ -49,4 +49,8 @@ run = "gotestsum" ## <> +[tasks.generate] +description = "Run codegen" +run = ["bun install","go run ./tools/codegen"] + ## <> diff --git a/README.md b/README.md index 3989717..f781906 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,9 @@ tool. The templates used can be found in the `embed` directory in the same CLI directory. +When you bump dependency versions — specifically, the client-go package — be +sure to run `mise generate` to pull in the latest changes to the package. + ## Special Thanks Huge special thanks to the [mockgen] and [ifacemaker] project for making diff --git a/aliases.go b/aliases.go index 2c3ac30..f04e0c6 100644 --- a/aliases.go +++ b/aliases.go @@ -99,6 +99,18 @@ type CreateBroadcastMessageOptions = gitlab.CreateBroadcastMessageOptions // UpdateBroadcastMessageOptions is an alias to [gitlab.UpdateBroadcastMessageOptions] type UpdateBroadcastMessageOptions = gitlab.UpdateBroadcastMessageOptions +// BulkImportStartMigrationConfiguration is an alias to [gitlab.BulkImportStartMigrationConfiguration] +type BulkImportStartMigrationConfiguration = gitlab.BulkImportStartMigrationConfiguration + +// BulkImportStartMigrationEntity is an alias to [gitlab.BulkImportStartMigrationEntity] +type BulkImportStartMigrationEntity = gitlab.BulkImportStartMigrationEntity + +// BulkImportStartMigrationOptions is an alias to [gitlab.BulkImportStartMigrationOptions] +type BulkImportStartMigrationOptions = gitlab.BulkImportStartMigrationOptions + +// BulkImportStartMigrationResponse is an alias to [gitlab.BulkImportStartMigrationResponse] +type BulkImportStartMigrationResponse = gitlab.BulkImportStartMigrationResponse + // CIYMLTemplate is an alias to [gitlab.CIYMLTemplate] type CIYMLTemplate = gitlab.CIYMLTemplate @@ -843,6 +855,9 @@ type CreateServiceAccountOptions = gitlab.CreateServiceAccountOptions // CreateServiceAccountPersonalAccessTokenOptions is an alias to [gitlab.CreateServiceAccountPersonalAccessTokenOptions] type CreateServiceAccountPersonalAccessTokenOptions = gitlab.CreateServiceAccountPersonalAccessTokenOptions +// RotateServiceAccountPersonalAccessTokenOptions is an alias to [gitlab.RotateServiceAccountPersonalAccessTokenOptions] +type RotateServiceAccountPersonalAccessTokenOptions = gitlab.RotateServiceAccountPersonalAccessTokenOptions + // GroupSSHCertificate is an alias to [gitlab.GroupSSHCertificate] type GroupSSHCertificate = gitlab.GroupSSHCertificate diff --git a/bulkimportsservice_inf.go b/bulkimportsservice_inf.go new file mode 100644 index 0000000..9f4697d --- /dev/null +++ b/bulkimportsservice_inf.go @@ -0,0 +1,11 @@ +// Code generated by ifacemaker; DO NOT EDIT. + +package gitlab + +// BulkImportsService is an interface for [gitlab.Client.BulkImports] +type BulkImportsService interface { + // StartMigration starts a migration. + // + // GitLab API docs: https://docs.gitlab.com/ee/api/bulk_imports.html#start-a-new-group-or-project-migration + StartMigration(startMigrationOptions *BulkImportStartMigrationOptions, options ...RequestOptionFunc) (*BulkImportStartMigrationResponse, *Response, error) +} diff --git a/client.go b/client.go index 1bb841c..e3cf2aa 100644 --- a/client.go +++ b/client.go @@ -34,6 +34,7 @@ type client struct { awardEmojiService AwardEmojiService branchesService BranchesService broadcastMessagesService BroadcastMessagesService + bulkImportsService BulkImportsService cIYMLTemplatesService CIYMLTemplatesService clusterAgentsService ClusterAgentsService commitsService CommitsService @@ -195,6 +196,11 @@ func (c *client) BroadcastMessage() BroadcastMessagesService { return c.broadcastMessagesService } +// BulkImports returns the [BulkImportsService] service for the client. +func (c *client) BulkImports() BulkImportsService { + return c.bulkImportsService +} + // CIYMLTemplate returns the [CIYMLTemplatesService] service for the client. func (c *client) CIYMLTemplate() CIYMLTemplatesService { return c.cIYMLTemplatesService @@ -812,6 +818,7 @@ func FromClient(gl *gitlab.Client) Client { awardEmojiService: gl.AwardEmoji, branchesService: gl.Branches, broadcastMessagesService: gl.BroadcastMessage, + bulkImportsService: gl.BulkImports, cIYMLTemplatesService: gl.CIYMLTemplate, clusterAgentsService: gl.ClusterAgents, commitsService: gl.Commits, diff --git a/go.mod b/go.mod index 28fb740..2024a0c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/1password/gitlab go 1.23 require ( - gitlab.com/gitlab-org/api/client-go v0.121.0 + gitlab.com/gitlab-org/api/client-go v0.123.0 go.uber.org/mock v0.5.0 gotest.tools/v3 v3.5.2 ) diff --git a/go.sum b/go.sum index 6363b89..874a6b1 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -gitlab.com/gitlab-org/api/client-go v0.121.0 h1:tivRdXcu5d7sOB2aR2BhQkp16tMmESnfhYPYPZN03eo= -gitlab.com/gitlab-org/api/client-go v0.121.0/go.mod h1:ygHmS3AU3TpvK+AC6DYO1QuAxLlv6yxYK+/Votr/WFQ= +gitlab.com/gitlab-org/api/client-go v0.123.0 h1:W3LZ5QNyiSCJA0Zchkwz8nQIUzOuDoSWMZtRDT5DjPI= +gitlab.com/gitlab-org/api/client-go v0.123.0/go.mod h1:Jh0qjLILEdbO6z/OY94RD+3NDQRUKiuFSFYozN6cpKM= go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= diff --git a/go.work.sum b/go.work.sum index 4baba44..4a4e613 100644 --- a/go.work.sum +++ b/go.work.sum @@ -97,6 +97,8 @@ github.com/xanzy/go-gitlab v0.115.0/go.mod h1:5XCDtM7AM6WMKmfDdOiEpyRWUqui2iS9IL github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +gitlab.com/gitlab-org/api/client-go v0.123.0 h1:W3LZ5QNyiSCJA0Zchkwz8nQIUzOuDoSWMZtRDT5DjPI= +gitlab.com/gitlab-org/api/client-go v0.123.0/go.mod h1:Jh0qjLILEdbO6z/OY94RD+3NDQRUKiuFSFYozN6cpKM= golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= diff --git a/groupsservice_inf.go b/groupsservice_inf.go index 958a9bd..4798cc4 100644 --- a/groupsservice_inf.go +++ b/groupsservice_inf.go @@ -97,7 +97,7 @@ type GroupsService interface { // service account user for a group. // // GitLab API docs: https://docs.gitlab.com/ee/api/groups.html#create-personal-access-token-for-service-account-user - RotateServiceAccountPersonalAccessToken(gid interface{}, serviceAccount, token int, options ...RequestOptionFunc) (*PersonalAccessToken, *Response, error) + RotateServiceAccountPersonalAccessToken(gid interface{}, serviceAccount, token int, opt *RotateServiceAccountPersonalAccessTokenOptions, options ...RequestOptionFunc) (*PersonalAccessToken, *Response, error) // DeleteServiceAccount Deletes a service account user. // // This API endpoint works on top-level groups only. It does not work on subgroups. diff --git a/interface.go b/interface.go index 9176b20..f851766 100644 --- a/interface.go +++ b/interface.go @@ -30,6 +30,7 @@ type Client interface { AwardEmoji() AwardEmojiService Branches() BranchesService BroadcastMessage() BroadcastMessagesService + BulkImports() BulkImportsService CIYMLTemplate() CIYMLTemplatesService ClusterAgents() ClusterAgentsService Commits() CommitsService diff --git a/mock_client.go b/mock_client.go index 8845b08..06d55e1 100644 --- a/mock_client.go +++ b/mock_client.go @@ -39,6 +39,7 @@ type MockClient struct { AwardEmojiServiceM *mocks.MockAwardEmojiService BranchesServiceM *mocks.MockBranchesService BroadcastMessagesServiceM *mocks.MockBroadcastMessagesService + BulkImportsServiceM *mocks.MockBulkImportsService CIYMLTemplatesServiceM *mocks.MockCIYMLTemplatesService ClusterAgentsServiceM *mocks.MockClusterAgentsService CommitsServiceM *mocks.MockCommitsService @@ -173,6 +174,7 @@ func NewMockClient(t *testing.T) *MockClient { AwardEmojiServiceM: mocks.NewMockAwardEmojiService(m), BranchesServiceM: mocks.NewMockBranchesService(m), BroadcastMessagesServiceM: mocks.NewMockBroadcastMessagesService(m), + BulkImportsServiceM: mocks.NewMockBulkImportsService(m), CIYMLTemplatesServiceM: mocks.NewMockCIYMLTemplatesService(m), ClusterAgentsServiceM: mocks.NewMockClusterAgentsService(m), CommitsServiceM: mocks.NewMockCommitsService(m), @@ -335,6 +337,11 @@ func (m *MockClient) BroadcastMessage() BroadcastMessagesService { return m.BroadcastMessagesServiceM } +// BulkImports returns a mocked [BulkImportsService] service. +func (m *MockClient) BulkImports() BulkImportsService { + return m.BulkImportsServiceM +} + // CIYMLTemplate returns a mocked [CIYMLTemplatesService] service. func (m *MockClient) CIYMLTemplate() CIYMLTemplatesService { return m.CIYMLTemplatesServiceM diff --git a/mocks/bulkimportsservice_inf.go b/mocks/bulkimportsservice_inf.go new file mode 100644 index 0000000..97882f5 --- /dev/null +++ b/mocks/bulkimportsservice_inf.go @@ -0,0 +1,62 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: bulkimportsservice_inf.go +// +// Generated by this command: +// +// mockgen -package=mocks -source=bulkimportsservice_inf.go -destination=mocks/bulkimportsservice_inf.go +// + +// Package mocks is a generated GoMock package. +package mocks + +import ( + reflect "reflect" + + gitlab "gitlab.com/gitlab-org/api/client-go" + gomock "go.uber.org/mock/gomock" +) + +// MockBulkImportsService is a mock of BulkImportsService interface. +type MockBulkImportsService struct { + ctrl *gomock.Controller + recorder *MockBulkImportsServiceMockRecorder + isgomock struct{} +} + +// MockBulkImportsServiceMockRecorder is the mock recorder for MockBulkImportsService. +type MockBulkImportsServiceMockRecorder struct { + mock *MockBulkImportsService +} + +// NewMockBulkImportsService creates a new mock instance. +func NewMockBulkImportsService(ctrl *gomock.Controller) *MockBulkImportsService { + mock := &MockBulkImportsService{ctrl: ctrl} + mock.recorder = &MockBulkImportsServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBulkImportsService) EXPECT() *MockBulkImportsServiceMockRecorder { + return m.recorder +} + +// StartMigration mocks base method. +func (m *MockBulkImportsService) StartMigration(startMigrationOptions *gitlab.BulkImportStartMigrationOptions, options ...gitlab.RequestOptionFunc) (*gitlab.BulkImportStartMigrationResponse, *gitlab.Response, error) { + m.ctrl.T.Helper() + varargs := []any{startMigrationOptions} + for _, a := range options { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "StartMigration", varargs...) + ret0, _ := ret[0].(*gitlab.BulkImportStartMigrationResponse) + ret1, _ := ret[1].(*gitlab.Response) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// StartMigration indicates an expected call of StartMigration. +func (mr *MockBulkImportsServiceMockRecorder) StartMigration(startMigrationOptions any, options ...any) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]any{startMigrationOptions}, options...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartMigration", reflect.TypeOf((*MockBulkImportsService)(nil).StartMigration), varargs...) +} diff --git a/mocks/groupsservice_inf.go b/mocks/groupsservice_inf.go index 6fcd06c..f4de212 100644 --- a/mocks/groupsservice_inf.go +++ b/mocks/groupsservice_inf.go @@ -831,9 +831,9 @@ func (mr *MockGroupsServiceMockRecorder) RestoreGroup(gid any, options ...any) * } // RotateServiceAccountPersonalAccessToken mocks base method. -func (m *MockGroupsService) RotateServiceAccountPersonalAccessToken(gid any, serviceAccount, token int, options ...gitlab.RequestOptionFunc) (*gitlab.PersonalAccessToken, *gitlab.Response, error) { +func (m *MockGroupsService) RotateServiceAccountPersonalAccessToken(gid any, serviceAccount, token int, opt *gitlab.RotateServiceAccountPersonalAccessTokenOptions, options ...gitlab.RequestOptionFunc) (*gitlab.PersonalAccessToken, *gitlab.Response, error) { m.ctrl.T.Helper() - varargs := []any{gid, serviceAccount, token} + varargs := []any{gid, serviceAccount, token, opt} for _, a := range options { varargs = append(varargs, a) } @@ -845,9 +845,9 @@ func (m *MockGroupsService) RotateServiceAccountPersonalAccessToken(gid any, ser } // RotateServiceAccountPersonalAccessToken indicates an expected call of RotateServiceAccountPersonalAccessToken. -func (mr *MockGroupsServiceMockRecorder) RotateServiceAccountPersonalAccessToken(gid, serviceAccount, token any, options ...any) *gomock.Call { +func (mr *MockGroupsServiceMockRecorder) RotateServiceAccountPersonalAccessToken(gid, serviceAccount, token, opt any, options ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]any{gid, serviceAccount, token}, options...) + varargs := append([]any{gid, serviceAccount, token, opt}, options...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RotateServiceAccountPersonalAccessToken", reflect.TypeOf((*MockGroupsService)(nil).RotateServiceAccountPersonalAccessToken), varargs...) } diff --git a/usersservice_inf.go b/usersservice_inf.go index 4fd76e9..180e67a 100644 --- a/usersservice_inf.go +++ b/usersservice_inf.go @@ -64,7 +64,7 @@ type UsersService interface { GetUserAssociationsCount(user int, options ...RequestOptionFunc) (*UserAssociationsCount, *Response, error) // ListSSHKeys gets a list of currently authenticated user's SSH keys. // - // GitLab API docs: https://docs.gitlab.com/ee/api/users.html#list-ssh-keys + // GitLab API docs: https://docs.gitlab.com/ee/api/user_keys.html#list-all-ssh-keys ListSSHKeys(opt *ListSSHKeysOptions, options ...RequestOptionFunc) ([]*SSHKey, *Response, error) // ListSSHKeysForUser gets a list of a specified user's SSH keys. //