Skip to content

Commit

Permalink
Added operator-sdk support to the e2e workflow
Browse files Browse the repository at this point in the history
Signed-off-by: jubittajohn <jujohn@redhat.com>
  • Loading branch information
jubittajohn committed Jul 24, 2023
1 parent 12efcfb commit 2dbce7b
Show file tree
Hide file tree
Showing 6 changed files with 678 additions and 450 deletions.
32 changes: 0 additions & 32 deletions test/operator-e2e/config/catalog_config.yaml

This file was deleted.

70 changes: 0 additions & 70 deletions test/operator-e2e/config/read_config.go

This file was deleted.

83 changes: 33 additions & 50 deletions test/operator-e2e/create_fbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (

"github.com/operator-framework/operator-registry/alpha/declcfg"
"github.com/operator-framework/operator-registry/alpha/property"

"github.com/operator-framework/operator-controller/test/operator-e2e/config"
)

const (
Expand All @@ -20,85 +18,70 @@ const (
BundleMediatype = "plain+v0"
)

// reuires bundle info
// operatorname
// defaultchannel
// Reads the catalog-config and creates the FBC by calling functions for forming the package, channel and bundles.
func CreateFBC(configFilePath string) (*declcfg.DeclarativeConfig, error) {
config, err := config.ReadFile(configFilePath)
if err != nil {
return nil, err
}

dPackage := formPackage(*config)
dChannel := formChannel(*config)
dBundle := formBundle(*config)
func CreateFBC(operatorName, defaultChannel string, bundleRef, bundleVersions []string) *declcfg.DeclarativeConfig {
dPackage := formPackage(operatorName, defaultChannel)
dChannel := formChannel(operatorName, defaultChannel, bundleVersions)
dBundle := formBundle(operatorName, bundleVersions, bundleRef)

fbc := declcfg.DeclarativeConfig{
Packages: []declcfg.Package{dPackage},
Channels: dChannel,
Channels: []declcfg.Channel{dChannel},
Bundles: dBundle,
}
return &fbc, nil
return &fbc
}

// Forms package schema for the FBC
func formPackage(config config.Config) declcfg.Package {
func formPackage(pkgName, defaultChannelName string) declcfg.Package {
packageFormed := declcfg.Package{
Schema: SchemaPackage,
Name: config.PackageName,
DefaultChannel: config.ChannelData[0].ChannelName,
Name: pkgName,
DefaultChannel: defaultChannelName,
}
return packageFormed
}

// Forms channel schema for the FBC
func formChannel(config config.Config) []declcfg.Channel {
channelFormed := make([]declcfg.Channel, 0, len(config.ChannelData))
for _, channel := range config.ChannelData {
channelEntries := formChannelEntries(config.PackageName, channel)
channelFormed = append(channelFormed, declcfg.Channel{
Schema: SchemaChannel,
Name: channel.ChannelName,
Package: config.PackageName,
Entries: channelEntries,
})
func formChannel(pkgName, channelName string, bundleVersions []string) declcfg.Channel {
channelEntries := formChannelEntries(pkgName, bundleVersions)
channelFormed := declcfg.Channel{
Schema: SchemaChannel,
Name: channelName,
Package: pkgName,
Entries: channelEntries,
}
return channelFormed
}

// Forms the uprade graph for the FBC
func formChannelEntries(pkgName string, channel config.ChannelData) []declcfg.ChannelEntry {
channelEntries := make([]declcfg.ChannelEntry, 0, len(channel.ChannelEntries))
for _, channelEntry := range channel.ChannelEntries {
func formChannelEntries(pkgName string, bundleVersions []string) []declcfg.ChannelEntry {
channelEntries := make([]declcfg.ChannelEntry, 0, len(bundleVersions))
for i, version := range bundleVersions {
replace := ""
if channelEntry.Replaces != "" {
replace = pkgName + "." + channelEntry.Replaces
if i != 0 {
replace = pkgName + "." + bundleVersions[i-1]
}

skip := []string{}
if len(channelEntry.Skips) != 0 {
for _, s := range channelEntry.Skips {
if s != "" {
skip = append(skip, pkgName+"."+s)
}
}
}
channelEntries = append(channelEntries, declcfg.ChannelEntry{
Name: pkgName + "." + channelEntry.EntryVersion,
Replaces: replace,
Skips: skip,
SkipRange: channelEntry.SkipRange,
Name: pkgName + "." + version,
Replaces: replace,
})
}
return channelEntries
}

// Forms bundle schema for the FBC
func formBundle(config config.Config) []declcfg.Bundle {
bundleFormed := make([]declcfg.Bundle, 0, len(config.BundleData))
for _, bundle := range config.BundleData {
func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
bundleFormed := make([]declcfg.Bundle, 0, len(imageRefs))
for i := 0; i < len(imageRefs); i++ {
var properties []property.Property
properties = append(properties, property.Property{
Type: SchemaPackage,
Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, config.PackageName, bundle.BundleVersion)),
Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, pkgName, versions[i])),
})
properties = append(properties, property.Property{
Type: SchemaBundleMediatype,
Expand All @@ -107,9 +90,9 @@ func formBundle(config config.Config) []declcfg.Bundle {

bundleFormed = append(bundleFormed, declcfg.Bundle{
Schema: SchemaBundle,
Name: config.PackageName + "." + bundle.BundleVersion,
Package: config.PackageName,
Image: bundle.BundleImage,
Name: pkgName + "." + versions[i],
Package: pkgName,
Image: imageRefs[i],
Properties: properties,
})
}
Expand Down
36 changes: 0 additions & 36 deletions test/operator-e2e/generate_dockerfile.go

This file was deleted.

Loading

0 comments on commit 2dbce7b

Please sign in to comment.