Skip to content

Commit 6e9d03f

Browse files
committed
Don't list all channels when making a kots release
1 parent 9e8c21a commit 6e9d03f

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

cli/cmd/channel_ls.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func (r *runners) InitChannelList(parent *cobra.Command) {
1717
}
1818

1919
func (r *runners) channelList(cmd *cobra.Command, args []string) error {
20-
channels, err := r.api.ListChannels(r.appID, r.appType, r.appSlug)
20+
channels, err := r.api.ListChannels(r.appID, r.appType, r.appSlug, "")
2121
if err != nil {
2222
return err
2323
}

cli/cmd/root.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package cmd
22

33
import (
4-
"github.com/pkg/errors"
54
"io"
65
"os"
76
"path/filepath"
87
"text/tabwriter"
98

9+
"github.com/pkg/errors"
10+
1011
"github.com/replicatedhq/replicated/pkg/kotsclient"
1112
"github.com/replicatedhq/replicated/pkg/shipclient"
1213

@@ -46,6 +47,11 @@ func init() {
4647
if enterpriseOriginFromEnv != "" {
4748
enterpriseOrigin = enterpriseOriginFromEnv
4849
}
50+
51+
graphqlOriginFromEnv := os.Getenv("REPLICATED_GRAPHQL_ORIGIN")
52+
if graphqlOriginFromEnv != "" {
53+
graphqlOrigin = graphqlOriginFromEnv
54+
}
4955
}
5056

5157
// RootCmd represents the base command when called without any subcommands

client/channel.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package client
22

33
import (
44
"fmt"
5+
56
"github.com/pkg/errors"
67

78
channels "github.com/replicatedhq/replicated/gen/go/v1"
89
"github.com/replicatedhq/replicated/pkg/types"
910
)
1011

11-
func (c *Client) ListChannels(appID string, appType string, appSlug string) ([]types.Channel, error) {
12+
func (c *Client) ListChannels(appID string, appType string, appSlug string, channelName string) ([]types.Channel, error) {
1213

1314
if appType == "platform" {
1415
platformChannels, err := c.PlatformClient.ListChannels(appID)
@@ -33,7 +34,7 @@ func (c *Client) ListChannels(appID string, appType string, appSlug string) ([]t
3334
} else if appType == "ship" {
3435
return c.ShipClient.ListChannels(appID)
3536
} else if appType == "kots" {
36-
return c.KotsHTTPClient.ListChannels(appID, appSlug)
37+
return c.KotsHTTPClient.ListChannels(appID, appSlug, channelName)
3738
}
3839

3940
return nil, errors.New("unknown app type")
@@ -71,7 +72,7 @@ func (c *Client) CreateChannel(appID string, appType string, appSlug string, nam
7172
if err := c.PlatformClient.CreateChannel(appID, name, description); err != nil {
7273
return nil, err
7374
}
74-
return c.ListChannels(appID, appType, appSlug)
75+
return c.ListChannels(appID, appType, appSlug, name)
7576
} else if appType == "ship" {
7677
if _, err := c.ShipClient.CreateChannel(appID, name, description); err != nil {
7778
return nil, err
@@ -81,14 +82,14 @@ func (c *Client) CreateChannel(appID string, appType string, appSlug string, nam
8182
if _, err := c.KotsClient.CreateChannel(appID, name, description); err != nil {
8283
return nil, err
8384
}
84-
return c.KotsHTTPClient.ListChannels(appID, appSlug)
85+
return c.KotsHTTPClient.ListChannels(appID, appSlug, name)
8586
}
8687

8788
return nil, errors.New("unknown app type")
8889
}
8990

9091
func (c *Client) GetOrCreateChannelByName(appID string, appType string, appSlug string, name string, description string, createIfAbsent bool) (*types.Channel, error) {
91-
allChannels, err := c.ListChannels(appID, appType, appSlug)
92+
allChannels, err := c.ListChannels(appID, appType, appSlug, name)
9293
if err != nil {
9394
return nil, err
9495
}

pkg/kotsclient/channel.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ package kotsclient
22

33
import (
44
"fmt"
5+
"net/http"
6+
"net/url"
7+
"os"
8+
59
"github.com/pkg/errors"
610
channels "github.com/replicatedhq/replicated/gen/go/v1"
711
"github.com/replicatedhq/replicated/pkg/graphql"
812
"github.com/replicatedhq/replicated/pkg/types"
9-
"net/http"
10-
"os"
1113
)
1214

1315
type GraphQLResponseGetChannel struct {
@@ -94,9 +96,13 @@ type ListChannelsResponse struct {
9496
Channels []*KotsChannel `json:"channels"`
9597
}
9698

97-
func (c *VendorV3Client) ListChannels(appID string, appSlug string) ([]types.Channel, error) {
99+
func (c *VendorV3Client) ListChannels(appID string, appSlug string, channelName string) ([]types.Channel, error) {
98100
var response = ListChannelsResponse{}
99-
url := fmt.Sprintf("/v3/app/%s/channels", appID)
101+
102+
v := url.Values{}
103+
v.Set("channelName", channelName)
104+
105+
url := fmt.Sprintf("/v3/app/%s/channels?%s", appID, v.Encode())
100106
err := c.DoJSON("GET", url, http.StatusOK, nil, &response)
101107
if err != nil {
102108
return nil, errors.Wrap(err, "list channels")

0 commit comments

Comments
 (0)