Skip to content
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
5 changes: 5 additions & 0 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ enableFips: enable-fips
# Default: false
# [Optional]
enableInteractiveFlow: enable-interactive-flow
# Rename CatalogSource names generated by oc-mirror to the default naming.
# E.g. 'redhat-operators' instead of 'cs-redhat-operator-index-v4-19'.
# Default: false
# [Optional]
useDefaultSourceNames: use-default-source-names
# Additional images to be included in the appliance disk image.
# [Optional]
additionalImages:
Expand Down
8 changes: 7 additions & 1 deletion pkg/asset/config/appliance_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ stopLocalRegistry: %t
# [Optional]
# enableInteractiveFlow: %t

# Rename CatalogSource names generated by oc-mirror to the default naming.
# E.g. 'redhat-operators' instead of 'cs-redhat-operator-index-v4-19'.
# Default: false
# [Optional]
# useDefaultSourceNames: %t

# Additional images to be included in the appliance disk image.
# [Optional]
# additionalImages:
Expand All @@ -207,7 +213,7 @@ stopLocalRegistry: %t
graph.ReleaseChannelStable, CpuArchitectureX86, MinDiskSize,
RegistryMinPort, RegistryMaxPort, consts.RegistryPort,
consts.EnableDefaultSources, consts.StopLocalRegistry, consts.CreatePinnedImageSets,
consts.EnableFips, consts.EnableInteractiveFlow)
consts.EnableFips, consts.EnableInteractiveFlow, consts.UseDefaultSourceNames)

return nil
}
Expand Down
36 changes: 33 additions & 3 deletions pkg/asset/ignition/bootstrap_ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"path/filepath"
"regexp"
"strings"

"github.com/coreos/ignition/v2/config/util"
Expand Down Expand Up @@ -41,6 +42,17 @@ const (
extraManifestsPath = "/etc/assisted/extra-manifests"
)

type CatalogSource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec CatalogSourceSpec `json:"spec"`
}
type CatalogSourceSpec struct {
Image string `json:"image,omitempty"`
SourceType SourceType `json:"sourceType"`
}
type SourceType string

var (
bootstrapServices = []string{
"start-local-registry.service",
Expand Down Expand Up @@ -200,7 +212,7 @@ func (i *BootstrapIgnition) Generate(_ context.Context, dependencies asset.Paren
}

// Add manifests generated by oc-mirror
if err := i.addGeneratedManifests(envConfig); err != nil {
if err := i.addGeneratedManifests(envConfig.CacheDir, applianceConfig.Config.UseDefaultSourceNames); err != nil {
return err
}

Expand Down Expand Up @@ -263,9 +275,9 @@ func (i *BootstrapIgnition) addExtraManifests(config *igntypes.Config, extraMani
return nil
}

func (i *BootstrapIgnition) addGeneratedManifests(envConfig *config.EnvConfig) error {
func (i *BootstrapIgnition) addGeneratedManifests(cacheDir string, useDefaultSourceNames *bool) error {
// Find manifests yaml files
files, err := filepath.Glob(filepath.Join(envConfig.CacheDir, release.OcGeneratedManifestsDir, "*.yaml"))
files, err := filepath.Glob(filepath.Join(cacheDir, release.OcGeneratedManifestsDir, "*.yaml"))
if err != nil {
logrus.Error("Missing manifests files in cache")
return err
Expand All @@ -283,6 +295,24 @@ func (i *BootstrapIgnition) addGeneratedManifests(envConfig *config.EnvConfig) e
// Use CatalogSource instead
continue
}

// Convert to default source naming (e.g. redhat-operators)
if swag.BoolValue(useDefaultSourceNames) {
var cs CatalogSource
if err = yaml.Unmarshal(fileBytes, &cs); err != nil {
return err
}

re := regexp.MustCompile(`.*?(\w+-operator)-index.*`)
name := re.ReplaceAllString(cs.Name, "${1}")
cs.Name = strings.Replace(name, "operator", "operators", 1)

fileBytes, err = yaml.Marshal(cs)
if err != nil {
return err
}
}

manifestPath := fmt.Sprintf("%s/%s", extraManifestsPath, filepath.Base(file))
manifestFile := ignasset.FileFromBytes(manifestPath, "root", 0644, fileBytes)
i.Config.Storage.Files = append(i.Config.Storage.Files, manifestFile)
Expand Down
1 change: 1 addition & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ const (
CreatePinnedImageSets = false
EnableFips = false
EnableInteractiveFlow = false
UseDefaultSourceNames = false
)
1 change: 1 addition & 0 deletions pkg/types/appliance_config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ApplianceConfig struct {
StopLocalRegistry *bool `json:"stopLocalRegistry"`
CreatePinnedImageSets *bool `json:"createPinnedImageSets"`
EnableInteractiveFlow *bool `json:"enableInteractiveFlow"`
UseDefaultSourceNames *bool `json:"useDefaultSourceNames"`
AdditionalImages *[]Image `json:"additionalImages,omitempty"`
Operators *[]Operator `json:"operators,omitempty"`
}
Expand Down