From aee8788a34f5fe77a73d476ea863ca29bfa58162 Mon Sep 17 00:00:00 2001 From: Ahmed Belhoula Date: Thu, 11 Jan 2024 21:10:24 +0100 Subject: [PATCH] feat(scopedrepository): add support for project scoped repository Signed-off-by: Ahmed Belhoula --- apis/repositories/v1alpha1/types.go | 4 ++++ .../v1alpha1/zz_generated.deepcopy.go | 5 +++++ examples/repositories/repository.yaml | 17 +++++++++++++++++ ...ories.argocd.crossplane.io_repositories.yaml | 4 ++++ pkg/controller/repositories/controller.go | 6 ++++++ 5 files changed, 36 insertions(+) diff --git a/apis/repositories/v1alpha1/types.go b/apis/repositories/v1alpha1/types.go index 3214cfd..07e2457 100644 --- a/apis/repositories/v1alpha1/types.go +++ b/apis/repositories/v1alpha1/types.go @@ -53,6 +53,10 @@ type RepositoryParameters struct { // type of the repo, maybe "git or "helm, "git" is assumed if empty or absent // +optional Type *string `json:"type,omitempty"` + // Project is a reference to the project with scoped repositories + // +optional + // only for git repos + Project *string `json:"project,omitempty"` // only for Helm repos // +optional Name *string `json:"name,omitempty"` diff --git a/apis/repositories/v1alpha1/zz_generated.deepcopy.go b/apis/repositories/v1alpha1/zz_generated.deepcopy.go index db9e555..7610c36 100644 --- a/apis/repositories/v1alpha1/zz_generated.deepcopy.go +++ b/apis/repositories/v1alpha1/zz_generated.deepcopy.go @@ -162,6 +162,11 @@ func (in *RepositoryParameters) DeepCopyInto(out *RepositoryParameters) { *out = new(string) **out = **in } + if in.Project != nil { + in, out := &in.Project, &out.Project + *out = new(string) + **out = **in + } if in.Name != nil { in, out := &in.Name, &out.Name *out = new(string) diff --git a/examples/repositories/repository.yaml b/examples/repositories/repository.yaml index de9b36b..4a21ac8 100644 --- a/examples/repositories/repository.yaml +++ b/examples/repositories/repository.yaml @@ -14,3 +14,20 @@ spec: key: token providerConfigRef: name: argocd-provider +--- +apiVersion: repositories.argocd.crossplane.io/v1alpha1 +kind: Repository +metadata: + name: example-scoped-project.git +spec: + forProvider: + project: example-project # project scoped repository + repo: https://gitlab.com/example-group/example-project-scoped.git + type: git + username: example-user + passwordRef: + name: example-project.git + namespace: crossplane-system + key: token + providerConfigRef: + name: argocd-provider diff --git a/package/crds/repositories.argocd.crossplane.io_repositories.yaml b/package/crds/repositories.argocd.crossplane.io_repositories.yaml index a226466..1102a25 100644 --- a/package/crds/repositories.argocd.crossplane.io_repositories.yaml +++ b/package/crds/repositories.argocd.crossplane.io_repositories.yaml @@ -127,6 +127,10 @@ spec: - name - namespace type: object + project: + description: Project is a reference to the project with scoped + repositories only for git repos + type: string repo: description: URL of the repo type: string diff --git a/pkg/controller/repositories/controller.go b/pkg/controller/repositories/controller.go index 2986879..5f533c1 100644 --- a/pkg/controller/repositories/controller.go +++ b/pkg/controller/repositories/controller.go @@ -317,6 +317,9 @@ func generateCreateRepositoryOptions(p *v1alpha1.RepositoryParameters) *reposito if p.Type != nil { repo.Type = *p.Type } + if p.Project != nil { + repo.Project = *p.Project + } if p.Name != nil { repo.Name = *p.Name } @@ -360,6 +363,9 @@ func generateUpdateRepositoryOptions(p *v1alpha1.RepositoryParameters) *reposito if p.Type != nil { repo.Type = *p.Type } + if p.Project != nil { + repo.Project = *p.Project + } if p.Name != nil { repo.Name = *p.Name }