Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Go Azure examples to fnOutput form #1154

Merged
merged 11 commits into from
Jan 21, 2022
4 changes: 2 additions & 2 deletions azure-go-aci/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/pulumi/examples/azure-go-aci
go 1.15

require (
github.com/pulumi/pulumi-azure-native/sdk v1.0.0
github.com/pulumi/pulumi/sdk/v3 v3.0.0
github.com/pulumi/pulumi-azure-native/sdk v1.53.0
github.com/pulumi/pulumi/sdk/v3 v3.20.0
)
131 changes: 10 additions & 121 deletions azure-go-aci/go.sum

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions azure-go-aci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ func main() {
return err
}

ctx.Export("containerIPv4Address", containerGroup.IpAddress.ApplyT(func(ip *containerinstance.IpAddressResponse) (string, error) {
if ip == nil || ip.Ip == nil {
return "", nil
}
return *ip.Ip, nil
}).(pulumi.StringOutput))
ctx.Export("containerIPv4Address", containerGroup.IpAddress.Ip())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ApplyT used to coerce *string to string by interpreting nil as "". IS that still happening? Does ctx.Export work with nils? Have you had a chance to test this? The CI does not test all examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kdixler@kdixler-20xw004aus ~/GolandProjects/examples/azure-go-aci (git)-[dixler/1115/refactor-azure-go-binless] % pulumi up
Previewing update (issue1115)

View Live: https://app.pulumi.com/kyle/azure-go-aci/issue1115/previews/c49fb6bf-3e9c-4581-b200-56878bd789e1

     Type                                              Name                    Plan       
 +   pulumi:pulumi:Stack                               azure-go-aci-issue1115  create     
 +   ├─ azure-native:resources:ResourceGroup           aci-rg                  create     
 +   └─ azure-native:containerinstance:ContainerGroup  helloworld              create     
 
Resources:
    + 3 to create

Do you want to perform this update? yes
Updating (issue1115)

View Live: https://app.pulumi.com/kyle/azure-go-aci/issue1115/updates/6

     Type                                              Name                    Status      
 +   pulumi:pulumi:Stack                               azure-go-aci-issue1115  created     
 +   ├─ azure-native:resources:ResourceGroup           aci-rg                  created     
 +   └─ azure-native:containerinstance:ContainerGroup  helloworld              created     
 
Outputs:
    containerIPv4Address: "20.120.145.148"

Resources:
    + 3 created

Duration: 1m11s


return nil
})
Expand Down
5 changes: 0 additions & 5 deletions azure-go-aks-helm/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ func buildCluster(ctx *pulumi.Context, cfg Config) (*ClusterInfo, error) {
k8sCluster, err := cs.NewManagedCluster(ctx, "cluster",
&cs.ManagedClusterArgs{
ResourceGroupName: resourceGroup.Name,
AddonProfiles: cs.ManagedClusterAddonProfileMap{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The k8s version bump broke compatibility with this addon so I removed it. It didn't appear to be a significant part of the README.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

"KubeDashboard": cs.ManagedClusterAddonProfileArgs{
Enabled: pulumi.Bool(true),
},
},
AgentPoolProfiles: cs.ManagedClusterAgentPoolProfileArray{
cs.ManagedClusterAgentPoolProfileArgs{
Count: pulumi.Int(cfg.NodeCount),
Expand Down
2 changes: 1 addition & 1 deletion azure-go-aks-helm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func configure(ctx *pulumi.Context) (Config, error) {

out.K8sVersion = cfg.Get("k8sVersion")
if out.K8sVersion == "" {
out.K8sVersion = "1.18.14"
Copy link
Contributor Author

@dixler dixler Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This k8s version was no longer supported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

out.K8sVersion = "1.22.2"
}

generatedKeyPair, err := tls.NewPrivateKey(ctx, "ssh-key",
Expand Down
4 changes: 2 additions & 2 deletions azure-go-aks-helm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module azure-go-aks-helm
go 1.15

require (
github.com/pulumi/pulumi-azure-native/sdk v1.0.0
github.com/pulumi/pulumi-azure-native/sdk v1.53.0
github.com/pulumi/pulumi-azuread/sdk/v4 v4.0.0
github.com/pulumi/pulumi-kubernetes/sdk/v3 v3.0.0
github.com/pulumi/pulumi-random/sdk/v4 v4.0.0
github.com/pulumi/pulumi-tls/sdk/v4 v4.0.0
github.com/pulumi/pulumi/sdk/v3 v3.0.0
github.com/pulumi/pulumi/sdk/v3 v3.20.0
)
9 changes: 9 additions & 0 deletions azure-go-aks-helm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ github.com/pulumi/pulumi-azure-native/sdk v0.7.1 h1:ss2Gm8tz+Z/5NG95tzZaNzR4wJE0
github.com/pulumi/pulumi-azure-native/sdk v0.7.1/go.mod h1:+sOZTR3B8SmjeJ+uiLjz9FCFj9VruMZf1lW846ZdKcE=
github.com/pulumi/pulumi-azure-native/sdk v1.0.0 h1:hkt1SRMuKPMgDzQrERbz/Ev9K0OtO4+C6t4gE/gyFM0=
github.com/pulumi/pulumi-azure-native/sdk v1.0.0/go.mod h1:+6SXTdCHr4vvAW7UUpYqJwXfF2nqDSVKHOs0zXOlfBY=
github.com/pulumi/pulumi-azure-native/sdk v1.53.0 h1:jrcGpA4NKH42yV9O76EVpSF8I93aeKB9Fae7M4kb1L0=
github.com/pulumi/pulumi-azure-native/sdk v1.53.0/go.mod h1:9uZoN23JHENKfngVUlZdFr1eRYXpRF8saW5eSASw0tY=
github.com/pulumi/pulumi-azuread/sdk/v3 v3.5.0 h1:1HG5pOt1ng6ShNRD+2f3TGHedomfC6HRT1MEBfN8zjY=
github.com/pulumi/pulumi-azuread/sdk/v3 v3.5.0/go.mod h1:2V1t2Ceb5qk26RkqvBmJzDOZ+6E8bf/HDQbIW3iMNU4=
github.com/pulumi/pulumi-azuread/sdk/v4 v4.0.0 h1:Fo8KNxSTyStg8R4aDMr4/cDEVnTkE262iio76Sol2Mw=
Expand All @@ -262,6 +264,10 @@ github.com/pulumi/pulumi/sdk/v2 v2.21.2/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqL
github.com/pulumi/pulumi/sdk/v3 v3.0.0-beta.1/go.mod h1:of2on912OvQZLA33FfNUcTEgRrTId7jvk9yFuvtaV88=
github.com/pulumi/pulumi/sdk/v3 v3.0.0 h1:zkragE05t1Rco/ymfqMU4UXdEmKMmOH0SXhUKQxujxQ=
github.com/pulumi/pulumi/sdk/v3 v3.0.0/go.mod h1:GBHyQ7awNQSRmiKp/p8kIKrGrMOZeA/k2czoM/GOqds=
github.com/pulumi/pulumi/sdk/v3 v3.20.0 h1:GBQ0sBepo3W2xQm/osMD6JDC02qiMQwK4q4Yi4bdkHk=
github.com/pulumi/pulumi/sdk/v3 v3.20.0/go.mod h1:AnbQmAhp0ezO/MhcVjqkhvoQnxZ0+79Xb035NcuKrtM=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af h1:gu+uRPtBe88sKxUCEXRoeCvVG90TJmwhiqRpvdhQFng=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
Expand Down Expand Up @@ -398,6 +404,8 @@ golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down Expand Up @@ -478,5 +486,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
4 changes: 2 additions & 2 deletions azure-go-aks-multicluster/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module azure-go-aks-multicluster
go 1.16

require (
github.com/pulumi/pulumi-azure-native/sdk v1.0.0
github.com/pulumi/pulumi-azure-native/sdk v1.53.0
github.com/pulumi/pulumi-azuread/sdk/v4 v4.0.0
github.com/pulumi/pulumi/sdk/v3 v3.0.0
github.com/pulumi/pulumi/sdk/v3 v3.20.0
)
9 changes: 9 additions & 0 deletions azure-go-aks-multicluster/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ github.com/pulumi/pulumi-azure-native/sdk v0.8.0 h1:IBINThu99ApZ2ZaVxerF5QflLgUE
github.com/pulumi/pulumi-azure-native/sdk v0.8.0/go.mod h1:D/zqGWwHxDfGyjiJlmMxWN0boUTr4ZxMigEPLeHLMac=
github.com/pulumi/pulumi-azure-native/sdk v1.0.0 h1:hkt1SRMuKPMgDzQrERbz/Ev9K0OtO4+C6t4gE/gyFM0=
github.com/pulumi/pulumi-azure-native/sdk v1.0.0/go.mod h1:+6SXTdCHr4vvAW7UUpYqJwXfF2nqDSVKHOs0zXOlfBY=
github.com/pulumi/pulumi-azure-native/sdk v1.53.0 h1:jrcGpA4NKH42yV9O76EVpSF8I93aeKB9Fae7M4kb1L0=
github.com/pulumi/pulumi-azure-native/sdk v1.53.0/go.mod h1:9uZoN23JHENKfngVUlZdFr1eRYXpRF8saW5eSASw0tY=
github.com/pulumi/pulumi-azuread/sdk/v3 v3.5.1 h1:tEWr5bWBFpQwxRoun6Ai7dTqz/BrwxeR9Prvkd/xU5M=
github.com/pulumi/pulumi-azuread/sdk/v3 v3.5.1/go.mod h1:2V1t2Ceb5qk26RkqvBmJzDOZ+6E8bf/HDQbIW3iMNU4=
github.com/pulumi/pulumi-azuread/sdk/v4 v4.0.0 h1:Fo8KNxSTyStg8R4aDMr4/cDEVnTkE262iio76Sol2Mw=
Expand All @@ -248,6 +250,10 @@ github.com/pulumi/pulumi/sdk/v2 v2.24.1/go.mod h1:sHQdzD0/cIopR5uLeoikXi1pNBv5Sw
github.com/pulumi/pulumi/sdk/v3 v3.0.0-beta.1/go.mod h1:of2on912OvQZLA33FfNUcTEgRrTId7jvk9yFuvtaV88=
github.com/pulumi/pulumi/sdk/v3 v3.0.0 h1:zkragE05t1Rco/ymfqMU4UXdEmKMmOH0SXhUKQxujxQ=
github.com/pulumi/pulumi/sdk/v3 v3.0.0/go.mod h1:GBHyQ7awNQSRmiKp/p8kIKrGrMOZeA/k2czoM/GOqds=
github.com/pulumi/pulumi/sdk/v3 v3.20.0 h1:GBQ0sBepo3W2xQm/osMD6JDC02qiMQwK4q4Yi4bdkHk=
github.com/pulumi/pulumi/sdk/v3 v3.20.0/go.mod h1:AnbQmAhp0ezO/MhcVjqkhvoQnxZ0+79Xb035NcuKrtM=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af h1:gu+uRPtBe88sKxUCEXRoeCvVG90TJmwhiqRpvdhQFng=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
Expand Down Expand Up @@ -378,6 +384,8 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down Expand Up @@ -457,5 +465,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
2 changes: 1 addition & 1 deletion azure-go-aks-multicluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func main() {
},
},
DnsPrefix: pulumi.String(fmt.Sprintf("%s-kube", ctx.Stack())),
KubernetesVersion: pulumi.String("1.18.14"),
KubernetesVersion: pulumi.String("1.22.2"),
})
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions azure-go-aks/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module goaks
go 1.15

require (
github.com/pulumi/pulumi-azure-native/sdk v1.0.0
github.com/pulumi/pulumi-azure-native/sdk v1.53.0
github.com/pulumi/pulumi-azuread/sdk/v4 v4.0.0
github.com/pulumi/pulumi-random/sdk/v4 v4.0.0
github.com/pulumi/pulumi-tls/sdk/v4 v4.0.0
github.com/pulumi/pulumi/sdk/v3 v3.0.0
github.com/pulumi/pulumi/sdk/v3 v3.20.0
)
9 changes: 9 additions & 0 deletions azure-go-aks/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ github.com/pulumi/pulumi-azure-native/sdk v0.7.1 h1:ss2Gm8tz+Z/5NG95tzZaNzR4wJE0
github.com/pulumi/pulumi-azure-native/sdk v0.7.1/go.mod h1:+sOZTR3B8SmjeJ+uiLjz9FCFj9VruMZf1lW846ZdKcE=
github.com/pulumi/pulumi-azure-native/sdk v1.0.0 h1:hkt1SRMuKPMgDzQrERbz/Ev9K0OtO4+C6t4gE/gyFM0=
github.com/pulumi/pulumi-azure-native/sdk v1.0.0/go.mod h1:+6SXTdCHr4vvAW7UUpYqJwXfF2nqDSVKHOs0zXOlfBY=
github.com/pulumi/pulumi-azure-native/sdk v1.53.0 h1:jrcGpA4NKH42yV9O76EVpSF8I93aeKB9Fae7M4kb1L0=
github.com/pulumi/pulumi-azure-native/sdk v1.53.0/go.mod h1:9uZoN23JHENKfngVUlZdFr1eRYXpRF8saW5eSASw0tY=
github.com/pulumi/pulumi-azuread/sdk/v2 v2.4.0 h1:Cpr2odOCkzyKg3/RrcgYubARtihvd50SjxWl3N6DuBI=
github.com/pulumi/pulumi-azuread/sdk/v2 v2.4.0/go.mod h1:xOo5e0+RVfT6169djjoWCMixlYzuUSFZMbWGYGVI+Aw=
github.com/pulumi/pulumi-azuread/sdk/v4 v4.0.0 h1:Fo8KNxSTyStg8R4aDMr4/cDEVnTkE262iio76Sol2Mw=
Expand All @@ -264,6 +266,10 @@ github.com/pulumi/pulumi/sdk/v2 v2.21.2/go.mod h1:fCFhRV6NmidWetmgDPA76efL+s0JqL
github.com/pulumi/pulumi/sdk/v3 v3.0.0-beta.1/go.mod h1:of2on912OvQZLA33FfNUcTEgRrTId7jvk9yFuvtaV88=
github.com/pulumi/pulumi/sdk/v3 v3.0.0 h1:zkragE05t1Rco/ymfqMU4UXdEmKMmOH0SXhUKQxujxQ=
github.com/pulumi/pulumi/sdk/v3 v3.0.0/go.mod h1:GBHyQ7awNQSRmiKp/p8kIKrGrMOZeA/k2czoM/GOqds=
github.com/pulumi/pulumi/sdk/v3 v3.20.0 h1:GBQ0sBepo3W2xQm/osMD6JDC02qiMQwK4q4Yi4bdkHk=
github.com/pulumi/pulumi/sdk/v3 v3.20.0/go.mod h1:AnbQmAhp0ezO/MhcVjqkhvoQnxZ0+79Xb035NcuKrtM=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af h1:gu+uRPtBe88sKxUCEXRoeCvVG90TJmwhiqRpvdhQFng=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
Expand Down Expand Up @@ -407,6 +413,8 @@ golang.org/x/sys v0.0.0-20200317113312-5766fd39f98d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980 h1:OjiUf46hAmXblsZdnoSXsEUSKU8r1UEzcL5RVZ4gO9Y=
golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2 h1:c8PlLMqBbOHoqtjteWm5/kbe6rNY2pbRfbIMVnepueo=
golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down Expand Up @@ -492,5 +500,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
41 changes: 23 additions & 18 deletions azure-go-aks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func getKubeconfig(ctx *pulumi.Context, cluster *containerservice.ManagedCluster, resourceGroup *resources.ResourceGroup) pulumi.Output {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broke this out into a separate function to break apart the instantiation logic and the kubeconfig logic.

kubeconfig := pulumi.All(cluster.Name, resourceGroup.Name, resourceGroup.ID()).ApplyT(func(args interface{}) (string, error) {
clusterName := args.([]interface{})[0].(string)
resourceGroupName := args.([]interface{})[1].(string)
creds, err := containerservice.ListManagedClusterUserCredentials(ctx, &containerservice.ListManagedClusterUserCredentialsArgs{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there now a ListManagedClusterUserCredentialsOutput function?

The idea is that the code may be simplified if you use that since it would let you avoid pulumi.All plus unpacking of args. You would pass cluster.Name etc directly to that function.

ResourceGroupName: resourceGroupName,
ResourceName: clusterName,
})
if err != nil {
return "", err
}
encoded := creds.Kubeconfigs[0].Value
kubeconfig, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
return "", err
}
return string(kubeconfig), nil
})
return kubeconfig
}

func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create an Azure Resource Group
Expand Down Expand Up @@ -93,29 +114,13 @@ func main() {
ClientId: adApp.ApplicationId,
Secret: adSpPassword.Value,
},
KubernetesVersion: pulumi.String("1.18.14"),
KubernetesVersion: pulumi.String("1.22.2"),
})
if err != nil {
return err
}

ctx.Export("kubeconfig", pulumi.All(cluster.Name, resourceGroup.Name, resourceGroup.ID()).ApplyT(func(args interface{}) (string, error) {
clusterName := args.([]interface{})[0].(string)
resourceGroupName := args.([]interface{})[1].(string)
creds, err := containerservice.ListManagedClusterUserCredentials(ctx, &containerservice.ListManagedClusterUserCredentialsArgs{
ResourceGroupName: resourceGroupName,
ResourceName: clusterName,
})
if err != nil {
return "", err
}
encoded := creds.Kubeconfigs[0].Value
kubeconfig, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
return "", err
}
return string(kubeconfig), nil
}))
ctx.Export("kubeconfig", getKubeconfig(ctx, cluster, resourceGroup))

return nil
})
Expand Down
28 changes: 26 additions & 2 deletions azure-go-appservice-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,33 @@ The example shows two scenarios:

```
$ pulumi stack output helloEndpoint
http:https://hello-app-91dfea.azurewebsites.net/hello
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the image to an image that exists so I updated the README with the expected outputs.

https:https://helloappecc2f992.azurewebsites.net
$ curl "$(pulumi stack output helloEndpoint)"
Hello, world!
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http:https://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http:https://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>



$ pulumi stack output getStartedEndpoint
http:https://get-started-15da13.azurewebsites.net
Expand Down
4 changes: 2 additions & 2 deletions azure-go-appservice-docker/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/pulumi/examples/azure-go-appservice
go 1.15

require (
github.com/pulumi/pulumi-azure-native/sdk v1.0.0
github.com/pulumi/pulumi-azure-native/sdk v1.53.0
github.com/pulumi/pulumi-docker/sdk/v3 v3.0.0
github.com/pulumi/pulumi/sdk/v3 v3.0.0
github.com/pulumi/pulumi/sdk/v3 v3.20.0
)
Loading