This message was deleted.
# golang
s
This message was deleted.
q
you need to
ctx.Export()
them from your pulumi main function that uses your
NewAks
b
you have some sample somewhere?
@quiet-laptop-13439 if you want to use this output as input for another function you also should do this in the main function right?
q
no, you create a field in your Aks struct and access that field directly
e.g. aks, err := NewAks(...)
somethingElseArgs:= { AksId: aks.ID() }
if you want k8s.Name there, just create Name in Aks struct, and at the end of your NewAks assign
aks.Name = k8s.Name.ToStringOutput()
, or something similar
b
Also when i have two different pacackes? aks.go and acr.go are in different packages
In the main.go file i reference those functions
So if i want to use output between functions i can do this directly?
q
cant make too many assumptions about your package structure, but if you can pass outputs via args after assignment, similar to terraform
b
Yeah terraform is referencing outputs through main
b
b
@billowy-army-68599 the complete code is at https://github.com/dkooll/pulumi-go-webapp
Will have a look at your examples
my main question would be how to use for example something like a aks cluster ID as input in the ACR package with the current package structure using different functions and packages
resource components should be ok in this sample right?
@billowy-army-68599 you have some time to look? 😀
b
If I do it won't be for a couple days I'm afraid
b
@quiet-laptop-13439, @billowy-army-68599 i got a working output now using
Copy code
aksnames := k8s.Name.ApplyT(func(aksname string) string {
    return aksname
  }).(pulumi.StringOutput)

  aks.AksNames = aksnames

  if err := ctx.RegisterResourceOutputs(aks, pulumi.Map{
    "aksnames": aksnames,
  }); err != nil {
    return nil, err
  }

  ctx.Export("AksNames", aks.AksNames)
  return aks, nil
}
you have any idea how i get the id instead of the name
q
you dont need that applyt, it does nothing
b
ahk.. thanks.. according to the docs Id should be available as output
q
for id just do the same assignment
as for the name, just type is different
b
it give me a
k8s.Id undefined (type *containerservice.ManagedCluster has no field or method Id)
using
Copy code
aksnames := k8s.Id.ApplyT(func(aksname string) string {
    return aksname
  }).(pulumi.StringOutput)
am i missing something
q
im not following why did you do that
first, as i said, you dont need that applyt
id is k8s.ID()
b
can you provide a more complete sample to make this a output using component resources, cause this aint helping much
q
I'm on a phone
do you intend aksnames to be an array?
Copy code
aks.AksNames = k8s.Name
then
Copy code
aks.ResourceId := k8s.ID() // make sure Aks struct field is ResourceId
remove ctx.Export from the module, do it in main
Copy code
ctx.Export("k8s_resource_id", aks.ResourceId)
b
hmm thanks.. only getting a
expected identifier on left side of :=
on this one aks.ResourceId := k8s.ID()
for example
aks.ResourceState := k8s.State()
works, but
aks.ResourceId := k8s.ID()
gives me a
expected identifier on left side of :=
@quiet-laptop-13439 if i remove the semicolon i get a
cannot use k8s.ID() (value of type pulumi.IDOutput) as pulumi.StringOutput value in assignment
so this one works
aks.ResourceId = k8s.ID().ToStringOutput()
so this is working.. now how to pass this output which is in the aks package as input to a resource in the acr package?
do i have to pass this in my main function?