Skip to content

Commit 03cec63

Browse files
committed
pr feedback
1 parent f473264 commit 03cec63

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

cmd/kots/cli/install.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,10 @@ func InstallCmd() *cobra.Command {
163163
}()
164164

165165
upstream := pull.RewriteUpstream(args[0])
166-
preferredChannelSlug, err := extractPreferredChannelSlug(upstream)
166+
preferredChannelSlug, err := extractPreferredChannelSlug(log, upstream)
167167
if err != nil {
168168
return errors.Wrap(err, "failed to extract preferred channel slug")
169169
}
170-
if preferredChannelSlug == "" {
171-
preferredChannelSlug = "stable"
172-
log.ActionWithoutSpinner(fmt.Sprintf("No channel specified in upstream URI, falling back to channel %q.", preferredChannelSlug))
173-
}
174170

175171
license, err = kotslicense.VerifyAndUpdateLicense(log, license, preferredChannelSlug, isAirgap)
176172
if err != nil {

cmd/kots/cli/pull.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cli
22

33
import (
4-
"fmt"
54
"os"
65
"path"
76
"strings"
@@ -106,16 +105,11 @@ func PullCmd() *cobra.Command {
106105
log := logger.NewCLILogger(cmd.OutOrStdout())
107106
log.Initialize()
108107

109-
preferredChannelSlug, err := extractPreferredChannelSlug(upstream)
108+
preferredChannelSlug, err := extractPreferredChannelSlug(log, upstream)
110109
if err != nil {
111110
return errors.Wrap(err, "failed to extract preferred channel slug")
112111
}
113112

114-
if preferredChannelSlug == "" {
115-
preferredChannelSlug = "stable"
116-
log.ActionWithoutSpinner(fmt.Sprintf("No channel specified in upstream URI, falling back to channel %q.", preferredChannelSlug))
117-
}
118-
119113
// If we are passed a multi-channel license, verify that the requested channel is in the license
120114
// so that we can warn the user immediately if it is not.
121115
license, err = kotslicense.VerifyAndUpdateLicense(log, license, preferredChannelSlug, false)

cmd/kots/cli/util.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88

99
"github.com/pkg/errors"
10+
"github.com/replicatedhq/kots/pkg/logger"
1011
"github.com/replicatedhq/kots/pkg/replicatedapp"
1112
"github.com/replicatedhq/kots/pkg/util"
1213
)
@@ -53,7 +54,7 @@ func splitEndpointAndNamespace(endpoint string) (string, string) {
5354
return registryEndpoint, registryNamespace
5455
}
5556

56-
func extractPreferredChannelSlug(upstreamURI string) (string, error) {
57+
func extractPreferredChannelSlug(log *logger.CLILogger, upstreamURI string) (string, error) {
5758
u, err := url.ParseRequestURI(upstreamURI)
5859
if err != nil {
5960
return "", errors.Wrap(err, "failed to parse uri")
@@ -67,5 +68,9 @@ func extractPreferredChannelSlug(upstreamURI string) (string, error) {
6768
if replicatedUpstream.Channel != nil {
6869
return *replicatedUpstream.Channel, nil
6970
}
70-
return "", nil
71+
72+
if log != nil {
73+
log.ActionWithoutSpinner("No channel specified in upstream URI, falling back to channel slug 'stable.")
74+
}
75+
return "stable", nil
7176
}

cmd/kots/cli/util_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func Test_extractPreferredChannelSlug(t *testing.T) {
111111
args{
112112
upstreamURI: "replicated://app-slug",
113113
},
114-
"",
114+
"stable",
115115
false,
116116
},
117117
{
@@ -133,7 +133,7 @@ func Test_extractPreferredChannelSlug(t *testing.T) {
133133
}
134134
for _, tt := range tests {
135135
t.Run(tt.name, func(t *testing.T) {
136-
got, err := extractPreferredChannelSlug(tt.args.upstreamURI)
136+
got, err := extractPreferredChannelSlug(nil, tt.args.upstreamURI)
137137
if (err != nil) != tt.wantErr {
138138
t.Errorf("extractPreferredChannelSlug() error = %v, wantErr %v", err, tt.wantErr)
139139
return

0 commit comments

Comments
 (0)