I'm trying out the new pulumix / generics feature ...
# general
p
I'm trying out the new pulumix / generics feature for golang - in combination with helm charts. First, I want to simplify the my function to get the ingress resource from a helm chart. I've started but I still can't get rid of one
ApplyT
with the old
interface{}
conversion:
Copy code
func (dex *Dex) getIngress() pulumix.Output[*networkingv1.Ingress] {
    // i: pulumi.AnyOutput
    i := dex.HelmChart.GetResource("<http://networking.k8s.io/v1/Ingress|networking.k8s.io/v1/Ingress>", dex.fqn(), dex.P.Cfg().Dex.Namespace)

    in := i.ApplyT(func(i interface{}) *networkingv1.Ingress {
        return i.(*networkingv1.Ingress)
    })

    b := pulumix.MustConvertTyped[*networkingv1.Ingress](in)

    return b
}
My second problem is even a bit more tricky as I need to get the IP of the Ingress. I needed to nest two
Apply
function and then I fear the output types get a bit scrambled:
Copy code
func (dex *Dex) IngressIP() pulumix.Output[string] {
	ingress := dex.getIngress()

	frontendIP := pulumix.Apply(ingress, func(r *networkingv1.Ingress) pulumi.StringOutput {
		status := r.Status
		loadBalancer := status.LoadBalancer()
		ingress := loadBalancer.Ingress()

		lbiao := ingress.ToIngressLoadBalancerIngressArrayOutput()

		ip := pulumix.Apply(lbiao, func(vs []networkingv1.IngressLoadBalancerIngress) string {
			index := 0
			if len(vs) <= index {
				return ""
			}
			return *vs[index].Ip
		})

		return pulumix.Cast[pulumi.StringOutput](ip)
	})

	// leads to "cannot convert pulumi.StringOutput to string"
	return pulumix.MustConvertTyped[string](frontendIP.ToOutput(context.Background()))
}
e
The second one you probably want pulumix.Flatten to squash two outputs together. The first one will probably be fixed when we roll out support to generate generic types in the sdks.
p
Thanks for your response. The kubernetes/helm provider is already full of pulumix so I hoped it would already be supported. For the second one I will try today 🙂
e
The kubernetes/helm provider is already full of pulumix
We're going to publish "sdkx" versions at some point which will generate pulumix style structs for things like the return value of GetResource.