-
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
Conversation
…ure compatible one. removed KubeDashboard since incompatible with azure compatible kubernetes
…mage to pull since the old image 404s. refactored to use fnOutput form
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good.
@@ -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 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.
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.
Sounds good.
azure-go-aks/main.go
Outdated
@@ -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 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.
@@ -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 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.
// | ||
imageInDockerHub := "microsoft/azure-appservices-go-quickstart" |
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.
this image was 404'ing
I replaced it with an nginx base image since it's about deploying an image from docker hub
@@ -57,7 +57,7 @@ func main() { | |||
} | |||
|
|||
ctx.Export("helloEndpoint", helloApp.DefaultHostName.ApplyT(func(defaultHostName string) (string, error) { | |||
return fmt.Sprintf("%v%v%v", "https://", defaultHostName, "/hello"), nil |
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 nginx image doesn't have a /hello
route
@@ -44,7 +44,7 @@ func main() { | |||
} | |||
_, err = authorization.NewRoleAssignment(ctx, "access-from-cluster", &authorization.RoleAssignmentArgs{ | |||
PrincipalId: pulumi.String(currentPrincipal), | |||
PrincipalType: authorization.PrincipalTypeUser, // adjust the type if you are running as a service principal |
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.
Bumped the version and this line threw an error.
@@ -22,7 +22,7 @@ func main() { | |||
profile, err := cdn.NewProfile(ctx, "profile", &cdn.ProfileArgs{ | |||
ResourceGroupName: resourceGroup.Name, | |||
Sku: &cdn.SkuArgs{ | |||
Name: cdn.SkuName_Standard_Microsoft, |
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.
Bumped the version and this line threw an error.
} | ||
return *ip.Ip, nil | ||
}).(pulumi.StringOutput)) | ||
ctx.Export("containerIPv4Address", containerGroup.IpAddress.Ip()) |
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
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.
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.
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
azure-go-aks/main.go
Outdated
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 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.
}) | ||
}, | ||
) | ||
credentials := containerregistry.ListRegistryCredentialsOutput(ctx, containerregistry.ListRegistryCredentialsOutputArgs{ |
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.
👍
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.
Looking good, had a few comments. Are these all examples that can use Output forms? I vaguely remember a few more but I don't have a list handy. Let me check my notes.
Mini list in #1094 - if you haven't looked at those yet it'd be good to double-check
|
@@ -98,25 +93,21 @@ func buildCluster(ctx *pulumi.Context, cfg Config) (*ClusterInfo, error) { | |||
} | |||
|
|||
func getKubeconfig(ctx *pulumi.Context, cluster *ClusterInfo) pulumi.StringOutput { |
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.
Found and refactored this function as well @t0yv0
|
||
kubeconfig := creds.Kubeconfigs().Index(pulumi.Int(0)).Value(). | ||
ApplyT(func(encoded string) string { | ||
kubeconfig, err := base64.StdEncoding.DecodeString(encoded) |
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.
Looking good I'm just paranoid about go runtime errors , sometimes Go compiles but throws a runtime error; running this would be invaluable (unless it's included in CI).
Still LGTM. |
Is CI failure related to the changes? CI here is sometimes a little flaky. |
/home/runner/work/examples/examples/classic-azure-ts-stream-analytics |
#1115
examples/azure-go-containerapps
attempted bumping azure-native, but ran into an issue another user ran into. It was due to an upstream dependency on azure. Omitting changes.