Skip to content

Bug 1996878: Add deprecation warnings for CLIs that use or depend on sqlite #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2021
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
6 changes: 5 additions & 1 deletion staging/operator-registry/cmd/initializer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion staging/operator-registry/cmd/opm/index/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion staging/operator-registry/cmd/opm/index/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ 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.
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 {
Expand All @@ -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.")
}
Expand Down
5 changes: 4 additions & 1 deletion staging/operator-registry/cmd/opm/index/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion staging/operator-registry/cmd/opm/index/deprecatetruncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand All @@ -26,7 +27,7 @@ var deprecateLong = templates.LongDesc(`
1.4.0 -- replaces -> 1.3.0 [deprecated]

Deprecating a bundle that removes the default channel is not allowed. 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{
Expand Down
3 changes: 2 additions & 1 deletion staging/operator-registry/cmd/opm/index/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
Expand All @@ -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{
Expand Down
5 changes: 4 additions & 1 deletion staging/operator-registry/cmd/opm/index/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion staging/operator-registry/cmd/opm/index/prunestranded.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion staging/operator-registry/cmd/opm/registry/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion staging/operator-registry/cmd/opm/registry/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ 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
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)
Expand Down
6 changes: 5 additions & 1 deletion staging/operator-registry/cmd/opm/registry/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions staging/operator-registry/cmd/opm/registry/prune.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions staging/operator-registry/cmd/opm/registry/prunestranded.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions staging/operator-registry/cmd/opm/registry/rm.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion staging/operator-registry/cmd/opm/registry/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions staging/operator-registry/cmd/opm/render/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/operator-framework/operator-registry/internal/action"
"github.com/operator-framework/operator-registry/internal/declcfg"
"github.com/operator-framework/operator-registry/pkg/sqlite"
)

func NewCmd() *cobra.Command {
Expand All @@ -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

Expand Down
6 changes: 5 additions & 1 deletion staging/operator-registry/cmd/registry-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions staging/operator-registry/internal/action/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"strings"
"sync"

"github.com/h2non/filetype"
"github.com/h2non/filetype/matchers"
Expand All @@ -26,6 +27,8 @@ import (
"github.com/operator-framework/operator-registry/pkg/sqlite"
)

var logDeprecationMessage sync.Once

type RefType uint

const (
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions staging/operator-registry/pkg/sqlite/deprecationmessage.go
Original file line number Diff line number Diff line change
@@ -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.`)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading