forked from operator-framework/operator-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema migration optional; default to olm.bundle.object
Signed-off-by: Jordan Keister <jordan@nimblewidget.com>
- Loading branch information
Showing
14 changed files
with
111 additions
and
106 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
alpha/action/internal/migrations/000_bundle_object_to_csv_metadata.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
alpha/action/migrations/000_bundle_object_to_csv_metadata.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package migrations | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
|
||
"github.com/operator-framework/operator-registry/alpha/declcfg" | ||
"github.com/operator-framework/operator-registry/alpha/property" | ||
) | ||
|
||
var BundleObjectToCSVMetadata = newMigration( | ||
"bundle-object-to-csv-metadata", | ||
"migrates bundles' `olm.bundle.object` to `olm.csv.metadata`", | ||
func(cfg *declcfg.DeclarativeConfig) error { | ||
convertBundleObjectToCSVMetadata := func(b *declcfg.Bundle) error { | ||
if b.Image == "" || b.CsvJSON == "" { | ||
return nil | ||
} | ||
|
||
var csv v1alpha1.ClusterServiceVersion | ||
if err := json.Unmarshal([]byte(b.CsvJSON), &csv); err != nil { | ||
return err | ||
} | ||
|
||
props := b.Properties[:0] | ||
for _, p := range b.Properties { | ||
switch p.Type { | ||
case property.TypeBundleObject: | ||
// Get rid of the bundle objects | ||
case property.TypeCSVMetadata: | ||
// If this bundle already has a CSV metadata | ||
// property, we won't mutate the bundle at all. | ||
return nil | ||
default: | ||
// Keep all of the other properties | ||
props = append(props, p) | ||
} | ||
} | ||
b.Properties = append(props, property.MustBuildCSVMetadata(csv)) | ||
return nil | ||
} | ||
|
||
for bi := range cfg.Bundles { | ||
if err := convertBundleObjectToCSVMetadata(&cfg.Bundles[bi]); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.