Skip to content

Commit

Permalink
Faster channel list and channel rm for kots apps
Browse files Browse the repository at this point in the history
  • Loading branch information
divolgin committed Nov 25, 2020
1 parent 4924e96 commit eac91b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
24 changes: 24 additions & 0 deletions pkg/kotsclient/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit eac91b3

Please sign in to comment.