diff --git a/cli/cmd/channel_adoption.go b/cli/cmd/channel_adoption.go index 0b3d444bf..20fd62ae7 100644 --- a/cli/cmd/channel_adoption.go +++ b/cli/cmd/channel_adoption.go @@ -24,13 +24,25 @@ func (r *runners) channelAdoption(cmd *cobra.Command, args []string) error { } chanID := args[0] - appChan, _, err := r.platformAPI.GetChannel(r.appID, chanID) + appType, err := r.api.GetAppType(r.appID) if err != nil { return err } - if err = print.ChannelAdoption(r.w, appChan.Adoption); err != nil { - return err + if appType == "platform" { + appChan, _, err := r.platformAPI.GetChannel(r.appID, chanID) + if err != nil { + return err + } + + if err = print.ChannelAdoption(r.w, appChan.Adoption); err != nil { + return err + } + + } else if appType == "ship" { + return errors.New("This feature is not supported for Ship applications.") + } else if appType == "kots" { + return errors.New("This feature is not supported for Kots applications.") } return nil diff --git a/cli/cmd/channel_counts.go b/cli/cmd/channel_counts.go index 256221ed3..2bbd517f0 100644 --- a/cli/cmd/channel_counts.go +++ b/cli/cmd/channel_counts.go @@ -24,13 +24,24 @@ func (r *runners) channelCounts(cmd *cobra.Command, args []string) error { } chanID := args[0] - appChan, _, err := r.platformAPI.GetChannel(r.appID, chanID) + appType, err := r.api.GetAppType(r.appID) if err != nil { return err } - if err = print.LicenseCounts(r.w, appChan.LicenseCounts); err != nil { - return err + if appType == "platform" { + appChan, _, err := r.api.GetChannel(r.appID, chanID) + if err != nil { + return err + } + + if err = print.LicenseCounts(r.w, appChan.LicenseCounts); err != nil { + return err + } + } else if appType == "ship" { + return errors.New("This feature is not supported for Ship applications.") + } else if appType == "kots" { + return errors.New("This feature is not supported for Kots applications.") } return nil diff --git a/cli/cmd/channel_releases.go b/cli/cmd/channel_releases.go index 54a3e9170..96382a1d9 100644 --- a/cli/cmd/channel_releases.go +++ b/cli/cmd/channel_releases.go @@ -24,13 +24,25 @@ func (r *runners) channelReleases(cmd *cobra.Command, args []string) error { } chanID := args[0] - _, releases, err := r.platformAPI.GetChannel(r.appID, chanID) + appType, err := r.api.GetAppType(r.appID) if err != nil { return err } - if err = print.ChannelReleases(r.w, releases); err != nil { - return err + if appType == "platform" { + + _, releases, err := r.api.GetChannel(r.appID, chanID) + if err != nil { + return err + } + + if err = print.ChannelReleases(r.w, releases); err != nil { + return err + } + } else if appType == "ship" { + return errors.New("This feature is not supported for Ship applications.") + } else if appType == "kots" { + return errors.New("This feature is not supported for Kots applications.") } return nil diff --git a/cli/cmd/release_inspect.go b/cli/cmd/release_inspect.go index 27a721117..f1bbf6c88 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.platformAPI.GetRelease(r.appID, seq) + release, err := r.api.GetRelease(r.appID, seq) if err != nil { if err == platformclient.ErrNotFound { return fmt.Errorf("No such release %d", seq) diff --git a/client/release.go b/client/release.go index 49d111f32..194c5f0a5 100644 --- a/client/release.go +++ b/client/release.go @@ -3,6 +3,7 @@ package client import ( "errors" + releases "github.com/replicatedhq/replicated/gen/go/v1" "github.com/replicatedhq/replicated/pkg/types" ) @@ -143,8 +144,20 @@ 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) (interface{}, error) { - return nil, nil +func (c *Client) GetRelease(appID string, sequence int64) (*releases.AppRelease, error) { + appType, err := c.GetAppType(appID) + if err != nil { + return nil, err + } + + if appType == "platform" { + return c.PlatformClient.GetRelease(appID, sequence) + } else if appType == "ship" { + return nil, errors.New("This feature is not supported for Ship applications.") + } else if appType == "kots" { + return nil, errors.New("This feature is not supported for Kots applications.") + } + return nil, errors.New("unknown app type") } func (c *Client) PromoteRelease(appID string, sequence int64, label string, notes string, required bool, channelIDs ...string) error {