@@ -15,8 +15,9 @@ import (
1515// Zone represents a DNS Zone
1616type 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