From a2fd184003fa0375bde6aef5c91315552b98dd0b Mon Sep 17 00:00:00 2001 From: Tobias Germer Date: Mon, 4 Sep 2023 14:01:42 +0200 Subject: [PATCH 1/4] update minimum go version to 1.19; add Ptr function to use generics for allocating pointers deprecate all other functions which were allocating pointers before --- access_requests_test.go | 4 +- applications_test.go | 2 +- avatar_test.go | 2 +- broadcast_messages_test.go | 24 ++--- cluster_agents_test.go | 28 ++--- commits_test.go | 30 +++--- deploy_keys_test.go | 16 +-- deploy_tokens_test.go | 8 +- deployments_merge_requests_test.go | 4 +- environments_test.go | 6 +- epics_test.go | 12 +-- error_tracking_test.go | 4 +- examples/applications.go | 6 +- examples/cluster_agents.go | 2 +- examples/impersonation.go | 2 +- examples/labels.go | 4 +- examples/personal_access_tokens.go | 2 +- examples/pipelines.go | 20 ++-- examples/pipelinestestreport.go | 2 +- examples/projects.go | 18 ++-- examples/repository_files.go | 16 +-- examples/topics.go | 4 +- go.mod | 2 +- group_badges_test.go | 4 +- group_import_export_test.go | 8 +- group_labels_test.go | 14 +-- group_milestones_test.go | 12 +-- group_protected_environments_test.go | 56 +++++----- group_repository_storage_move_test.go | 2 +- group_variables_test.go | 8 +- group_wikis_test.go | 12 +-- groups_test.go | 34 +++---- invites_test.go | 8 +- issues_statistics_test.go | 12 +-- issues_test.go | 40 ++++---- job_token_scope_test.go | 2 +- jobs_test.go | 2 +- labels_test.go | 18 ++-- markdown_test.go | 6 +- merge_request_approvals_test.go | 4 +- merge_requests_test.go | 4 +- merge_trains_test.go | 2 +- milestones_test.go | 8 +- namespaces_test.go | 18 ++-- personal_access_tokens_test.go | 2 +- pipeline_triggers_test.go | 2 +- pipelines_test.go | 6 +- plan_limits_test.go | 6 +- project_managed_licenses_test.go | 6 +- project_repository_storage_move_test.go | 2 +- project_vulnerabilities_test.go | 2 +- projects_test.go | 114 ++++++++++----------- protected_branches_test.go | 12 +-- protected_environments_test.go | 56 +++++----- protected_tags_test.go | 6 +- releaselinks_test.go | 18 ++-- releases_test.go | 46 ++++----- repositories_test.go | 12 +-- repository_files_test.go | 4 +- repository_submodules_test.go | 2 +- resource_weight_events_test.go | 2 +- runners_test.go | 60 +++++------ services_test.go | 72 ++++++------- settings_test.go | 2 +- snippet_repository_storage_move_test.go | 2 +- snippets_test.go | 20 ++-- system_hooks_test.go | 2 +- tags_test.go | 4 +- topics_test.go | 6 +- types.go | 130 +++++++++++------------- users_test.go | 14 +-- validate_test.go | 12 +-- wikis_test.go | 14 +-- 73 files changed, 556 insertions(+), 572 deletions(-) diff --git a/access_requests_test.go b/access_requests_test.go index c809befeb..61ec6bc4e 100644 --- a/access_requests_test.go +++ b/access_requests_test.go @@ -285,7 +285,7 @@ func TestApproveProjectAccessRequest(t *testing.T) { } opt := &ApproveAccessRequestOptions{ - AccessLevel: AccessLevel(DeveloperPermissions), + AccessLevel: Ptr(DeveloperPermissions), } request, resp, err := client.AccessRequests.ApproveProjectAccessRequest(1, 10, opt) @@ -344,7 +344,7 @@ func TestApproveGroupAccessRequest(t *testing.T) { } opt := &ApproveAccessRequestOptions{ - AccessLevel: AccessLevel(DeveloperPermissions), + AccessLevel: Ptr(DeveloperPermissions), } request, resp, err := client.AccessRequests.ApproveGroupAccessRequest(1, 10, opt) diff --git a/applications_test.go b/applications_test.go index 6a5b29262..134f420a4 100644 --- a/applications_test.go +++ b/applications_test.go @@ -38,7 +38,7 @@ func TestCreateApplication(t *testing.T) { ) opt := &CreateApplicationOptions{ - Name: String("testApplication"), + Name: Ptr("testApplication"), } app, _, err := client.Applications.CreateApplication(opt) if err != nil { diff --git a/avatar_test.go b/avatar_test.go index b11f271ca..3e8c90ed2 100644 --- a/avatar_test.go +++ b/avatar_test.go @@ -37,7 +37,7 @@ func TestGetAvatar(t *testing.T) { }, ) - opt := &GetAvatarOptions{Email: String("sander@vanharmelen.nnl")} + opt := &GetAvatarOptions{Email: Ptr("sander@vanharmelen.nnl")} avatar, resp, err := client.Avatar.GetAvatar(opt) if err != nil { t.Fatalf("Avatar.GetAvatar returned error: %v", err) diff --git a/broadcast_messages_test.go b/broadcast_messages_test.go index 1e059a0a3..e55e1c7ea 100644 --- a/broadcast_messages_test.go +++ b/broadcast_messages_test.go @@ -168,15 +168,15 @@ func TestCreateBroadcastMessages(t *testing.T) { }) opt := &CreateBroadcastMessageOptions{ - Message: String("Some Message"), + Message: Ptr("Some Message"), StartsAt: &wantedStartsAt, EndsAt: &wantedEndsAt, - Color: String("#E75E40"), - Font: String("#FFFFFF"), + Color: Ptr("#E75E40"), + Font: Ptr("#FFFFFF"), TargetAccessLevels: []AccessLevelValue{GuestPermissions, DeveloperPermissions}, - TargetPath: String("*/welcome"), - BroadcastType: String("banner"), - Dismissable: Bool(false), + TargetPath: Ptr("*/welcome"), + BroadcastType: Ptr("banner"), + Dismissable: Ptr(false), } got, _, err := client.BroadcastMessage.CreateBroadcastMessage(opt) @@ -227,15 +227,15 @@ func TestUpdateBroadcastMessages(t *testing.T) { }) opt := &UpdateBroadcastMessageOptions{ - Message: String("Some Message Updated"), + Message: Ptr("Some Message Updated"), StartsAt: &wantedStartsAt, EndsAt: &wantedEndsAt, - Color: String("#E75E40"), - Font: String("#FFFFFF"), + Color: Ptr("#E75E40"), + Font: Ptr("#FFFFFF"), TargetAccessLevels: []AccessLevelValue{GuestPermissions, DeveloperPermissions}, - TargetPath: String("*/welcome"), - BroadcastType: String("banner"), - Dismissable: Bool(false), + TargetPath: Ptr("*/welcome"), + BroadcastType: Ptr("banner"), + Dismissable: Ptr(false), } got, _, err := client.BroadcastMessage.UpdateBroadcastMessage(1, opt) diff --git a/cluster_agents_test.go b/cluster_agents_test.go index 391d1dad2..edc3474fc 100644 --- a/cluster_agents_test.go +++ b/cluster_agents_test.go @@ -82,9 +82,9 @@ func ListClusterAgents(t *testing.T) { NameWithNamespace: "Administrator / test", Path: "test", PathWithNamespace: "root/test", - CreatedAt: Time(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), }, - CreatedAt: Time(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), CreatedByUserID: 42, }, { @@ -97,9 +97,9 @@ func ListClusterAgents(t *testing.T) { NameWithNamespace: "Administrator / test", Path: "test", PathWithNamespace: "root/test", - CreatedAt: Time(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), }, - CreatedAt: Time(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), CreatedByUserID: 42, }, } @@ -148,9 +148,9 @@ func GetClusterAgent(t *testing.T) { NameWithNamespace: "Administrator / test", Path: "test", PathWithNamespace: "root/test", - CreatedAt: Time(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), }, - CreatedAt: Time(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), CreatedByUserID: 42, } if !reflect.DeepEqual(want, clusterAgent) { @@ -182,7 +182,7 @@ func RegisterClusterAgent(t *testing.T) { `) }) - opt := &RegisterAgentOptions{Name: String("agent-1")} + opt := &RegisterAgentOptions{Name: Ptr("agent-1")} clusterAgent, _, err := client.ClusterAgents.RegisterAgent(20, opt) if err != nil { t.Errorf("ClusterAgents.RegisterClusterAgent returned error: %v", err) @@ -198,9 +198,9 @@ func RegisterClusterAgent(t *testing.T) { NameWithNamespace: "Administrator / test", Path: "test", PathWithNamespace: "root/test", - CreatedAt: Time(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 20, 20, 42, 40, 221000000, time.UTC)), }, - CreatedAt: Time(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.April, 20, 20, 42, 40, 221000000, time.UTC)), CreatedByUserID: 42, } if !reflect.DeepEqual(want, clusterAgent) { @@ -250,7 +250,7 @@ func ListAgentTokens(t *testing.T) { Description: "Some token", AgentID: 5, Status: "active", - CreatedAt: Time(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), CreatedByUserID: 1, }, { @@ -259,7 +259,7 @@ func ListAgentTokens(t *testing.T) { Description: "", AgentID: 5, Status: "active", - CreatedAt: Time(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), CreatedByUserID: 1, }, } @@ -299,7 +299,7 @@ func GetAgentToken(t *testing.T) { Description: "Some token", AgentID: 5, Status: "active", - CreatedAt: Time(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), CreatedByUserID: 1, LastUsedAt: nil, } @@ -328,7 +328,7 @@ func RegisterAgentToken(t *testing.T) { `) }) - opt := &CreateAgentTokenOptions{Name: String("abcd"), Description: String("Some token")} + opt := &CreateAgentTokenOptions{Name: Ptr("abcd"), Description: Ptr("Some token")} clusterAgentToken, _, err := client.ClusterAgents.CreateAgentToken(20, 5, opt) if err != nil { t.Errorf("ClusterAgents.CreateAgentToken returned error: %v", err) @@ -340,7 +340,7 @@ func RegisterAgentToken(t *testing.T) { Description: "Some token", AgentID: 5, Status: "active", - CreatedAt: Time(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), + CreatedAt: Ptr(time.Date(2022, time.March, 25, 14, 12, 11, 497000000, time.UTC)), CreatedByUserID: 1, LastUsedAt: nil, Token: "qeY8UVRisx9y3Loxo1scLxFuRxYcgeX3sxsdrpP_fR3Loq4xyg", diff --git a/commits_test.go b/commits_test.go index fd00e0c9c..49873340d 100644 --- a/commits_test.go +++ b/commits_test.go @@ -58,7 +58,7 @@ func TestGetCommit(t *testing.T) { Message: "Sanitize for network graph", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, Stats: &CommitStats{Additions: 15, Deletions: 10, Total: 25}, - Status: BuildState(Running), + Status: Ptr(Running), LastPipeline: &PipelineInfo{ ID: 8, Ref: "master", @@ -83,10 +83,10 @@ func TestGetCommitStatuses(t *testing.T) { }) opt := &GetCommitStatusesOptions{ - Ref: String("master"), - Stage: String("test"), - Name: String("ci/jenkins"), - All: Bool(true), + Ref: Ptr("master"), + Stage: Ptr("test"), + Name: Ptr("ci/jenkins"), + All: Ptr(true), } statuses, _, err := client.Commits.GetCommitStatuses("1", "b0b3a907f41409829b307a28b82fdbd552ee5a27", opt) if err != nil { @@ -119,11 +119,11 @@ func TestSetCommitStatus(t *testing.T) { cov := 99.9 opt := &SetCommitStatusOptions{ State: Running, - Ref: String("master"), - Name: String("ci/jenkins"), - Context: String(""), - TargetURL: String("http://abc"), - Description: String("build"), + Ref: Ptr("master"), + Name: Ptr("ci/jenkins"), + Context: Ptr(""), + TargetURL: Ptr("http://abc"), + Description: Ptr("build"), Coverage: &cov, } status, _, err := client.Commits.SetCommitStatus("1", "b0b3a907f41409829b307a28b82fdbd552ee5a27", opt) @@ -163,7 +163,7 @@ func TestRevertCommit_NoOptions(t *testing.T) { Message: "Sanitize for network graph", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, Stats: &CommitStats{Additions: 15, Deletions: 10, Total: 25}, - Status: BuildState(Running), + Status: Ptr(Running), LastPipeline: &PipelineInfo{ ID: 8, Ref: "master", @@ -208,7 +208,7 @@ func TestRevertCommit_WithOptions(t *testing.T) { Message: "Sanitize for network graph", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, Stats: &CommitStats{Additions: 15, Deletions: 10, Total: 25}, - Status: BuildState(Running), + Status: Ptr(Running), LastPipeline: &PipelineInfo{ ID: 8, Ref: "master", @@ -302,7 +302,7 @@ func TestCommitsService_ListCommits(t *testing.T) { Message: "Sanitize for network graph", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, Stats: &CommitStats{Additions: 15, Deletions: 10, Total: 25}, - Status: BuildState(Running), + Status: Ptr(Running), LastPipeline: &PipelineInfo{ ID: 8, Ref: "master", @@ -442,7 +442,7 @@ func TestCommitsService_CreateCommit(t *testing.T) { Message: "Sanitize for network graph", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, Stats: &CommitStats{Additions: 15, Deletions: 10, Total: 25}, - Status: BuildState(Running), + Status: Ptr(Running), LastPipeline: &PipelineInfo{ ID: 8, Ref: "master", @@ -896,7 +896,7 @@ func TestCommitsService_CherryPickCommit(t *testing.T) { Message: "Sanitize for network graph", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, Stats: &CommitStats{Additions: 15, Deletions: 10, Total: 25}, - Status: BuildState(Running), + Status: Ptr(Running), LastPipeline: &PipelineInfo{ ID: 8, Ref: "master", diff --git a/deploy_keys_test.go b/deploy_keys_test.go index 86bba8f37..260ee1ca3 100644 --- a/deploy_keys_test.go +++ b/deploy_keys_test.go @@ -230,9 +230,9 @@ func TestAddDeployKey(t *testing.T) { }) opt := &AddDeployKeyOptions{ - Key: String("ssh-rsa AAAA..."), - Title: String("My deploy key"), - CanPush: Bool(true), + Key: Ptr("ssh-rsa AAAA..."), + Title: Ptr("My deploy key"), + CanPush: Ptr(true), } deployKey, _, err := client.DeployKeys.AddDeployKey(5, opt) if err != nil { @@ -245,9 +245,9 @@ func TestAddDeployKey(t *testing.T) { } want := &ProjectDeployKey{ - Title: *String("My deploy key"), + Title: "My deploy key", ID: 12, - Key: *String("ssh-rsa AAAA..."), + Key: "ssh-rsa AAAA...", CreatedAt: &createdAt, CanPush: true, } @@ -318,8 +318,8 @@ func TestUpdateDeployKey(t *testing.T) { }) opt := &UpdateDeployKeyOptions{ - Title: String("New deploy key"), - CanPush: Bool(true), + Title: Ptr("New deploy key"), + CanPush: Ptr(true), } deployKey, _, err := client.DeployKeys.UpdateDeployKey(5, 11, opt) if err != nil { @@ -333,7 +333,7 @@ func TestUpdateDeployKey(t *testing.T) { want := &ProjectDeployKey{ ID: 11, - Title: *String("New deploy key"), + Title: "New deploy key", Key: "ssh-rsa AAAA...", CreatedAt: &createdAt, CanPush: true, diff --git a/deploy_tokens_test.go b/deploy_tokens_test.go index 01b917b09..8ef4cbd93 100644 --- a/deploy_tokens_test.go +++ b/deploy_tokens_test.go @@ -184,8 +184,8 @@ func TestCreateProjectDeployToken(t *testing.T) { expiresAt := time.Date(2021, 0o1, 0o1, 0, 0, 0, 0, time.UTC) deployToken, _, err := client.DeployTokens.CreateProjectDeployToken(5, &CreateProjectDeployTokenOptions{ - Name: String("My deploy token"), - Username: String("custom-user"), + Name: Ptr("My deploy token"), + Username: Ptr("custom-user"), ExpiresAt: &expiresAt, Scopes: &[]string{ "read_repository", @@ -342,8 +342,8 @@ func TestCreateGroupDeployToken(t *testing.T) { expiresAt := time.Date(2021, 0o1, 0o1, 0, 0, 0, 0, time.UTC) deployToken, _, err := client.DeployTokens.CreateGroupDeployToken(5, &CreateGroupDeployTokenOptions{ - Name: String("My deploy token"), - Username: String("custom-user"), + Name: Ptr("My deploy token"), + Username: Ptr("custom-user"), ExpiresAt: &expiresAt, Scopes: &[]string{ "read_repository", diff --git a/deployments_merge_requests_test.go b/deployments_merge_requests_test.go index eac4173cd..4c892475e 100644 --- a/deployments_merge_requests_test.go +++ b/deployments_merge_requests_test.go @@ -20,8 +20,8 @@ func TestDeploymentMergeRequestsService_ListDeploymentMergeRequests(t *testing.T opts := ListMergeRequestsOptions{ AssigneeID: AssigneeID(UserIDAny), - WithLabelsDetails: Bool(true), - WithMergeStatusRecheck: Bool(true), + WithLabelsDetails: Ptr(true), + WithMergeStatusRecheck: Ptr(true), } mergeRequests, _, err := client.DeploymentMergeRequests.ListDeploymentMergeRequests(278964, 2, &opts) diff --git a/environments_test.go b/environments_test.go index cc43dd05c..bdfb4bf2e 100644 --- a/environments_test.go +++ b/environments_test.go @@ -47,7 +47,7 @@ func TestListEnvironments(t *testing.T) { ]`) }) - envs, _, err := client.Environments.ListEnvironments(1, &ListEnvironmentsOptions{Name: String("review/fix-foo"), ListOptions: ListOptions{Page: 1, PerPage: 10}}) + envs, _, err := client.Environments.ListEnvironments(1, &ListEnvironmentsOptions{Name: Ptr("review/fix-foo"), ListOptions: ListOptions{Page: 1, PerPage: 10}}) if err != nil { log.Fatal(err) } @@ -120,7 +120,7 @@ func TestCreateEnvironment(t *testing.T) { }`) }) - envs, _, err := client.Environments.CreateEnvironment(1, &CreateEnvironmentOptions{Name: String("deploy"), ExternalURL: String("https://deploy.example.gitlab.com"), Tier: String("production")}) + envs, _, err := client.Environments.CreateEnvironment(1, &CreateEnvironmentOptions{Name: Ptr("deploy"), ExternalURL: Ptr("https://deploy.example.gitlab.com"), Tier: Ptr("production")}) if err != nil { log.Fatal(err) } @@ -146,7 +146,7 @@ func TestEditEnvironment(t *testing.T) { }`) }) - envs, _, err := client.Environments.EditEnvironment(1, 1, &EditEnvironmentOptions{Name: String("staging"), ExternalURL: String("https://staging.example.gitlab.com"), Tier: String("staging")}) + envs, _, err := client.Environments.EditEnvironment(1, 1, &EditEnvironmentOptions{Name: Ptr("staging"), ExternalURL: Ptr("https://staging.example.gitlab.com"), Tier: Ptr("staging")}) if err != nil { log.Fatal(err) } diff --git a/epics_test.go b/epics_test.go index a8cabd4ee..06720af07 100644 --- a/epics_test.go +++ b/epics_test.go @@ -72,8 +72,8 @@ func TestListGroupEpics(t *testing.T) { }) listGroupEpics := &ListGroupEpicsOptions{ - AuthorID: Int(26), - State: String("opened"), + AuthorID: Ptr(26), + State: Ptr("opened"), } epics, _, err := client.Epics.ListGroupEpics("7", listGroupEpics) @@ -102,8 +102,8 @@ func TestCreateEpic(t *testing.T) { }) createEpicOptions := &CreateEpicOptions{ - Title: String("Incredible idea"), - Description: String("This is a test epic"), + Title: Ptr("Incredible idea"), + Description: Ptr("This is a test epic"), } epic, _, err := client.Epics.CreateEpic("7", createEpicOptions) @@ -132,8 +132,8 @@ func TestUpdateEpic(t *testing.T) { }) updateEpicOptions := &UpdateEpicOptions{ - Title: String("Incredible idea"), - Description: String("This is a test epic"), + Title: Ptr("Incredible idea"), + Description: Ptr("This is a test epic"), } epic, _, err := client.Epics.UpdateEpic("7", 8, updateEpicOptions) diff --git a/error_tracking_test.go b/error_tracking_test.go index cc2cfa4ed..ccc31ca70 100644 --- a/error_tracking_test.go +++ b/error_tracking_test.go @@ -72,8 +72,8 @@ func TestDisableErrorTracking(t *testing.T) { et, _, err := client.ErrorTracking.EnableDisableErrorTracking( 1, &EnableDisableErrorTrackingOptions{ - Active: Bool(false), - Integrated: Bool(false), + Active: Ptr(false), + Integrated: Ptr(false), }, ) if err != nil { diff --git a/examples/applications.go b/examples/applications.go index c0b68e70a..4fd5371a3 100644 --- a/examples/applications.go +++ b/examples/applications.go @@ -30,9 +30,9 @@ func applicationsExample() { // Create an application opts := &gitlab.CreateApplicationOptions{ - Name: gitlab.String("Travis"), - RedirectURI: gitlab.String("http://example.org"), - Scopes: gitlab.String("api"), + Name: gitlab.Ptr("Travis"), + RedirectURI: gitlab.Ptr("http://example.org"), + Scopes: gitlab.Ptr("api"), } created, _, err := git.Applications.CreateApplication(opts) if err != nil { diff --git a/examples/cluster_agents.go b/examples/cluster_agents.go index 9b4d9252a..70aaf2b78 100644 --- a/examples/cluster_agents.go +++ b/examples/cluster_agents.go @@ -30,7 +30,7 @@ func clusterAgentsExample() { projectID := 33 opt := &gitlab.RegisterAgentOptions{ - Name: gitlab.String("agent-2"), + Name: gitlab.Ptr("agent-2"), } // Register Cluster Agent diff --git a/examples/impersonation.go b/examples/impersonation.go index 8e6ca4bac..ce8dcf0d5 100644 --- a/examples/impersonation.go +++ b/examples/impersonation.go @@ -33,7 +33,7 @@ func impersonationExample() { // list impersonation token from an user tokens, _, err := git.Users.GetAllImpersonationTokens( uid, - &gitlab.GetAllImpersonationTokensOptions{State: gitlab.String("active")}, + &gitlab.GetAllImpersonationTokensOptions{State: gitlab.Ptr("active")}, ) if err != nil { log.Fatal(err) diff --git a/examples/labels.go b/examples/labels.go index bd760620d..fb4206e3d 100644 --- a/examples/labels.go +++ b/examples/labels.go @@ -30,8 +30,8 @@ func labelExample() { // Create new label opt := &gitlab.CreateLabelOptions{ - Name: gitlab.String("My Label"), - Color: gitlab.String("#11FF22"), + Name: gitlab.Ptr("My Label"), + Color: gitlab.Ptr("#11FF22"), } label, _, err := git.Labels.CreateLabel("myname/myproject", opt) if err != nil { diff --git a/examples/personal_access_tokens.go b/examples/personal_access_tokens.go index 9ec21e309..5706ddabf 100644 --- a/examples/personal_access_tokens.go +++ b/examples/personal_access_tokens.go @@ -46,7 +46,7 @@ func patListExampleWithUserFilter() { opt := &gitlab.ListPersonalAccessTokensOptions{ ListOptions: gitlab.ListOptions{Page: 1, PerPage: 10}, - UserID: gitlab.Int(12345), + UserID: gitlab.Ptr(12345), } personalAccessTokens, _, err := git.PersonalAccessTokens.ListPersonalAccessTokens(opt) diff --git a/examples/pipelines.go b/examples/pipelines.go index eaafb49d4..d4b6d968a 100644 --- a/examples/pipelines.go +++ b/examples/pipelines.go @@ -30,16 +30,16 @@ func pipelineExample() { } opt := &gitlab.ListProjectPipelinesOptions{ - Scope: gitlab.String("branches"), - Status: gitlab.BuildState(gitlab.Running), - Ref: gitlab.String("master"), - YamlErrors: gitlab.Bool(true), - Name: gitlab.String("name"), - Username: gitlab.String("username"), - UpdatedAfter: gitlab.Time(time.Now().Add(-24 * 365 * time.Hour)), - UpdatedBefore: gitlab.Time(time.Now().Add(-7 * 24 * time.Hour)), - OrderBy: gitlab.String("status"), - Sort: gitlab.String("asc"), + Scope: gitlab.Ptr("branches"), + Status: gitlab.Ptr(gitlab.Running), + Ref: gitlab.Ptr("master"), + YamlErrors: gitlab.Ptr(true), + Name: gitlab.Ptr("name"), + Username: gitlab.Ptr("username"), + UpdatedAfter: gitlab.Ptr(time.Now().Add(-24 * 365 * time.Hour)), + UpdatedBefore: gitlab.Ptr(time.Now().Add(-7 * 24 * time.Hour)), + OrderBy: gitlab.Ptr("status"), + Sort: gitlab.Ptr("asc"), } pipelines, _, err := git.Pipelines.ListProjectPipelines(2743054, opt) diff --git a/examples/pipelinestestreport.go b/examples/pipelinestestreport.go index 1c7e6c3e1..bdc242781 100644 --- a/examples/pipelinestestreport.go +++ b/examples/pipelinestestreport.go @@ -28,7 +28,7 @@ func pipelineTestReportExample() { log.Fatal(err) } - opt := &gitlab.ListProjectPipelinesOptions{Ref: gitlab.String("master")} + opt := &gitlab.ListProjectPipelinesOptions{Ref: gitlab.Ptr("master")} projectID := 1234 pipelines, _, err := git.Pipelines.ListProjectPipelines(projectID, opt) diff --git a/examples/projects.go b/examples/projects.go index b5a9196c2..2e9e9e672 100644 --- a/examples/projects.go +++ b/examples/projects.go @@ -30,11 +30,11 @@ func projectExample() { // Create new project p := &gitlab.CreateProjectOptions{ - Name: gitlab.String("My Project"), - Description: gitlab.String("Just a test project to play with"), - MergeRequestsEnabled: gitlab.Bool(true), - SnippetsEnabled: gitlab.Bool(true), - Visibility: gitlab.Visibility(gitlab.PublicVisibility), + Name: gitlab.Ptr("My Project"), + Description: gitlab.Ptr("Just a test project to play with"), + MergeRequestsEnabled: gitlab.Ptr(true), + SnippetsEnabled: gitlab.Ptr(true), + Visibility: gitlab.Ptr(gitlab.PublicVisibility), } project, _, err := git.Projects.CreateProject(p) if err != nil { @@ -43,10 +43,10 @@ func projectExample() { // Add a new snippet s := &gitlab.CreateProjectSnippetOptions{ - Title: gitlab.String("Dummy Snippet"), - FileName: gitlab.String("snippet.go"), - Content: gitlab.String("package main...."), - Visibility: gitlab.Visibility(gitlab.PublicVisibility), + Title: gitlab.Ptr("Dummy Snippet"), + FileName: gitlab.Ptr("snippet.go"), + Content: gitlab.Ptr("package main...."), + Visibility: gitlab.Ptr(gitlab.PublicVisibility), } _, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s) if err != nil { diff --git a/examples/repository_files.go b/examples/repository_files.go index de73e9f74..b1a078332 100644 --- a/examples/repository_files.go +++ b/examples/repository_files.go @@ -30,9 +30,9 @@ func repositoryFileExample() { // Create a new repository file cf := &gitlab.CreateFileOptions{ - Branch: gitlab.String("master"), - Content: gitlab.String("My file contents"), - CommitMessage: gitlab.String("Adding a test file"), + Branch: gitlab.Ptr("master"), + Content: gitlab.Ptr("My file contents"), + CommitMessage: gitlab.Ptr("Adding a test file"), } file, _, err := git.RepositoryFiles.CreateFile("myname/myproject", "file.go", cf) if err != nil { @@ -41,9 +41,9 @@ func repositoryFileExample() { // Update a repository file uf := &gitlab.UpdateFileOptions{ - Branch: gitlab.String("master"), - Content: gitlab.String("My file content"), - CommitMessage: gitlab.String("Fixing typo"), + Branch: gitlab.Ptr("master"), + Content: gitlab.Ptr("My file content"), + CommitMessage: gitlab.Ptr("Fixing typo"), } _, _, err = git.RepositoryFiles.UpdateFile("myname/myproject", file.FilePath, uf) if err != nil { @@ -51,7 +51,7 @@ func repositoryFileExample() { } gf := &gitlab.GetFileOptions{ - Ref: gitlab.String("master"), + Ref: gitlab.Ptr("master"), } f, _, err := git.RepositoryFiles.GetFile("myname/myproject", file.FilePath, gf) if err != nil { @@ -61,7 +61,7 @@ func repositoryFileExample() { log.Printf("File contains: %s", f.Content) gfb := &gitlab.GetFileBlameOptions{ - Ref: gitlab.String("master"), + Ref: gitlab.Ptr("master"), } fb, _, err := git.RepositoryFiles.GetFileBlame("myname/myproject", file.FilePath, gfb) if err != nil { diff --git a/examples/topics.go b/examples/topics.go index ffc5c52f8..64e7e078e 100644 --- a/examples/topics.go +++ b/examples/topics.go @@ -31,8 +31,8 @@ func topicExample() { // New topic topic, _, err := git.Topics.CreateTopic(&gitlab.CreateTopicOptions{ - Name: gitlab.String("My Topic 2"), - Description: gitlab.String("Some description"), + Name: gitlab.Ptr("My Topic 2"), + Description: gitlab.Ptr("Some description"), }) if err != nil { panic(err) diff --git a/go.mod b/go.mod index a7fad8df6..26fe69c63 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xanzy/go-gitlab -go 1.18 +go 1.19 require ( github.com/google/go-querystring v1.1.0 diff --git a/group_badges_test.go b/group_badges_test.go index 5c9e13785..aaae30e10 100644 --- a/group_badges_test.go +++ b/group_badges_test.go @@ -72,7 +72,7 @@ func TestAddGroupBadge(t *testing.T) { fmt.Fprint(w, `{"id":3, "name":"three", "link_url":"LINK", "image_url":"IMAGE", "kind":"group"}`) }) - opt := &AddGroupBadgeOptions{ImageURL: String("IMAGE"), LinkURL: String("LINK")} + opt := &AddGroupBadgeOptions{ImageURL: Ptr("IMAGE"), LinkURL: Ptr("LINK")} badge, _, err := client.GroupBadges.AddGroupBadge(1, opt) if err != nil { t.Errorf("GroupBadges.AddGroupBadge returned error: %v", err) @@ -93,7 +93,7 @@ func TestEditGroupBadge(t *testing.T) { fmt.Fprint(w, `{"id":2, "name":"two", "link_url":"NEW_LINK", "image_url":"NEW_IMAGE", "kind":"group"}`) }) - opt := &EditGroupBadgeOptions{ImageURL: String("NEW_IMAGE"), LinkURL: String("NEW_LINK")} + opt := &EditGroupBadgeOptions{ImageURL: Ptr("NEW_IMAGE"), LinkURL: Ptr("NEW_LINK")} badge, _, err := client.GroupBadges.EditGroupBadge(1, 2, opt) if err != nil { t.Errorf("GroupBadges.EditGroupBadge returned error: %v", err) diff --git a/group_import_export_test.go b/group_import_export_test.go index 98c049487..3e3efb171 100644 --- a/group_import_export_test.go +++ b/group_import_export_test.go @@ -76,10 +76,10 @@ func TestGroupImport(t *testing.T) { }) opt := &GroupImportFileOptions{ - Name: String("test"), - Path: String("path"), - File: String(tmpfile.Name()), - ParentID: Int(1), + Name: Ptr("test"), + Path: Ptr("path"), + File: Ptr(tmpfile.Name()), + ParentID: Ptr(1), } _, err = client.GroupImportExport.ImportFile(opt) diff --git a/group_labels_test.go b/group_labels_test.go index d1c91d81c..c79ab7824 100644 --- a/group_labels_test.go +++ b/group_labels_test.go @@ -33,8 +33,8 @@ func TestCreateGroupGroupLabel(t *testing.T) { }) l := &CreateGroupLabelOptions{ - Name: String("My / GroupLabel"), - Color: String("#11FF22"), + Name: Ptr("My / GroupLabel"), + Color: Ptr("#11FF22"), } label, _, err := client.GroupLabels.CreateGroupLabel("1", l) if err != nil { @@ -54,7 +54,7 @@ func TestDeleteGroupLabel(t *testing.T) { }) label := &DeleteGroupLabelOptions{ - Name: String("My / GroupLabel"), + Name: Ptr("My / GroupLabel"), } _, err := client.GroupLabels.DeleteGroupLabel("1", label) @@ -72,10 +72,10 @@ func TestUpdateGroupLabel(t *testing.T) { }) l := &UpdateGroupLabelOptions{ - Name: String("My / GroupLabel"), - NewName: String("New / GroupLabel"), - Color: String("#11FF23"), - Description: String("This is updated label"), + Name: Ptr("My / GroupLabel"), + NewName: Ptr("New / GroupLabel"), + Color: Ptr("#11FF23"), + Description: Ptr("This is updated label"), } label, resp, err := client.GroupLabels.UpdateGroupLabel("1", l) diff --git a/group_milestones_test.go b/group_milestones_test.go index b5fee3a79..c16b5bfba 100644 --- a/group_milestones_test.go +++ b/group_milestones_test.go @@ -36,7 +36,7 @@ func TestGroupMilestonesService_ListGroupMilestones(t *testing.T) { Title: "10.0", Description: "Version", State: "active", - Expired: Bool(false), + Expired: Ptr(false), }} gms, resp, err := client.GroupMilestones.ListGroupMilestones(5, nil, nil) @@ -86,7 +86,7 @@ func TestGroupMilestonesService_GetGroupMilestone(t *testing.T) { Title: "10.0", Description: "Version", State: "active", - Expired: Bool(false), + Expired: Ptr(false), } gm, resp, err := client.GroupMilestones.GetGroupMilestone(5, 12, nil, nil) @@ -136,7 +136,7 @@ func TestGroupMilestonesService_CreateGroupMilestone(t *testing.T) { Title: "10.0", Description: "Version", State: "active", - Expired: Bool(false), + Expired: Ptr(false), } gm, resp, err := client.GroupMilestones.CreateGroupMilestone(5, nil, nil) @@ -186,7 +186,7 @@ func TestGroupMilestonesService_UpdateGroupMilestone(t *testing.T) { Title: "10.0", Description: "Version", State: "active", - Expired: Bool(false), + Expired: Ptr(false), } gm, resp, err := client.GroupMilestones.UpdateGroupMilestone(5, 12, nil, nil) @@ -561,8 +561,8 @@ func TestGroupMilestonesService_GetGroupMilestoneBurndownChartEvents(t *testing. }) want := []*BurndownChartEvent{{ - Weight: Int(10), - Action: String("update"), + Weight: Ptr(10), + Action: Ptr("update"), }} bces, resp, err := client.GroupMilestones.GetGroupMilestoneBurndownChartEvents(3, 12, nil, nil) diff --git a/group_protected_environments_test.go b/group_protected_environments_test.go index b8ede66f6..2866e524c 100644 --- a/group_protected_environments_test.go +++ b/group_protected_environments_test.go @@ -249,16 +249,16 @@ func TestGroupProtectEnvironments(t *testing.T) { } opt := &ProtectGroupEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*GroupEnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, - RequiredApprovalCount: Int(2), + RequiredApprovalCount: Ptr(2), ApprovalRules: &[]*GroupEnvironmentApprovalRuleOptions{ { - GroupID: Int(10), - AccessLevel: AccessLevel(0), - AccessLevelDescription: String("devops"), + GroupID: Ptr(10), + AccessLevel: Ptr(AccessLevelValue(0)), + AccessLevelDescription: Ptr("devops"), }, }, } @@ -294,9 +294,9 @@ func TestGroupProtectEnvironments(t *testing.T) { } opt = &ProtectGroupEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*GroupEnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, } environment, _, err = client.GroupProtectedEnvironments.ProtectGroupEnvironment(2, opt) @@ -357,16 +357,16 @@ func TestGroupUpdateProtectedEnvironments(t *testing.T) { } opt := &UpdateGroupProtectedEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*UpdateGroupEnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, - RequiredApprovalCount: Int(2), + RequiredApprovalCount: Ptr(2), ApprovalRules: &[]*UpdateGroupEnvironmentApprovalRuleOptions{ { - GroupID: Int(10), - AccessLevel: AccessLevel(0), - AccessLevelDescription: String("devops"), + GroupID: Ptr(10), + AccessLevel: Ptr(AccessLevelValue(0)), + AccessLevelDescription: Ptr("devops"), }, }, } @@ -402,9 +402,9 @@ func TestGroupUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateGroupProtectedEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*UpdateGroupEnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, } environment, _, err = client.GroupProtectedEnvironments.UpdateGroupProtectedEnvironment(2, environmentName, opt) @@ -440,11 +440,11 @@ func TestGroupUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateGroupProtectedEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*UpdateGroupEnvironmentAccessOptions{ { - ID: Int(42), - AccessLevel: AccessLevel(30), + ID: Ptr(42), + AccessLevel: Ptr(AccessLevelValue(30)), }, }, } @@ -500,13 +500,13 @@ func TestGroupUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateGroupProtectedEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), ApprovalRules: &[]*UpdateGroupEnvironmentApprovalRuleOptions{ { - ID: Int(1), - GroupID: Int(10), - AccessLevel: AccessLevel(0), - AccessLevelDescription: String("devops"), + ID: Ptr(1), + GroupID: Ptr(10), + AccessLevel: Ptr(AccessLevelValue(0)), + AccessLevelDescription: Ptr("devops"), }, }, } @@ -546,14 +546,14 @@ func TestGroupUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateGroupProtectedEnvironmentOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), ApprovalRules: &[]*UpdateGroupEnvironmentApprovalRuleOptions{ { - ID: Int(1), - Destroy: Bool(true), + ID: Ptr(1), + Destroy: Ptr(true), }, }, - RequiredApprovalCount: Int(0), + RequiredApprovalCount: Ptr(0), } environment, _, err = client.GroupProtectedEnvironments.UpdateGroupProtectedEnvironment(5, environmentName, opt) diff --git a/group_repository_storage_move_test.go b/group_repository_storage_move_test.go index 36fe7aee3..fe4d7bc92 100644 --- a/group_repository_storage_move_test.go +++ b/group_repository_storage_move_test.go @@ -222,7 +222,7 @@ func TestGroupRepositoryStorageMove_ScheduleAllStorageMoves(t *testing.T) { _, err := client.GroupRepositoryStorageMove.ScheduleAllStorageMoves( ScheduleAllGroupStorageMovesOptions{ - SourceStorageName: String("default"), + SourceStorageName: Ptr("default"), }, ) require.NoError(t, err) diff --git a/group_variables_test.go b/group_variables_test.go index e4fc5cd30..d0b0e2025 100644 --- a/group_variables_test.go +++ b/group_variables_test.go @@ -81,10 +81,10 @@ func TestCreateGroupVariable(t *testing.T) { }) opt := &CreateGroupVariableOptions{ - Key: String("TEST_VARIABLE_1"), - Value: String("test1"), - Protected: Bool(false), - Masked: Bool(true), + Key: Ptr("TEST_VARIABLE_1"), + Value: Ptr("test1"), + Protected: Ptr(false), + Masked: Ptr(true), } variable, _, err := client.GroupVariables.CreateVariable(1, opt, nil) diff --git a/group_wikis_test.go b/group_wikis_test.go index 9aee99521..e0badd30b 100644 --- a/group_wikis_test.go +++ b/group_wikis_test.go @@ -88,9 +88,9 @@ func TestCreateGroupWikiPage(t *testing.T) { }) groupwiki, _, err := client.GroupWikis.CreateGroupWikiPage(1, &CreateGroupWikiPageOptions{ - Content: String("content here"), - Title: String("deploy title"), - Format: WikiFormat(WikiFormatRDoc), + Content: Ptr("content here"), + Title: Ptr("deploy title"), + Format: Ptr(WikiFormatRDoc), }) if err != nil { t.Errorf("GroupWikis.CreateGroupWikiPage returned error: %v", err) @@ -122,9 +122,9 @@ func TestEditGroupWikiPage(t *testing.T) { }) groupwiki, _, err := client.GroupWikis.EditGroupWikiPage(1, "deploy", &EditGroupWikiPageOptions{ - Content: String("content here"), - Title: String("deploy title"), - Format: WikiFormat(WikiFormatRDoc), + Content: Ptr("content here"), + Title: Ptr("deploy title"), + Format: Ptr(WikiFormatRDoc), }) if err != nil { t.Errorf("GroupWikis.EditGroupWikiPage returned error: %v", err) diff --git a/groups_test.go b/groups_test.go index a6818ef2c..b6f8e0499 100644 --- a/groups_test.go +++ b/groups_test.go @@ -77,8 +77,8 @@ func TestCreateGroup(t *testing.T) { }) opt := &CreateGroupOptions{ - Name: String("g"), - Path: String("g"), + Name: Ptr("g"), + Path: Ptr("g"), } group, _, err := client.Groups.CreateGroup(opt, nil) @@ -122,7 +122,7 @@ func TestTransferSubGroup(t *testing.T) { }) opt := &TransferSubGroupOptions{ - GroupID: Int(2), + GroupID: Ptr(2), } group, _, err := client.Groups.TransferSubGroup(1, opt) @@ -295,9 +295,9 @@ func TestAddGroupLDAPLink(t *testing.T) { }) opt := &AddGroupLDAPLinkOptions{ - CN: String("gitlab_group_example_30"), - GroupAccess: AccessLevel(30), - Provider: String("example_ldap_provider"), + CN: Ptr("gitlab_group_example_30"), + GroupAccess: Ptr(AccessLevelValue(30)), + Provider: Ptr("example_ldap_provider"), } link, _, err := client.Groups.AddGroupLDAPLink(1, opt) @@ -330,9 +330,9 @@ func TestAddGroupLDAPLinkFilter(t *testing.T) { }) opt := &AddGroupLDAPLinkOptions{ - Filter: String("(memberOf=example_group_dn)"), - GroupAccess: AccessLevel(30), - Provider: String("example_ldap_provider"), + Filter: Ptr("(memberOf=example_group_dn)"), + GroupAccess: Ptr(AccessLevelValue(30)), + Provider: Ptr("example_ldap_provider"), } link, _, err := client.Groups.AddGroupLDAPLink(1, opt) @@ -429,8 +429,8 @@ func TestAddGroupSAMLLink(t *testing.T) { }) opt := &AddGroupSAMLLinkOptions{ - SAMLGroupName: String("gitlab_group_example_developer"), - AccessLevel: AccessLevel(DeveloperPermissions), + SAMLGroupName: Ptr("gitlab_group_example_developer"), + AccessLevel: Ptr(DeveloperPermissions), } link, _, err := client.Groups.AddGroupSAMLLink(1, opt) @@ -474,8 +474,8 @@ func TestShareGroupWithGroup(t *testing.T) { }) group, _, err := client.Groups.ShareGroupWithGroup(1, &ShareGroupWithGroupOptions{ - GroupID: Int(1), - GroupAccess: AccessLevel(DeveloperPermissions), + GroupID: Ptr(1), + GroupAccess: Ptr(DeveloperPermissions), }) if err != nil { t.Errorf("Groups.ShareGroupWithGroup returned error: %v", err) @@ -513,9 +513,9 @@ func TestCreateGroupWithIPRestrictionRanges(t *testing.T) { }) opt := &CreateGroupOptions{ - Name: String("g"), - Path: String("g"), - IPRestrictionRanges: String("192.168.0.0/24"), + Name: Ptr("g"), + Path: Ptr("g"), + IPRestrictionRanges: Ptr("192.168.0.0/24"), } group, _, err := client.Groups.CreateGroup(opt, nil) @@ -539,7 +539,7 @@ func TestUpdateGroupWithIPRestrictionRanges(t *testing.T) { }) group, _, err := client.Groups.UpdateGroup(1, &UpdateGroupOptions{ - IPRestrictionRanges: String("192.168.0.0/24"), + IPRestrictionRanges: Ptr("192.168.0.0/24"), }) if err != nil { t.Errorf("Groups.UpdateGroup returned error: %v", err) diff --git a/invites_test.go b/invites_test.go index d3178a274..e211c28b5 100644 --- a/invites_test.go +++ b/invites_test.go @@ -39,7 +39,7 @@ func TestGroupInvites(t *testing.T) { }) opt := &InvitesOptions{ - Email: String("example@member.org"), + Email: Ptr("example@member.org"), } projects, _, err := client.Invites.GroupInvites("test", opt) @@ -62,7 +62,7 @@ func TestGroupInvitesError(t *testing.T) { }) opt := &InvitesOptions{ - Email: String("example@member.org"), + Email: Ptr("example@member.org"), } projects, _, err := client.Invites.GroupInvites("test", opt) @@ -108,7 +108,7 @@ func TestProjectInvites(t *testing.T) { }) opt := &InvitesOptions{ - Email: String("example@member.org"), + Email: Ptr("example@member.org"), } projects, _, err := client.Invites.ProjectInvites("test", opt) @@ -131,7 +131,7 @@ func TestProjectInvitesError(t *testing.T) { }) opt := &InvitesOptions{ - Email: String("example@member.org"), + Email: Ptr("example@member.org"), } projects, _, err := client.Invites.ProjectInvites("test", opt) diff --git a/issues_statistics_test.go b/issues_statistics_test.go index 42de5a28c..6021bc6c7 100644 --- a/issues_statistics_test.go +++ b/issues_statistics_test.go @@ -34,8 +34,8 @@ func TestGetIssuesStatistics(t *testing.T) { }) opt := &GetIssuesStatisticsOptions{ - AssigneeID: Int(1), - AuthorID: Int(1), + AssigneeID: Ptr(1), + AuthorID: Ptr(1), } issue, _, err := client.IssuesStatistics.GetIssuesStatistics(opt) @@ -76,8 +76,8 @@ func TestGetGroupIssuesStatistics(t *testing.T) { }) opt := &GetGroupIssuesStatisticsOptions{ - AssigneeID: Int(1), - AuthorID: Int(1), + AssigneeID: Ptr(1), + AuthorID: Ptr(1), } issue, _, err := client.IssuesStatistics.GetGroupIssuesStatistics(1, opt) @@ -118,8 +118,8 @@ func TestGetProjectIssuesStatistics(t *testing.T) { }) opt := &GetProjectIssuesStatisticsOptions{ - AssigneeID: Int(1), - AuthorID: Int(1), + AssigneeID: Ptr(1), + AuthorID: Ptr(1), } issue, _, err := client.IssuesStatistics.GetProjectIssuesStatistics(1, opt) diff --git a/issues_test.go b/issues_test.go index 16f52c6a5..22a303835 100644 --- a/issues_test.go +++ b/issues_test.go @@ -100,7 +100,7 @@ func TestMoveIssue(t *testing.T) { mustWriteHTTPResponse(t, w, "testdata/issue_move.json") }) - issue, _, err := client.Issues.MoveIssue("1", 11, &MoveIssueOptions{ToProjectID: Int(5)}) + issue, _, err := client.Issues.MoveIssue("1", 11, &MoveIssueOptions{ToProjectID: Ptr(5)}) if err != nil { log.Fatal(err) } @@ -173,7 +173,7 @@ func TestListIssues(t *testing.T) { }) listProjectIssue := &ListIssuesOptions{ - AuthorID: Int(0o1), + AuthorID: Ptr(0o1), AssigneeID: AssigneeID(0o2), } @@ -239,7 +239,7 @@ func TestListIssuesWithLabelDetails(t *testing.T) { }) listProjectIssue := &ListIssuesOptions{ - AuthorID: Int(0o1), + AuthorID: Ptr(0o1), AssigneeID: AssigneeID(0o2), } @@ -283,8 +283,8 @@ func TestListIssuesSearchInTitle(t *testing.T) { }) listProjectIssue := &ListIssuesOptions{ - Search: String("Title"), - In: String("title"), + Search: Ptr("Title"), + In: Ptr("title"), } issues, _, err := client.Issues.ListIssues(listProjectIssue) @@ -321,8 +321,8 @@ func TestListIssuesSearchInDescription(t *testing.T) { }) listProjectIssue := &ListIssuesOptions{ - Search: String("description"), - In: String("description"), + Search: Ptr("description"), + In: Ptr("description"), } issues, _, err := client.Issues.ListIssues(listProjectIssue) @@ -367,7 +367,7 @@ func TestListIssuesSearchByIterationID(t *testing.T) { }) listProjectIssue := &ListIssuesOptions{ - IterationID: Int(90), + IterationID: Ptr(90), } issues, _, err := client.Issues.ListIssues(listProjectIssue) @@ -404,7 +404,7 @@ func TestListProjectIssues(t *testing.T) { }) listProjectIssue := &ListProjectIssuesOptions{ - AuthorID: Int(0o1), + AuthorID: Ptr(0o1), AssigneeID: AssigneeID(0o2), } issues, _, err := client.Issues.ListProjectIssues("1", listProjectIssue) @@ -450,7 +450,7 @@ func TestListProjectIssuesSearchByIterationID(t *testing.T) { }) listProjectIssue := &ListProjectIssuesOptions{ - IterationID: Int(90), + IterationID: Ptr(90), } issues, _, err := client.Issues.ListProjectIssues(1, listProjectIssue) @@ -487,8 +487,8 @@ func TestListGroupIssues(t *testing.T) { }) listGroupIssue := &ListGroupIssuesOptions{ - State: String("Open"), - AuthorID: Int(0o1), + State: Ptr("Open"), + AuthorID: Ptr(0o1), AssigneeID: AssigneeID(0o2), } @@ -535,7 +535,7 @@ func TestListGroupIssuesSearchByIterationID(t *testing.T) { }) listProjectIssue := &ListGroupIssuesOptions{ - IterationID: Int(90), + IterationID: Ptr(90), } issues, _, err := client.Issues.ListGroupIssues(1, listProjectIssue) @@ -571,8 +571,8 @@ func TestCreateIssue(t *testing.T) { }) createIssueOptions := &CreateIssueOptions{ - Title: String("Title of issue"), - Description: String("This is description of an issue"), + Title: Ptr("Title of issue"), + Description: Ptr("This is description of an issue"), } issue, _, err := client.Issues.CreateIssue("1", createIssueOptions) @@ -602,8 +602,8 @@ func TestUpdateIssue(t *testing.T) { }) updateIssueOpt := &UpdateIssueOptions{ - Title: String("Title of issue"), - Description: String("This is description of an issue"), + Title: Ptr("Title of issue"), + Description: Ptr("This is description of an issue"), } issue, _, err := client.Issues.UpdateIssue(1, 5, updateIssueOpt) if err != nil { @@ -736,7 +736,7 @@ func TestSetTimeEstimate(t *testing.T) { }) setTimeEstiOpt := &SetTimeEstimateOptions{ - Duration: String("3h 30m"), + Duration: Ptr("3h 30m"), } timeState, _, err := client.Issues.SetTimeEstimate("1", 5, setTimeEstiOpt) @@ -779,8 +779,8 @@ func TestAddSpentTime(t *testing.T) { fmt.Fprint(w, `{"human_time_estimate": null, "human_total_time_spent": "1h", "time_estimate": 0, "total_time_spent": 3600}`) }) addSpentTimeOpt := &AddSpentTimeOptions{ - Duration: String("1h"), - Summary: String("test"), + Duration: Ptr("1h"), + Summary: Ptr("test"), } timeState, _, err := client.Issues.AddSpentTime("1", 5, addSpentTimeOpt) diff --git a/job_token_scope_test.go b/job_token_scope_test.go index 0e33f73e9..4300f21cd 100644 --- a/job_token_scope_test.go +++ b/job_token_scope_test.go @@ -142,7 +142,7 @@ func TestAddProjectToJobScopeAllowList(t *testing.T) { addTokenResponse, resp, err := client.JobTokenScope.AddProjectToJobScopeAllowList( 1, - &JobTokenInboundAllowOptions{TargetProjectID: Int(2)}, + &JobTokenInboundAllowOptions{TargetProjectID: Ptr(2)}, ) assert.NoError(t, err) assert.Equal(t, want, addTokenResponse) diff --git a/jobs_test.go b/jobs_test.go index 0bdeb6bf2..5c65d410e 100644 --- a/jobs_test.go +++ b/jobs_test.go @@ -199,7 +199,7 @@ func TestDownloadSingleArtifactsFileByTagOrBranch(t *testing.T) { w.Write(wantContent) }) - opt := &DownloadArtifactsFileOptions{Job: String("publish")} + opt := &DownloadArtifactsFileOptions{Job: Ptr("publish")} reader, resp, err := client.Jobs.DownloadSingleArtifactsFileByTagOrBranch(9, "abranch", "foo/bar.pdf", opt) if err != nil { t.Fatalf("Jobs.DownloadSingleArtifactsFileByTagOrBranch returns an error: %v", err) diff --git a/labels_test.go b/labels_test.go index 967e32fad..3abfe3aa4 100644 --- a/labels_test.go +++ b/labels_test.go @@ -34,9 +34,9 @@ func TestCreateLabel(t *testing.T) { // Create new label l := &CreateLabelOptions{ - Name: String("My Label"), - Color: String("#11FF22"), - Priority: Int(2), + Name: Ptr("My Label"), + Color: Ptr("#11FF22"), + Priority: Ptr(2), } label, _, err := client.Labels.CreateLabel("1", l) if err != nil { @@ -57,7 +57,7 @@ func TestDeleteLabel(t *testing.T) { // Delete label label := &DeleteLabelOptions{ - Name: String("My Label"), + Name: Ptr("My Label"), } _, err := client.Labels.DeleteLabel("1", label) @@ -76,11 +76,11 @@ func TestUpdateLabel(t *testing.T) { // Update label l := &UpdateLabelOptions{ - Name: String("My Label"), - NewName: String("New Label"), - Color: String("#11FF23"), - Description: String("This is updated label"), - Priority: Int(42), + Name: Ptr("My Label"), + NewName: Ptr("New Label"), + Color: Ptr("#11FF23"), + Description: Ptr("This is updated label"), + Priority: Ptr(42), } label, resp, err := client.Labels.UpdateLabel("1", l) diff --git a/markdown_test.go b/markdown_test.go index 5a4aad4dc..96eaa2de5 100644 --- a/markdown_test.go +++ b/markdown_test.go @@ -20,9 +20,9 @@ func TestRender(t *testing.T) { }) opt := &RenderOptions{ - Text: String("# Testing"), - GitlabFlavouredMarkdown: Bool(true), - Project: String("some/sub/group/project"), + Text: Ptr("# Testing"), + GitlabFlavouredMarkdown: Ptr(true), + Project: Ptr("some/sub/group/project"), } markdown, resp, err := client.Markdown.Render(opt) if err != nil { diff --git a/merge_request_approvals_test.go b/merge_request_approvals_test.go index 619f538d8..71132dd3b 100644 --- a/merge_request_approvals_test.go +++ b/merge_request_approvals_test.go @@ -367,8 +367,8 @@ func TestCreateApprovalRules(t *testing.T) { }) opt := &CreateMergeRequestApprovalRuleOptions{ - Name: String("security"), - ApprovalsRequired: Int(3), + Name: Ptr("security"), + ApprovalsRequired: Ptr(3), UserIDs: &[]int{5, 50}, GroupIDs: &[]int{5}, } diff --git a/merge_requests_test.go b/merge_requests_test.go index cfee8161f..8a7b191f7 100644 --- a/merge_requests_test.go +++ b/merge_requests_test.go @@ -159,8 +159,8 @@ func TestListProjectMergeRequests(t *testing.T) { opts := ListProjectMergeRequestsOptions{ AssigneeID: AssigneeID(UserIDAny), - WithLabelsDetails: Bool(true), - WithMergeStatusRecheck: Bool(true), + WithLabelsDetails: Ptr(true), + WithMergeStatusRecheck: Ptr(true), } mergeRequests, _, err := client.MergeRequests.ListProjectMergeRequests(278964, &opts) diff --git a/merge_trains_test.go b/merge_trains_test.go index fe4d9972c..101ca239b 100644 --- a/merge_trains_test.go +++ b/merge_trains_test.go @@ -225,7 +225,7 @@ func TestAddMergeRequestToMergeTrain(t *testing.T) { mustWriteHTTPResponse(t, w, "testdata/add_merge_request_in_merge_train.json") }) - opt := &AddMergeRequestToMergeTrainOptions{WhenPipelineSucceeds: Bool(true), Squash: Bool(true)} + opt := &AddMergeRequestToMergeTrainOptions{WhenPipelineSucceeds: Ptr(true), Squash: Ptr(true)} mergeTrains, _, err := client.MergeTrains.AddMergeRequestToMergeTrain(597, 1, opt) if err != nil { diff --git a/milestones_test.go b/milestones_test.go index 33dbf3406..24c6cf7c6 100644 --- a/milestones_test.go +++ b/milestones_test.go @@ -36,7 +36,7 @@ func TestMilestonesService_ListMilestones(t *testing.T) { Description: "Version", State: "active", WebURL: "", - Expired: Bool(false), + Expired: Ptr(false), }} ms, resp, err := client.Milestones.ListMilestones(5, nil) @@ -86,7 +86,7 @@ func TestMilestonesService_GetMilestone(t *testing.T) { Description: "Version", State: "active", WebURL: "", - Expired: Bool(false), + Expired: Ptr(false), } m, resp, err := client.Milestones.GetMilestone(5, 12, nil) @@ -136,7 +136,7 @@ func TestMilestonesService_CreateMilestone(t *testing.T) { Description: "Version", State: "active", WebURL: "", - Expired: Bool(false), + Expired: Ptr(false), } m, resp, err := client.Milestones.CreateMilestone(5, nil) @@ -186,7 +186,7 @@ func TestMilestonesService_UpdateMilestone(t *testing.T) { Description: "Version", State: "active", WebURL: "", - Expired: Bool(false), + Expired: Ptr(false), } m, resp, err := client.Milestones.UpdateMilestone(5, 12, nil) diff --git a/namespaces_test.go b/namespaces_test.go index c12df3ea0..b11ff3295 100644 --- a/namespaces_test.go +++ b/namespaces_test.go @@ -95,8 +95,8 @@ func TestListNamespaces(t *testing.T) { ownedOnly *bool }{ {"with_nothing", nil, nil}, - {"with_search", String("foobar"), nil}, - {"with_owned_only", nil, Bool(false)}, + {"with_search", Ptr("foobar"), nil}, + {"with_owned_only", nil, Ptr(false)}, } for _, tc := range testCases { @@ -113,7 +113,7 @@ func TestListNamespaces(t *testing.T) { Path: "user1", Kind: "user", FullPath: "user1", - AvatarURL: String("https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"), + AvatarURL: Ptr("https://secure.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon"), WebURL: "https://gitlab.example.com/user1", Plan: "default", BillableMembersCount: 1, @@ -155,7 +155,7 @@ func TestListNamespaces(t *testing.T) { Path: "group2", Kind: "group", FullPath: "group2", - AvatarURL: String("https://gitlab.example.com/groups/group2"), + AvatarURL: Ptr("https://gitlab.example.com/groups/group2"), WebURL: "https://gitlab.example.com/group2", Plan: "default", BillableMembersCount: 1, @@ -209,8 +209,8 @@ func TestGetNamespace(t *testing.T) { WebURL: "https://gitlab.example.com/groups/group1", MembersCountWithDescendants: 2, BillableMembersCount: 2, - MaxSeatsUsed: Int(0), - SeatsInUse: Int(0), + MaxSeatsUsed: Ptr(0), + SeatsInUse: Ptr(0), Plan: "default", TrialEndsOn: nil, Trial: false, @@ -235,7 +235,7 @@ func TestNamespaceExists(t *testing.T) { }) opt := &NamespaceExistsOptions{ - ParentID: Int(1), + ParentID: Ptr(1), } exists, _, err := client.Namespaces.NamespaceExists("my-group", opt) if err != nil { @@ -292,8 +292,8 @@ func TestSearchNamespace(t *testing.T) { WebURL: "https://gitlab.example.com/groups/twitter", MembersCountWithDescendants: 2, BillableMembersCount: 2, - MaxSeatsUsed: Int(0), - SeatsInUse: Int(0), + MaxSeatsUsed: Ptr(0), + SeatsInUse: Ptr(0), Plan: "default", TrialEndsOn: nil, Trial: false, diff --git a/personal_access_tokens_test.go b/personal_access_tokens_test.go index 7d4f09dbc..de92d830a 100644 --- a/personal_access_tokens_test.go +++ b/personal_access_tokens_test.go @@ -31,7 +31,7 @@ func TestListPersonalAccessTokensWithUserFilter(t *testing.T) { mustWriteHTTPResponse(t, w, "testdata/list_personal_access_tokens_with_user_filter.json") }) - personalAccessTokens, _, err := client.PersonalAccessTokens.ListPersonalAccessTokens(&ListPersonalAccessTokensOptions{UserID: Int(1), ListOptions: ListOptions{Page: 1, PerPage: 10}}) + personalAccessTokens, _, err := client.PersonalAccessTokens.ListPersonalAccessTokens(&ListPersonalAccessTokensOptions{UserID: Ptr(1), ListOptions: ListOptions{Page: 1, PerPage: 10}}) if err != nil { t.Errorf("PersonalAccessTokens.ListPersonalAccessTokens returned error: %v", err) } diff --git a/pipeline_triggers_test.go b/pipeline_triggers_test.go index 7ca789a6a..828a416b6 100644 --- a/pipeline_triggers_test.go +++ b/pipeline_triggers_test.go @@ -31,7 +31,7 @@ func TestRunPipeline(t *testing.T) { fmt.Fprint(w, `{"id":1, "status":"pending"}`) }) - opt := &RunPipelineTriggerOptions{Ref: String("master")} + opt := &RunPipelineTriggerOptions{Ref: Ptr("master")} pipeline, _, err := client.PipelineTriggers.RunPipelineTrigger(1, opt) if err != nil { t.Errorf("PipelineTriggers.RunPipelineTrigger returned error: %v", err) diff --git a/pipelines_test.go b/pipelines_test.go index 71d02f517..870f2ea0c 100644 --- a/pipelines_test.go +++ b/pipelines_test.go @@ -33,7 +33,7 @@ func TestListProjectPipelines(t *testing.T) { fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) - opt := &ListProjectPipelinesOptions{Ref: String("master")} + opt := &ListProjectPipelinesOptions{Ref: Ptr("master")} piplines, _, err := client.Pipelines.ListProjectPipelines(1, opt) if err != nil { t.Errorf("Pipelines.ListProjectPipelines returned error: %v", err) @@ -194,7 +194,7 @@ func TestGetLatestPipeline_WithRef(t *testing.T) { }) pipeline, _, err := client.Pipelines.GetLatestPipeline(1, &GetLatestPipelineOptions{ - Ref: String("abc"), + Ref: Ptr("abc"), }) assert.NoError(t, err) @@ -209,7 +209,7 @@ func TestCreatePipeline(t *testing.T) { fmt.Fprint(w, `{"id":1, "status":"pending"}`) }) - opt := &CreatePipelineOptions{Ref: String("master")} + opt := &CreatePipelineOptions{Ref: Ptr("master")} pipeline, _, err := client.Pipelines.CreatePipeline(1, opt) if err != nil { t.Errorf("Pipelines.CreatePipeline returned error: %v", err) diff --git a/plan_limits_test.go b/plan_limits_test.go index 1d6a1b171..f6c08dc96 100644 --- a/plan_limits_test.go +++ b/plan_limits_test.go @@ -41,7 +41,7 @@ func TestGetCurrentPlanLimits(t *testing.T) { }) opt := &GetCurrentPlanLimitsOptions{ - PlanName: String("default"), + PlanName: Ptr("default"), } planlimit, _, err := client.PlanLimits.GetCurrentPlanLimits(opt) if err != nil { @@ -82,8 +82,8 @@ func TestChangePlanLimits(t *testing.T) { }) opt := &ChangePlanLimitOptions{ - PlanName: String("default"), - ConanMaxFileSize: Int(3221225472), + PlanName: Ptr("default"), + ConanMaxFileSize: Ptr(3221225472), } planlimit, _, err := client.PlanLimits.ChangePlanLimits(opt) if err != nil { diff --git a/project_managed_licenses_test.go b/project_managed_licenses_test.go index 6438a7d8f..c4223fe71 100644 --- a/project_managed_licenses_test.go +++ b/project_managed_licenses_test.go @@ -87,8 +87,8 @@ func TestAddManagedLicenses(t *testing.T) { }) ops := AddManagedLicenseOptions{ - Name: String("MIT"), - ApprovalStatus: LicenseApprovalStatus(LicenseApproved), + Name: Ptr("MIT"), + ApprovalStatus: Ptr(LicenseApproved), } license, _, err := client.ManagedLicenses.AddManagedLicense(1, &ops) if err != nil { @@ -129,7 +129,7 @@ func TestEditManagedLicenses(t *testing.T) { }) ops := EditManagedLicenceOptions{ - ApprovalStatus: LicenseApprovalStatus(LicenseBlacklisted), + ApprovalStatus: Ptr(LicenseBlacklisted), } license, _, err := client.ManagedLicenses.EditManagedLicense(1, 3, &ops) if err != nil { diff --git a/project_repository_storage_move_test.go b/project_repository_storage_move_test.go index 81f7edc36..e8322c28e 100644 --- a/project_repository_storage_move_test.go +++ b/project_repository_storage_move_test.go @@ -208,7 +208,7 @@ func TestProjectRepositoryStorageMove_ScheduleAllStorageMoves(t *testing.T) { _, err := client.ProjectRepositoryStorageMove.ScheduleAllStorageMoves( ScheduleAllProjectStorageMovesOptions{ - SourceStorageName: String("default"), + SourceStorageName: Ptr("default"), }, ) require.NoError(t, err) diff --git a/project_vulnerabilities_test.go b/project_vulnerabilities_test.go index 5bf0b8dd5..1345d95ce 100644 --- a/project_vulnerabilities_test.go +++ b/project_vulnerabilities_test.go @@ -55,7 +55,7 @@ func TestCreateVulnerability(t *testing.T) { }) opt := &CreateVulnerabilityOptions{ - FindingID: Int(1), + FindingID: Ptr(1), } projectVulnerability, _, err := client.ProjectVulnerabilities.CreateVulnerability(1, opt) diff --git a/projects_test.go b/projects_test.go index c3e9b9a19..e905986d9 100644 --- a/projects_test.go +++ b/projects_test.go @@ -40,12 +40,12 @@ func TestListProjects(t *testing.T) { opt := &ListProjectsOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Archived: Bool(true), - OrderBy: String("name"), - Sort: String("asc"), - Search: String("query"), - Simple: Bool(true), - Visibility: Visibility(PublicVisibility), + Archived: Ptr(true), + OrderBy: Ptr("name"), + Sort: Ptr("asc"), + Search: Ptr("query"), + Simple: Ptr(true), + Visibility: Ptr(PublicVisibility), } projects, _, err := client.Projects.ListProjects(opt) @@ -69,12 +69,12 @@ func TestListUserProjects(t *testing.T) { opt := &ListProjectsOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Archived: Bool(true), - OrderBy: String("name"), - Sort: String("asc"), - Search: String("query"), - Simple: Bool(true), - Visibility: Visibility(PublicVisibility), + Archived: Ptr(true), + OrderBy: Ptr("name"), + Sort: Ptr("asc"), + Search: Ptr("query"), + Simple: Ptr(true), + Visibility: Ptr(PublicVisibility), } projects, _, err := client.Projects.ListUserProjects(1, opt) @@ -127,12 +127,12 @@ func TestListUserStarredProjects(t *testing.T) { opt := &ListProjectsOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Archived: Bool(true), - OrderBy: String("name"), - Sort: String("asc"), - Search: String("query"), - Simple: Bool(true), - Visibility: Visibility(PublicVisibility), + Archived: Ptr(true), + OrderBy: Ptr("name"), + Sort: Ptr("asc"), + Search: Ptr("query"), + Simple: Ptr(true), + Visibility: Ptr(PublicVisibility), } projects, _, err := client.Projects.ListUserStarredProjects(1, opt) @@ -157,7 +157,7 @@ func TestListProjectsUsersByID(t *testing.T) { opt := &ListProjectUserOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Search: String("query"), + Search: Ptr("query"), } projects, _, err := client.Projects.ListProjectsUsers(1, opt) @@ -182,7 +182,7 @@ func TestListProjectsUsersByName(t *testing.T) { opt := &ListProjectUserOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Search: String("query"), + Search: Ptr("query"), } projects, _, err := client.Projects.ListProjectsUsers("namespace/name", opt) @@ -207,7 +207,7 @@ func TestListProjectsGroupsByID(t *testing.T) { opt := &ListProjectGroupOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Search: String("query"), + Search: Ptr("query"), } groups, _, err := client.Projects.ListProjectsGroups(1, opt) @@ -232,7 +232,7 @@ func TestListProjectsGroupsByName(t *testing.T) { opt := &ListProjectGroupOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Search: String("query"), + Search: Ptr("query"), } groups, _, err := client.Projects.ListProjectsGroups("namespace/name", opt) @@ -256,13 +256,13 @@ func TestListOwnedProjects(t *testing.T) { opt := &ListProjectsOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Archived: Bool(true), - OrderBy: String("name"), - Sort: String("asc"), - Search: String("query"), - Simple: Bool(true), - Owned: Bool(true), - Visibility: Visibility(PublicVisibility), + Archived: Ptr(true), + OrderBy: Ptr("name"), + Sort: Ptr("asc"), + Search: Ptr("query"), + Simple: Ptr(true), + Owned: Ptr(true), + Visibility: Ptr(PublicVisibility), } projects, _, err := client.Projects.ListProjects(opt) @@ -286,13 +286,13 @@ func TestListStarredProjects(t *testing.T) { opt := &ListProjectsOptions{ ListOptions: ListOptions{Page: 2, PerPage: 3}, - Archived: Bool(true), - OrderBy: String("name"), - Sort: String("asc"), - Search: String("query"), - Simple: Bool(true), - Starred: Bool(true), - Visibility: Visibility(PublicVisibility), + Archived: Ptr(true), + OrderBy: Ptr("name"), + Sort: Ptr("asc"), + Search: Ptr("query"), + Simple: Ptr(true), + Starred: Ptr(true), + Visibility: Ptr(PublicVisibility), } projects, _, err := client.Projects.ListProjects(opt) @@ -403,7 +403,7 @@ func TestGetProjectWithOptions(t *testing.T) { UploadsSize: 6523619, }} - project, _, err := client.Projects.GetProject(1, &GetProjectOptions{Statistics: Bool(true)}) + project, _, err := client.Projects.GetProject(1, &GetProjectOptions{Statistics: Ptr(true)}) if err != nil { t.Fatalf("Projects.GetProject returns an error: %v", err) } @@ -422,8 +422,8 @@ func TestCreateProject(t *testing.T) { }) opt := &CreateProjectOptions{ - Name: String("n"), - MergeMethod: MergeMethod(RebaseMerge), + Name: Ptr("n"), + MergeMethod: Ptr(RebaseMerge), } project, _, err := client.Projects.CreateProject(opt) @@ -573,12 +573,12 @@ func TestListProjectForks(t *testing.T) { opt := &ListProjectsOptions{} opt.ListOptions = ListOptions{Page: 2, PerPage: 3} - opt.Archived = Bool(true) - opt.OrderBy = String("name") - opt.Sort = String("asc") - opt.Search = String("query") - opt.Simple = Bool(true) - opt.Visibility = Visibility(PublicVisibility) + opt.Archived = Ptr(true) + opt.OrderBy = Ptr("name") + opt.Sort = Ptr("asc") + opt.Search = Ptr("query") + opt.Simple = Ptr(true) + opt.Visibility = Ptr(PublicVisibility) projects, _, err := client.Projects.ListProjectForks("namespace/name", opt) if err != nil { @@ -599,8 +599,8 @@ func TestShareProjectWithGroup(t *testing.T) { }) opt := &ShareWithGroupOptions{ - GroupID: Int(1), - GroupAccess: AccessLevel(AccessLevelValue(50)), + GroupID: Ptr(1), + GroupAccess: Ptr(AccessLevelValue(50)), } _, err := client.Projects.ShareProjectWithGroup(1, opt) @@ -679,7 +679,7 @@ func TestChangeApprovalConfiguration(t *testing.T) { }) opt := &ChangeApprovalConfigurationOptions{ - ApprovalsBeforeMerge: Int(3), + ApprovalsBeforeMerge: Ptr(3), } approvals, _, err := client.Projects.ChangeApprovalConfiguration(1, opt) @@ -773,9 +773,9 @@ func TestForkProject(t *testing.T) { }) project, _, err := client.Projects.ForkProject(1, &ForkProjectOptions{ - NamespaceID: Int(namespaceID), - Name: String(name), - Path: String(path), + NamespaceID: Ptr(namespaceID), + Name: Ptr(name), + Path: Ptr(path), }) if err != nil { t.Errorf("Projects.ForkProject returned error: %v", err) @@ -1219,8 +1219,8 @@ func TestCreateProjectApprovalRule(t *testing.T) { }) opt := &CreateProjectLevelRuleOptions{ - Name: String("security"), - ApprovalsRequired: Int(3), + Name: Ptr("security"), + ApprovalsRequired: Ptr(3), UserIDs: &[]int{5, 50}, GroupIDs: &[]int{5}, ReportType: String("code_coverage"), @@ -1370,8 +1370,8 @@ func TestCreateProjectApprovalRuleEligibleApprovers(t *testing.T) { }) opt := &CreateProjectLevelRuleOptions{ - Name: String("Any name"), - ApprovalsRequired: Int(1), + Name: Ptr("Any name"), + ApprovalsRequired: Ptr(1), } rule, _, err := client.Projects.CreateProjectApprovalRule(1, opt) @@ -1398,7 +1398,7 @@ func TestCreateProjectApprovalRuleEligibleApprovers(t *testing.T) { func TestProjectModelsOptionalMergeAttribute(t *testing.T) { // Create a `CreateProjectOptions` struct, ensure that merge attribute doesn't serialize jsonString, err := json.Marshal(&CreateProjectOptions{ - Name: String("testProject"), + Name: Ptr("testProject"), }) if err != nil { t.Fatal("Failed to marshal object", err) @@ -1407,7 +1407,7 @@ func TestProjectModelsOptionalMergeAttribute(t *testing.T) { // Test the same thing but for `EditProjectOptions` struct jsonString, err = json.Marshal(&EditProjectOptions{ - Name: String("testProject"), + Name: Ptr("testProject"), }) if err != nil { t.Fatal("Failed to marshal object", err) diff --git a/protected_branches_test.go b/protected_branches_test.go index 6e8e5b6a1..0aaecbeea 100644 --- a/protected_branches_test.go +++ b/protected_branches_test.go @@ -150,11 +150,11 @@ func TestProtectRepositoryBranches(t *testing.T) { }`) }) opt := &ProtectRepositoryBranchesOptions{ - Name: String("master"), - PushAccessLevel: AccessLevel(MaintainerPermissions), - MergeAccessLevel: AccessLevel(MaintainerPermissions), - AllowForcePush: Bool(true), - CodeOwnerApprovalRequired: Bool(true), + Name: Ptr("master"), + PushAccessLevel: Ptr(MaintainerPermissions), + MergeAccessLevel: Ptr(MaintainerPermissions), + AllowForcePush: Ptr(true), + CodeOwnerApprovalRequired: Ptr(true), } projects, _, err := client.ProtectedBranches.ProtectRepositoryBranches("1", opt) if err != nil { @@ -195,7 +195,7 @@ func TestUpdateRepositoryBranches(t *testing.T) { }`) }) opt := &UpdateProtectedBranchOptions{ - CodeOwnerApprovalRequired: Bool(true), + CodeOwnerApprovalRequired: Ptr(true), } protectedBranch, _, err := client.ProtectedBranches.UpdateProtectedBranch("1", "master", opt) if err != nil { diff --git a/protected_environments_test.go b/protected_environments_test.go index e4cf3b987..dda3b38d1 100644 --- a/protected_environments_test.go +++ b/protected_environments_test.go @@ -247,16 +247,16 @@ func TestProtectRepositoryEnvironments(t *testing.T) { } opt := &ProtectRepositoryEnvironmentsOptions{ - Name: String("my-awesome-environment"), + Name: Ptr("my-awesome-environment"), DeployAccessLevels: &[]*EnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, - RequiredApprovalCount: Int(2), + RequiredApprovalCount: Ptr(2), ApprovalRules: &[]*EnvironmentApprovalRuleOptions{ { - GroupID: Int(10), - AccessLevel: AccessLevel(0), - AccessLevelDescription: String("devops"), + GroupID: Ptr(10), + AccessLevel: Ptr(AccessLevelValue(0)), + AccessLevelDescription: Ptr("devops"), }, }, } @@ -290,9 +290,9 @@ func TestProtectRepositoryEnvironments(t *testing.T) { } opt = &ProtectRepositoryEnvironmentsOptions{ - Name: String("my-awesome-environment2"), + Name: Ptr("my-awesome-environment2"), DeployAccessLevels: &[]*EnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, } environment, _, err = client.ProtectedEnvironments.ProtectRepositoryEnvironments(2, opt) @@ -353,16 +353,16 @@ func TestUpdateProtectedEnvironments(t *testing.T) { } opt := &UpdateProtectedEnvironmentsOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*UpdateEnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, - RequiredApprovalCount: Int(2), + RequiredApprovalCount: Ptr(2), ApprovalRules: &[]*UpdateEnvironmentApprovalRuleOptions{ { - GroupID: Int(10), - AccessLevel: AccessLevel(0), - AccessLevelDescription: String("devops"), + GroupID: Ptr(10), + AccessLevel: Ptr(AccessLevelValue(0)), + AccessLevelDescription: Ptr("devops"), }, }, } @@ -398,9 +398,9 @@ func TestUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateProtectedEnvironmentsOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*UpdateEnvironmentAccessOptions{ - {AccessLevel: AccessLevel(30)}, + {AccessLevel: Ptr(AccessLevelValue(30))}, }, } environment, _, err = client.ProtectedEnvironments.UpdateProtectedEnvironments(2, environmentName, opt) @@ -436,11 +436,11 @@ func TestUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateProtectedEnvironmentsOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), DeployAccessLevels: &[]*UpdateEnvironmentAccessOptions{ { - ID: Int(42), - AccessLevel: AccessLevel(30), + ID: Ptr(42), + AccessLevel: Ptr(AccessLevelValue(30)), }, }, } @@ -496,13 +496,13 @@ func TestUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateProtectedEnvironmentsOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), ApprovalRules: &[]*UpdateEnvironmentApprovalRuleOptions{ { - ID: Int(1), - GroupID: Int(10), - AccessLevel: AccessLevel(0), - AccessLevelDescription: String("devops"), + ID: Ptr(1), + GroupID: Ptr(10), + AccessLevel: Ptr(AccessLevelValue(0)), + AccessLevelDescription: Ptr("devops"), }, }, } @@ -542,14 +542,14 @@ func TestUpdateProtectedEnvironments(t *testing.T) { } opt = &UpdateProtectedEnvironmentsOptions{ - Name: String(environmentName), + Name: Ptr(environmentName), ApprovalRules: &[]*UpdateEnvironmentApprovalRuleOptions{ { - ID: Int(1), - Destroy: Bool(true), + ID: Ptr(1), + Destroy: Ptr(true), }, }, - RequiredApprovalCount: Int(0), + RequiredApprovalCount: Ptr(0), } environment, _, err = client.ProtectedEnvironments.UpdateProtectedEnvironments(5, environmentName, opt) diff --git a/protected_tags_test.go b/protected_tags_test.go index 87c4b8f1e..345b7c357 100644 --- a/protected_tags_test.go +++ b/protected_tags_test.go @@ -114,11 +114,11 @@ func TestProtectRepositoryTags(t *testing.T) { } opt := &ProtectRepositoryTagsOptions{ - Name: String("my-awesome-tag"), - CreateAccessLevel: AccessLevel(30), + Name: Ptr("my-awesome-tag"), + CreateAccessLevel: Ptr(AccessLevelValue(30)), AllowedToCreate: &[]*TagsPermissionOptions{ { - GroupID: Int(300), + GroupID: Ptr(300), }, }, } diff --git a/releaselinks_test.go b/releaselinks_test.go index ff6f947b1..a922636c5 100644 --- a/releaselinks_test.go +++ b/releaselinks_test.go @@ -68,8 +68,8 @@ func TestReleaseLinksService_CreateReleaseLink(t *testing.T) { { description: "Mandatory Attributes", options: &CreateReleaseLinkOptions{ - Name: String("awesome-v0.2.dmg"), - URL: String("http://192.168.10.15:3000"), + Name: Ptr("awesome-v0.2.dmg"), + URL: Ptr("http://192.168.10.15:3000"), }, response: `{ "id":1, @@ -87,10 +87,10 @@ func TestReleaseLinksService_CreateReleaseLink(t *testing.T) { { description: "Optional Attributes", options: &CreateReleaseLinkOptions{ - Name: String("release-notes.md"), - URL: String("http://192.168.10.15:3000"), - FilePath: String("docs/release-notes.md"), - LinkType: LinkType(OtherLinkType), + Name: Ptr("release-notes.md"), + URL: Ptr("http://192.168.10.15:3000"), + FilePath: Ptr("docs/release-notes.md"), + LinkType: Ptr(OtherLinkType), }, response: `{ "id":1, @@ -159,9 +159,9 @@ func TestReleaseLinksService_UpdateReleaseLink(t *testing.T) { releaseLink, _, err := client.ReleaseLinks.UpdateReleaseLink( 1, exampleTagName, 1, &UpdateReleaseLinkOptions{ - Name: String(exampleReleaseName), - FilePath: String("http://192.168.10.15:3000/namespace/example/-/releases/v0.1/downloads/awesome-v0.2.dmg"), - LinkType: LinkType(OtherLinkType), + Name: Ptr(exampleReleaseName), + FilePath: Ptr("http://192.168.10.15:3000/namespace/example/-/releases/v0.1/downloads/awesome-v0.2.dmg"), + LinkType: Ptr(OtherLinkType), }) require.NoError(t, err) diff --git a/releases_test.go b/releases_test.go index d4bb4411f..013f80f19 100644 --- a/releases_test.go +++ b/releases_test.go @@ -92,9 +92,9 @@ func TestReleasesService_CreateRelease(t *testing.T) { }) opts := &CreateReleaseOptions{ - Name: String("name"), - TagName: String(exampleTagName), - Description: String("Description"), + Name: Ptr("name"), + TagName: Ptr(exampleTagName), + Description: Ptr("Description"), } release, _, err := client.Releases.CreateRelease(1, opts) @@ -136,12 +136,12 @@ func TestReleasesService_CreateReleaseWithAsset(t *testing.T) { }) opts := &CreateReleaseOptions{ - Name: String("name"), - TagName: String(exampleTagName), - Description: String("Description"), + Name: Ptr("name"), + TagName: Ptr(exampleTagName), + Description: Ptr("Description"), Assets: &ReleaseAssetsOptions{ Links: []*ReleaseAssetLinkOptions{ - {String("sldkf"), String("sldkfj"), String("sldkfh"), LinkType(OtherLinkType)}, + {Ptr("sldkf"), Ptr("sldkfj"), Ptr("sldkfh"), Ptr(OtherLinkType)}, }, }, } @@ -185,12 +185,12 @@ func TestReleasesService_CreateReleaseWithAssetAndNameMetadata(t *testing.T) { }) opts := &CreateReleaseOptions{ - Name: String("name"), - TagName: String(exampleTagNameWithMetadata), - Description: String("Description"), + Name: Ptr("name"), + TagName: Ptr(exampleTagNameWithMetadata), + Description: Ptr("Description"), Assets: &ReleaseAssetsOptions{ Links: []*ReleaseAssetLinkOptions{ - {String("sldkf"), String("sldkfj"), String("sldkfh"), LinkType(OtherLinkType)}, + {Ptr("sldkf"), Ptr("sldkfj"), Ptr("sldkfh"), Ptr(OtherLinkType)}, }, }, } @@ -234,9 +234,9 @@ func TestReleasesService_CreateReleaseWithMilestones(t *testing.T) { }) opts := &CreateReleaseOptions{ - Name: String("name"), - TagName: String(exampleTagName), - Description: String("Description"), + Name: Ptr("name"), + TagName: Ptr(exampleTagName), + Description: Ptr("Description"), Milestones: &[]string{exampleTagName, "v0.1.0"}, } @@ -279,9 +279,9 @@ func TestReleasesService_CreateReleaseWithReleasedAt(t *testing.T) { }) opts := &CreateReleaseOptions{ - Name: String("name"), - TagName: String(exampleTagName), - Description: String("Description"), + Name: Ptr("name"), + TagName: Ptr(exampleTagName), + Description: Ptr("Description"), ReleasedAt: &time.Time{}, } @@ -316,8 +316,8 @@ func TestReleasesService_UpdateRelease(t *testing.T) { }) opts := &UpdateReleaseOptions{ - Name: String("name"), - Description: String("Description"), + Name: Ptr("name"), + Description: Ptr("Description"), } release, _, err := client.Releases.UpdateRelease(1, exampleTagName, opts) @@ -351,8 +351,8 @@ func TestReleasesService_UpdateReleaseWithMilestones(t *testing.T) { }) opts := &UpdateReleaseOptions{ - Name: String("name"), - Description: String("Description"), + Name: Ptr("name"), + Description: Ptr("Description"), Milestones: &[]string{exampleTagName, "v0.1.0"}, } @@ -387,8 +387,8 @@ func TestReleasesService_UpdateReleaseWithReleasedAt(t *testing.T) { }) opts := &UpdateReleaseOptions{ - Name: String("name"), - Description: String("Description"), + Name: Ptr("name"), + Description: Ptr("Description"), ReleasedAt: &time.Time{}, } diff --git a/repositories_test.go b/repositories_test.go index ae630045f..e08b67ef4 100644 --- a/repositories_test.go +++ b/repositories_test.go @@ -146,7 +146,7 @@ func TestRepositoriesService_Archive(t *testing.T) { ) }) - opt := &ArchiveOptions{Format: String("gz")} + opt := &ArchiveOptions{Format: Ptr("gz")} want := []byte("{" + "size: 100" + "content: content" + @@ -181,7 +181,7 @@ func TestRepositoriesService_StreamArchive(t *testing.T) { }) var w http.ResponseWriter - opt := &ArchiveOptions{Format: String("gz")} + opt := &ArchiveOptions{Format: Ptr("gz")} resp, err := client.Repositories.StreamArchive(1, w, opt, nil) require.NoError(t, err) @@ -239,8 +239,8 @@ func TestRepositoriesService_Compare(t *testing.T) { }) opt := &CompareOptions{ - From: String("master"), - To: String("feature"), + From: Ptr("master"), + To: Ptr("feature"), } want := &Compare{ Commit: &Commit{ @@ -402,7 +402,7 @@ func TestAddChangelogData(t *testing.T) { resp, err := client.Repositories.AddChangelog( 1, &AddChangelogOptions{ - Version: String("1.0.0"), + Version: Ptr("1.0.0"), }) require.NoError(t, err) assert.Equal(t, http.StatusOK, resp.StatusCode) @@ -424,7 +424,7 @@ func TestGenerateChangelogData(t *testing.T) { notes, _, err := client.Repositories.GenerateChangelogData( 1, GenerateChangelogDataOptions{ - Version: String("1.0.0"), + Version: Ptr("1.0.0"), }, ) require.NoError(t, err) diff --git a/repository_files_test.go b/repository_files_test.go index 6945b6f9e..34e27a0ba 100644 --- a/repository_files_test.go +++ b/repository_files_test.go @@ -268,7 +268,7 @@ func TestRepositoryFilesService_CreateFile(t *testing.T) { require.NotNil(t, resp) require.Equal(t, want, fi) - fi, resp, err = client.RepositoryFiles.CreateFile(13083, "app%2Fproject%2Erb", &CreateFileOptions{ExecuteFilemode: Bool(true)}) + fi, resp, err = client.RepositoryFiles.CreateFile(13083, "app%2Fproject%2Erb", &CreateFileOptions{ExecuteFilemode: Ptr(true)}) require.NoError(t, err) require.NotNil(t, resp) require.Equal(t, want, fi) @@ -312,7 +312,7 @@ func TestRepositoryFilesService_UpdateFile(t *testing.T) { require.NotNil(t, resp) require.Equal(t, want, fi) - fi, resp, err = client.RepositoryFiles.UpdateFile(13083, "app%2Fproject%2Erb", &UpdateFileOptions{ExecuteFilemode: Bool(true)}) + fi, resp, err = client.RepositoryFiles.UpdateFile(13083, "app%2Fproject%2Erb", &UpdateFileOptions{ExecuteFilemode: Ptr(true)}) require.NoError(t, err) require.NotNil(t, resp) require.Equal(t, want, fi) diff --git a/repository_submodules_test.go b/repository_submodules_test.go index fed614d76..f6707730c 100644 --- a/repository_submodules_test.go +++ b/repository_submodules_test.go @@ -41,7 +41,7 @@ func TestRepositorySubmodulesService_UpdateSubmodule(t *testing.T) { CommitterEmail: "noty@gmail.com", Message: "Update my submodule", ParentIDs: []string{"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"}, - Status: BuildState(Running), + Status: Ptr(Running), } sc, resp, err := client.RepositorySubmodules.UpdateSubmodule(13083, "app%2Fproject", nil) diff --git a/resource_weight_events_test.go b/resource_weight_events_test.go index ac59db4d2..ec72cc9aa 100644 --- a/resource_weight_events_test.go +++ b/resource_weight_events_test.go @@ -47,7 +47,7 @@ func TestResourceWeightEventsService_ListIssueWightEvents(t *testing.T) { AvatarURL: "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", WebURL: "http://gitlab.example.com/root", }, - CreatedAt: Time(time.Date(2018, time.August, 20, 13, 38, 20, 77000000, time.UTC)), + CreatedAt: Ptr(time.Date(2018, time.August, 20, 13, 38, 20, 77000000, time.UTC)), IssueID: 253, Weight: 3, }} diff --git a/runners_test.go b/runners_test.go index aaefd19e4..9ed77d79e 100644 --- a/runners_test.go +++ b/runners_test.go @@ -74,9 +74,9 @@ func TestListRunnersJobs(t *testing.T) { Stage: "test", Name: "run_tests", Ref: "master", - CreatedAt: Time(time.Date(2021, time.October, 22, 11, 59, 25, 201000000, time.UTC)), - StartedAt: Time(time.Date(2021, time.October, 22, 11, 59, 33, 660000000, time.UTC)), - FinishedAt: Time(time.Date(2021, time.October, 22, 15, 59, 25, 201000000, time.UTC)), + CreatedAt: Ptr(time.Date(2021, time.October, 22, 11, 59, 25, 201000000, time.UTC)), + StartedAt: Ptr(time.Date(2021, time.October, 22, 11, 59, 33, 660000000, time.UTC)), + FinishedAt: Ptr(time.Date(2021, time.October, 22, 15, 59, 25, 201000000, time.UTC)), Duration: 171.540594, QueuedDuration: 2.535766, User: &User{ @@ -91,16 +91,16 @@ func TestListRunnersJobs(t *testing.T) { Commit: &Commit{ ID: "6c016b801a88f4bd31f927fc045b5c746a6f823e", ShortID: "6c016b80", - CreatedAt: Time(time.Date(2018, time.March, 21, 14, 41, 0, 0, time.UTC)), + CreatedAt: Ptr(time.Date(2018, time.March, 21, 14, 41, 0, 0, time.UTC)), ParentIDs: []string{"6008b4902d40799ab11688e502d9f1f27f6d2e18"}, Title: "Update env for specific runner", Message: "Update env for specific runner\n", AuthorName: "John SMITH", AuthorEmail: "john.smith@example.com", - AuthoredDate: Time(time.Date(2018, time.March, 21, 14, 41, 0, 0, time.UTC)), + AuthoredDate: Ptr(time.Date(2018, time.March, 21, 14, 41, 0, 0, time.UTC)), CommitterName: "John SMITH", CommitterEmail: "john.smith@example.com", - CommittedDate: Time(time.Date(2018, time.March, 21, 14, 41, 0, 0, time.UTC)), + CommittedDate: Ptr(time.Date(2018, time.March, 21, 14, 41, 0, 0, time.UTC)), WebURL: "https://gitlab.example.com/awesome/packages/common/-/commit/6c016b801a88f4bd31f927fc045b5c746a6f823e", }, Pipeline: pipeline, @@ -112,7 +112,7 @@ func TestListRunnersJobs(t *testing.T) { NameWithNamespace: "awesome", Path: "common", PathWithNamespace: "awesome", - CreatedAt: Time(time.Date(2018, time.February, 13, 9, 21, 48, 107000000, time.UTC)), + CreatedAt: Ptr(time.Date(2018, time.February, 13, 9, 21, 48, 107000000, time.UTC)), }, }, } @@ -170,7 +170,7 @@ func TestUpdateRunnersDetails(t *testing.T) { ID: 6, IsShared: false, RunnerType: "project_type", - ContactedAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + ContactedAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), Online: true, Status: "online", Token: "205086a8e3b9a2b818ffac9b89d102", @@ -219,7 +219,7 @@ func TestGetRunnerDetails(t *testing.T) { ID: 6, IsShared: false, RunnerType: "project_type", - ContactedAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + ContactedAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), Online: true, Status: "online", Token: "205086a8e3b9a2b818ffac9b89d102", @@ -254,7 +254,7 @@ func TestRegisterNewRunner(t *testing.T) { want := &Runner{ ID: 12345, Token: "6337ff461c94fd3fa32ba3b1ff4125", - TokenExpiresAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + TokenExpiresAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), } if !reflect.DeepEqual(want, runner) { t.Errorf("Runners.RegisterNewRunner returned %+v, want %+v", runner, want) @@ -288,19 +288,19 @@ func TestRegisterNewRunnerInfo(t *testing.T) { }) opt := &RegisterNewRunnerOptions{ - Token: String("6337ff461c94fd3fa32ba3b1ff4125"), - Description: String("some description"), + Token: Ptr("6337ff461c94fd3fa32ba3b1ff4125"), + Description: Ptr("some description"), Info: &RegisterNewRunnerInfoOptions{ - String("some name"), - String("13.7.0"), - String("943fc252"), - String("linux"), - String("amd64"), + Ptr("some name"), + Ptr("13.7.0"), + Ptr("943fc252"), + Ptr("linux"), + Ptr("amd64"), }, - Active: Bool(true), - Locked: Bool(true), - RunUntagged: Bool(false), - MaximumTimeout: Int(45), + Active: Ptr(true), + Locked: Ptr(true), + RunUntagged: Ptr(false), + MaximumTimeout: Ptr(45), } runner, resp, err := client.Runners.RegisterNewRunner(opt, nil) if err != nil { @@ -316,7 +316,7 @@ func TestRegisterNewRunnerInfo(t *testing.T) { Online: true, Status: "online", Token: "1111122222333333444444", - TokenExpiresAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + TokenExpiresAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), } if !reflect.DeepEqual(want, runner) { t.Errorf("Runners.RegisterNewRunner returned %+v, want %+v", runner, want) @@ -409,8 +409,8 @@ func TestResetInstanceRunnerRegistrationToken(t *testing.T) { } want := &RunnerRegistrationToken{ - Token: String("6337ff461c94fd3fa32ba3b1ff4125"), - TokenExpiresAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + Token: Ptr("6337ff461c94fd3fa32ba3b1ff4125"), + TokenExpiresAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), } if !reflect.DeepEqual(want, token) { t.Errorf("Runners.ResetInstanceRunnerRegistrationToken returned %+v, want %+v", token, want) @@ -440,8 +440,8 @@ func TestResetGroupRunnerRegistrationToken(t *testing.T) { } want := &RunnerRegistrationToken{ - Token: String("6337ff461c94fd3fa32ba3b1ff4125"), - TokenExpiresAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + Token: Ptr("6337ff461c94fd3fa32ba3b1ff4125"), + TokenExpiresAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), } if !reflect.DeepEqual(want, token) { t.Errorf("Runners.ResetGroupRunnerRegistrationToken returned %+v, want %+v", token, want) @@ -471,8 +471,8 @@ func TestResetProjectRunnerRegistrationToken(t *testing.T) { } want := &RunnerRegistrationToken{ - Token: String("6337ff461c94fd3fa32ba3b1ff4125"), - TokenExpiresAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + Token: Ptr("6337ff461c94fd3fa32ba3b1ff4125"), + TokenExpiresAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), } if !reflect.DeepEqual(want, token) { t.Errorf("Runners.ResetProjectRunnerRegistrationToken returned %+v, want %+v", token, want) @@ -502,8 +502,8 @@ func TestResetRunnerAuthenticationToken(t *testing.T) { } want := &RunnerAuthenticationToken{ - Token: String("6337ff461c94fd3fa32ba3b1ff4125"), - TokenExpiresAt: Time(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), + Token: Ptr("6337ff461c94fd3fa32ba3b1ff4125"), + TokenExpiresAt: Ptr(time.Date(2016, time.January, 25, 16, 39, 48, 166000000, time.UTC)), } if !reflect.DeepEqual(want, token) { t.Errorf("Runners.ResetRunnerAuthenticationToken returned %+v, want %+v", token, want) diff --git a/services_test.go b/services_test.go index b2515a060..fe8a8d488 100644 --- a/services_test.go +++ b/services_test.go @@ -87,12 +87,12 @@ func TestSetCustomIssueTrackerService(t *testing.T) { }) opt := &SetCustomIssueTrackerServiceOptions{ - NewIssueURL: String("1"), - IssuesURL: String("2"), - ProjectURL: String("3"), - Description: String("4"), - Title: String("5"), - PushEvents: Bool(true), + NewIssueURL: Ptr("1"), + IssuesURL: Ptr("2"), + ProjectURL: Ptr("3"), + Description: Ptr("4"), + Title: Ptr("5"), + PushEvents: Ptr(true), } _, err := client.Services.SetCustomIssueTrackerService(1, opt) @@ -215,7 +215,7 @@ func TestSetDiscordService(t *testing.T) { }) opt := &SetDiscordServiceOptions{ - WebHook: String("webhook_uri"), + WebHook: Ptr("webhook_uri"), } _, err := client.Services.SetDiscordService(1, opt) @@ -262,7 +262,7 @@ func TestSetDroneCIService(t *testing.T) { testMethod(t, r, http.MethodPut) }) - opt := &SetDroneCIServiceOptions{String("t"), String("u"), Bool(true)} + opt := &SetDroneCIServiceOptions{Ptr("t"), Ptr("u"), Ptr(true)} _, err := client.Services.SetDroneCIService(1, opt) if err != nil { @@ -308,7 +308,7 @@ func TestSetEmailsOnPushService(t *testing.T) { testMethod(t, r, http.MethodPut) }) - opt := &SetEmailsOnPushServiceOptions{String("t"), Bool(true), Bool(true), Bool(true), Bool(true), String("t")} + opt := &SetEmailsOnPushServiceOptions{Ptr("t"), Ptr(true), Ptr(true), Ptr(true), Ptr(true), Ptr("t")} _, err := client.Services.SetEmailsOnPushService(1, opt) if err != nil { @@ -397,16 +397,16 @@ func TestSetJiraService(t *testing.T) { }) opt := &SetJiraServiceOptions{ - URL: String("asd"), - APIURL: String("asd"), - ProjectKey: String("as"), - Username: String("aas"), - Password: String("asd"), - Active: Bool(true), - JiraIssueTransitionID: String("2,3"), - CommitEvents: Bool(true), - CommentOnEventEnabled: Bool(true), - MergeRequestsEvents: Bool(true), + URL: Ptr("asd"), + APIURL: Ptr("asd"), + ProjectKey: Ptr("as"), + Username: Ptr("aas"), + Password: Ptr("asd"), + Active: Ptr(true), + JiraIssueTransitionID: Ptr("2,3"), + CommitEvents: Ptr(true), + CommentOnEventEnabled: Ptr(true), + MergeRequestsEvents: Ptr(true), } _, err := client.Services.SetJiraService(1, opt) @@ -454,9 +454,9 @@ func TestSetMattermostService(t *testing.T) { }) opt := &SetMattermostServiceOptions{ - WebHook: String("webhook_uri"), - Username: String("username"), - Channel: String("#development"), + WebHook: Ptr("webhook_uri"), + Username: Ptr("username"), + Channel: Ptr("#development"), } _, err := client.Services.SetMattermostService(1, opt) @@ -504,9 +504,9 @@ func TestSetPipelinesEmailService(t *testing.T) { }) opt := &SetPipelinesEmailServiceOptions{ - Recipients: String("test@email.com"), - NotifyOnlyBrokenPipelines: Bool(true), - NotifyOnlyDefaultBranch: Bool(false), + Recipients: Ptr("test@email.com"), + NotifyOnlyBrokenPipelines: Ptr(true), + NotifyOnlyDefaultBranch: Ptr(false), AddPusher: nil, BranchesToBeNotified: nil, PipelineEvents: nil, @@ -556,7 +556,7 @@ func TestSetPrometheusService(t *testing.T) { testMethod(t, r, http.MethodPut) }) - opt := &SetPrometheusServiceOptions{String("t"), String("u"), String("a")} + opt := &SetPrometheusServiceOptions{Ptr("t"), Ptr("u"), Ptr("a")} _, err := client.Services.SetPrometheusService(1, opt) if err != nil { @@ -603,9 +603,9 @@ func TestSetSlackService(t *testing.T) { }) opt := &SetSlackServiceOptions{ - WebHook: String("webhook_uri"), - Username: String("username"), - Channel: String("#development"), + WebHook: Ptr("webhook_uri"), + Username: Ptr("username"), + Channel: Ptr("#development"), } _, err := client.Services.SetSlackService(1, opt) @@ -653,10 +653,10 @@ func TestSetYouTrackService(t *testing.T) { }) opt := &SetYouTrackServiceOptions{ - IssuesURL: String("https://example.org/youtrack/issue/:id"), - ProjectURL: String("https://example.org/youtrack/projects/1"), - Description: String("description"), - PushEvents: Bool(true), + IssuesURL: Ptr("https://example.org/youtrack/issue/:id"), + ProjectURL: Ptr("https://example.org/youtrack/projects/1"), + Description: Ptr("description"), + PushEvents: Ptr(true), } _, err := client.Services.SetYouTrackService(1, opt) @@ -704,7 +704,7 @@ func TestSetSlackSlashCommandsService(t *testing.T) { }) opt := &SetSlackSlashCommandsServiceOptions{ - Token: String("token"), + Token: Ptr("token"), } _, err := client.Services.SetSlackSlashCommandsService(1, opt) @@ -752,8 +752,8 @@ func TestSetMattermostSlashCommandsService(t *testing.T) { }) opt := &SetMattermostSlashCommandsServiceOptions{ - Token: String("token"), - Username: String("username"), + Token: Ptr("token"), + Username: Ptr("username"), } _, err := client.Services.SetMattermostSlashCommandsService(1, opt) diff --git a/settings_test.go b/settings_test.go index 20aadb2ee..a4ad6ce48 100644 --- a/settings_test.go +++ b/settings_test.go @@ -51,7 +51,7 @@ func TestUpdateSettings(t *testing.T) { }) options := &UpdateSettingsOptions{ - DefaultProjectsLimit: Int(100), + DefaultProjectsLimit: Ptr(100), } settings, _, err := client.Settings.UpdateSettings(options) if err != nil { diff --git a/snippet_repository_storage_move_test.go b/snippet_repository_storage_move_test.go index 84e2f3d00..8dab45167 100644 --- a/snippet_repository_storage_move_test.go +++ b/snippet_repository_storage_move_test.go @@ -208,7 +208,7 @@ func TestSnippetRepositoryStorageMove_ScheduleAllStorageMoves(t *testing.T) { _, err := client.SnippetRepositoryStorageMove.ScheduleAllStorageMoves( ScheduleAllSnippetStorageMovesOptions{ - SourceStorageName: String("default"), + SourceStorageName: Ptr("default"), }, ) require.NoError(t, err) diff --git a/snippets_test.go b/snippets_test.go index 7da054bfa..25790c447 100644 --- a/snippets_test.go +++ b/snippets_test.go @@ -49,11 +49,11 @@ func TestSnippetsService_CreateSnippet(t *testing.T) { }) opt := &CreateSnippetOptions{ - Title: String("test"), - FileName: String("file"), - Description: String("description"), - Content: String("content"), - Visibility: Visibility(PublicVisibility), + Title: Ptr("test"), + FileName: Ptr("file"), + Description: Ptr("description"), + Content: Ptr("content"), + Visibility: Ptr(PublicVisibility), } s, _, err := client.Snippets.CreateSnippet(opt) @@ -72,11 +72,11 @@ func TestSnippetsService_UpdateSnippet(t *testing.T) { }) opt := &UpdateSnippetOptions{ - Title: String("test"), - FileName: String("file"), - Description: String("description"), - Content: String("content"), - Visibility: Visibility(PublicVisibility), + Title: Ptr("test"), + FileName: Ptr("file"), + Description: Ptr("description"), + Content: Ptr("content"), + Visibility: Ptr(PublicVisibility), } s, _, err := client.Snippets.UpdateSnippet(1, opt) diff --git a/system_hooks_test.go b/system_hooks_test.go index 1205ff00d..1cd33d3e8 100644 --- a/system_hooks_test.go +++ b/system_hooks_test.go @@ -90,7 +90,7 @@ func TestSystemHooksService_AddHook(t *testing.T) { }) opt := &AddHookOptions{ - URL: String("https://gitlab.example.com/hook"), + URL: Ptr("https://gitlab.example.com/hook"), } hook, _, err := client.SystemHooks.AddHook(opt) diff --git a/tags_test.go b/tags_test.go index 320ceb788..77793de5a 100644 --- a/tags_test.go +++ b/tags_test.go @@ -74,7 +74,7 @@ func TestTagsService_CreateReleaseNote(t *testing.T) { fmt.Fprint(w, `{"tag_name": "1.0.0", "description": "Amazing release. Wow"}`) }) - opt := &CreateReleaseNoteOptions{Description: String("Amazing release. Wow")} + opt := &CreateReleaseNoteOptions{Description: Ptr("Amazing release. Wow")} release, _, err := client.Tags.CreateReleaseNote(1, "1.0.0", opt) if err != nil { @@ -96,7 +96,7 @@ func TestTagsService_UpdateReleaseNote(t *testing.T) { fmt.Fprint(w, `{"tag_name": "1.0.0", "description": "Amazing release. Wow!"}`) }) - opt := &UpdateReleaseNoteOptions{Description: String("Amazing release. Wow!")} + opt := &UpdateReleaseNoteOptions{Description: Ptr("Amazing release. Wow!")} release, _, err := client.Tags.UpdateReleaseNote(1, "1.0.0", opt) if err != nil { diff --git a/topics_test.go b/topics_test.go index 0098fe9b4..d8776c1b1 100644 --- a/topics_test.go +++ b/topics_test.go @@ -56,7 +56,7 @@ func TestTopicsService_ListTopics(t *testing.T) { ]`) }) - opt := &ListTopicsOptions{Search: String("git")} + opt := &ListTopicsOptions{Search: Ptr("git")} topics, _, err := client.Topics.ListTopics(opt) if err != nil { t.Errorf("Tags.ListTags returned error: %v", err) @@ -135,7 +135,7 @@ func TestTopicsService_CreateTopic(t *testing.T) { }`) }) - opt := &CreateTopicOptions{Name: String("topic1"), Title: String("Topic 1"), Description: String("description")} + opt := &CreateTopicOptions{Name: Ptr("topic1"), Title: Ptr("Topic 1"), Description: Ptr("description")} release, _, err := client.Topics.CreateTopic(opt) if err != nil { t.Errorf("Topics.CreateTopic returned error: %v", err) @@ -162,7 +162,7 @@ func TestTopicsService_UpdateTopic(t *testing.T) { }`) }) - opt := &UpdateTopicOptions{Name: String("topic1"), Title: String("Topic 1"), Description: String("description")} + opt := &UpdateTopicOptions{Name: Ptr("topic1"), Title: Ptr("Topic 1"), Description: Ptr("description")} release, _, err := client.Topics.UpdateTopic(1, opt) if err != nil { t.Errorf("Topics.UpdateTopic returned error: %v", err) diff --git a/types.go b/types.go index cd8aad768..5eb6490c3 100644 --- a/types.go +++ b/types.go @@ -26,6 +26,14 @@ import ( "time" ) +// Ptr is a helper routine that allocates a new T +// to store t and returns a pointer to it. +func Ptr[T any](t T) *T { + p := new(T) + *p = t + return p +} + // AccessControlValue represents an access control value within GitLab, // used for managing access to certain project features. // @@ -44,10 +52,9 @@ const ( // AccessControl is a helper routine that allocates a new AccessControlValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func AccessControl(v AccessControlValue) *AccessControlValue { - p := new(AccessControlValue) - *p = v - return p + return Ptr(v) } // AccessLevelValue represents a permission level within GitLab. @@ -76,10 +83,9 @@ const ( // AccessLevel is a helper routine that allocates a new AccessLevelValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func AccessLevel(v AccessLevelValue) *AccessLevelValue { - p := new(AccessLevelValue) - *p = v - return p + return Ptr(v) } // UserIDValue represents a user ID value within GitLab. @@ -217,10 +223,9 @@ const ( // Availability is a helper routine that allocates a new AvailabilityValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func Availability(v AvailabilityValue) *AvailabilityValue { - p := new(AvailabilityValue) - *p = v - return p + return Ptr(v) } // BuildStateValue represents a GitLab build state. @@ -243,10 +248,9 @@ const ( // BuildState is a helper routine that allocates a new BuildStateValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func BuildState(v BuildStateValue) *BuildStateValue { - p := new(BuildStateValue) - *p = v - return p + return Ptr(v) } // DeploymentStatusValue represents a Gitlab deployment status. @@ -263,10 +267,9 @@ const ( // DeploymentStatus is a helper routine that allocates a new // DeploymentStatusValue to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func DeploymentStatus(v DeploymentStatusValue) *DeploymentStatusValue { - p := new(DeploymentStatusValue) - *p = v - return p + return Ptr(v) } // EventTypeValue represents actions type for contribution events @@ -321,10 +324,9 @@ const ( // FileAction is a helper routine that allocates a new FileActionValue value // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func FileAction(v FileActionValue) *FileActionValue { - p := new(FileActionValue) - *p = v - return p + return Ptr(v) } // GenericPackageSelectValue represents a generic package select value. @@ -337,10 +339,9 @@ const ( // GenericPackageSelect is a helper routine that allocates a new // GenericPackageSelectValue value to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func GenericPackageSelect(v GenericPackageSelectValue) *GenericPackageSelectValue { - p := new(GenericPackageSelectValue) - *p = v - return p + return Ptr(v) } // GenericPackageStatusValue represents a generic package status. @@ -354,10 +355,9 @@ const ( // GenericPackageStatus is a helper routine that allocates a new // GenericPackageStatusValue value to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func GenericPackageStatus(v GenericPackageStatusValue) *GenericPackageStatusValue { - p := new(GenericPackageStatusValue) - *p = v - return p + return Ptr(v) } // ISOTime represents an ISO 8601 formatted date. @@ -434,10 +434,9 @@ const ( // LinkType is a helper routine that allocates a new LinkType value // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func LinkType(v LinkTypeValue) *LinkTypeValue { - p := new(LinkTypeValue) - *p = v - return p + return Ptr(v) } // LicenseApprovalStatusValue describe the approval statuses of a license. @@ -455,10 +454,9 @@ const ( // LicenseApprovalStatus is a helper routine that allocates a new license // approval status value to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func LicenseApprovalStatus(v LicenseApprovalStatusValue) *LicenseApprovalStatusValue { - p := new(LicenseApprovalStatusValue) - *p = v - return p + return Ptr(v) } // MergeMethodValue represents a project merge type within GitLab. @@ -476,11 +474,10 @@ const ( ) // MergeMethod is a helper routine that allocates a new MergeMethod -// to sotre v and returns a pointer to it. +// to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func MergeMethod(v MergeMethodValue) *MergeMethodValue { - p := new(MergeMethodValue) - *p = v - return p + return Ptr(v) } // NoteTypeValue represents the type of a Note. @@ -496,10 +493,9 @@ const ( // NoteType is a helper routine that allocates a new NoteTypeValue to // store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func NoteType(v NoteTypeValue) *NoteTypeValue { - p := new(NoteTypeValue) - *p = v - return p + return Ptr(v) } // NotificationLevelValue represents a notification level. @@ -566,10 +562,9 @@ var notificationLevelTypes = map[string]NotificationLevelValue{ // NotificationLevel is a helper routine that allocates a new NotificationLevelValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue { - p := new(NotificationLevelValue) - *p = v - return p + return Ptr(v) } // ProjectCreationLevelValue represents a project creation level within GitLab. @@ -588,10 +583,9 @@ const ( // ProjectCreationLevel is a helper routine that allocates a new ProjectCreationLevelValue // to store v and returns a pointer to it. +// Please use Ptr instead. func ProjectCreationLevel(v ProjectCreationLevelValue) *ProjectCreationLevelValue { - p := new(ProjectCreationLevelValue) - *p = v - return p + return Ptr(v) } // SharedRunnersSettingValue determines whether shared runners are enabled for a @@ -616,10 +610,9 @@ const ( // SharedRunnersSetting is a helper routine that allocates a new SharedRunnersSettingValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func SharedRunnersSetting(v SharedRunnersSettingValue) *SharedRunnersSettingValue { - p := new(SharedRunnersSettingValue) - *p = v - return p + return Ptr(v) } // SubGroupCreationLevelValue represents a sub group creation level within GitLab. @@ -637,10 +630,9 @@ const ( // SubGroupCreationLevel is a helper routine that allocates a new SubGroupCreationLevelValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func SubGroupCreationLevel(v SubGroupCreationLevelValue) *SubGroupCreationLevelValue { - p := new(SubGroupCreationLevelValue) - *p = v - return p + return Ptr(v) } // SquashOptionValue represents a squash optional level within GitLab. @@ -660,10 +652,9 @@ const ( // SquashOption is a helper routine that allocates a new SquashOptionValue // to store s and returns a pointer to it. +// Deprecated: Please use Ptr instead. func SquashOption(s SquashOptionValue) *SquashOptionValue { - p := new(SquashOptionValue) - *p = s - return p + return Ptr(s) } // TasksCompletionStatus represents tasks of the issue/merge request. @@ -723,10 +714,9 @@ const ( // VariableType is a helper routine that allocates a new VariableTypeValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func VariableType(v VariableTypeValue) *VariableTypeValue { - p := new(VariableTypeValue) - *p = v - return p + return Ptr(v) } // VisibilityValue represents a visibility level within GitLab. @@ -745,10 +735,9 @@ const ( // Visibility is a helper routine that allocates a new VisibilityValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func Visibility(v VisibilityValue) *VisibilityValue { - p := new(VisibilityValue) - *p = v - return p + return Ptr(v) } // WikiFormatValue represents the available wiki formats. @@ -766,42 +755,37 @@ const ( // WikiFormat is a helper routine that allocates a new WikiFormatValue // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func WikiFormat(v WikiFormatValue) *WikiFormatValue { - p := new(WikiFormatValue) - *p = v - return p + return Ptr(v) } // Bool is a helper routine that allocates a new bool value // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func Bool(v bool) *bool { - p := new(bool) - *p = v - return p + return Ptr(v) } // Int is a helper routine that allocates a new int value // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func Int(v int) *int { - p := new(int) - *p = v - return p + return Ptr(v) } // String is a helper routine that allocates a new string value // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func String(v string) *string { - p := new(string) - *p = v - return p + return Ptr(v) } // Time is a helper routine that allocates a new time.Time value // to store v and returns a pointer to it. +// Deprecated: Please use Ptr instead. func Time(v time.Time) *time.Time { - p := new(time.Time) - *p = v - return p + return Ptr(v) } // BoolValue is a boolean value with advanced json unmarshaling features. diff --git a/users_test.go b/users_test.go index 5525ab7af..2fca55d0c 100644 --- a/users_test.go +++ b/users_test.go @@ -48,7 +48,7 @@ func TestGetUser(t *testing.T) { Name: "John Smith", State: "active", WebURL: "http://localhost:3000/john_smith", - CreatedAt: Time(time.Date(2012, time.May, 23, 8, 0o0, 58, 0, time.UTC)), + CreatedAt: Ptr(time.Date(2012, time.May, 23, 8, 0o0, 58, 0, time.UTC)), Bio: "Bio of John Smith", Location: "USA", PublicEmail: "john@example.com", @@ -87,7 +87,7 @@ func TestGetUserAdmin(t *testing.T) { Name: "John Smith", State: "active", WebURL: "http://localhost:3000/john_smith", - CreatedAt: Time(time.Date(2012, time.May, 23, 8, 0, 58, 0, time.UTC)), + CreatedAt: Ptr(time.Date(2012, time.May, 23, 8, 0, 58, 0, time.UTC)), Bio: "Bio of John Smith", Location: "USA", PublicEmail: "john@example.com", @@ -105,11 +105,11 @@ func TestGetUserAdmin(t *testing.T) { CanCreateGroup: true, CanCreateProject: true, ProjectsLimit: 100, - CurrentSignInAt: Time(time.Date(2012, time.June, 2, 6, 36, 55, 0, time.UTC)), + CurrentSignInAt: Ptr(time.Date(2012, time.June, 2, 6, 36, 55, 0, time.UTC)), CurrentSignInIP: ¤tSignInIP, - LastSignInAt: Time(time.Date(2012, time.June, 1, 11, 41, 1, 0, time.UTC)), + LastSignInAt: Ptr(time.Date(2012, time.June, 1, 11, 41, 1, 0, time.UTC)), LastSignInIP: &lastSignInIP, - ConfirmedAt: Time(time.Date(2012, time.May, 23, 9, 0o5, 22, 0, time.UTC)), + ConfirmedAt: Ptr(time.Date(2012, time.May, 23, 9, 0o5, 22, 0, time.UTC)), TwoFactorEnabled: true, Note: "DMCA Request: 2018-11-05 | DMCA Violation | Abuse | https://gitlab.zendesk.com/agent/tickets/123", Identities: []*UserIdentity{{Provider: "github", ExternUID: "2435223452345"}}, @@ -669,8 +669,8 @@ func TestCreateUserRunner(t *testing.T) { }) createRunnerOpts := &CreateUserRunnerOptions{ - ProjectID: Int(1), - RunnerType: String("project_type"), + ProjectID: Ptr(1), + RunnerType: Ptr("project_type"), } response, _, err := client.Users.CreateUserRunner(createRunnerOpts) diff --git a/validate_test.go b/validate_test.go index 55e9d6205..ab4bfc350 100644 --- a/validate_test.go +++ b/validate_test.go @@ -163,10 +163,10 @@ func TestValidateProjectNamespace(t *testing.T) { { description: "valid", request: &ProjectNamespaceLintOptions{ - Content: String("{'build': {'script': 'echo build'}}"), - DryRun: Bool(false), - IncludeJobs: Bool(true), - Ref: String("foo"), + Content: Ptr("{'build': {'script': 'echo build'}}"), + DryRun: Ptr(false), + IncludeJobs: Ptr(true), + Ref: Ptr("foo"), }, response: `{ "valid": true, @@ -184,8 +184,8 @@ func TestValidateProjectNamespace(t *testing.T) { { description: "invalid", request: &ProjectNamespaceLintOptions{ - Content: String("{'build': {'script': 'echo build', 'bad_key': 'value'}}"), - DryRun: Bool(false), + Content: Ptr("{'build': {'script': 'echo build', 'bad_key': 'value'}}"), + DryRun: Ptr(false), }, response: `{ "valid": false, diff --git a/wikis_test.go b/wikis_test.go index e3922160f..3bfe51ca6 100644 --- a/wikis_test.go +++ b/wikis_test.go @@ -49,7 +49,7 @@ func TestListWikis(t *testing.T) { ]`) }) - wikis, _, err := client.Wikis.ListWikis(1, &ListWikisOptions{WithContent: Bool(true)}) + wikis, _, err := client.Wikis.ListWikis(1, &ListWikisOptions{WithContent: Ptr(true)}) if err != nil { t.Errorf("Wikis.ListWikis returned error: %v", err) } @@ -126,9 +126,9 @@ func TestCreateWikiPage(t *testing.T) { }) opt := &CreateWikiPageOptions{ - Content: String("Hello world"), - Title: String("Hello"), - Format: WikiFormat(WikiFormatMarkdown), + Content: Ptr("Hello world"), + Title: Ptr("Hello"), + Format: Ptr(WikiFormatMarkdown), } wiki, _, err := client.Wikis.CreateWikiPage(1, opt) if err != nil { @@ -161,9 +161,9 @@ func TestEditWikiPage(t *testing.T) { }) opt := &EditWikiPageOptions{ - Content: String("documentation"), - Format: WikiFormat(WikiFormatMarkdown), - Title: String("Docs"), + Content: Ptr("documentation"), + Format: Ptr(WikiFormatMarkdown), + Title: Ptr("Docs"), } wiki, _, err := client.Wikis.EditWikiPage(1, "foo", opt) if err != nil { From ce857a2572da9867163027cbb9fc854de61145e5 Mon Sep 17 00:00:00 2001 From: Tobias Germer Date: Tue, 5 Sep 2023 00:30:08 +0200 Subject: [PATCH 2/4] update readme examples --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1652705af..305871517 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ to list all projects for user "svanharmelen": ```go git := gitlab.NewClient("yourtokengoeshere") -opt := &gitlab.ListProjectsOptions{Search: gitlab.String("svanharmelen")} +opt := &gitlab.ListProjectsOptions{Search: gitlab.Ptr("svanharmelen")} projects, _, err := git.Projects.ListProjects(opt) ``` @@ -159,11 +159,11 @@ func main() { // Create new project p := &gitlab.CreateProjectOptions{ - Name: gitlab.String("My Project"), - Description: gitlab.String("Just a test project to play with"), - MergeRequestsEnabled: gitlab.Bool(true), - SnippetsEnabled: gitlab.Bool(true), - Visibility: gitlab.Visibility(gitlab.PublicVisibility), + Name: gitlab.Ptr("My Project"), + Description: gitlab.Ptr("Just a test project to play with"), + MergeRequestsEnabled: gitlab.Ptr(true), + SnippetsEnabled: gitlab.Ptr(true), + Visibility: gitlab.Ptr(gitlab.PublicVisibility), } project, _, err := git.Projects.CreateProject(p) if err != nil { @@ -172,10 +172,10 @@ func main() { // Add a new snippet s := &gitlab.CreateProjectSnippetOptions{ - Title: gitlab.String("Dummy Snippet"), - FileName: gitlab.String("snippet.go"), - Content: gitlab.String("package main...."), - Visibility: gitlab.Visibility(gitlab.PublicVisibility), + Title: gitlab.Ptr("Dummy Snippet"), + FileName: gitlab.Ptr("snippet.go"), + Content: gitlab.Ptr("package main...."), + Visibility: gitlab.Ptr(gitlab.PublicVisibility), } _, _, err = git.ProjectSnippets.CreateSnippet(project.ID, s) if err != nil { From 2bf8cd2ee2c748b055f6f65a9cca26481d42bcdf Mon Sep 17 00:00:00 2001 From: Tobias Germer Date: Tue, 5 Sep 2023 00:34:15 +0200 Subject: [PATCH 3/4] update deprecation docs --- types.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/types.go b/types.go index 5eb6490c3..40af20a8e 100644 --- a/types.go +++ b/types.go @@ -52,6 +52,7 @@ const ( // AccessControl is a helper routine that allocates a new AccessControlValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func AccessControl(v AccessControlValue) *AccessControlValue { return Ptr(v) @@ -83,6 +84,7 @@ const ( // AccessLevel is a helper routine that allocates a new AccessLevelValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func AccessLevel(v AccessLevelValue) *AccessLevelValue { return Ptr(v) @@ -223,6 +225,7 @@ const ( // Availability is a helper routine that allocates a new AvailabilityValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func Availability(v AvailabilityValue) *AvailabilityValue { return Ptr(v) @@ -248,6 +251,7 @@ const ( // BuildState is a helper routine that allocates a new BuildStateValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func BuildState(v BuildStateValue) *BuildStateValue { return Ptr(v) @@ -267,6 +271,7 @@ const ( // DeploymentStatus is a helper routine that allocates a new // DeploymentStatusValue to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func DeploymentStatus(v DeploymentStatusValue) *DeploymentStatusValue { return Ptr(v) @@ -324,6 +329,7 @@ const ( // FileAction is a helper routine that allocates a new FileActionValue value // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func FileAction(v FileActionValue) *FileActionValue { return Ptr(v) @@ -339,6 +345,7 @@ const ( // GenericPackageSelect is a helper routine that allocates a new // GenericPackageSelectValue value to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func GenericPackageSelect(v GenericPackageSelectValue) *GenericPackageSelectValue { return Ptr(v) @@ -355,6 +362,7 @@ const ( // GenericPackageStatus is a helper routine that allocates a new // GenericPackageStatusValue value to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func GenericPackageStatus(v GenericPackageStatusValue) *GenericPackageStatusValue { return Ptr(v) @@ -434,6 +442,7 @@ const ( // LinkType is a helper routine that allocates a new LinkType value // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func LinkType(v LinkTypeValue) *LinkTypeValue { return Ptr(v) @@ -454,6 +463,7 @@ const ( // LicenseApprovalStatus is a helper routine that allocates a new license // approval status value to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func LicenseApprovalStatus(v LicenseApprovalStatusValue) *LicenseApprovalStatusValue { return Ptr(v) @@ -475,6 +485,7 @@ const ( // MergeMethod is a helper routine that allocates a new MergeMethod // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func MergeMethod(v MergeMethodValue) *MergeMethodValue { return Ptr(v) @@ -493,6 +504,7 @@ const ( // NoteType is a helper routine that allocates a new NoteTypeValue to // store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func NoteType(v NoteTypeValue) *NoteTypeValue { return Ptr(v) @@ -562,6 +574,7 @@ var notificationLevelTypes = map[string]NotificationLevelValue{ // NotificationLevel is a helper routine that allocates a new NotificationLevelValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue { return Ptr(v) @@ -610,6 +623,7 @@ const ( // SharedRunnersSetting is a helper routine that allocates a new SharedRunnersSettingValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func SharedRunnersSetting(v SharedRunnersSettingValue) *SharedRunnersSettingValue { return Ptr(v) @@ -630,6 +644,7 @@ const ( // SubGroupCreationLevel is a helper routine that allocates a new SubGroupCreationLevelValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func SubGroupCreationLevel(v SubGroupCreationLevelValue) *SubGroupCreationLevelValue { return Ptr(v) @@ -652,6 +667,7 @@ const ( // SquashOption is a helper routine that allocates a new SquashOptionValue // to store s and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func SquashOption(s SquashOptionValue) *SquashOptionValue { return Ptr(s) @@ -714,6 +730,7 @@ const ( // VariableType is a helper routine that allocates a new VariableTypeValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func VariableType(v VariableTypeValue) *VariableTypeValue { return Ptr(v) @@ -735,6 +752,7 @@ const ( // Visibility is a helper routine that allocates a new VisibilityValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func Visibility(v VisibilityValue) *VisibilityValue { return Ptr(v) @@ -755,6 +773,7 @@ const ( // WikiFormat is a helper routine that allocates a new WikiFormatValue // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func WikiFormat(v WikiFormatValue) *WikiFormatValue { return Ptr(v) @@ -762,6 +781,7 @@ func WikiFormat(v WikiFormatValue) *WikiFormatValue { // Bool is a helper routine that allocates a new bool value // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func Bool(v bool) *bool { return Ptr(v) @@ -769,6 +789,7 @@ func Bool(v bool) *bool { // Int is a helper routine that allocates a new int value // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func Int(v int) *int { return Ptr(v) @@ -776,6 +797,7 @@ func Int(v int) *int { // String is a helper routine that allocates a new string value // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func String(v string) *string { return Ptr(v) @@ -783,6 +805,7 @@ func String(v string) *string { // Time is a helper routine that allocates a new time.Time value // to store v and returns a pointer to it. +// // Deprecated: Please use Ptr instead. func Time(v time.Time) *time.Time { return Ptr(v) From 664c0acc489bceb9d34cde5285c044f788d1d11f Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Mon, 13 Nov 2023 10:01:40 +0100 Subject: [PATCH 4/4] Simplify the Ptr func --- types.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/types.go b/types.go index 40af20a8e..d737aec99 100644 --- a/types.go +++ b/types.go @@ -26,12 +26,9 @@ import ( "time" ) -// Ptr is a helper routine that allocates a new T -// to store t and returns a pointer to it. -func Ptr[T any](t T) *T { - p := new(T) - *p = t - return p +// Ptr is a helper returns a pointer to v. +func Ptr[T any](v T) *T { + return &v } // AccessControlValue represents an access control value within GitLab,