Skip to content

Commit 5eca200

Browse files
committed
inject ClusterInfo into AgentImage asset
1 parent ed7d590 commit 5eca200

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

pkg/asset/agent/image/agentimage.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414
"github.com/openshift/assisted-image-service/pkg/isoeditor"
1515
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
1616
"github.com/openshift/installer/pkg/asset"
17+
"github.com/openshift/installer/pkg/asset/agent/joiner"
1718
"github.com/openshift/installer/pkg/asset/agent/manifests"
19+
"github.com/openshift/installer/pkg/asset/agent/workflow"
1820
)
1921

2022
const (
@@ -39,6 +41,8 @@ var _ asset.WritableAsset = (*AgentImage)(nil)
3941
// Dependencies returns the assets on which the Bootstrap asset depends.
4042
func (a *AgentImage) Dependencies() []asset.Asset {
4143
return []asset.Asset{
44+
&workflow.AgentWorkflow{},
45+
&joiner.ClusterInfo{},
4246
&AgentArtifacts{},
4347
&manifests.AgentManifests{},
4448
&BaseIso{},
@@ -47,10 +51,23 @@ func (a *AgentImage) Dependencies() []asset.Asset {
4751

4852
// Generate generates the image file for to ISO asset.
4953
func (a *AgentImage) Generate(dependencies asset.Parents) error {
54+
agentWorkflow := &workflow.AgentWorkflow{}
55+
clusterInfo := &joiner.ClusterInfo{}
5056
agentArtifacts := &AgentArtifacts{}
5157
agentManifests := &manifests.AgentManifests{}
5258
baseIso := &BaseIso{}
53-
dependencies.Get(agentArtifacts, agentManifests, baseIso)
59+
dependencies.Get(agentArtifacts, agentManifests, baseIso, agentWorkflow, clusterInfo)
60+
61+
switch agentWorkflow.Workflow {
62+
case workflow.AgentWorkflowTypeInstall:
63+
a.platform = agentManifests.AgentClusterInstall.Spec.PlatformType
64+
65+
case workflow.AgentWorkflowTypeAddNodes:
66+
a.platform = clusterInfo.PlatformType
67+
68+
default:
69+
return fmt.Errorf("AgentWorkflowType value not supported: %s", agentWorkflow.Workflow)
70+
}
5471

5572
a.cpuArch = agentArtifacts.CPUArch
5673
a.rendezvousIP = agentArtifacts.RendezvousIP
@@ -64,7 +81,6 @@ func (a *AgentImage) Generate(dependencies asset.Parents) error {
6481
}
6582
a.volumeID = volumeID
6683

67-
a.platform = agentManifests.AgentClusterInstall.Spec.PlatformType
6884
if a.platform == hiveext.ExternalPlatformType {
6985
// when the bootArtifactsBaseURL is specified, construct the custom rootfs URL
7086
if a.bootArtifactsBaseURL != "" {

pkg/asset/agent/joiner/clusterinfo.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import (
1212
"k8s.io/client-go/tools/clientcmd"
1313
"sigs.k8s.io/yaml"
1414

15+
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
1516
configclient "github.com/openshift/client-go/config/clientset/versioned"
1617
"github.com/openshift/installer/pkg/asset"
18+
"github.com/openshift/installer/pkg/asset/agent"
1719
"github.com/openshift/installer/pkg/asset/agent/workflow"
1820
"github.com/openshift/installer/pkg/types"
1921
)
@@ -33,6 +35,7 @@ type ClusterInfo struct {
3335
Architecture string
3436
ImageDigestSources []types.ImageDigestSource
3537
DeprecatedImageContentSources []types.ImageContentSource
38+
PlatformType hiveext.PlatformType
3639
}
3740

3841
var _ asset.WritableAsset = (*ClusterInfo)(nil)
@@ -99,7 +102,7 @@ func (ci *ClusterInfo) Generate(dependencies asset.Parents) error {
99102
if err != nil {
100103
return err
101104
}
102-
err = ci.retrieveImageDigestSources(k8sclientset)
105+
err = ci.retrieveInstallConfigData(k8sclientset)
103106
if err != nil {
104107
return err
105108
}
@@ -191,7 +194,7 @@ func (ci *ClusterInfo) retrieveArchitecture(clientset *kubernetes.Clientset) err
191194
return nil
192195
}
193196

194-
func (ci *ClusterInfo) retrieveImageDigestSources(clientset *kubernetes.Clientset) error {
197+
func (ci *ClusterInfo) retrieveInstallConfigData(clientset *kubernetes.Clientset) error {
195198
clusterConfig, err := clientset.CoreV1().ConfigMaps("kube-system").Get(context.Background(), "cluster-config-v1", metav1.GetOptions{})
196199
if err != nil {
197200
if errors.IsNotFound(err) {
@@ -208,8 +211,10 @@ func (ci *ClusterInfo) retrieveImageDigestSources(clientset *kubernetes.Clientse
208211
if err = yaml.Unmarshal([]byte(data), &installConfig); err != nil {
209212
return err
210213
}
214+
211215
ci.ImageDigestSources = installConfig.ImageDigestSources
212216
ci.DeprecatedImageContentSources = installConfig.DeprecatedImageContentSources
217+
ci.PlatformType = agent.HivePlatformType(installConfig.Platform)
213218

214219
return nil
215220
}

0 commit comments

Comments
 (0)