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

Branch name must be unique? #31

Closed
RobCannon opened this issue Oct 28, 2023 · 3 comments · Fixed by #44
Closed

Branch name must be unique? #31

RobCannon opened this issue Oct 28, 2023 · 3 comments · Fixed by #44

Comments

@RobCannon
Copy link

Just starting to play with this resource and I am immediately seeing an issue. If try to create a repo and branch with this, it works:

apiVersion: repo.github.upbound.io/v1alpha1
kind: Repository
metadata:
  name: crossplane-test
spec:
  forProvider:
    visibility: private
    archiveOnDestroy: false
    template:
    - owner: myorg
      repository: repository-template
  providerConfigRef:
    name: my-provider
---
apiVersion: repo.github.upbound.io/v1alpha1
kind: Branch
metadata:
  name: dev
spec:
  forProvider:
    repository: crossplane-test
    repositoryRef:
      name: crossplane-test
  providerConfigRef:
    name: my-provider

But, since these resources are Cluster wide resource, the Branch name will be unique in the cluster. So, if I try to create another Branch named dev for another repo, it won't work.

Shouldn't the branchName be an attribute of the Branch resource so it does not use the resource name for the branch?

@RobCannon
Copy link
Author

OK, I found an answer. I am not sure if this is the recommended way. I was wondering how to handle importing resources in Crossplane and I found out about the external-name annotation. It looks like I can use that to create a resource with an arbitrary resource name and use the annotation to name the branch what I want.

apiVersion: repo.github.upbound.io/v1alpha1
kind: Branch
metadata:
  name: crossplane-test-dev
  annotations:
    crossplane.io/external-name: dev
spec:
  forProvider:
    repository: crossplane-test
    repositoryRef:
      name: crossplane-test
  providerConfigRef:
    name: my-provider

While this works, it is not obvious, it is not documented in the Branch resource and it is overloading an annotation that is meant to be used for importing a resource.

Thoughts?

Also, I see a number of documentation issues. Should I submit a PR with the corrections or would you like an issue first?

@AtzeDeVries
Copy link
Collaborator

AtzeDeVries commented Dec 6, 2023

@RobCannon yes please create a pr on doc issues!

@AtzeDeVries
Copy link
Collaborator

This is actually an interesting issue. We dont really use this to create branch resource to create branches so i have not come across this issue. I think disconnecting the branch name from metadata.name makes sense here.

If you want you can create a PR for it, else i'll create add it to a task list

AtzeDeVries added a commit that referenced this issue Feb 8, 2024
Managed resources are cluster wide objects so relating branch name to
object name will cause naming conflict.

Closes: #31
AtzeDeVries added a commit that referenced this issue Feb 8, 2024
Managed resources are cluster wide objects so relating branch name to
object name will cause naming conflict.

Closes: #31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants