@@ -27,11 +27,10 @@ import (
27
27
"github.com/operator-framework/api/pkg/operators/v1alpha1"
28
28
"github.com/operator-framework/operator-registry/alpha/action"
29
29
declarativeconfig "github.com/operator-framework/operator-registry/alpha/declcfg"
30
- "github.com/operator-framework/operator-registry/pkg/containertools"
31
30
registrybundle "github.com/operator-framework/operator-registry/pkg/lib/bundle"
31
+ fbcutil "github.com/operator-framework/operator-sdk/internal/olm/fbcutil"
32
32
"github.com/operator-framework/operator-sdk/internal/olm/operator"
33
33
"github.com/operator-framework/operator-sdk/internal/olm/operator/registry"
34
- registryutil "github.com/operator-framework/operator-sdk/internal/registry"
35
34
)
36
35
37
36
type Install struct {
@@ -54,7 +53,7 @@ func NewInstall(cfg *operator.Configuration) Install {
54
53
}
55
54
56
55
func (i * Install ) BindFlags (fs * pflag.FlagSet ) {
57
- fs .StringVar (& i .IndexImage , "index-image" , registry .DefaultIndexImage , "index image in which to inject bundle" )
56
+ fs .StringVar (& i .IndexImage , "index-image" , fbcutil .DefaultIndexImage , "index image in which to inject bundle" )
58
57
fs .Var (& i .InstallMode , "install-mode" , "install mode" )
59
58
60
59
// --mode is hidden so only users who know what they're doing can alter add mode.
@@ -95,15 +94,15 @@ func (i *Install) setup(ctx context.Context) error {
95
94
return err
96
95
}
97
96
98
- // get index image labels.
99
- catalogLabels , err := registryutil . GetImageLabels (ctx , nil , i .IndexImageCatalogCreator .IndexImage , false )
97
+ // check if index image adopts File-Based Catalog or SQLite index image format
98
+ isFBCImage , err := fbcutil . IsFBC (ctx , i .IndexImageCatalogCreator .IndexImage )
100
99
if err != nil {
101
- return fmt .Errorf ("get index image labels: %v " , err )
100
+ return fmt .Errorf ("error in upgrading the bundle %q that was installed traditionally " , i . IndexImageCatalogCreator . BundleImage )
102
101
}
102
+ i .IndexImageCatalogCreator .HasFBCLabel = isFBCImage
103
103
104
104
// set the field to true if FBC label is on the image or for a default index image.
105
- if _ , hasFBCLabel := catalogLabels [containertools .ConfigsLocationLabel ]; hasFBCLabel || i .IndexImageCatalogCreator .IndexImage == registry .DefaultIndexImage {
106
- i .IndexImageCatalogCreator .HasFBCLabel = true
105
+ if i .IndexImageCatalogCreator .HasFBCLabel {
107
106
if i .IndexImageCatalogCreator .BundleAddMode != "" {
108
107
return fmt .Errorf ("specifying the bundle add mode is not supported for File-Based Catalog bundles and index images" )
109
108
}
@@ -115,7 +114,7 @@ func (i *Install) setup(ctx context.Context) error {
115
114
116
115
if i .IndexImageCatalogCreator .HasFBCLabel {
117
116
// FBC variables
118
- f := & registry .FBCContext {
117
+ f := & fbcutil .FBCContext {
119
118
Package : labels [registrybundle .PackageLabel ],
120
119
Refs : []string {i .BundleImage },
121
120
ChannelEntry : declarativeconfig.ChannelEntry {
@@ -126,7 +125,7 @@ func (i *Install) setup(ctx context.Context) error {
126
125
if _ , hasChannelMetadata := labels [registrybundle .ChannelsLabel ]; hasChannelMetadata {
127
126
f .ChannelName = strings .Split (labels [registrybundle .ChannelsLabel ], "," )[0 ]
128
127
} else {
129
- f .ChannelName = registry .DefaultChannel
128
+ f .ChannelName = fbcutil .DefaultChannel
130
129
}
131
130
132
131
// generate an fbc if an fbc specific label is found on the image or for a default index image.
@@ -151,7 +150,7 @@ func (i *Install) setup(ctx context.Context) error {
151
150
}
152
151
153
152
// generateFBCContent creates a File-Based Catalog using the bundle image and index image from the run bundle command.
154
- func generateFBCContent (ctx context.Context , f * registry .FBCContext , bundleImage , indexImage string ) (string , error ) {
153
+ func generateFBCContent (ctx context.Context , f * fbcutil .FBCContext , bundleImage , indexImage string ) (string , error ) {
155
154
log .Infof ("Creating a File-Based Catalog of the bundle %q" , bundleImage )
156
155
// generate a File-Based Catalog representation of the bundle image
157
156
bundleDeclcfg , err := f .CreateFBC (ctx )
@@ -165,7 +164,7 @@ func generateFBCContent(ctx context.Context, f *registry.FBCContext, bundleImage
165
164
Channels : []declarativeconfig.Channel {bundleDeclcfg .Channel },
166
165
}
167
166
168
- if indexImage != registry .DefaultIndexImage { // non-default index image was specified.
167
+ if indexImage != fbcutil .DefaultIndexImage { // non-default index image was specified.
169
168
// since an index image is specified, the bundle image will be added to the index image.
170
169
// addBundleToIndexImage will ensure that the bundle is not already present in the index image and error out if it does.
171
170
declcfg , err = addBundleToIndexImage (ctx , indexImage , bundleDeclcfg )
@@ -176,7 +175,7 @@ func generateFBCContent(ctx context.Context, f *registry.FBCContext, bundleImage
176
175
177
176
// validate the declarative config and convert it to a string
178
177
var content string
179
- if content , err = registry .ValidateAndStringify (declcfg ); err != nil {
178
+ if content , err = fbcutil .ValidateAndStringify (declcfg ); err != nil {
180
179
return "" , fmt .Errorf ("error validating and converting the declarative config object to a string format: %v" , err )
181
180
}
182
181
@@ -186,7 +185,7 @@ func generateFBCContent(ctx context.Context, f *registry.FBCContext, bundleImage
186
185
}
187
186
188
187
// addBundleToIndexImage adds the bundle to an existing index image if the bundle is not already present in the index image.
189
- func addBundleToIndexImage (ctx context.Context , indexImage string , bundleDeclConfig registry .BundleDeclcfg ) (* declarativeconfig.DeclarativeConfig , error ) {
188
+ func addBundleToIndexImage (ctx context.Context , indexImage string , bundleDeclConfig fbcutil .BundleDeclcfg ) (* declarativeconfig.DeclarativeConfig , error ) {
190
189
log .Infof ("Rendering a File-Based Catalog of the Index Image %q" , indexImage )
191
190
log .SetOutput (ioutil .Discard )
192
191
render := action.Render {
0 commit comments