From eac91b34cdc6ce00f5cb35a435288b09df05663c Mon Sep 17 00:00:00 2001 From: divolgin Date: Wed, 25 Nov 2020 21:01:42 +0000 Subject: [PATCH] Faster channel list and channel rm for kots apps --- client/channel.go | 2 +- pkg/kotsclient/channel.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/client/channel.go b/client/channel.go index afedcfeed..9c0ce9ad0 100644 --- a/client/channel.go +++ b/client/channel.go @@ -60,7 +60,7 @@ func (c *Client) ArchiveChannel(appID string, appType string, channelID string) } else if appType == "ship" { return errors.New("This feature is not currently supported for Ship applications.") } else if appType == "kots" { - return errors.New("This feature is not currently supported for Kots applications.") + return c.KotsClient.ArchiveChannel(channelID) } return errors.New("unknown app type") diff --git a/pkg/kotsclient/channel.go b/pkg/kotsclient/channel.go index 6e33ea349..e0290f0fa 100644 --- a/pkg/kotsclient/channel.go +++ b/pkg/kotsclient/channel.go @@ -101,6 +101,7 @@ func (c *VendorV3Client) ListChannels(appID string, appSlug string, channelName v := url.Values{} v.Set("channelName", channelName) + v.Set("excludeDetail", "true") url := fmt.Sprintf("/v3/app/%s/channels?%s", appID, v.Encode()) err := c.DoJSON("GET", url, http.StatusOK, nil, &response) @@ -253,3 +254,26 @@ func (c *GraphQLClient) GetChannel(appID string, channelID string) (*channels.Ap } return &channelDetail, nil, nil } + +const archiveKotsChannelMutation = ` +mutation archiveKotsChannel($channelId: ID!) { + archiveKotsChannel(channelId: $channelId) + } +` + +func (c *GraphQLClient) ArchiveChannel(channelId string) error { + response := graphql.ResponseErrorOnly{} + + request := graphql.Request{ + Query: archiveKotsChannelMutation, + Variables: map[string]interface{}{ + "channelId": channelId, + }, + } + + if err := c.ExecuteRequest(request, &response); err != nil { + return err + } + + return nil +}