`Type Name Plan ...
# general
b
Type                 Name                 Plan       Info
+   pulumi:pulumi:Stack  pulumi-azure-go-dev  create     1 error
Diagnostics:
pulumi:pulumi:Stack (pulumi-azure-go-dev):
error: Duplicate resource URN 'urn:pulumi:dev::pulumi-azure-go::pulumi:pulumi:Stack::pulumi-azure-go-dev'; try giving it a unique name
b
what does
Copy code
acr.CreateAcr(sx.rgName, sx.location)
do?
b
that’s a local package
Copy code
package acr

import (
  "math/rand"

  containerregistry "<http://github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerregistry|github.com/pulumi/pulumi-azure-native/sdk/go/azure/containerregistry>"
  "<http://github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core|github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core>"
  "<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
)

func RandomString(n int) string {
  var letters = []rune("abcdefghijklmnopqrstuvwxyz")

  s := make([]rune, n)
  for i := range s {
    s[i] = letters[rand.Intn(len(letters))]
  }
  return string(s)
}

func CreateAcr(rgName, location string) {
  pulumi.Run(func(ctx *pulumi.Context) error {

    rg, err := core.NewResourceGroup(ctx, "resourceGroup", &core.ResourceGroupArgs{
      Name:     pulumi.String(rgName),
      Location: pulumi.String(location),
    }, nil)
    if err != nil {
      return err
    }

    containerregistry.NewRegistry(ctx, "acr", &containerregistry.RegistryArgs{
      RegistryName:      pulumi.String("acr" + RandomString(5)),
      AdminUserEnabled:  pulumi.Bool(true),
      Location:          rg.Location,
      ResourceGroupName: rg.Name,
      Sku: &containerregistry.SkuArgs{
        Name: pulumi.String("Standard"),
      },
    })
    return nil
  })
}
it just passes a resourcegroup name and location
b
it's because you have this in there:
Copy code
pulumi.Run(func(ctx *pulumi.Context) error {
it's trying to create a second stack
b
yeah.. hmm but how to load the config from the main function
b
instead of making this a function, make it a component: https://www.pulumi.com/docs/intro/concepts/resources/components/
b
i will try that one..
i guess it’s not possible the way i wanted it with functions?
also you have some other examples using components resources?
b
it is, but you're just gonna jump though hoops that components solve
b
ah ok, i’m gonna focus on it. thanks
@billowy-army-68599 you can still load local packages and use component resources right?
b
yep
b
Nice the key feature is if i'm understand right to group resources using parent
b
it's mainly a mechanism that helps you build abstractions, like you were doing with your functions
b
Yeah having multiple funtions in a package you mean
Or just multiple resources in a function
Hmm i like it tho, gonna experiment with it😀
b
protip: you can also make components multi language
b
i got the resource components working.. it took away all my issue’s with functions and packages
❤️ 1
awesome stuff