Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing desired resources when metadata.name is missing or same for multiple resources #119

Open
sschne opened this issue Jul 19, 2024 · 5 comments · Fixed by #123
Open
Labels
enhancement New feature or request

Comments

@sschne
Copy link

sschne commented Jul 19, 2024

What happened?

When having multiple desired resources with the same metadata.name or metadata.name is omitted, only the last resource will be returned from the function

How can we reproduce it?

Take e.g. examples/resources/network and remove metadata.name from both resources to be generated.

What environment did it happen in?

Function version: v0.9.0

@sschne sschne added the bug Something isn't working label Jul 19, 2024
@Peefy Peefy added help wanted Extra attention is needed good first issue Good for newcomers labels Jul 19, 2024
@Peefy
Copy link
Collaborator

Peefy commented Jul 19, 2024

Thanks for the feedback. At present, different resource names need to be set according to the following method.
image

Perhaps we can add necessary name checks to crossplane function-kcl, PRs welcome!

@sschne
Copy link
Author

sschne commented Jul 19, 2024

Ok i totally overlooked that one, sorry for that. A check would be good, i will try to come up with a PR.
What i also noticed that the annotation only works for target "Default", but not for target "Resources", which should also be supported, right?

@Peefy
Copy link
Collaborator

Peefy commented Jul 19, 2024

Yes, all targets should be supported, thank you very much for your contribution! ❤️

@patpicos
Copy link

patpicos commented Jul 30, 2024

I ran into a similar issue yesterday. I was generating 2 resources, with different api/kind, but with same metadata.name, the last one won.

# Resource One
              apiVersion = "projects.gitlab.crossplane.io/v1alpha1"
              kind = "Group"

              metadata.name = "{}-{}".format(isv,cnf)

# Resource Two
              apiVersion = "projects.gitlab.crossplane.io/v1alpha1"
              kind = "Project"

              metadata.name = "{}-{}".format(isv,cnf)

# Result: only the resource #2 would be generated.

Behavior wise, it would be good to have the granularity at the api/kind/name or at the very least warn the developer that a resource has been overwritten when rendering/testing.

@Peefy Peefy closed this as completed in #123 Aug 7, 2024
@Peefy Peefy reopened this Aug 13, 2024
@Peefy Peefy added enhancement New feature or request and removed bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Aug 13, 2024
@ajski1701
Copy link

ajski1701 commented Sep 23, 2024

I ran into a similar issue yesterday. I was generating 2 resources, with different api/kind, but with same metadata.name, the last one won.

# Resource One
              apiVersion = "projects.gitlab.crossplane.io/v1alpha1"
              kind = "Group"

              metadata.name = "{}-{}".format(isv,cnf)

# Resource Two
              apiVersion = "projects.gitlab.crossplane.io/v1alpha1"
              kind = "Project"

              metadata.name = "{}-{}".format(isv,cnf)

# Result: only the resource #2 would be generated.

Behavior wise, it would be good to have the granularity at the api/kind/name or at the very least warn the developer that a resource has been overwritten when rendering/testing.

I've also encountered something similar to this with two different resources types and not defining a metadata.name so they pick up the composite resource name with a random suffix. Only the second resource in the items array gets created.

# Resource One
kms = {
    apiVersion: "kms.aws.upbound.io/v1beta1"
    kind: "Key"
    spec:
    <spec>
}

# Resource Two
kms_alias = {
    apiVersion: "kms.aws.upbound.io/v1beta1"
    kind: "Alias"
    spec:
    <spec>
}

items = [kms, kms_alias]

This could also be an edification error on my part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants