Skip to content

Commit d4a3aa1

Browse files
Merge pull request #177 from joelanford/bz-1996878
Bug 1996878: Add deprecation warnings for CLIs that use or depend on sqlite
2 parents 0178564 + c3c64d4 commit d4a3aa1

File tree

38 files changed

+206
-48
lines changed

38 files changed

+206
-48
lines changed

staging/operator-registry/cmd/initializer/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import (
1212

1313
var rootCmd = &cobra.Command{
1414
Short: "initializer",
15-
Long: `initializer takes a directory of OLM manifests and outputs a sqlite database containing them`,
15+
Long: `initializer takes a directory of OLM manifests and outputs a sqlite database containing them
1616
17+
` + sqlite.DeprecationMessage,
18+
PersistentPreRun: func(_ *cobra.Command, _ []string) {
19+
sqlite.LogSqliteDeprecation()
20+
},
1721
PreRunE: func(cmd *cobra.Command, args []string) error {
1822
if debug, _ := cmd.Flags().GetBool("debug"); debug {
1923
logrus.SetLevel(logrus.DebugLevel)

staging/operator-registry/cmd/opm/index/add.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/operator-framework/operator-registry/pkg/containertools"
1111
"github.com/operator-framework/operator-registry/pkg/lib/indexer"
1212
"github.com/operator-framework/operator-registry/pkg/registry"
13+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1314
)
1415

1516
var (
@@ -25,7 +26,7 @@ var (
2526
0.1.1 -> 0.1.2 -> 0.1.2-1
2627
will be pruned on add to:
2728
0.1.1 -> 0.1.2
28-
`)
29+
`) + "\n\n" + sqlite.DeprecationMessage
2930

3031
addExample = templates.Examples(`
3132
# Create an index image from scratch with a single bundle image

staging/operator-registry/cmd/opm/index/cmd.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ package index
33
import (
44
"github.com/sirupsen/logrus"
55
"github.com/spf13/cobra"
6+
7+
"github.com/operator-framework/operator-registry/pkg/sqlite"
68
)
79

810
// AddCommand adds the index subcommand to the given parent command.
911
func AddCommand(parent *cobra.Command) {
1012
cmd := &cobra.Command{
1113
Use: "index",
1214
Short: "generate operator index container images",
13-
Long: `generate operator index container images from preexisting operator bundles`,
15+
Long: `generate operator index container images from preexisting operator bundles
16+
17+
` + sqlite.DeprecationMessage,
1418

1519
PreRunE: func(cmd *cobra.Command, args []string) error {
1620
if debug, _ := cmd.Flags().GetBool("debug"); debug {
@@ -19,6 +23,7 @@ func AddCommand(parent *cobra.Command) {
1923
return nil
2024
},
2125
PersistentPreRun: func(cmd *cobra.Command, args []string) {
26+
sqlite.LogSqliteDeprecation()
2227
if skipTLS, err := cmd.Flags().GetBool("skip-tls"); err == nil && skipTLS {
2328
logrus.Warn("--skip-tls flag is set: this mode is insecure and meant for development purposes only.")
2429
}

staging/operator-registry/cmd/opm/index/delete.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import (
66

77
"github.com/operator-framework/operator-registry/pkg/containertools"
88
"github.com/operator-framework/operator-registry/pkg/lib/indexer"
9+
"github.com/operator-framework/operator-registry/pkg/sqlite"
910
)
1011

1112
func newIndexDeleteCmd() *cobra.Command {
1213
indexCmd := &cobra.Command{
1314
Use: "rm",
1415
Short: "delete an entire operator from an index",
15-
Long: `delete an entire operator from an index`,
16+
Long: `delete an entire operator from an index
17+
18+
` + sqlite.DeprecationMessage,
1619

1720
PreRunE: func(cmd *cobra.Command, args []string) error {
1821
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/index/deprecatetruncate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/operator-framework/operator-registry/pkg/containertools"
99
"github.com/operator-framework/operator-registry/pkg/lib/indexer"
10+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1011
)
1112

1213
var deprecateLong = templates.LongDesc(`
@@ -26,7 +27,7 @@ var deprecateLong = templates.LongDesc(`
2627
1.4.0 -- replaces -> 1.3.0 [deprecated]
2728
2829
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.
29-
`)
30+
`) + "\n\n" + sqlite.DeprecationMessage
3031

3132
func newIndexDeprecateTruncateCmd() *cobra.Command {
3233
indexCmd := &cobra.Command{

staging/operator-registry/cmd/opm/index/export.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"github.com/operator-framework/operator-registry/pkg/containertools"
1111
"github.com/operator-framework/operator-registry/pkg/lib/indexer"
12+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1213
)
1314

1415
var exportLong = templates.LongDesc(`
@@ -18,7 +19,7 @@ var exportLong = templates.LongDesc(`
1819
the --package option) and export the operator metadata into an appregistry compliant format (a package.yaml file).
1920
2021
Note: the appregistry format is being deprecated in favor of the new index image and image bundle format.
21-
`)
22+
`) + "\n\n" + sqlite.DeprecationMessage
2223

2324
func newIndexExportCmd() *cobra.Command {
2425
indexCmd := &cobra.Command{

staging/operator-registry/cmd/opm/index/prune.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import (
88

99
"github.com/operator-framework/operator-registry/pkg/containertools"
1010
"github.com/operator-framework/operator-registry/pkg/lib/indexer"
11+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1112
)
1213

1314
func newIndexPruneCmd() *cobra.Command {
1415
indexCmd := &cobra.Command{
1516
Use: "prune",
1617
Short: "prune an index of all but specified packages",
17-
Long: `prune an index of all but specified packages`,
18+
Long: `prune an index of all but specified packages
19+
20+
` + sqlite.DeprecationMessage,
1821

1922
PreRunE: func(cmd *cobra.Command, args []string) error {
2023
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/index/prunestranded.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import (
88

99
"github.com/operator-framework/operator-registry/pkg/containertools"
1010
"github.com/operator-framework/operator-registry/pkg/lib/indexer"
11+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1112
)
1213

1314
func newIndexPruneStrandedCmd() *cobra.Command {
1415
indexCmd := &cobra.Command{
1516
Use: "prune-stranded",
1617
Short: "prune an index of stranded bundles",
17-
Long: `prune an index of stranded bundles - bundles that are not associated with a particular package`,
18+
Long: `prune an index of stranded bundles - bundles that are not associated with a particular package
19+
20+
` + sqlite.DeprecationMessage,
1821

1922
PreRunE: func(cmd *cobra.Command, args []string) error {
2023
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/registry/add.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import (
1010
"github.com/operator-framework/operator-registry/pkg/containertools"
1111
"github.com/operator-framework/operator-registry/pkg/lib/registry"
1212
reg "github.com/operator-framework/operator-registry/pkg/registry"
13+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1314
)
1415

1516
func newRegistryAddCmd() *cobra.Command {
1617
rootCmd := &cobra.Command{
1718
Use: "add",
1819
Short: "add operator bundle to operator registry DB",
19-
Long: `add operator bundle to operator registry DB`,
20+
Long: `add operator bundle to operator registry DB
21+
22+
` + sqlite.DeprecationMessage,
2023

2124
PreRunE: func(cmd *cobra.Command, args []string) error {
2225
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/registry/cmd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@ package registry
33
import (
44
"github.com/sirupsen/logrus"
55
"github.com/spf13/cobra"
6+
7+
"github.com/operator-framework/operator-registry/pkg/sqlite"
68
)
79

810
// NewOpmRegistryCmd returns the appregistry-server command
911
func NewOpmRegistryCmd() *cobra.Command {
1012
rootCmd := &cobra.Command{
1113
Use: "registry",
1214
Short: "interact with operator-registry database",
13-
Long: `interact with operator-registry database building, modifying and/or serving the operator-registry database`,
15+
Long: `interact with operator-registry database building, modifying and/or serving the operator-registry database
1416
17+
` + sqlite.DeprecationMessage,
18+
PersistentPreRun: func(_ *cobra.Command, _ []string) {
19+
sqlite.LogSqliteDeprecation()
20+
},
1521
PreRunE: func(cmd *cobra.Command, args []string) error {
1622
if debug, _ := cmd.Flags().GetBool("debug"); debug {
1723
logrus.SetLevel(logrus.DebugLevel)

staging/operator-registry/cmd/opm/registry/mirror.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ import (
55
"github.com/spf13/cobra"
66

77
"github.com/operator-framework/operator-registry/pkg/mirror"
8+
"github.com/operator-framework/operator-registry/pkg/sqlite"
89
)
910

1011
func MirrorCmd() *cobra.Command {
12+
// TODO(joelanford): MirrorCmd is unused. Delete it and any other code used only by it.
1113
o := mirror.DefaultImageIndexMirrorerOptions()
1214
cmd := &cobra.Command{
1315
Hidden: true,
1416
Use: "mirror [src image] [dest image]",
1517
Short: "mirror an operator-registry catalog",
16-
Long: `mirror an operator-registry catalog image from one registry to another`,
18+
Long: `mirror an operator-registry catalog image from one registry to another
19+
20+
` + sqlite.DeprecationMessage,
1721

1822
PreRunE: func(cmd *cobra.Command, args []string) error {
1923
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/registry/prune.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package registry
22

33
import (
4-
"github.com/operator-framework/operator-registry/pkg/lib/registry"
5-
64
"github.com/sirupsen/logrus"
75
"github.com/spf13/cobra"
6+
7+
"github.com/operator-framework/operator-registry/pkg/lib/registry"
8+
"github.com/operator-framework/operator-registry/pkg/sqlite"
89
)
910

1011
func newRegistryPruneCmd() *cobra.Command {
1112
rootCmd := &cobra.Command{
1213
Use: "prune",
1314
Short: "prune an operator registry DB of all but specified packages",
14-
Long: `prune an operator registry DB of all but specified packages`,
15+
Long: `prune an operator registry DB of all but specified packages
16+
17+
` + sqlite.DeprecationMessage,
1518

1619
PreRunE: func(cmd *cobra.Command, args []string) error {
1720
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/registry/prunestranded.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package registry
22

33
import (
4-
"github.com/operator-framework/operator-registry/pkg/lib/registry"
5-
64
"github.com/sirupsen/logrus"
75
"github.com/spf13/cobra"
6+
7+
"github.com/operator-framework/operator-registry/pkg/lib/registry"
8+
"github.com/operator-framework/operator-registry/pkg/sqlite"
89
)
910

1011
func newRegistryPruneStrandedCmd() *cobra.Command {
1112
rootCmd := &cobra.Command{
1213
Use: "prune-stranded",
1314
Short: "prune an operator registry DB of stranded bundles",
14-
Long: `prune an operator registry DB of stranded bundles - bundles that are not associated with a particular package`,
15+
Long: `prune an operator registry DB of stranded bundles - bundles that are not associated with a particular package
16+
17+
` + sqlite.DeprecationMessage,
1518

1619
PreRunE: func(cmd *cobra.Command, args []string) error {
1720
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/registry/rm.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
package registry
22

33
import (
4-
"github.com/operator-framework/operator-registry/pkg/lib/registry"
5-
64
"github.com/sirupsen/logrus"
75
"github.com/spf13/cobra"
6+
7+
"github.com/operator-framework/operator-registry/pkg/lib/registry"
8+
"github.com/operator-framework/operator-registry/pkg/sqlite"
89
)
910

1011
func newRegistryRmCmd() *cobra.Command {
1112
rootCmd := &cobra.Command{
1213
Use: "rm",
1314
Short: "remove operator from operator registry DB",
14-
Long: `Remove operator from operator registry DB`,
15+
Long: `Remove operator from operator registry DB
16+
17+
` + sqlite.DeprecationMessage,
1518

1619
PreRunE: func(cmd *cobra.Command, args []string) error {
1720
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/registry/serve.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ func newRegistryServeCmd() *cobra.Command {
2828
rootCmd := &cobra.Command{
2929
Use: "serve",
3030
Short: "serve an operator-registry database",
31-
Long: `serve an operator-registry database that is queriable using grpc`,
31+
Long: `serve an operator-registry database that is queriable using grpc
32+
33+
` + sqlite.DeprecationMessage,
3234

3335
PreRunE: func(cmd *cobra.Command, args []string) error {
3436
if debug, _ := cmd.Flags().GetBool("debug"); debug {

staging/operator-registry/cmd/opm/render/cmd.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/operator-framework/operator-registry/internal/action"
1313
"github.com/operator-framework/operator-registry/internal/declcfg"
14+
"github.com/operator-framework/operator-registry/pkg/sqlite"
1415
)
1516

1617
func NewCmd() *cobra.Command {
@@ -20,8 +21,11 @@ func NewCmd() *cobra.Command {
2021
)
2122
cmd := &cobra.Command{
2223
Use: "render [index-image | bundle-image | sqlite-file]...",
23-
Short: "Generate a declarative config blob from the provided index images, bundle images, and sqlite database files",
24-
Args: cobra.MinimumNArgs(1),
24+
Short: "Generate a declarative config blob from catalogs and bundles",
25+
Long: `Generate a declarative config blob from the provided index images, bundle images, and sqlite database files
26+
27+
` + sqlite.DeprecationMessage,
28+
Args: cobra.MinimumNArgs(1),
2529
Run: func(cmd *cobra.Command, args []string) {
2630
render.Refs = args
2731

staging/operator-registry/cmd/registry-server/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ import (
2424

2525
var rootCmd = &cobra.Command{
2626
Short: "registry-server",
27-
Long: `registry loads a sqlite database containing operator manifests and serves a grpc API to query it`,
27+
Long: `registry loads a sqlite database containing operator manifests and serves a grpc API to query it
2828
29+
` + sqlite.DeprecationMessage,
30+
PersistentPreRun: func(_ *cobra.Command, _ []string) {
31+
sqlite.LogSqliteDeprecation()
32+
},
2933
PreRunE: func(cmd *cobra.Command, args []string) error {
3034
if debug, _ := cmd.Flags().GetBool("debug"); debug {
3135
logrus.SetLevel(logrus.DebugLevel)

staging/operator-registry/internal/action/render.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"os"
1111
"path/filepath"
1212
"strings"
13+
"sync"
1314

1415
"github.com/h2non/filetype"
1516
"github.com/h2non/filetype/matchers"
@@ -26,6 +27,8 @@ import (
2627
"github.com/operator-framework/operator-registry/pkg/sqlite"
2728
)
2829

30+
var logDeprecationMessage sync.Once
31+
2932
type RefType uint
3033

3134
const (
@@ -197,6 +200,10 @@ func checkDBFile(ref string) error {
197200
}
198201

199202
func sqliteToDeclcfg(ctx context.Context, dbFile string) (*declcfg.DeclarativeConfig, error) {
203+
logDeprecationMessage.Do(func() {
204+
sqlite.LogSqliteDeprecation()
205+
})
206+
200207
db, err := sqlite.Open(dbFile)
201208
if err != nil {
202209
return nil, err
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package sqlite
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/sirupsen/logrus"
7+
)
8+
9+
const noticeColor = "\033[1;33m%s\033[0m"
10+
11+
func LogSqliteDeprecation() {
12+
log := logrus.New()
13+
log.Warnf(DeprecationMessage)
14+
}
15+
16+
var DeprecationMessage = fmt.Sprintf(noticeColor, `DEPRECATION NOTICE:
17+
Sqlite-based catalogs and their related subcommands are deprecated. Support for
18+
them will be removed in a future release. Please migrate your catalog workflows
19+
to the new file-based catalog format.`)

vendor/github.com/operator-framework/operator-registry/cmd/initializer/main.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)