Skip to content

Commit 13e8ce9

Browse files
authored
feat: Implement DNS zone selection for AWS and Azure and update polly to the latest version (#713)
* use latest version of polly * implement dropdown selection for Azure DNS zones in domain setup * implement dropdown selection for AWS hosted zones in domain setup * remove redundant DNS zone selection logic for AWS and Azure * streamline GCP provider logic in DNS zone selection
1 parent f479172 commit 13e8ce9

File tree

30 files changed

+115
-86
lines changed

30 files changed

+115
-86
lines changed

cmd/command/cd/cd_clusters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88

99
"github.com/AlecAivazis/survey/v2"
1010
gqlclient "github.com/pluralsh/console/go/client"
11-
"github.com/pluralsh/polly/algorithms"
12-
"github.com/pluralsh/polly/containers"
11+
"github.com/pluralsh/console/go/polly/algorithms"
12+
"github.com/pluralsh/console/go/polly/containers"
1313
"github.com/samber/lo"
1414
"github.com/urfave/cli"
1515
"sigs.k8s.io/yaml"

cmd/command/cd/cd_notifications.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package cd
33
import (
44
"github.com/AlecAivazis/survey/v2"
55
consoleclient "github.com/pluralsh/console/go/client"
6+
"github.com/pluralsh/console/go/polly/algorithms"
67
"github.com/pluralsh/plural-cli/pkg/common"
78
"github.com/pluralsh/plural-cli/pkg/utils"
8-
"github.com/pluralsh/polly/algorithms"
99
"github.com/urfave/cli"
1010
)
1111

cmd/command/cd/cd_services.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/pluralsh/console/go/polly/fs"
1112
"github.com/pluralsh/plural-cli/pkg/common"
12-
"github.com/pluralsh/polly/fs"
1313
lua "github.com/yuin/gopher-lua"
1414

1515
gqlclient "github.com/pluralsh/console/go/client"
16+
"github.com/pluralsh/console/go/polly/containers"
17+
"github.com/pluralsh/console/go/polly/luautils"
1618
"github.com/pluralsh/plural-cli/pkg/cd/template"
1719
"github.com/pluralsh/plural-cli/pkg/console"
1820
"github.com/pluralsh/plural-cli/pkg/utils"
19-
"github.com/pluralsh/polly/containers"
20-
"github.com/pluralsh/polly/luautils"
2121
"github.com/samber/lo"
2222
"github.com/urfave/cli"
2323
"k8s.io/apimachinery/pkg/util/yaml"

cmd/command/up/up.go

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88

99
"github.com/AlecAivazis/survey/v2"
10-
"github.com/pluralsh/polly/algorithms"
10+
"github.com/pluralsh/console/go/polly/algorithms"
1111
"github.com/samber/lo"
1212
"github.com/urfave/cli"
1313

@@ -26,6 +26,7 @@ import (
2626

2727
const (
2828
defaultBootstrapBranch = "main"
29+
noneOption = "None"
2930
)
3031

3132
type Plural struct {
@@ -244,15 +245,52 @@ func askAppDomain(project *manifest.ProjectManifest) error {
244245
}
245246

246247
var domain string
247-
message := "Enter the domain for your application. It's expected that the root domain already exist in your clouds DNS provider. Leave empty to ignore:"
248-
if project.Provider == api.ProviderGCP {
249-
message = "Enter the DNS zone name for your application. This should be the DNS zone name already configured in your cloud's DNS provider. Leave empty to ignore:"
250-
}
251-
prompt := &survey.Input{
252-
Message: message,
253-
}
254-
if err := survey.AskOne(prompt, &domain); err != nil {
255-
return err
248+
249+
switch project.Provider {
250+
case api.ProviderAWS:
251+
hostedZones, err := provider.AWSHostedZones(context.Background(), project.Region)
252+
if err != nil {
253+
return err
254+
}
255+
256+
if err := survey.AskOne(
257+
&survey.Select{Message: "Select hosted zone (leave as None to skip):", Options: append([]string{noneOption}, hostedZones...)},
258+
&domain,
259+
); err != nil {
260+
return err
261+
}
262+
263+
if domain == noneOption {
264+
domain = ""
265+
}
266+
case api.ProviderAzure:
267+
dnsZones, err := provider.AzureDNSZones(context.Background(), project.Project)
268+
if err != nil {
269+
return err
270+
}
271+
272+
if err := survey.AskOne(
273+
&survey.Select{Message: "Select DNS zone (leave as None to skip):", Options: append([]string{noneOption}, dnsZones...)},
274+
&domain,
275+
); err != nil {
276+
return err
277+
}
278+
279+
if domain == noneOption {
280+
domain = ""
281+
}
282+
case api.ProviderGCP:
283+
if err := survey.AskOne(&survey.Input{
284+
Message: "Enter the DNS zone name for your application. This should be the DNS zone name already configured in your cloud's DNS provider. Leave empty to ignore:",
285+
}, &domain); err != nil {
286+
return err
287+
}
288+
default:
289+
if err := survey.AskOne(&survey.Input{
290+
Message: "Enter the domain for your application. It's expected that the root domain already exist in your clouds DNS provider. Leave empty to ignore:",
291+
}, &domain); err != nil {
292+
return err
293+
}
256294
}
257295

258296
return processAppDomain(domain, project)
@@ -264,18 +302,7 @@ func processAppDomain(domain string, project *manifest.ProjectManifest) error {
264302
return nil
265303
}
266304

267-
switch project.Provider {
268-
case api.ProviderAWS:
269-
// For AWS, we need to validate that the domain is set up in Route 53.
270-
if err := provider.ValidateAWSDomainRegistration(context.Background(), domain, project.Region); err != nil {
271-
return err
272-
}
273-
case api.ProviderAzure:
274-
// For Azure, we need to validate that the domain is set up in Azure DNS.
275-
if err := provider.ValidateAzureDomainRegistration(context.Background(), domain, project.Project); err != nil {
276-
return err
277-
}
278-
case api.ProviderGCP:
305+
if project.Provider == api.ProviderGCP {
279306
// For GCP, besides just validating that the domain is set up,
280307
// we also need to determine the managed DNS zone to use.
281308
// If there is one it will be automatically selected, if there are multiple,

go.mod

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ require (
3838
github.com/likexian/doh v0.7.1
3939
github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a
4040
github.com/mitchellh/go-homedir v1.1.0
41-
github.com/mitchellh/mapstructure v1.5.0
41+
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c
4242
github.com/olekukonko/tablewriter v0.0.5
4343
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
4444
github.com/pluralsh/console/go/client v1.61.0
4545
github.com/pluralsh/console/go/controller v0.0.0-20260129150042-18e31f596bd7
46+
github.com/pluralsh/console/go/polly v1.0.0
4647
github.com/pluralsh/gqlclient v1.12.2
4748
github.com/pluralsh/plural-operator v0.5.5
48-
github.com/pluralsh/polly v0.3.7
4949
github.com/posthog/posthog-go v1.4.10
5050
github.com/samber/lo v1.52.0
5151
github.com/urfave/cli v1.22.16
@@ -60,7 +60,7 @@ require (
6060
gotest.tools/v3 v3.5.1
6161
helm.sh/helm/v3 v3.20.0
6262
k8s.io/api v0.35.1
63-
k8s.io/apimachinery v0.35.1
63+
k8s.io/apimachinery v0.35.2
6464
k8s.io/client-go v0.35.1
6565
sigs.k8s.io/controller-runtime v0.23.1
6666
sigs.k8s.io/yaml v1.6.0
@@ -172,13 +172,14 @@ require (
172172
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
173173
github.com/mitchellh/pointerstructure v1.2.1 // indirect
174174
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
175-
github.com/osteele/liquid v1.6.0 // indirect
176-
github.com/osteele/tuesday v1.0.3 // indirect
175+
github.com/osteele/liquid v1.8.1 // indirect
176+
github.com/osteele/tuesday v1.0.4 // indirect
177177
github.com/outcaste-io/ristretto v0.2.3 // indirect
178178
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
179179
github.com/pjbgf/sha1cd v0.5.0 // indirect
180180
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
181181
github.com/pluralsh/controller-reconcile-helper v0.1.0 // indirect
182+
github.com/pluralsh/polly v0.3.6 // indirect
182183
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
183184
github.com/prometheus/client_golang v1.23.2 // indirect
184185
github.com/prometheus/client_model v0.6.2 // indirect
@@ -224,6 +225,7 @@ require (
224225
go.yaml.in/yaml/v3 v3.0.4 // indirect
225226
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect
226227
golang.org/x/mod v0.33.0 // indirect
228+
golang.org/x/tools v0.42.0 // indirect
227229
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
228230
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
229231
google.golang.org/genproto v0.0.0-20260217215200-42d3e9bedb6d // indirect

go.sum

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN
284284
github.com/distribution/distribution/v3 v3.0.0/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU=
285285
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
286286
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
287-
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
288-
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
287+
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
288+
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
289289
github.com/docker/cli v29.2.0+incompatible h1:9oBd9+YM7rxjZLfyMGxjraKBKE4/nVyvVfN4qNl9XRM=
290290
github.com/docker/cli v29.2.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
291291
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
@@ -565,8 +565,9 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
565565
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
566566
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
567567
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
568-
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
569568
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
569+
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c h1:cqn374mizHuIWj+OSJCajGr/phAmuMug9qIX3l9CflE=
570+
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
570571
github.com/mitchellh/pointerstructure v1.2.1 h1:ZhBBeX8tSlRpu/FFhXH4RC4OJzFlqsQhoHZAz4x7TIw=
571572
github.com/mitchellh/pointerstructure v1.2.1/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
572573
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
@@ -600,10 +601,10 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
600601
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
601602
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
602603
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
603-
github.com/osteele/liquid v1.6.0 h1:bTsbZjPIr7F+pU+K6o//Y5//W4McMzvUlMXWGOVvpc0=
604-
github.com/osteele/liquid v1.6.0/go.mod h1:xU0Z2dn2hOQIEFEWNmeltOmCtfhtoW/2fCyiNQeNG+U=
605-
github.com/osteele/tuesday v1.0.3 h1:SrCmo6sWwSgnvs1bivmXLvD7Ko9+aJvvkmDjB5G4FTU=
606-
github.com/osteele/tuesday v1.0.3/go.mod h1:pREKpE+L03UFuR+hiznj3q7j3qB1rUZ4XfKejwWFF2M=
604+
github.com/osteele/liquid v1.8.1 h1:b+uxMOkD1OOLxueaSvrE0yx6nMqf023DZPPAjPWT5eI=
605+
github.com/osteele/liquid v1.8.1/go.mod h1:SFqQ9ddbCoKceuG6RckCLJ0hcxUbGhLpvcXJGmHlCWA=
606+
github.com/osteele/tuesday v1.0.4 h1:iX0xOLW08/FJtXUCr20ngYwOwBE6l/mf7mz8NIv4yl8=
607+
github.com/osteele/tuesday v1.0.4/go.mod h1:5fgEemYhErJF09RNEwU+PdYiwm5Ar7Bknlhs1CD/Ol8=
607608
github.com/outcaste-io/ristretto v0.2.3 h1:AK4zt/fJ76kjlYObOeNwh4T3asEuaCmp26pOvUOL9w0=
608609
github.com/outcaste-io/ristretto v0.2.3/go.mod h1:W8HywhmtlopSB1jeMg3JtdIhf+DYkLAr0VN/s4+MHac=
609610
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
@@ -625,6 +626,8 @@ github.com/pluralsh/console/go/client v1.61.0 h1:gy5tglnBLoMA6iBgXoCxXJFGpTUvRWh
625626
github.com/pluralsh/console/go/client v1.61.0/go.mod h1:lqN15ajFf+0MtnNQNb9rvQpxkdsuMg47Yd9dSdQDIAk=
626627
github.com/pluralsh/console/go/controller v0.0.0-20260129150042-18e31f596bd7 h1:CwBTb7Tvt11nO/XJ1PA9fbCsJSlz9/nDN1OJU0Pddsg=
627628
github.com/pluralsh/console/go/controller v0.0.0-20260129150042-18e31f596bd7/go.mod h1:bbAQqSq+Rne2mBzUwAVAaGOcR75sJZhnHdpDmHLTq2U=
629+
github.com/pluralsh/console/go/polly v1.0.0 h1:NRg8CMITGllEJ08oYidNuuG/gJGDdDuga8TM+gdIcFA=
630+
github.com/pluralsh/console/go/polly v1.0.0/go.mod h1:eH42iPlRip2bs6tB+Vg6fxC/sz6oWxyNGVDE9uyA5EY=
628631
github.com/pluralsh/controller-reconcile-helper v0.1.0 h1:BV3dYZFH5rn8ZvZjtpkACSv/GmLEtRftNQj/Y4ddHEo=
629632
github.com/pluralsh/controller-reconcile-helper v0.1.0/go.mod h1:RxAbvSB4/jkvx616krCdNQXPbpGJXW3J1L3rASxeFOA=
630633
github.com/pluralsh/gqlclient v1.12.2 h1:BrEFAASktf4quFw57CIaLAd+NZUTLhG08fe6tnhBQN4=
@@ -633,8 +636,8 @@ github.com/pluralsh/oauth v0.9.2 h1:tM9hBK4tCnJUeCOgX0ctxBBCS3hiCDPoxkJLODtedmQ=
633636
github.com/pluralsh/oauth v0.9.2/go.mod h1:aTUw/75rzcsbvW+/TLvWtHVDXFIdtFrDtUncOq9vHyM=
634637
github.com/pluralsh/plural-operator v0.5.5 h1:57GxniNjUa3hpHgvFr9oDonFgvDUC8XDD5B0e7Xduzk=
635638
github.com/pluralsh/plural-operator v0.5.5/go.mod h1:WIXiz26/WDcUn0FA7Q1jPxmfsm98U1/JL8YpIdKVLX0=
636-
github.com/pluralsh/polly v0.3.7 h1:Nc7tvCbKdOGDABRa4jUE+FLifrPOgA2u49hQSCHESoo=
637-
github.com/pluralsh/polly v0.3.7/go.mod h1:R58Twx1xxoc5a5o8ZDsaVJxqcqQp16Aajd/iqmOw3ak=
639+
github.com/pluralsh/polly v0.3.6 h1:mzPz+xqszE/WxM75GpL2OjaRIeIa/2tvV9yETJqQ28k=
640+
github.com/pluralsh/polly v0.3.6/go.mod h1:R58Twx1xxoc5a5o8ZDsaVJxqcqQp16Aajd/iqmOw3ak=
638641
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
639642
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
640643
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -1042,8 +1045,8 @@ k8s.io/api v0.35.1 h1:0PO/1FhlK/EQNVK5+txc4FuhQibV25VLSdLMmGpDE/Q=
10421045
k8s.io/api v0.35.1/go.mod h1:28uR9xlXWml9eT0uaGo6y71xK86JBELShLy4wR1XtxM=
10431046
k8s.io/apiextensions-apiserver v0.35.1 h1:p5vvALkknlOcAqARwjS20kJffgzHqwyQRM8vHLwgU7w=
10441047
k8s.io/apiextensions-apiserver v0.35.1/go.mod h1:2CN4fe1GZ3HMe4wBr25qXyJnJyZaquy4nNlNmb3R7AQ=
1045-
k8s.io/apimachinery v0.35.1 h1:yxO6gV555P1YV0SANtnTjXYfiivaTPvCTKX6w6qdDsU=
1046-
k8s.io/apimachinery v0.35.1/go.mod h1:jQCgFZFR1F4Ik7hvr2g84RTJSZegBc8yHgFWKn//hns=
1048+
k8s.io/apimachinery v0.35.2 h1:NqsM/mmZA7sHW02JZ9RTtk3wInRgbVxL8MPfzSANAK8=
1049+
k8s.io/apimachinery v0.35.2/go.mod h1:jQCgFZFR1F4Ik7hvr2g84RTJSZegBc8yHgFWKn//hns=
10471050
k8s.io/apiserver v0.35.1 h1:potxdhhTL4i6AYAa2QCwtlhtB1eCdWQFvJV6fXgJzxs=
10481051
k8s.io/apiserver v0.35.1/go.mod h1:BiL6Dd3A2I/0lBnteXfWmCFobHM39vt5+hJQd7Lbpi4=
10491052
k8s.io/cli-runtime v0.35.1 h1:uKcXFe8J7AMAM4Gm2JDK4mp198dBEq2nyeYtO+JfGJE=

pkg/api/users.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package api
33
import (
44
"fmt"
55

6+
"github.com/pluralsh/console/go/polly/algorithms"
67
"github.com/pluralsh/gqlclient"
7-
"github.com/pluralsh/polly/algorithms"
88
"github.com/samber/lo"
99
)
1010

pkg/cd/control_plane_install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"gopkg.in/yaml.v3"
1111

1212
"github.com/AlecAivazis/survey/v2"
13-
pollytemplate "github.com/pluralsh/polly/template"
13+
pollytemplate "github.com/pluralsh/console/go/polly/template"
1414

1515
"github.com/pluralsh/plural-cli/pkg/api"
1616
"github.com/pluralsh/plural-cli/pkg/bundle"

pkg/cd/template/render.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77

88
console "github.com/pluralsh/console/go/client"
9-
"github.com/pluralsh/polly/template"
9+
"github.com/pluralsh/console/go/polly/template"
1010
)
1111

1212
func RenderYaml(path string, bindings map[string]interface{}) ([]byte, error) {

pkg/client/plural.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"os/exec"
88
"strings"
99

10+
"github.com/pluralsh/console/go/polly/algorithms"
1011
gitutils "github.com/pluralsh/plural-cli/pkg/utils/git"
11-
"github.com/pluralsh/polly/algorithms"
1212
"github.com/samber/lo"
1313
apierrors "k8s.io/apimachinery/pkg/api/errors"
1414

0 commit comments

Comments
 (0)