diff --git a/alpha/action/render.go b/alpha/action/render.go index eac8bc4bb..52363d004 100644 --- a/alpha/action/render.go +++ b/alpha/action/render.go @@ -10,6 +10,7 @@ import ( "os" "path/filepath" "strings" + "sync" "github.com/h2non/filetype" "github.com/h2non/filetype/matchers" @@ -26,6 +27,8 @@ import ( "github.com/operator-framework/operator-registry/pkg/sqlite" ) +var logDeprecationMessage sync.Once + type RefType uint const ( @@ -197,6 +200,10 @@ func checkDBFile(ref string) error { } func sqliteToDeclcfg(ctx context.Context, dbFile string) (*declcfg.DeclarativeConfig, error) { + logDeprecationMessage.Do(func() { + sqlite.LogSqliteDeprecation() + }) + db, err := sqlite.Open(dbFile) if err != nil { return nil, err diff --git a/cmd/initializer/main.go b/cmd/initializer/main.go index 68f1b435b..742cc79a9 100644 --- a/cmd/initializer/main.go +++ b/cmd/initializer/main.go @@ -12,8 +12,12 @@ import ( var rootCmd = &cobra.Command{ Short: "initializer", - Long: `initializer takes a directory of OLM manifests and outputs a sqlite database containing them`, + Long: `initializer takes a directory of OLM manifests and outputs a sqlite database containing them +` + sqlite.DeprecationMessage, + PersistentPreRun: func(_ *cobra.Command, _ []string) { + sqlite.LogSqliteDeprecation() + }, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { logrus.SetLevel(logrus.DebugLevel) diff --git a/cmd/opm/index/add.go b/cmd/opm/index/add.go index 3c958fe93..480cd9aca 100644 --- a/cmd/opm/index/add.go +++ b/cmd/opm/index/add.go @@ -10,6 +10,7 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/indexer" "github.com/operator-framework/operator-registry/pkg/registry" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) var ( @@ -25,7 +26,7 @@ var ( 0.1.1 -> 0.1.2 -> 0.1.2-1 will be pruned on add to: 0.1.1 -> 0.1.2 - `) +`) + "\n\n" + sqlite.DeprecationMessage addExample = templates.Examples(` # Create an index image from scratch with a single bundle image diff --git a/cmd/opm/index/cmd.go b/cmd/opm/index/cmd.go index c555a7253..44141415b 100644 --- a/cmd/opm/index/cmd.go +++ b/cmd/opm/index/cmd.go @@ -3,6 +3,8 @@ package index import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/operator-framework/operator-registry/pkg/sqlite" ) // AddCommand adds the index subcommand to the given parent command. @@ -10,7 +12,9 @@ func AddCommand(parent *cobra.Command) { cmd := &cobra.Command{ Use: "index", Short: "generate operator index container images", - Long: `generate operator index container images from preexisting operator bundles`, + Long: `generate operator index container images from preexisting operator bundles + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { @@ -19,6 +23,7 @@ func AddCommand(parent *cobra.Command) { return nil }, PersistentPreRun: func(cmd *cobra.Command, args []string) { + sqlite.LogSqliteDeprecation() if skipTLS, err := cmd.Flags().GetBool("skip-tls"); err == nil && skipTLS { logrus.Warn("--skip-tls flag is set: this mode is insecure and meant for development purposes only.") } diff --git a/cmd/opm/index/delete.go b/cmd/opm/index/delete.go index cc33bedcd..9b249e202 100644 --- a/cmd/opm/index/delete.go +++ b/cmd/opm/index/delete.go @@ -6,13 +6,16 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/indexer" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newIndexDeleteCmd() *cobra.Command { indexCmd := &cobra.Command{ Use: "rm", Short: "delete an entire operator from an index", - Long: `delete an entire operator from an index`, + Long: `delete an entire operator from an index + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/index/deprecatetruncate.go b/cmd/opm/index/deprecatetruncate.go index 212c5f5fa..dc76e9ab9 100644 --- a/cmd/opm/index/deprecatetruncate.go +++ b/cmd/opm/index/deprecatetruncate.go @@ -7,6 +7,7 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/indexer" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) var deprecateLong = templates.LongDesc(` @@ -28,7 +29,7 @@ var deprecateLong = templates.LongDesc(` Deprecating a bundle that removes the default channel is not allowed unless the head(s) of all channels are being deprecated (the package is subsequently removed from the index). This behavior can be enabled via the allow-package-removal flag. Changing the default channel prior to deprecation is possible by publishing a new bundle to the index. - `) + `) + "\n\n" + sqlite.DeprecationMessage func newIndexDeprecateTruncateCmd() *cobra.Command { indexCmd := &cobra.Command{ diff --git a/cmd/opm/index/export.go b/cmd/opm/index/export.go index 1025baaa5..910b6d02e 100644 --- a/cmd/opm/index/export.go +++ b/cmd/opm/index/export.go @@ -9,6 +9,7 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/indexer" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) var exportLong = templates.LongDesc(` @@ -18,7 +19,7 @@ var exportLong = templates.LongDesc(` the --package option) and export the operator metadata into an appregistry compliant format (a package.yaml file). Note: the appregistry format is being deprecated in favor of the new index image and image bundle format. - `) + `) + "\n\n" + sqlite.DeprecationMessage func newIndexExportCmd() *cobra.Command { indexCmd := &cobra.Command{ diff --git a/cmd/opm/index/prune.go b/cmd/opm/index/prune.go index 73ed36021..5cee90279 100644 --- a/cmd/opm/index/prune.go +++ b/cmd/opm/index/prune.go @@ -8,13 +8,16 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/indexer" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newIndexPruneCmd() *cobra.Command { indexCmd := &cobra.Command{ Use: "prune", Short: "prune an index of all but specified packages", - Long: `prune an index of all but specified packages`, + Long: `prune an index of all but specified packages + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/index/prunestranded.go b/cmd/opm/index/prunestranded.go index 2616b9ada..c323c619a 100644 --- a/cmd/opm/index/prunestranded.go +++ b/cmd/opm/index/prunestranded.go @@ -8,13 +8,16 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/indexer" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newIndexPruneStrandedCmd() *cobra.Command { indexCmd := &cobra.Command{ Use: "prune-stranded", Short: "prune an index of stranded bundles", - Long: `prune an index of stranded bundles - bundles that are not associated with a particular package`, + Long: `prune an index of stranded bundles - bundles that are not associated with a particular package + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/registry/add.go b/cmd/opm/registry/add.go index 5f0c37ac6..0e7a399ef 100644 --- a/cmd/opm/registry/add.go +++ b/cmd/opm/registry/add.go @@ -10,13 +10,16 @@ import ( "github.com/operator-framework/operator-registry/pkg/containertools" "github.com/operator-framework/operator-registry/pkg/lib/registry" reg "github.com/operator-framework/operator-registry/pkg/registry" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newRegistryAddCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "add", Short: "add operator bundle to operator registry DB", - Long: `add operator bundle to operator registry DB`, + Long: `add operator bundle to operator registry DB + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/registry/cmd.go b/cmd/opm/registry/cmd.go index 69ae6ddc3..15019f9c0 100644 --- a/cmd/opm/registry/cmd.go +++ b/cmd/opm/registry/cmd.go @@ -3,6 +3,8 @@ package registry import ( "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/operator-framework/operator-registry/pkg/sqlite" ) // NewOpmRegistryCmd returns the appregistry-server command @@ -10,8 +12,12 @@ func NewOpmRegistryCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "registry", Short: "interact with operator-registry database", - Long: `interact with operator-registry database building, modifying and/or serving the operator-registry database`, + Long: `interact with operator-registry database building, modifying and/or serving the operator-registry database +` + sqlite.DeprecationMessage, + PersistentPreRun: func(_ *cobra.Command, _ []string) { + sqlite.LogSqliteDeprecation() + }, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { logrus.SetLevel(logrus.DebugLevel) diff --git a/cmd/opm/registry/mirror.go b/cmd/opm/registry/mirror.go index 8ba2af6cc..cda5d030e 100644 --- a/cmd/opm/registry/mirror.go +++ b/cmd/opm/registry/mirror.go @@ -5,15 +5,19 @@ import ( "github.com/spf13/cobra" "github.com/operator-framework/operator-registry/pkg/mirror" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func MirrorCmd() *cobra.Command { + // TODO(joelanford): MirrorCmd is unused. Delete it and any other code used only by it. o := mirror.DefaultImageIndexMirrorerOptions() cmd := &cobra.Command{ Hidden: true, Use: "mirror [src image] [dest image]", Short: "mirror an operator-registry catalog", - Long: `mirror an operator-registry catalog image from one registry to another`, + Long: `mirror an operator-registry catalog image from one registry to another + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/registry/prune.go b/cmd/opm/registry/prune.go index 01052187e..05bbdd712 100644 --- a/cmd/opm/registry/prune.go +++ b/cmd/opm/registry/prune.go @@ -1,17 +1,20 @@ package registry import ( - "github.com/operator-framework/operator-registry/pkg/lib/registry" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/operator-framework/operator-registry/pkg/lib/registry" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newRegistryPruneCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "prune", Short: "prune an operator registry DB of all but specified packages", - Long: `prune an operator registry DB of all but specified packages`, + Long: `prune an operator registry DB of all but specified packages + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/registry/prunestranded.go b/cmd/opm/registry/prunestranded.go index 103e5aa18..a3ff44a0f 100644 --- a/cmd/opm/registry/prunestranded.go +++ b/cmd/opm/registry/prunestranded.go @@ -1,17 +1,20 @@ package registry import ( - "github.com/operator-framework/operator-registry/pkg/lib/registry" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/operator-framework/operator-registry/pkg/lib/registry" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newRegistryPruneStrandedCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "prune-stranded", Short: "prune an operator registry DB of stranded bundles", - Long: `prune an operator registry DB of stranded bundles - bundles that are not associated with a particular package`, + Long: `prune an operator registry DB of stranded bundles - bundles that are not associated with a particular package + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/registry/rm.go b/cmd/opm/registry/rm.go index 87cf661f1..17a4a5167 100644 --- a/cmd/opm/registry/rm.go +++ b/cmd/opm/registry/rm.go @@ -1,17 +1,20 @@ package registry import ( - "github.com/operator-framework/operator-registry/pkg/lib/registry" - "github.com/sirupsen/logrus" "github.com/spf13/cobra" + + "github.com/operator-framework/operator-registry/pkg/lib/registry" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func newRegistryRmCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "rm", Short: "remove operator from operator registry DB", - Long: `Remove operator from operator registry DB`, + Long: `Remove operator from operator registry DB + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/registry/serve.go b/cmd/opm/registry/serve.go index ff402c58b..794553fa4 100644 --- a/cmd/opm/registry/serve.go +++ b/cmd/opm/registry/serve.go @@ -28,7 +28,9 @@ func newRegistryServeCmd() *cobra.Command { rootCmd := &cobra.Command{ Use: "serve", Short: "serve an operator-registry database", - Long: `serve an operator-registry database that is queriable using grpc`, + Long: `serve an operator-registry database that is queriable using grpc + +` + sqlite.DeprecationMessage, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { diff --git a/cmd/opm/render/cmd.go b/cmd/opm/render/cmd.go index a448dd346..913eb21a0 100644 --- a/cmd/opm/render/cmd.go +++ b/cmd/opm/render/cmd.go @@ -11,6 +11,7 @@ import ( "github.com/operator-framework/operator-registry/alpha/action" "github.com/operator-framework/operator-registry/alpha/declcfg" + "github.com/operator-framework/operator-registry/pkg/sqlite" ) func NewCmd() *cobra.Command { @@ -20,8 +21,11 @@ func NewCmd() *cobra.Command { ) cmd := &cobra.Command{ Use: "render [index-image | bundle-image | sqlite-file]...", - Short: "Generate a declarative config blob from the provided index images, bundle images, and sqlite database files", - Args: cobra.MinimumNArgs(1), + Short: "Generate a declarative config blob from catalogs and bundles", + Long: `Generate a declarative config blob from the provided index images, bundle images, and sqlite database files + +` + sqlite.DeprecationMessage, + Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { render.Refs = args diff --git a/cmd/registry-server/main.go b/cmd/registry-server/main.go index 529a02a9c..4d88b0604 100644 --- a/cmd/registry-server/main.go +++ b/cmd/registry-server/main.go @@ -24,8 +24,12 @@ import ( var rootCmd = &cobra.Command{ Short: "registry-server", - Long: `registry loads a sqlite database containing operator manifests and serves a grpc API to query it`, + Long: `registry loads a sqlite database containing operator manifests and serves a grpc API to query it +` + sqlite.DeprecationMessage, + PersistentPreRun: func(_ *cobra.Command, _ []string) { + sqlite.LogSqliteDeprecation() + }, PreRunE: func(cmd *cobra.Command, args []string) error { if debug, _ := cmd.Flags().GetBool("debug"); debug { logrus.SetLevel(logrus.DebugLevel) diff --git a/pkg/sqlite/deprecationmessage.go b/pkg/sqlite/deprecationmessage.go new file mode 100644 index 000000000..20a1389b7 --- /dev/null +++ b/pkg/sqlite/deprecationmessage.go @@ -0,0 +1,19 @@ +package sqlite + +import ( + "fmt" + + "github.com/sirupsen/logrus" +) + +const noticeColor = "\033[1;33m%s\033[0m" + +func LogSqliteDeprecation() { + log := logrus.New() + log.Warnf(DeprecationMessage) +} + +var DeprecationMessage = fmt.Sprintf(noticeColor, `DEPRECATION NOTICE: +Sqlite-based catalogs and their related subcommands are deprecated. Support for +them will be removed in a future release. Please migrate your catalog workflows +to the new file-based catalog format.`)