Skip to content

Commit aa0264f

Browse files
committed
Fills CIS or DNS CRN in Metadata, never both
Signed-off-by: Hiro Miyamoto <[email protected]>
1 parent 4454d62 commit aa0264f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

pkg/asset/installconfig/installconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (a *InstallConfig) finish(filename string) error {
151151
a.IBMCloud = icibmcloud.NewMetadata(a.Config)
152152
}
153153
if a.Config.PowerVS != nil {
154-
a.PowerVS = icpowervs.NewMetadata(a.Config.BaseDomain)
154+
a.PowerVS = icpowervs.NewMetadata(a.Config)
155155
}
156156
if a.Config.VSphere != nil {
157157
a.VSphere = icvsphere.NewMetadata()

pkg/asset/installconfig/powervs/metadata.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ type MetadataAPI interface {
2424
// do not need to be user-supplied (e.g. because it can be retrieved
2525
// from external APIs).
2626
type Metadata struct {
27-
BaseDomain string
27+
BaseDomain string
28+
PublishStrategy types.PublishingStrategy
2829

2930
accountID string
3031
apiKey string
@@ -36,8 +37,8 @@ type Metadata struct {
3637
}
3738

3839
// NewMetadata initializes a new Metadata object.
39-
func NewMetadata(baseDomain string) *Metadata {
40-
return &Metadata{BaseDomain: baseDomain}
40+
func NewMetadata(config *types.InstallConfig) *Metadata {
41+
return &Metadata{BaseDomain: config.BaseDomain, PublishStrategy: config.Publish}
4142
}
4243

4344
// AccountID returns the IBM Cloud account ID associated with the authentication
@@ -105,7 +106,7 @@ func (m *Metadata) CISInstanceCRN(ctx context.Context) (string, error) {
105106
m.client = client
106107
}
107108

108-
if m.cisInstanceCRN == "" {
109+
if m.PublishStrategy == types.ExternalPublishingStrategy && m.cisInstanceCRN == "" {
109110
m.cisInstanceCRN, err = m.client.GetInstanceCRNByName(ctx, m.BaseDomain, types.ExternalPublishingStrategy)
110111
if err != nil {
111112
return "", err
@@ -135,7 +136,7 @@ func (m *Metadata) DNSInstanceCRN(ctx context.Context) (string, error) {
135136
m.client = client
136137
}
137138

138-
if m.dnsInstanceCRN == "" {
139+
if m.PublishStrategy == types.InternalPublishingStrategy && m.dnsInstanceCRN == "" {
139140
m.dnsInstanceCRN, err = m.client.GetInstanceCRNByName(ctx, m.BaseDomain, types.InternalPublishingStrategy)
140141
if err != nil {
141142
return "", err

0 commit comments

Comments
 (0)