Skip to content

Commit 0432677

Browse files
Merge pull request openshift#8752 from mresvanis/ocpbugs-37226-enhance-imagebased-config-template-ux
OCPBUGS-37226: Persist image-based config manifests from state instead of template
2 parents 5b6b221 + 6c93aba commit 0432677

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

pkg/asset/imagebased/configimage/configiso.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ func (ci *ConfigImage) Generate(_ context.Context, dependencies asset.Parents) e
9191
return nil
9292
}
9393

94-
// PersistToFile writes the iso image in the assets folder.
94+
// PersistToFile writes the ISO image in the assets folder.
9595
func (ci *ConfigImage) PersistToFile(directory string) error {
9696
defer os.RemoveAll(ci.tmpPath)
9797

9898
// If the tmpPath is not set then it means that either one of the Config
9999
// dependencies or the asset itself failed for some reason
100100
if ci.tmpPath == "" {
101-
return errors.New("cannot generate Config image due to configuration errors")
101+
return errors.New("cannot generate config image due to configuration errors")
102102
}
103103

104104
configImageFile := filepath.Join(directory, configImageFilename)

pkg/asset/imagebased/configimage/imagebased_config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ networkConfig:
8585

8686
// PersistToFile writes the image-based-config.yaml file to the assets folder.
8787
func (i *ImageBasedConfig) PersistToFile(directory string) error {
88-
templatePath := filepath.Join(directory, imageBasedConfigFilename)
89-
templateByte := []byte(i.Template)
88+
if i.File == nil {
89+
return nil
90+
}
9091

91-
err := os.WriteFile(templatePath, templateByte, 0o600)
92+
configPath := filepath.Join(directory, imageBasedConfigFilename)
93+
err := os.WriteFile(configPath, i.File.Data, 0o600)
9294
if err != nil {
9395
return err
9496
}

pkg/asset/imagebased/image/ignition.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (i *Ignition) Generate(_ context.Context, dependencies asset.Parents) error
7171

7272
ibiConfig := configAsset.Config
7373
if ibiConfig == nil {
74-
return nil
74+
return fmt.Errorf("%s is required", configFilename)
7575
}
7676

7777
config := &igntypes.Config{

pkg/asset/imagebased/image/image.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func (i *Image) Generate(_ context.Context, dependencies asset.Parents) error {
6060

6161
// PersistToFile writes the ISO image in the assets folder.
6262
func (i *Image) PersistToFile(directory string) error {
63-
if i.Config == nil {
64-
return fmt.Errorf("imagebased installation configuration is nil")
63+
if i.Config == nil || len(i.IgnitionByte) == 0 {
64+
return fmt.Errorf("could not generate image because of configuration errors")
6565
}
6666

6767
// Create a tmp folder to store all the pieces required to generate the image-based installer artifacts.

pkg/asset/imagebased/image/imagebased_config.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ pullSecret: '<your-pull-secret>'
9494

9595
// PersistToFile writes the image-based-installation-config.yaml file to the assets folder.
9696
func (i *ImageBasedInstallationConfig) PersistToFile(directory string) error {
97-
templatePath := filepath.Join(directory, configFilename)
98-
templateByte := []byte(i.Template)
97+
if i.File == nil {
98+
return nil
99+
}
99100

100-
err := os.WriteFile(templatePath, templateByte, 0o600)
101+
configPath := filepath.Join(directory, configFilename)
102+
err := os.WriteFile(configPath, i.File.Data, 0o600)
101103
if err != nil {
102104
return err
103105
}

0 commit comments

Comments
 (0)