Skip to content

Commit

Permalink
Deprecate --chart flag (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
divolgin authored Sep 23, 2024
1 parent c93479b commit 47573af
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/cmd/cluster_prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ replicated cluster prepare --distribution eks --version 1.27 --instance-type c6.

// for builders plan (chart only)
cmd.Flags().StringVar(&r.args.prepareClusterChart, "chart", "", "Path to the helm chart package to deploy")
cmd.Flags().MarkHidden("chart")

addValueOptionsFlags(cmd.Flags(), &r.args.prepareClusterValueOpts)

cmd.Flags().StringVar(&r.args.prepareClusterNamespace, "namespace", "default", "The namespace into which to deploy the KOTS application or Helm chart.")
Expand Down Expand Up @@ -130,6 +132,7 @@ func validateClusterPrepareFlags(args runnerArgs) error {
}

if args.prepareClusterChart != "" {
printChartDeprecationWarning()
if args.prepareClusterKotsSharedPassword != "" {
return errors.New("The --shared-password flag cannot be used when deploying a Helm chart")
}
Expand Down Expand Up @@ -309,6 +312,7 @@ func prepareRelease(r *runners, log *logger.Logger) (*types.ReleaseInfo, error)
}

if r.args.prepareClusterChart != "" {
printChartDeprecationWarning()
fmt.Fprintln(r.w)
log.ActionWithSpinner("Reading chart from %s", r.args.prepareClusterChart)
var err error
Expand Down
5 changes: 5 additions & 0 deletions cli/cmd/release_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (r *runners) InitReleaseCreate(parent *cobra.Command) error {
cmd.Flags().MarkHidden("yaml-file")
cmd.Flags().MarkHidden("yaml")

// deprecated
cmd.Flags().MarkHidden("chart")

cmd.RunE = r.releaseCreate
return nil
}
Expand Down Expand Up @@ -242,6 +245,8 @@ Prepared to create release with defaults:
}

if r.args.createReleaseChart != "" {
printChartDeprecationWarning()

fmt.Fprint(r.w, "You are creating a release that will only be installable with the helm CLI.\n"+
"For more information, see \n"+
"https://docs.replicated.com/vendor/helm-install#about-helm-installations-with-replicated\n")
Expand Down
4 changes: 4 additions & 0 deletions cli/cmd/release_lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func (r *runners) InitReleaseLint(parent *cobra.Command) {
cmd.Flags().StringVar(&r.args.lintReleaseFailOn, "fail-on", "error", "The minimum severity to cause the command to exit with a non-zero exit code. Supported values are [info, warn, error, none].")
cmd.Flags().StringVar(&r.outputFormat, "output", "table", "The output format to use. One of: json|table (default: table)")

// deprecated
cmd.Flags().MarkHidden("chart")

cmd.RunE = r.releaseLint
}

Expand All @@ -60,6 +63,7 @@ func (r *runners) releaseLint(cmd *cobra.Command, args []string) error {
isBuildersRelease = isHelmChartsOnly
contentType = "application/tar"
} else if r.args.lintReleaseChart != "" {
printChartDeprecationWarning()
data, err := os.ReadFile(r.args.lintReleaseChart)
if err != nil {
return errors.Wrap(err, "failed to read chart file")
Expand Down
4 changes: 4 additions & 0 deletions cli/cmd/release_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ func (r *runners) InitReleaseUpdate(parent *cobra.Command) {
cmd.Flags().StringVar(&r.args.updateReleaseYamlDir, "yaml-dir", "", "The directory containing multiple yamls for a Kots release. Cannot be used with the --yaml flag.")
cmd.Flags().StringVar(&r.args.updateReleaseChart, "chart", "", "Helm chart to create the release from. Cannot be used with the --yaml, --yaml-file, or --yaml-dir flags.")

// deprecated
cmd.Flags().MarkHidden("chart")

cmd.RunE = r.releaseUpdate
}

Expand Down Expand Up @@ -85,6 +88,7 @@ func (r *runners) releaseUpdate(cmd *cobra.Command, args []string) error {
return errors.Wrap(err, "make release from dir")
}
} else if r.args.updateReleaseChart != "" {
printChartDeprecationWarning()
r.args.updateReleaseYaml, err = makeReleaseFromChart(r.args.updateReleaseChart)
if err != nil {
return errors.Wrap(err, "make release from chart")
Expand Down
6 changes: 6 additions & 0 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"text/tabwriter"

"github.com/fatih/color"
"github.com/pkg/errors"

"github.com/replicatedhq/replicated/pkg/credentials"
Expand Down Expand Up @@ -364,6 +365,11 @@ func printIfError(cmd *cobra.Command, err error) {
}
}

func printChartDeprecationWarning() {
red := color.New(color.FgHiRed)
red.Fprintf(os.Stderr, "\nThe --chart flag is deprecated and will be removed in a future release. Please use the --yaml or --yaml-dir flag instead.\n\n")
}

func parseTags(tags []string) ([]types.Tag, error) {
parsedTags := []types.Tag{}
for _, tag := range tags {
Expand Down

0 comments on commit 47573af

Please sign in to comment.