<@U01JQAEMT9Q> I've had some success with breaking...
# golang
g
@mammoth-honey-6147 I've had some success with breaking things out for instance I have a function with the signature
Copy code
func monitoring(ctx *pulumi.Context, k8sProvider *providers.Provider) error {...}
and call it happily within the pulumi.Run func with
Copy code
if err = monitoring(ctx, k8sProvider); err != nil {
	return err
}
m
Ooh, interesting. Thanks a lot for this, appreciated
👍 1
within your monitoring function do you run another pulumi.run or just interact with the types directly?
g
Interact directly 🙂
m
Nice. What do you use the ctx for in that function, output?
g
Not sure what you mean by output? As you can see on the function signature, we passed in *pulumi.Context
Do you mean the context here? That's the context from the pulumi.Run func
Copy code
if err = monitoring(ctx, k8sProvider); err != nil {
	return err
}
m
yeah, so you pass ctx to your monitoring function, what do you do with it if you're accessing the types directly?
I was assuming you were doing something like ctx.Export
g
Maybe I'm misunderstanding what you mean by accessing the types directly? In my monitoring function I have something like
Copy code
ns := pulumi.String("monitoring")
	_, err := corev1.NewNamespace(ctx, "monitoring", &corev1.NamespaceArgs{
		Metadata: &metav1.ObjectMetaArgs{
			Name: ns,
		},
	}, pulumi.Provider(k8sProvider))
	if err != nil {
		return err
	}

	prom, err := helm.NewChart(ctx, "prometheus", helm.ChartArgs{
		Chart: pulumi.Sprintf("prometheus"),
		FetchArgs: helm.FetchArgs{
			Repo: pulumi.Sprintf("<https://prometheus-community.github.io/helm-charts>"),
		},
		Namespace: ns,
	},
		pulumi.Provider(k8sProvider),
	)
	if err != nil {
		return err
	}
I haven't tried exporting anything in a child function, though I think it should work
m
Ahh so you're creating the resources in that function, now I understand
I probably need more coffee, my bad. Thank you 🙂
g
No worries 😄
I'm planning on open sourcing this project. Sounds like it could be useful to some people as a starting point
m
Definitely 👍