Repository: xanzy/go-gitlab
Pull request #624 (2019-05-17 13:49:29)

add "managed" flag for toggling managed clusters during create
The gitlab api now has a ["managed"](https://docs.gitlab.com/ee/api/project_clusters.html#add-existing-cluster-to-project) field to disable cluster management features when adding a kubernetes cluster.  Disabling this allows you to specify an unprivileged, namespace-scoped token to gitlab, to avoid granting it cluster admin. This implements that field. Default is true if you don't supply it.

Existing testing doesn't seem to cover stuff at the property-level, so I didn't implement it. Since it defaults to true if the field isn't sent, this _shouldn't_ affect anything else.


Patch:
diff --git a/pipeline_schedules.go b/pipeline_schedules.go
index 3790ea3..a3b5986 100644
--- a/pipeline_schedules.go
+++ b/pipeline_schedules.go
@@ -227,6 +227,11 @@ func (s *PipelineSchedulesService) DeletePipelineSchedule(pid interface{}, sched
 		return nil, err
 	}
 
+	req, err = s.client.NewRequest("DELETE", u, nil, options)
+	if err != nil {
+		return nil, err
+	}
+
 	return s.client.Do(req, nil)
 }
 
diff --git a/project_clusters.go b/project_clusters.go
index 0ae822e..d2be60e 100644
--- a/project_clusters.go
+++ b/project_clusters.go
@@ -118,6 +118,7 @@ type AddClusterOptions struct {
 	Name               *string                       `url:"name,omitempty" json:"name,omitempty"`
 	Domain             *string                       `url:"domain,omitempty" json:"domain,omitempty"`
 	Enabled            *bool                         `url:"enabled,omitempty" json:"enabled,omitempty"`
+	Managed            *bool                         `url:"managed,omitempty" json:"managed,omitempty"`
 	EnvironmentScope   *string                       `url:"environment_scope,omitempty" json:"environment_scope,omitempty"`
 	PlatformKubernetes *AddPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"`
 }
diff --git a/services.go b/services.go
index bb51e20..2ee8450 100644
--- a/services.go
+++ b/services.go
@@ -261,20 +261,20 @@ type SlackServiceProperties struct {
 	// We need to handle this, until the bug will be fixed.
 	// Ref: https://gitlab.com/gitlab-org/gitlab-ce/issues/50122
 
-	NotifyOnlyBrokenPipelines BoolValue `json:"notify_only_broken_pipelines,omitempty"`
-	NotifyOnlyDefaultBranch   BoolValue `json:"notify_only_default_branch,omitempty"`
-	WebHook                   string    `json:"webhook,omitempty"`
-	Username                  string    `json:"username,omitempty"`
-	Channel                   string    `json:"channel,omitempty"`
-	PushChannel               string    `json:"push_channel,omitempty"`
-	IssueChannel              string    `json:"issue_channel,omitempty"`
-	ConfidentialIssueChannel  string    `json:"confidential_issue_channel,omitempty"`
-	MergeRequestChannel       string    `json:"merge_request_channel,omitempty"`
-	NoteChannel               string    `json:"note_channel,omitempty"`
-	ConfidentialNoteChannel   string    `json:"confidential_note_channel,omitempty"`
-	TagPushChannel            string    `json:"tag_push_channel,omitempty"`
-	PipelineChannel           string    `json:"pipeline_channel,omitempty"`
-	WikiPageChannel           string    `json:"wiki_page_channel,omitempty"`
+	NotifyOnlyBrokenPipelines BoolValue `url:"notify_only_broken_pipelines,omitempty" json:"notify_only_broken_pipelines,omitempty"`
+	NotifyOnlyDefaultBranch   BoolValue `url:"notify_only_default_branch,omitempty" json:"notify_only_default_branch,omitempty"`
+	WebHook                   string    `url:"webhook,omitempty" json:"webhook,omitempty"`
+	Username                  string    `url:"username,omitempty" json:"username,omitempty"`
+	Channel                   string    `url:"channel,omitempty" json:"channel,omitempty"`
+	PushChannel               string    `url:"push_channel,omitempty" json:"push_channel,omitempty"`
+	IssueChannel              string    `url:"issue_channel,omitempty" json:"issue_channel,omitempty"`
+	ConfidentialIssueChannel  string    `url:"confidential_issue_channel,omitempty" json:"confidential_issue_channel,omitempty"`
+	MergeRequestChannel       string    `url:"merge_request_channel,omitempty" json:"merge_request_channel,omitempty"`
+	NoteChannel               string    `url:"note_channel,omitempty" json:"note_channel,omitempty"`
+	ConfidentialNoteChannel   string    `url:"confidential_note_channel,omitempty" json:"confidential_note_channel,omitempty"`
+	TagPushChannel            string    `url:"tag_push_channel,omitempty" json:"tag_push_channel,omitempty"`
+	PipelineChannel           string    `url:"pipeline_channel,omitempty" json:"pipeline_channel,omitempty"`
+	WikiPageChannel           string    `url:"wiki_page_channel,omitempty" json:"wiki_page_channel,omitempty"`
 }
 
 // GetSlackService gets Slack service settings for a project.
@@ -388,12 +388,12 @@ type JiraService struct {
 // GitLab API docs:
 // https://docs.gitlab.com/ce/api/services.html#jira
 type JiraServiceProperties struct {
-	URL                   string `json:"url,omitempty"`
-	APIURL                string `json:"api_url,omitempty"`
-	ProjectKey            string `json:"project_key,omitempty" `
-	Username              string `json:"username,omitempty" `
-	Password              string `json:"password,omitempty" `
-	JiraIssueTransitionID string `json:"jira_issue_transition_id,omitempty"`
+	URL                   *string `url:"url,omitempty" json:"url,omitempty"`
+	APIURL                *string `url:"api_url,omitempty" json:"api_url,omitempty"`
+	ProjectKey            *string `url:"project_key,omitempty" json:"project_key,omitempty" `
+	Username              *string `url:"username,omitempty" json:"username,omitempty" `
+	Password              *string `url:"password,omitempty" json:"password,omitempty" `
+	JiraIssueTransitionID *int    `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"`
 }
 
 // GetJiraService gets Jira service settings for a project.
@@ -426,14 +426,7 @@ func (s *ServicesService) GetJiraService(pid interface{}, options ...OptionFunc)
 //
 // GitLab API docs:
 // https://docs.gitlab.com/ce/api/services.html#edit-jira-service
-type SetJiraServiceOptions struct {
-	URL                   *string `url:"url,omitempty" json:"url,omitempty"`
-	APIURL                *string `url:"api_url,omitempty" json:"api_url,omitempty"`
-	ProjectKey            *string `url:"project_key,omitempty" json:"project_key,omitempty" `
-	Username              *string `url:"username,omitempty" json:"username,omitempty" `
-	Password              *string `url:"password,omitempty" json:"password,omitempty" `
-	JiraIssueTransitionID *string `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"`
-}
+type SetJiraServiceOptions JiraServiceProperties
 
 // SetJiraService sets Jira service for a project
 //
@@ -487,9 +480,9 @@ type JenkinsCIService struct {
 // GitLab API docs:
 // https://docs.gitlab.com/ee/api/services.html#jenkins-ci
 type JenkinsCIServiceProperties struct {
-	URL         string `json:"jenkins_url,omitempty"`
-	ProjectName string `json:"project_name,omitempty"`
-	Username    string `json:"username,omitempty"`
+	URL         *string `url:"jenkins_url,omitempty" json:"jenkins_url,omitempty"`
+	ProjectName *string `url:"project_name,omitempty" json:"project_name,omitempty"`
+	Username    *string `url:"username,omitempty" json:"username,omitempty"`
 }
 
 // GetJenkinsCIService gets Jenkins CI service settings for a project.


Test patch:
diff --git a/services_test.go b/services_test.go
index 5754701..1af67c1 100644
--- a/services_test.go
+++ b/services_test.go
@@ -142,7 +142,7 @@ func TestSetJiraService(t *testing.T) {
 		ProjectKey:            String("as"),
 		Username:              String("aas"),
 		Password:              String("asd"),
-		JiraIssueTransitionID: String("2"),
+		JiraIssueTransitionID: Int(2),
 	}
 
 	_, err := client.Services.SetJiraService(1, opt)