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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@

### Added

- Added the [`cleanup`](./website/content/en/docs/cli/operator-sdk_cleanup.md) subcommand and [`run --olm`](./website/content/en/docs/cli/operator-sdk_run.md) to manage deployment/deletion of operators. These commands currently interact with OLM via an in-cluster registry-server created using an operator's on-disk manifests and managed by `operator-sdk`. ([#2402](https://github.com/operator-framework/operator-sdk/pull/2402), [#2441](https://github.com/operator-framework/operator-sdk/pull/2441))
- Added the [`cleanup`](https://github.com/operator-framework/operator-sdk/blob/v0.15.0/doc/cli/operator-sdk_cleanup.md) subcommand and [`run --olm`](https://github.com/operator-framework/operator-sdk/blob/v0.15.0/doc/cli/operator-sdk_run.md) to manage deployment/deletion of operators. These commands currently interact with OLM via an in-cluster registry-server created using an operator's on-disk manifests and managed by `operator-sdk`. ([#2402](https://github.com/operator-framework/operator-sdk/pull/2402), [#2441](https://github.com/operator-framework/operator-sdk/pull/2441))
- Added [`bundle create`](https://github.com/operator-framework/operator-sdk/blob/v0.15.0/doc/cli/operator-sdk_bundle_create.md) which builds, and optionally generates metadata for, [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2076](https://github.com/operator-framework/operator-sdk/pull/2076), [#2438](https://github.com/operator-framework/operator-sdk/pull/2438))
- Added [`bundle validate`](https://github.com/operator-framework/operator-sdk/blob/v0.15.0/doc/cli/operator-sdk_bundle_validate.md) which validates [operator bundle images](https://github.com/openshift/enhancements/blob/ec2cf96/enhancements/olm/operator-registry.md). ([#2411](https://github.com/operator-framework/operator-sdk/pull/2411))
- Added `blacklist` field to the `watches.yaml` for Ansible based operators. Blacklisted secondary resources will not be watched or cached.([#2374](https://github.com/operator-framework/operator-sdk/pull/2374))
Expand All @@ -265,7 +265,7 @@
- Added retry logic to the cleanup function from the e2e test framework in order to allow it to be achieved in the scenarios where temporary network issues are faced. ([#2277](https://github.com/operator-framework/operator-sdk/pull/2277))
- **Breaking Change:** Moved `olm-catalog gen-csv` to the `generate csv` subcommand. ([#2439](https://github.com/operator-framework/operator-sdk/pull/2439))
- **Breaking Change:** `run ansible/helm` are now the hidden commands `exec-entrypoint ansible/helm`. All functionality of each subcommand is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441))
- **Breaking Change:** `up local` is now [`run --local`](./website/content/en/docs/cli/operator-sdk_run.md). All functionality of this command is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441))
- **Breaking Change:** `up local` is now [`run --local`](https://github.com/operator-framework/operator-sdk/blob/v0.15.0/doc/cli/operator-sdk_run.md). All functionality of this command is the same. ([#2441](https://github.com/operator-framework/operator-sdk/pull/2441))
- **Breaking Change:** Moved the `olm` subcommand from `alpha` to its own subcommand. All functionality of this command is the same. ([#2447](https://github.com/operator-framework/operator-sdk/pull/2447))

### Deprecated
Expand Down
14 changes: 14 additions & 0 deletions changelog/fragments/rm-legacy-run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
Remove legacy run amd cleanup commands
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

amd -> and


kind: "removal"

# Is this a breaking change?
breaking: true

migration:
header: Remove legacy run amd cleanup commands
body: TBD
111 changes: 1 addition & 110 deletions cmd/operator-sdk/cleanup/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@
package cleanup

import (
"errors"
"path/filepath"
"github.com/spf13/cobra"

"github.com/operator-framework/operator-sdk/cmd/operator-sdk/cleanup/packagemanifests"
olmcatalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog"
olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator"
"github.com/operator-framework/operator-sdk/internal/util/projutil"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewCmd() *cobra.Command {
Expand All @@ -44,104 +36,3 @@ Run 'operator-sdk cleanup --help' for more information.

return cmd
}

type cleanupCmd struct {
// Common options.
kubeconfig string
// TODO: remove --namespace and c.namespace
//Deprecated: use olmArgs.OperatorNamespace instead
namespace string

// Cleanup type.
olm bool

// Cleanup type-specific options.
olmArgs olmoperator.PackageManifestsCmd
}

// checkCleanupType ensures exactly one cleanup type has been selected.
func (c *cleanupCmd) checkCleanupType() error {
if !c.olm {
return errors.New("exactly one run-type flag must be set: --olm")
}
return nil
}

func NewCmdLegacy() *cobra.Command {
c := &cleanupCmd{}
cmd := &cobra.Command{
Use: "cleanup",
Short: "Delete and clean up after a running Operator",
RunE: func(cmd *cobra.Command, args []string) error {
if err := c.checkCleanupType(); err != nil {
return err
}
projutil.MustInProjectRoot()

switch {
case c.olm:
c.olmArgs.KubeconfigPath = c.kubeconfig
//TODO: remove --namespace and c.namespace
//use olmArgs.OperatorNamespace directly
if cmd.Flags().Changed("namespace") {
log.Warn("--namespace is deprecates use --operator-namespace instead")
if !cmd.Flags().Changed("operator-namespace") {
c.olmArgs.OperatorNamespace = c.namespace
} else {
log.Warn("--operator-namespace present; ignoring --namespace")
}
}
if c.olmArgs.ManifestsDir == "" {
operatorName := filepath.Base(projutil.MustGetwd())
c.olmArgs.ManifestsDir = filepath.Join(olmcatalog.OLMCatalogDir, operatorName)
}
if err := c.olmArgs.Cleanup(); err != nil {
log.Fatalf("Failed to clean up operator using OLM: %v", err)
}
}
return nil
},
}

// Shared flags.
cmd.Flags().StringVar(&c.kubeconfig, "kubeconfig", "",
"The file path to kubernetes configuration file. Defaults to location "+
"specified by $KUBECONFIG, or to default file rules if not set")
err := cmd.Flags().MarkDeprecated("kubeconfig", "use this flag with 'cleanup packagemanifests' instead")
if err != nil {
panic(err)
}
cmd.Flags().StringVar(&c.namespace, "namespace", "",
"The namespace from which operator and namespaces resources are cleaned up")
err = cmd.Flags().MarkDeprecated("namespace", "use --operator-namespace instead")
if err != nil {
panic(err)
}

// 'cleanup --olm' and related flags. Set as default since this is the only
// cleanup type.
cmd.Flags().BoolVar(&c.olm, "olm", true,
"The operator to be cleaned up is managed by OLM in a cluster. "+
"Cannot be set with another cleanup-type flag")
err = cmd.Flags().MarkDeprecated("olm", "use 'cleanup packagemanifests' instead")
if err != nil {
panic(err)
}
// Mark all flags used with '--olm' as deprecated and hidden separately so
// all other 'cleanup' flags are still available.
fs := pflag.NewFlagSet("olm", pflag.ExitOnError)
fs.StringVar(&c.olmArgs.ManifestsDir, "manifests", "",
"Directory containing operator package directories and a package manifest file")
c.olmArgs.AddToFlagSet(fs)
fs.VisitAll(func(f *pflag.Flag) {
f.Deprecated = "use this flag with 'cleanup packagemanifests' instead"
f.Hidden = true
})
cmd.Flags().AddFlagSet(fs)

cmd.AddCommand(
packagemanifests.NewCmd(),
)

return cmd
}
12 changes: 1 addition & 11 deletions cmd/operator-sdk/cleanup/packagemanifests/packagemanifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ package packagemanifests

import (
"fmt"
"path/filepath"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

olmcatalog "github.com/operator-framework/operator-sdk/internal/generate/olm-catalog"
olmoperator "github.com/operator-framework/operator-sdk/internal/olm/operator"
kbutil "github.com/operator-framework/operator-sdk/internal/util/kubebuilder"
"github.com/operator-framework/operator-sdk/internal/util/projutil"
)

type packagemanifestsCmd struct {
Expand All @@ -47,13 +43,7 @@ ex. '<project-root>/packagemanifests'.`,
}
c.ManifestsDir = args[0]
} else {
// Choose the default path depending on project configuration.
if kbutil.HasProjectFile() {
c.ManifestsDir = "packagemanifests"
} else {
operatorName := filepath.Base(projutil.MustGetwd())
c.ManifestsDir = filepath.Join(olmcatalog.OLMCatalogDir, operatorName)
}
c.ManifestsDir = "packagemanifests"
}

log.Infof("Cleaning up operator in directory %s", c.ManifestsDir)
Expand Down
4 changes: 0 additions & 4 deletions cmd/operator-sdk/cli/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ import (
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/build"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/bundle"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/cleanup"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/new"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/olm"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/run"
"github.com/operator-framework/operator-sdk/cmd/operator-sdk/version"
"github.com/operator-framework/operator-sdk/internal/flags"
"github.com/operator-framework/operator-sdk/internal/util/projutil"
Expand Down Expand Up @@ -69,12 +67,10 @@ func GetCLIRoot() *cobra.Command {
alpha.NewCmd(),
build.NewCmd(),
bundle.NewCmdLegacy(),
cleanup.NewCmdLegacy(),
completion.NewCmd(),
generate.NewCmdLegacy(),
new.NewCmd(),
olm.NewCmd(),
run.NewCmdLegacy(),
version.NewCmd(),
)

Expand Down
Loading