From f2af0edc05cf3a6c111fc8b320705aa001e0f5a4 Mon Sep 17 00:00:00 2001 From: Brandon WELSCH Date: Wed, 4 Sep 2019 11:26:02 +0200 Subject: [PATCH 1/2] Removed `source`, `auth_integration_uuid` and `scm_integration_uuid` for update call --- scm_repo_link.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scm_repo_link.go b/scm_repo_link.go index 467933f0..88e40d15 100644 --- a/scm_repo_link.go +++ b/scm_repo_link.go @@ -10,8 +10,8 @@ import ( type SCMRepoLinkService interface { SCMRepoLinkShow(app string) (*SCMRepoLink, error) - SCMRepoLinkCreate(app string, params SCMRepoLinkParams) (*SCMRepoLink, error) - SCMRepoLinkUpdate(app string, params SCMRepoLinkParams) (*SCMRepoLink, error) + SCMRepoLinkCreate(app string, params SCMRepoLinkCreateParams) (*SCMRepoLink, error) + SCMRepoLinkUpdate(app string, params SCMRepoLinkUpdateParams) (*SCMRepoLink, error) SCMRepoLinkDelete(app string) error SCMRepoLinkManualDeploy(app, branch string) error @@ -20,7 +20,7 @@ type SCMRepoLinkService interface { SCMRepoLinkReviewApps(app string) ([]*ReviewApp, error) } -type SCMRepoLinkParams struct { +type SCMRepoLinkCreateParams struct { Source *string `json:"source,omitempty"` Branch *string `json:"branch,omitempty"` AuthIntegrationUUID *string `json:"auth_integration_uuid,omitempty"` @@ -33,6 +33,16 @@ type SCMRepoLinkParams struct { HoursBeforeDeleteStale *uint `json:"hours_before_delete_stale,omitempty"` } +type SCMRepoLinkUpdateParams struct { + Branch *string `json:"branch,omitempty"` + AutoDeployEnabled *bool `json:"auto_deploy_enabled,omitempty"` + DeployReviewAppsEnabled *bool `json:"deploy_review_apps_enabled,omitempty"` + DestroyOnCloseEnabled *bool `json:"delete_on_close_enabled,omitempty"` + HoursBeforeDeleteOnClose *uint `json:"hours_before_delete_on_close,omitempty"` + DestroyStaleEnabled *bool `json:"delete_stale_enabled,omitempty"` + HoursBeforeDeleteStale *uint `json:"hours_before_delete_stale,omitempty"` +} + type SCMRepoLink struct { ID string `json:"id"` AppID string `json:"app_id"` @@ -86,13 +96,13 @@ func (c *Client) SCMRepoLinkShow(app string) (*SCMRepoLink, error) { return res.SCMRepoLink, nil } -func (c *Client) SCMRepoLinkCreate(app string, params SCMRepoLinkParams) (*SCMRepoLink, error) { +func (c *Client) SCMRepoLinkCreate(app string, params SCMRepoLinkCreateParams) (*SCMRepoLink, error) { var res ScmRepoLinkResponse err := c.ScalingoAPI().DoRequest(&http.APIRequest{ Method: "POST", Endpoint: "/apps/" + app + "/scm_repo_link", Expected: http.Statuses{201}, - Params: map[string]SCMRepoLinkParams{"scm_repo_link": params}, + Params: map[string]SCMRepoLinkCreateParams{"scm_repo_link": params}, }, &res) if err != nil { return nil, errgo.Notef(err, "fail to create the SCM repo link") @@ -101,13 +111,13 @@ func (c *Client) SCMRepoLinkCreate(app string, params SCMRepoLinkParams) (*SCMRe return res.SCMRepoLink, nil } -func (c *Client) SCMRepoLinkUpdate(app string, params SCMRepoLinkParams) (*SCMRepoLink, error) { +func (c *Client) SCMRepoLinkUpdate(app string, params SCMRepoLinkUpdateParams) (*SCMRepoLink, error) { var res ScmRepoLinkResponse err := c.ScalingoAPI().DoRequest(&http.APIRequest{ Method: "PATCH", Endpoint: "/apps/" + app + "/scm_repo_link", Expected: http.Statuses{200}, - Params: map[string]SCMRepoLinkParams{"scm_repo_link": params}, + Params: map[string]SCMRepoLinkUpdateParams{"scm_repo_link": params}, }, &res) if err != nil { return nil, errgo.Notef(err, "fail to update this SCM repo link") From b40724f4a91cc2f74a752a421e19c9f0b89b64ef Mon Sep 17 00:00:00 2001 From: Brandon WELSCH Date: Wed, 4 Sep 2019 13:33:17 +0200 Subject: [PATCH 2/2] Added changes in CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 654e5848..7d29ee4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## ToBeReleased +* Removed the `SCMRepoLinkParams` struct. You should use `SCMRepoLinkCreateParams` instead for creation call +* Added the `SCMRepoLinkUpdateParams` struct, you should use this for update call. + ## v3.0.3 * Add support (again) for the new SCM events [#135](https://github.com/Scalingo/go-scalingo/pull/135)