diff --git a/pkg/kotsclient/channel.go b/pkg/kotsclient/channel.go index 89da4aa8..8c2d0f17 100644 --- a/pkg/kotsclient/channel.go +++ b/pkg/kotsclient/channel.go @@ -93,18 +93,16 @@ func (c *VendorV3Client) ArchiveChannel(appID, channelID string) error { } func (c *VendorV3Client) UpdateSemanticVersioning(appID string, channel *types.Channel, enableSemver bool) error { - request := types.UpdateChannelRequest{ - Name: channel.Name, - SemverRequired: enableSemver, + request := types.PatchChannelRequest{ + SemverRequired: &enableSemver, } - type updateChannelResponse struct { + response := struct { Channel types.KotsChannel `json:"channel"` - } - var response updateChannelResponse + }{} url := fmt.Sprintf("/v3/app/%s/channel/%s", appID, channel.ID) - err := c.DoJSON("PUT", url, http.StatusOK, request, &response) + err := c.DoJSON("PATCH", url, http.StatusOK, request, &response) if err != nil { return errors.Wrap(err, "edit semantic versioning for channel") } diff --git a/pkg/kotsclient/channel_test.go b/pkg/kotsclient/channel_test.go index 70a4b049..8ab4492a 100644 --- a/pkg/kotsclient/channel_test.go +++ b/pkg/kotsclient/channel_test.go @@ -233,14 +233,13 @@ func Test_AddRemoveSemver(t *testing.T) { Given("Add Semver to a KOTS app channel"). UponReceiving("A request to add semver to kots app channel"). WithRequest(dsl.Request{ - Method: "PUT", + Method: "PATCH", Path: dsl.String("/v3/app/replicated-cli-semver-channel-app/channel/replicated-cli-semver-channel-unstable"), Headers: dsl.MapMatcher{ "Authorization": dsl.String("replicated-cli-semver-channel-token"), "Content-Type": dsl.String("application/json"), }, Body: map[string]interface{}{ - "name": "Unstable", "semverRequired": true, }, }). diff --git a/pkg/types/channel.go b/pkg/types/channel.go index a45b63e5..aaa6ff71 100644 --- a/pkg/types/channel.go +++ b/pkg/types/channel.go @@ -86,10 +86,8 @@ type CreateChannelRequest struct { Name string `json:"name"` } -type UpdateChannelRequest struct { - // Description of the channel that is to be created. - Name string `json:"name"` - SemverRequired bool `json:"semverRequired,omitempty"` +type PatchChannelRequest struct { + SemverRequired *bool `json:"semverRequired,omitempty"` } type Channel struct {