Skip to content

Commit 48134e7

Browse files
authored
kondo-ing the cli (#70)
* kondo-ing the cli; removing some redundant functions
1 parent 1f033db commit 48134e7

20 files changed

+42
-116
lines changed

cli/cmd/channel_adoption.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ func (r *runners) channelAdoption(cmd *cobra.Command, args []string) error {
2424
}
2525
chanID := args[0]
2626

27-
appType, err := r.api.GetAppType(r.appID)
28-
if err != nil {
29-
return err
30-
}
31-
32-
if appType == "platform" {
27+
if r.appType == "platform" {
3328
appChan, _, err := r.platformAPI.GetChannel(r.appID, chanID)
3429
if err != nil {
3530
return err
@@ -39,9 +34,9 @@ func (r *runners) channelAdoption(cmd *cobra.Command, args []string) error {
3934
return err
4035
}
4136

42-
} else if appType == "ship" {
37+
} else if r.appType == "ship" {
4338
return errors.New("This feature is not supported for Ship applications.")
44-
} else if appType == "kots" {
39+
} else if r.appType == "kots" {
4540
return errors.New("This feature is not supported for Kots applications.")
4641
}
4742

cli/cmd/channel_counts.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,18 @@ func (r *runners) channelCounts(cmd *cobra.Command, args []string) error {
2424
}
2525
chanID := args[0]
2626

27-
appType, err := r.api.GetAppType(r.appID)
28-
if err != nil {
29-
return err
30-
}
31-
32-
if appType == "platform" {
33-
appChan, _, err := r.api.GetChannel(r.appID, chanID)
27+
if r.appType == "platform" {
28+
appChan, _, err := r.api.GetChannel(r.appID, r.appType, chanID)
3429
if err != nil {
3530
return err
3631
}
3732

3833
if err = print.LicenseCounts(r.w, appChan.LicenseCounts); err != nil {
3934
return err
4035
}
41-
} else if appType == "ship" {
36+
} else if r.appType == "ship" {
4237
return errors.New("This feature is not supported for Ship applications.")
43-
} else if appType == "kots" {
38+
} else if r.appType == "kots" {
4439
return errors.New("This feature is not supported for Kots applications.")
4540
}
4641

cli/cmd/channel_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (r *runners) InitChannelCreate(parent *cobra.Command) {
2424
}
2525

2626
func (r *runners) channelCreate(cmd *cobra.Command, args []string) error {
27-
allChannels, err := r.api.CreateChannel(r.appID, r.args.channelCreateName, r.args.channelCreateDescription)
27+
allChannels, err := r.api.CreateChannel(r.appID, r.appType, r.args.channelCreateName, r.args.channelCreateDescription)
2828
if err != nil {
2929
return err
3030
}

cli/cmd/channel_inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (r *runners) channelInspect(cmd *cobra.Command, args []string) error {
2525
}
2626
chanID := args[0]
2727

28-
appChan, _, err := r.api.GetChannel(r.appID, chanID)
28+
appChan, _, err := r.api.GetChannel(r.appID, r.appType, chanID)
2929
if err != nil {
3030
return err
3131
}

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)
20+
channels, err := r.api.ListChannels(r.appID, r.appType)
2121
if err != nil {
2222
return err
2323
}

cli/cmd/channel_releases.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,19 @@ func (r *runners) channelReleases(cmd *cobra.Command, args []string) error {
2424
}
2525
chanID := args[0]
2626

27-
appType, err := r.api.GetAppType(r.appID)
28-
if err != nil {
29-
return err
30-
}
31-
32-
if appType == "platform" {
27+
if r.appType == "platform" {
3328

34-
_, releases, err := r.api.GetChannel(r.appID, chanID)
29+
_, releases, err := r.api.GetChannel(r.appID, r.appType, chanID)
3530
if err != nil {
3631
return err
3732
}
3833

3934
if err = print.ChannelReleases(r.w, releases); err != nil {
4035
return err
4136
}
42-
} else if appType == "ship" {
37+
} else if r.appType == "ship" {
4338
return errors.New("This feature is not supported for Ship applications.")
44-
} else if appType == "kots" {
39+
} else if r.appType == "kots" {
4540
return errors.New("This feature is not supported for Kots applications.")
4641
}
4742

cli/cmd/channel_rm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (r *runners) channelRemove(cmd *cobra.Command, args []string) error {
2424
}
2525
chanID := args[0]
2626

27-
if err := r.api.ArchiveChannel(r.appID, chanID); err != nil {
27+
if err := r.api.ArchiveChannel(r.appID, r.appType, chanID); err != nil {
2828
return err
2929
}
3030

cli/cmd/collector_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (r *runners) collectorCreate(cmd *cobra.Command, args []string) error {
5353
r.args.createCollectorYaml = string(bytes)
5454
}
5555

56-
_, err := r.api.CreateCollector(r.appID, r.args.createCollectorName, r.args.createCollectorYaml)
56+
_, err := r.api.CreateCollector(r.appID, r.appType, r.args.createCollectorName, r.args.createCollectorYaml)
5757
if err != nil {
5858
return err
5959
}

cli/cmd/collector_ls.go

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

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

cli/cmd/entitlements_definefields.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (r *runners) entitlementsDefineFields(cmd *cobra.Command, args []string) er
3131
return err
3232
}
3333

34-
definitions, err := r.api.CreateEntitlementSpec(r.args.entitlementsDefineFieldsName, string(spec), r.appID)
34+
definitions, err := r.api.CreateEntitlementSpec(r.appID, r.appType, r.args.entitlementsDefineFieldsName, string(spec))
3535
if err != nil {
3636
return errors.Wrap(err, "create definitions")
3737
}

0 commit comments

Comments
 (0)