diff --git a/cli/cmd/channel_adoption.go b/cli/cmd/channel_adoption.go index 20fd62ae7..104b5757e 100644 --- a/cli/cmd/channel_adoption.go +++ b/cli/cmd/channel_adoption.go @@ -24,12 +24,7 @@ func (r *runners) channelAdoption(cmd *cobra.Command, args []string) error { } chanID := args[0] - appType, err := r.api.GetAppType(r.appID) - if err != nil { - return err - } - - if appType == "platform" { + if r.appType == "platform" { appChan, _, err := r.platformAPI.GetChannel(r.appID, chanID) if err != nil { return err @@ -39,9 +34,9 @@ func (r *runners) channelAdoption(cmd *cobra.Command, args []string) error { return err } - } else if appType == "ship" { + } else if r.appType == "ship" { return errors.New("This feature is not supported for Ship applications.") - } else if appType == "kots" { + } else if r.appType == "kots" { return errors.New("This feature is not supported for Kots applications.") } diff --git a/cli/cmd/channel_counts.go b/cli/cmd/channel_counts.go index 2bbd517f0..424c45cad 100644 --- a/cli/cmd/channel_counts.go +++ b/cli/cmd/channel_counts.go @@ -24,13 +24,8 @@ func (r *runners) channelCounts(cmd *cobra.Command, args []string) error { } chanID := args[0] - appType, err := r.api.GetAppType(r.appID) - if err != nil { - return err - } - - if appType == "platform" { - appChan, _, err := r.api.GetChannel(r.appID, chanID) + if r.appType == "platform" { + appChan, _, err := r.api.GetChannel(r.appID, r.appType, chanID) if err != nil { return err } @@ -38,9 +33,9 @@ func (r *runners) channelCounts(cmd *cobra.Command, args []string) error { if err = print.LicenseCounts(r.w, appChan.LicenseCounts); err != nil { return err } - } else if appType == "ship" { + } else if r.appType == "ship" { return errors.New("This feature is not supported for Ship applications.") - } else if appType == "kots" { + } else if r.appType == "kots" { return errors.New("This feature is not supported for Kots applications.") } diff --git a/cli/cmd/channel_create.go b/cli/cmd/channel_create.go index c22764b4e..620208ed4 100644 --- a/cli/cmd/channel_create.go +++ b/cli/cmd/channel_create.go @@ -24,7 +24,7 @@ func (r *runners) InitChannelCreate(parent *cobra.Command) { } func (r *runners) channelCreate(cmd *cobra.Command, args []string) error { - allChannels, err := r.api.CreateChannel(r.appID, r.args.channelCreateName, r.args.channelCreateDescription) + allChannels, err := r.api.CreateChannel(r.appID, r.appType, r.args.channelCreateName, r.args.channelCreateDescription) if err != nil { return err } diff --git a/cli/cmd/channel_inspect.go b/cli/cmd/channel_inspect.go index caf4df676..61a7b9b03 100644 --- a/cli/cmd/channel_inspect.go +++ b/cli/cmd/channel_inspect.go @@ -25,7 +25,7 @@ func (r *runners) channelInspect(cmd *cobra.Command, args []string) error { } chanID := args[0] - appChan, _, err := r.api.GetChannel(r.appID, chanID) + appChan, _, err := r.api.GetChannel(r.appID, r.appType, chanID) if err != nil { return err } diff --git a/cli/cmd/channel_ls.go b/cli/cmd/channel_ls.go index f94a04773..c5f3984ad 100644 --- a/cli/cmd/channel_ls.go +++ b/cli/cmd/channel_ls.go @@ -17,7 +17,7 @@ func (r *runners) InitChannelList(parent *cobra.Command) { } func (r *runners) channelList(cmd *cobra.Command, args []string) error { - channels, err := r.api.ListChannels(r.appID) + channels, err := r.api.ListChannels(r.appID, r.appType) if err != nil { return err } diff --git a/cli/cmd/channel_releases.go b/cli/cmd/channel_releases.go index 96382a1d9..0e55fbf30 100644 --- a/cli/cmd/channel_releases.go +++ b/cli/cmd/channel_releases.go @@ -24,14 +24,9 @@ func (r *runners) channelReleases(cmd *cobra.Command, args []string) error { } chanID := args[0] - appType, err := r.api.GetAppType(r.appID) - if err != nil { - return err - } - - if appType == "platform" { + if r.appType == "platform" { - _, releases, err := r.api.GetChannel(r.appID, chanID) + _, releases, err := r.api.GetChannel(r.appID, r.appType, chanID) if err != nil { return err } @@ -39,9 +34,9 @@ func (r *runners) channelReleases(cmd *cobra.Command, args []string) error { if err = print.ChannelReleases(r.w, releases); err != nil { return err } - } else if appType == "ship" { + } else if r.appType == "ship" { return errors.New("This feature is not supported for Ship applications.") - } else if appType == "kots" { + } else if r.appType == "kots" { return errors.New("This feature is not supported for Kots applications.") } diff --git a/cli/cmd/channel_rm.go b/cli/cmd/channel_rm.go index 433479164..705d36ab8 100644 --- a/cli/cmd/channel_rm.go +++ b/cli/cmd/channel_rm.go @@ -24,7 +24,7 @@ func (r *runners) channelRemove(cmd *cobra.Command, args []string) error { } chanID := args[0] - if err := r.api.ArchiveChannel(r.appID, chanID); err != nil { + if err := r.api.ArchiveChannel(r.appID, r.appType, chanID); err != nil { return err } diff --git a/cli/cmd/collector_create.go b/cli/cmd/collector_create.go index 08d09277f..19163cb30 100644 --- a/cli/cmd/collector_create.go +++ b/cli/cmd/collector_create.go @@ -53,7 +53,7 @@ func (r *runners) collectorCreate(cmd *cobra.Command, args []string) error { r.args.createCollectorYaml = string(bytes) } - _, err := r.api.CreateCollector(r.appID, r.args.createCollectorName, r.args.createCollectorYaml) + _, err := r.api.CreateCollector(r.appID, r.appType, r.args.createCollectorName, r.args.createCollectorYaml) if err != nil { return err } diff --git a/cli/cmd/collector_ls.go b/cli/cmd/collector_ls.go index 766f27c31..c40b3df8f 100644 --- a/cli/cmd/collector_ls.go +++ b/cli/cmd/collector_ls.go @@ -17,7 +17,7 @@ func (r *runners) InitCollectorList(parent *cobra.Command) { } func (r *runners) collectorList(cmd *cobra.Command, args []string) error { - collectors, err := r.api.ListCollectors(r.appID) + collectors, err := r.api.ListCollectors(r.appID, r.appType) if err != nil { return err } diff --git a/cli/cmd/entitlements_definefields.go b/cli/cmd/entitlements_definefields.go index 81f5f9106..255c0c6a9 100644 --- a/cli/cmd/entitlements_definefields.go +++ b/cli/cmd/entitlements_definefields.go @@ -31,7 +31,7 @@ func (r *runners) entitlementsDefineFields(cmd *cobra.Command, args []string) er return err } - definitions, err := r.api.CreateEntitlementSpec(r.args.entitlementsDefineFieldsName, string(spec), r.appID) + definitions, err := r.api.CreateEntitlementSpec(r.appID, r.appType, r.args.entitlementsDefineFieldsName, string(spec)) if err != nil { return errors.Wrap(err, "create definitions") } diff --git a/cli/cmd/release_create.go b/cli/cmd/release_create.go index e7eb8d135..e8917e95f 100644 --- a/cli/cmd/release_create.go +++ b/cli/cmd/release_create.go @@ -115,7 +115,7 @@ func (r *runners) releaseCreate(cmd *cobra.Command, args []string) error { // channel before proceeding var promoteChanID string if r.args.createReleasePromote != "" { - channels, err := r.api.ListChannels(r.appID) + channels, err := r.api.ListChannels(r.appID, r.appType) if err != nil { return err } @@ -136,7 +136,7 @@ func (r *runners) releaseCreate(cmd *cobra.Command, args []string) error { promoteChanID = promoteChannelIDs[0] } - release, err := r.api.CreateRelease(r.appID, r.args.createReleaseYaml) + release, err := r.api.CreateRelease(r.appID, r.appType, r.args.createReleaseYaml) if err != nil { return err } @@ -149,6 +149,7 @@ func (r *runners) releaseCreate(cmd *cobra.Command, args []string) error { if promoteChanID != "" { if err := r.api.PromoteRelease( r.appID, + r.appType, release.Sequence, r.args.createReleasePromoteVersion, r.args.createReleasePromoteNotes, diff --git a/cli/cmd/release_inspect.go b/cli/cmd/release_inspect.go index f1bbf6c88..c611436fd 100644 --- a/cli/cmd/release_inspect.go +++ b/cli/cmd/release_inspect.go @@ -30,7 +30,7 @@ func (r *runners) releaseInspect(cmd *cobra.Command, args []string) error { return fmt.Errorf("Failed to parse sequence argument %s", args[0]) } - release, err := r.api.GetRelease(r.appID, seq) + release, err := r.api.GetRelease(r.appID, r.appType, seq) if err != nil { if err == platformclient.ErrNotFound { return fmt.Errorf("No such release %d", seq) diff --git a/cli/cmd/release_lint.go b/cli/cmd/release_lint.go index 9657a0b47..a26641f0e 100644 --- a/cli/cmd/release_lint.go +++ b/cli/cmd/release_lint.go @@ -48,7 +48,7 @@ func (r *runners) releaseLint(cmd *cobra.Command, args []string) error { r.args.lintReleaseYamlFile = string(bytes) } - lintResult, err := r.api.LintRelease(r.appID, r.args.lintReleaseYaml) + lintResult, err := r.api.LintRelease(r.appID, r.appType, r.args.lintReleaseYaml) if err != nil { return err } diff --git a/cli/cmd/release_ls.go b/cli/cmd/release_ls.go index 41c857da8..c1e509520 100644 --- a/cli/cmd/release_ls.go +++ b/cli/cmd/release_ls.go @@ -17,7 +17,7 @@ func (r *runners) IniReleaseList(parent *cobra.Command) { } func (r *runners) releaseList(cmd *cobra.Command, args []string) error { - releases, err := r.api.ListReleases(r.appID) + releases, err := r.api.ListReleases(r.appID, r.appType) if err != nil { return err } diff --git a/cli/cmd/release_promote.go b/cli/cmd/release_promote.go index 2c3e3ed7f..3988207a8 100644 --- a/cli/cmd/release_promote.go +++ b/cli/cmd/release_promote.go @@ -37,7 +37,7 @@ func (r *runners) releasePromote(cmd *cobra.Command, args []string) error { } chanID := args[1] - if err := r.api.PromoteRelease(r.appID, seq, r.args.releaseVersion, r.args.releaseNotes, !r.args.releaseOptional, chanID); err != nil { + if err := r.api.PromoteRelease(r.appID, r.appType, seq, r.args.releaseVersion, r.args.releaseNotes, !r.args.releaseOptional, chanID); err != nil { return err } diff --git a/cli/cmd/release_update.go b/cli/cmd/release_update.go index 46fac2835..88823cd93 100644 --- a/cli/cmd/release_update.go +++ b/cli/cmd/release_update.go @@ -107,7 +107,7 @@ func (r *runners) releaseUpdate(cmd *cobra.Command, args []string) error { } r.args.updateReleaseYaml = string(jsonAllYamls) } - if err := r.api.UpdateRelease(r.appID, seq, r.args.updateReleaseYaml); err != nil { + if err := r.api.UpdateRelease(r.appID, r.appType, seq, r.args.updateReleaseYaml); err != nil { return fmt.Errorf("Failure setting new yaml config for release: %v", err) } diff --git a/client/channel.go b/client/channel.go index d440756f3..d6e43dc1e 100644 --- a/client/channel.go +++ b/client/channel.go @@ -7,11 +7,7 @@ import ( "github.com/replicatedhq/replicated/pkg/types" ) -func (c *Client) ListChannels(appID string) ([]types.Channel, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) ListChannels(appID string, appType string) ([]types.Channel, error) { if appType == "platform" { platformChannels, err := c.PlatformClient.ListChannels(appID) @@ -42,11 +38,7 @@ func (c *Client) ListChannels(appID string) ([]types.Channel, error) { return nil, errors.New("unknown app type") } -func (c *Client) GetChannel(appID string, channelID string) (*channels.AppChannel, []channels.ChannelRelease, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, nil, err - } +func (c *Client) GetChannel(appID string, appType string, channelID string) (*channels.AppChannel, []channels.ChannelRelease, error) { if appType == "platform" { return c.PlatformClient.GetChannel(appID, channelID) @@ -59,11 +51,7 @@ func (c *Client) GetChannel(appID string, channelID string) (*channels.AppChanne } -func (c *Client) ArchiveChannel(appID string, channelID string) error { - appType, err := c.GetAppType(appID) - if err != nil { - return err - } +func (c *Client) ArchiveChannel(appID string, appType string, channelID string) error { if appType == "platform" { return c.PlatformClient.ArchiveChannel(appID, channelID) @@ -76,17 +64,13 @@ func (c *Client) ArchiveChannel(appID string, channelID string) error { } -func (c *Client) CreateChannel(appID string, name string, description string) ([]types.Channel, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) CreateChannel(appID string, appType string, name string, description string) ([]types.Channel, error) { if appType == "platform" { if err := c.PlatformClient.CreateChannel(appID, name, description); err != nil { return nil, err } - return c.ListChannels(appID) + return c.ListChannels(appID, appType) } else if appType == "ship" { if err := c.ShipClient.CreateChannel(appID, name, description); err != nil { return nil, err diff --git a/client/collector.go b/client/collector.go index b59906ac8..e63b2f2b6 100644 --- a/client/collector.go +++ b/client/collector.go @@ -6,12 +6,7 @@ import ( "github.com/replicatedhq/replicated/pkg/types" ) -func (c *Client) ListCollectors(appID string) ([]types.CollectorInfo, error) { - - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) ListCollectors(appID string, appType string) ([]types.CollectorInfo, error) { if appType == "kots" { return nil, errors.New("On a kots application, users must modify the support-bundle.yaml file in the release") @@ -59,12 +54,7 @@ func (c *Client) UpdateCollectorName(appID string, specID string, name string) ( } // func (c *Client) CreateCollector(appID string, name string, yaml string) (*collectors.AppCollectorInfo, error) { -func (c *Client) CreateCollector(appID string, name string, yaml string) (*collectors.AppCollectorInfo, error) { - - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) CreateCollector(appID string, appType string, name string, yaml string) (*collectors.AppCollectorInfo, error) { if appType == "kots" { return nil, errors.New("On a kots application, users must modify the support-bundle.yaml file in the release") @@ -78,16 +68,11 @@ func (c *Client) GetCollector(appID string, specID string) (*collectors.AppColle } -func (c *Client) PromoteCollector(appID string, specID string, channelIDs ...string) error { - - appType, err := c.GetAppType(appID) - if err != nil { - return err - } +func (c *Client) PromoteCollector(appID string, appType string, specID string, channelIDs ...string) error { if appType == "platform" { return c.PlatformClient.PromoteCollector(appID, specID, channelIDs...) - } else { + } else if appType == "ship" { return c.ShipClient.PromoteCollector(appID, specID, channelIDs...) } diff --git a/client/entitlements.go b/client/entitlements.go index c6a28bf96..55097f95c 100644 --- a/client/entitlements.go +++ b/client/entitlements.go @@ -6,11 +6,7 @@ import ( "github.com/replicatedhq/replicated/pkg/types" ) -func (c *Client) CreateEntitlementSpec(name string, spec string, appID string) (*types.EntitlementSpec, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) CreateEntitlementSpec(appID string, appType string, name string, spec string) (*types.EntitlementSpec, error) { if appType == "platform" { return nil, errors.New("This feature is not supported for platform applications.") diff --git a/client/release.go b/client/release.go index 194c5f0a5..cc6efdde0 100644 --- a/client/release.go +++ b/client/release.go @@ -7,11 +7,7 @@ import ( "github.com/replicatedhq/replicated/pkg/types" ) -func (c *Client) ListReleases(appID string) ([]types.ReleaseInfo, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) ListReleases(appID string, appType string) ([]types.ReleaseInfo, error) { if appType == "platform" { platformReleases, err := c.PlatformClient.ListReleases(appID) @@ -86,11 +82,7 @@ func (c *Client) ListReleases(appID string) ([]types.ReleaseInfo, error) { return nil, errors.New("unknown app type") } -func (c *Client) CreateRelease(appID string, yaml string) (*types.ReleaseInfo, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) CreateRelease(appID string, appType string, yaml string) (*types.ReleaseInfo, error) { if appType == "platform" { platformReleaseInfo, err := c.PlatformClient.CreateRelease(appID, yaml) @@ -127,12 +119,7 @@ func (c *Client) CreateRelease(appID string, yaml string) (*types.ReleaseInfo, e return nil, errors.New("unknown app type") } -func (c *Client) UpdateRelease(appID string, sequence int64, yaml string) error { - - appType, err := c.GetAppType(appID) - if err != nil { - return err - } +func (c *Client) UpdateRelease(appID string, appType string, sequence int64, yaml string) error { if appType == "platform" { return c.PlatformClient.UpdateRelease(appID, sequence, yaml) @@ -144,11 +131,7 @@ func (c *Client) UpdateRelease(appID string, sequence int64, yaml string) error return errors.New("unknown app type") } -func (c *Client) GetRelease(appID string, sequence int64) (*releases.AppRelease, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) GetRelease(appID string, appType string, sequence int64) (*releases.AppRelease, error) { if appType == "platform" { return c.PlatformClient.GetRelease(appID, sequence) @@ -160,11 +143,7 @@ func (c *Client) GetRelease(appID string, sequence int64) (*releases.AppRelease, return nil, errors.New("unknown app type") } -func (c *Client) PromoteRelease(appID string, sequence int64, label string, notes string, required bool, channelIDs ...string) error { - appType, err := c.GetAppType(appID) - if err != nil { - return err - } +func (c *Client) PromoteRelease(appID string, appType string, sequence int64, label string, notes string, required bool, channelIDs ...string) error { if appType == "platform" { return c.PlatformClient.PromoteRelease(appID, sequence, label, notes, required, channelIDs...) @@ -176,11 +155,7 @@ func (c *Client) PromoteRelease(appID string, sequence int64, label string, note return errors.New("unknown app type") } -func (c *Client) LintRelease(appID string, yaml string) ([]types.LintMessage, error) { - appType, err := c.GetAppType(appID) - if err != nil { - return nil, err - } +func (c *Client) LintRelease(appID string, appType string, yaml string) ([]types.LintMessage, error) { if appType == "platform" { return nil, errors.New("Linting is not yet supported for Platform applications")