Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions cli/cmd/channel_adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")
}

Expand Down
13 changes: 4 additions & 9 deletions cli/cmd/channel_counts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,18 @@ 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
}

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.")
}

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/channel_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/channel_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/channel_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 4 additions & 9 deletions cli/cmd/channel_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,19 @@ 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
}

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.")
}

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/channel_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/collector_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/collector_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/entitlements_definefields.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
5 changes: 3 additions & 2 deletions cli/cmd/release_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/release_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/release_lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/release_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/release_promote.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/release_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
26 changes: 5 additions & 21 deletions client/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down
23 changes: 4 additions & 19 deletions client/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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...)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that we're not specifically explaining that Kots apps collectors are handled differently, as we do with the CreateCollector call above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thought was that to call this you actual need to have created a spec and have a specID...which would be impossible if it was a kots app.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually


Expand Down
6 changes: 1 addition & 5 deletions client/entitlements.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
Loading