-
Notifications
You must be signed in to change notification settings - Fork 872
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
Changes from 8 commits
34e80a8
7e6bb9b
85d653a
58e0c75
8c22bec
5de4568
a1e605a
ae0cd5f
09c316e
b740088
317d0b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ func configure(ctx *pulumi.Context) (Config, error) { | |
|
||
out.K8sVersion = cfg.Get("k8sVersion") | ||
if out.K8sVersion == "" { | ||
out.K8sVersion = "1.18.14" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This k8s version was no longer supported. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
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 | ||
|
@@ -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 | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,33 @@ The example shows two scenarios: | |
|
||
``` | ||
$ pulumi stack output helloEndpoint | ||
http:https://hello-app-91dfea.azurewebsites.net/hello | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
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
tostring
by interpreting nil as "". IS that still happening? Doesctx.Export
work with nils? Have you had a chance to test this? The CI does not test all examples.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.