https://pulumi.com logo
#getting-started
Title
# getting-started
w

wide-activity-54187

06/04/2021, 12:55 PM
I have an k8s deployment in go that I’m trying to enumerate over appending each deployment to an array but I have no idea how to get it to work
b

billowy-army-68599

06/04/2021, 4:26 PM
hey, can you share a little more about what you're trying to do? maybe some pseudo code?
w

wide-activity-54187

06/04/2021, 5:40 PM
@billowy-army-68599 I have yaml like this right now:
Copy code
environments:
  - name: stage
    web:
      sites:
        - name: my-site
          fqdns:
            - <http://foo.bar.com|foo.bar.com>
            - <http://bar.com|bar.com>
And then for each of those
web.sites
, I want to create a deployment. Right now I’m just hard coding things in and trying to get the loop to run and I think I’m on the right path with DeploymentList. But basically I want this:
Copy code
func Deployments(pCtx *pulumi.Context, envConfig config.Environment, repoConfig config.Repo) apps.DeploymentTypeArrayOutput {
	var deploymentListArgs *apps.DeploymentListArgs
	deployments, err := apps.NewDeploymentList(pCtx, <site.name>, deploymentListArgs)
	for _ = range envConfig.Web.Sites {
		deployment, _ := apps.NewDeployment(pCtx, <site.name>, &apps.DeploymentArgs{
....
		})
		deployments.Items.ApplyT(deployment)
	}
	if err != nil {
		panic(err)
	}

	return deployments.Items
}
I know that last parts definitely off
(This is using the automation api if that’s important, which is awesome btw!)
So, I got it working a different way, Instead of looping inside of that
Deployments
function, I looped where it was called
Just wasn’t ablle to shovel the deployments into an array and then return that array which is nbd
3 Views