Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2958 from imain/generate_cr
Baremetal: Generate CR to configure baremetal.
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
data/data/manifests/openshift/baremetal-provisioning-config.yaml.template
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,10 @@ | ||
apiVersion: metal3.io/v1alpha1 | ||
kind: Provisioning | ||
metadata: | ||
name: provisioning-configuration | ||
spec: | ||
provisioningInterface: {{.ProvisioningNetworkInterface}} | ||
provisioningIP: {{.ClusterProvisioningIP}} | ||
provisioningNetworkCIDR: {{.ProvisioningNetworkCIDR}} | ||
provisioningDHCPExternal: {{.ProvisioningDHCPExternal}} | ||
provisioningDHCPRange: {{.ProvisioningDHCPRange}} |
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
64 changes: 64 additions & 0 deletions
64
pkg/asset/templates/content/openshift/baremetal-provisioning-config.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,64 @@ | ||
package openshift | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/openshift/installer/pkg/asset" | ||
"github.com/openshift/installer/pkg/asset/templates/content" | ||
) | ||
|
||
const ( | ||
baremetalConfigFilename = "baremetal-provisioning-config.yaml.template" | ||
) | ||
|
||
var _ asset.WritableAsset = (*BaremetalConfig)(nil) | ||
|
||
// BaremetalConfig is the custom resource definitions for the baremetal deployment | ||
type BaremetalConfig struct { | ||
FileList []*asset.File | ||
} | ||
|
||
// Dependencies returns all of the dependencies directly needed by the asset | ||
func (t *BaremetalConfig) Dependencies() []asset.Asset { | ||
return []asset.Asset{} | ||
} | ||
|
||
// Name returns the human-friendly name of the asset. | ||
func (t *BaremetalConfig) Name() string { | ||
return "Baremetal Config CR" | ||
} | ||
|
||
// Generate generates the actual files by this asset | ||
func (t *BaremetalConfig) Generate(parents asset.Parents) error { | ||
fileName := baremetalConfigFilename | ||
data, err := content.GetOpenshiftTemplate(fileName) | ||
if err != nil { | ||
return err | ||
} | ||
t.FileList = []*asset.File{ | ||
{ | ||
Filename: filepath.Join(content.TemplateDir, fileName), | ||
Data: []byte(data), | ||
}, | ||
} | ||
return nil | ||
} | ||
|
||
// Files returns the files generated by the asset. | ||
func (t *BaremetalConfig) Files() []*asset.File { | ||
return t.FileList | ||
} | ||
|
||
// Load returns the asset from disk. | ||
func (t *BaremetalConfig) Load(f asset.FileFetcher) (bool, error) { | ||
file, err := f.FetchByName(filepath.Join(content.TemplateDir, baremetalConfigFilename)) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
t.FileList = append(t.FileList, file) | ||
return true, nil | ||
} |