Skip to content

Commit 1db371c

Browse files
committed
Adding private DNS domains to survey for PowerVS
Signed-off-by: Hiro Miyamoto <[email protected]>
1 parent 8353ac4 commit 1db371c

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

pkg/asset/installconfig/basedomain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
gcpconfig "github.com/openshift/installer/pkg/asset/installconfig/gcp"
1212
ibmcloudconfig "github.com/openshift/installer/pkg/asset/installconfig/ibmcloud"
1313
powervsconfig "github.com/openshift/installer/pkg/asset/installconfig/powervs"
14+
"github.com/openshift/installer/pkg/types"
1415
"github.com/openshift/installer/pkg/types/aws"
1516
"github.com/openshift/installer/pkg/types/azure"
1617
"github.com/openshift/installer/pkg/types/gcp"
@@ -21,6 +22,7 @@ import (
2122

2223
type baseDomain struct {
2324
BaseDomain string
25+
Publish types.PublishingStrategy
2426
}
2527

2628
var _ asset.Asset = (*baseDomain)(nil)
@@ -78,6 +80,7 @@ func (a *baseDomain) Generate(parents asset.Parents) error {
7880
return err
7981
}
8082
a.BaseDomain = zone.Name
83+
a.Publish = zone.Publish
8184
return nil
8285
default:
8386
//Do nothing

pkg/asset/installconfig/installconfig.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (a *InstallConfig) Generate(parents asset.Parents) error {
8484
},
8585
SSHKey: sshPublicKey.Key,
8686
BaseDomain: baseDomain.BaseDomain,
87+
Publish: baseDomain.Publish,
8788
PullSecret: pullSecret.PullSecret,
8889
}
8990

pkg/asset/installconfig/installconfig_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
func TestInstallConfigGenerate_FillsInDefaults(t *testing.T) {
2222
sshPublicKey := &sshPublicKey{}
23-
baseDomain := &baseDomain{"test-domain"}
23+
baseDomain := &baseDomain{"test-domain", types.ExternalPublishingStrategy}
2424
clusterName := &clusterName{"test-cluster"}
2525
pullSecret := &pullSecret{`{"auths":{"example.com":{"auth":"authorization value"}}}`}
2626
platform := &platform{

pkg/asset/installconfig/powervs/dns.go

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
// Zone represents a DNS Zone
1616
type Zone struct {
1717
Name string
18-
CISInstanceCRN string
18+
InstanceCRN string
1919
ResourceGroupID string
20+
Publish types.PublishingStrategy
2021
}
2122

2223
// GetDNSZone returns a DNS Zone chosen by survey.
@@ -28,23 +29,29 @@ func GetDNSZone() (*Zone, error) {
2829
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
2930
defer cancel()
3031

31-
// Default to offering only external DNS entries, as IBM Cloud does in their provider
32-
// TODO(mjturek): Offer private zones (IBM DNS) when deploying a private cluster
33-
publicZones, err := client.GetDNSZones(ctx, types.ExternalPublishingStrategy)
34-
if err != nil {
35-
return nil, fmt.Errorf("could not retrieve base domains: %w", err)
36-
}
37-
3832
var options []string
39-
var optionToZoneMap = make(map[string]*Zone, len(publicZones))
40-
for _, zone := range publicZones {
41-
option := fmt.Sprintf("%s (%s)", zone.Name, zone.InstanceName)
42-
optionToZoneMap[option] = &Zone{
43-
Name: zone.Name,
44-
CISInstanceCRN: zone.InstanceCRN,
45-
ResourceGroupID: zone.ResourceGroupID,
33+
var optionToZoneMap = make(map[string]*Zone, 10)
34+
isInternal := ""
35+
strategies := []types.PublishingStrategy{types.ExternalPublishingStrategy, types.InternalPublishingStrategy}
36+
for _, s := range strategies {
37+
zones, err := client.GetDNSZones(ctx, s)
38+
if err != nil {
39+
return nil, fmt.Errorf("could not retrieve base domains: %w", err)
40+
}
41+
42+
for _, zone := range zones {
43+
if s == types.InternalPublishingStrategy {
44+
isInternal = " (Internal)"
45+
}
46+
option := fmt.Sprintf("%s%s", zone.Name, isInternal)
47+
optionToZoneMap[option] = &Zone{
48+
Name: zone.Name,
49+
InstanceCRN: zone.InstanceCRN,
50+
ResourceGroupID: zone.ResourceGroupID,
51+
Publish: s,
52+
}
53+
options = append(options, option)
4654
}
47-
options = append(options, option)
4855
}
4956
sort.Strings(options)
5057

@@ -58,7 +65,7 @@ func GetDNSZone() (*Zone, error) {
5865
survey.WithValidator(func(ans interface{}) error {
5966
choice := ans.(core.OptionAnswer).Value
6067
i := sort.SearchStrings(options, choice)
61-
if i == len(publicZones) || options[i] != choice {
68+
if i == len(options) || options[i] != choice {
6269
return fmt.Errorf("invalid base domain %q", choice)
6370
}
6471
return nil

0 commit comments

Comments
 (0)