Skip to content

Commit ec2d78a

Browse files
Rizwana777jgwest
andauthored
Add NamespaceManagement reconciliation (#1687)
* Fix merge conflicts in api files Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflics in config files Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix failing of tests Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix failing of namespace_managemen test Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix namespaceMangement e2e tests Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Remove namespaceManagement e2e tests Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflicts in api files 2 Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflicts in api files 3 Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix test errors by adding k8sClient in ReconcileArgoCD object Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflics in config files Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflics in config files Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix merge conflicts Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix failing of namespace_managemen test Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix merge conflicts Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Remove namespaceManagement e2e tests Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix merge conflicts Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix merge conflicts Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix merge conflicts Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflics in bundle file Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflicts in api files 4 Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflicts in bundle file Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Fix conflicts in bundle file Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> * Remove old 'olm-catalog' updates Signed-off-by: Jonathan West <jonwest@redhat.com> --------- Signed-off-by: Rizwana777 <rizwananaaz177@gmail.com> Signed-off-by: Jonathan West <jonwest@redhat.com> Co-authored-by: Jonathan West <jonwest@redhat.com>
1 parent 4ef7a80 commit ec2d78a

File tree

64 files changed

+2740
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2740
-325
lines changed

PROJECT

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Code generated by tool. DO NOT EDIT.
2+
# This file is used to track the info used to scaffold your project
3+
# and allow the plugins properly work.
4+
# More info: https://book.kubebuilder.io/reference/project-config.html
15
layout:
26
- go.kubebuilder.io/v4
37
plugins:
@@ -32,4 +36,11 @@ resources:
3236
webhooks:
3337
conversion: true
3438
webhookVersion: v1
39+
- api:
40+
crdVersion: v1
41+
namespaced: true
42+
group: argoproj.io
43+
kind: NamespaceManagement
44+
path: github.com/argoproj-labs/argocd-operator/api/v1beta1
45+
version: v1beta1
3546
version: "3"

api/v1alpha1/argocd_conversion.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func (src *ArgoCD) ConvertTo(dstRaw conversion.Hub) error {
100100
dst.Spec.DefaultClusterScopedRoleDisabled = src.Spec.DefaultClusterScopedRoleDisabled
101101
dst.Spec.AggregatedClusterRoles = src.Spec.AggregatedClusterRoles
102102
dst.Spec.ArgoCDAgent = ConvertAlphaToBetaArgoCDAgent(src.Spec.ArgoCDAgent)
103+
dst.Spec.NamespaceManagement = ConvertAlphaToBetaNamespaceManagement(src.Spec.NamespaceManagement)
103104

104105
// Status conversion
105106
dst.Status = v1beta1.ArgoCDStatus(src.Status)
@@ -174,6 +175,7 @@ func (dst *ArgoCD) ConvertFrom(srcRaw conversion.Hub) error {
174175
dst.Spec.DefaultClusterScopedRoleDisabled = src.Spec.DefaultClusterScopedRoleDisabled
175176
dst.Spec.AggregatedClusterRoles = src.Spec.AggregatedClusterRoles
176177
dst.Spec.ArgoCDAgent = ConvertBetaToAlphaArgoCDAgent(src.Spec.ArgoCDAgent)
178+
dst.Spec.NamespaceManagement = ConvertBetaToAlphaNamespaceManagement(src.Spec.NamespaceManagement)
177179

178180
// Status conversion
179181
dst.Status = ArgoCDStatus(src.Status)
@@ -720,6 +722,17 @@ func ConvertAlphaToBetaArgoCDAgent(src *ArgoCDAgentSpec) *v1beta1.ArgoCDAgentSpe
720722
return dst
721723
}
722724

725+
func ConvertBetaToAlphaNamespaceManagement(src []v1beta1.ManagedNamespaces) []ManagedNamespaces {
726+
var dst []ManagedNamespaces
727+
for _, s := range src {
728+
dst = append(dst, ManagedNamespaces{
729+
Name: s.Name,
730+
AllowManagedBy: s.AllowManagedBy,
731+
})
732+
}
733+
return dst
734+
}
735+
723736
func ConvertAlphaToBetaPrincipal(src *PrincipalSpec) *v1beta1.PrincipalSpec {
724737
var dst *v1beta1.PrincipalSpec
725738
if src != nil {
@@ -759,3 +772,15 @@ func ConvertBetaToAlphaPrincipal(src *v1beta1.PrincipalSpec) *PrincipalSpec {
759772
}
760773
return dst
761774
}
775+
776+
func ConvertAlphaToBetaNamespaceManagement(src []ManagedNamespaces) []v1beta1.ManagedNamespaces {
777+
var dst []v1beta1.ManagedNamespaces
778+
for _, s := range src {
779+
dst = append(dst, v1beta1.ManagedNamespaces{
780+
Name: s.Name,
781+
AllowManagedBy: s.AllowManagedBy,
782+
},
783+
)
784+
}
785+
return dst
786+
}

api/v1alpha1/argocd_conversion_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ func TestAlphaToBetaConversion(t *testing.T) {
327327
Kind: "Deployment",
328328
},
329329
}
330+
cr.Spec.NamespaceManagement = []ManagedNamespaces{
331+
{
332+
Name: "test-nm-namespace",
333+
AllowManagedBy: true,
334+
},
335+
}
330336
}),
331337
expectedOutput: makeTestArgoCDBeta(func(cr *v1beta1.ArgoCD) {
332338
cr.Spec.ResourceIgnoreDifferences = &v1beta1.ResourceIgnoreDifference{
@@ -374,6 +380,12 @@ func TestAlphaToBetaConversion(t *testing.T) {
374380
Kind: "Deployment",
375381
},
376382
}
383+
cr.Spec.NamespaceManagement = []v1beta1.ManagedNamespaces{
384+
{
385+
Name: "test-nm-namespace",
386+
AllowManagedBy: true,
387+
},
388+
}
377389
}),
378390
},
379391
{

api/v1alpha1/argocd_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,18 @@ type ArgoCDSpec struct {
853853

854854
// ArgoCDAgent defines configurations for the ArgoCD Agent component.
855855
ArgoCDAgent *ArgoCDAgentSpec `json:"argoCDAgent,omitempty"`
856+
857+
// NamespaceManagement defines the list of namespaces that Argo CD is allowed to manage.
858+
NamespaceManagement []ManagedNamespaces `json:"namespaceManagement,omitempty"`
859+
}
860+
861+
// NamespaceManagement defines the namespace management settings
862+
type ManagedNamespaces struct {
863+
// Name of the namespace or pattern to be managed
864+
Name string `json:"name"`
865+
866+
// Whether the namespace can be managed by ArgoCD
867+
AllowManagedBy bool `json:"allowManagedBy"`
856868
}
857869

858870
const (

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/argocd_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,18 @@ type ArgoCDSpec struct {
966966

967967
// ArgoCDAgent defines configurations for the ArgoCD Agent component.
968968
ArgoCDAgent *ArgoCDAgentSpec `json:"argoCDAgent,omitempty"`
969+
970+
// NamespaceManagement defines the list of namespaces that Argo CD is allowed to manage.
971+
NamespaceManagement []ManagedNamespaces `json:"namespaceManagement,omitempty"`
972+
}
973+
974+
// NamespaceManagement defines the namespace management settings
975+
type ManagedNamespaces struct {
976+
// Name of the namespace or pattern to be managed
977+
Name string `json:"name"`
978+
979+
// Whether the namespace can be managed by ArgoCD
980+
AllowManagedBy bool `json:"allowManagedBy"`
969981
}
970982

971983
const (
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
Copyright 2021.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25+
26+
// NamespaceManagementSpec defines the desired state of NamespaceManagement
27+
type NamespaceManagementSpec struct {
28+
ManagedBy string `json:"managedBy"`
29+
}
30+
31+
// NamespaceManagementStatus defines the observed state of NamespaceManagement
32+
type NamespaceManagementStatus struct {
33+
// Conditions is an array of the NamespaceManagement's status conditions
34+
Conditions []metav1.Condition `json:"conditions,omitempty"`
35+
}
36+
37+
// +kubebuilder:object:root=true
38+
// +kubebuilder:subresource:status
39+
40+
// NamespaceManagement is the Schema for the namespacemanagements API
41+
type NamespaceManagement struct {
42+
metav1.TypeMeta `json:",inline"`
43+
metav1.ObjectMeta `json:"metadata,omitempty"`
44+
45+
Spec NamespaceManagementSpec `json:"spec,omitempty"`
46+
Status NamespaceManagementStatus `json:"status,omitempty"`
47+
}
48+
49+
// +kubebuilder:object:root=true
50+
51+
// NamespaceManagementList contains a list of NamespaceManagement
52+
type NamespaceManagementList struct {
53+
metav1.TypeMeta `json:",inline"`
54+
metav1.ListMeta `json:"metadata,omitempty"`
55+
Items []NamespaceManagement `json:"items"`
56+
}
57+
58+
func init() {
59+
SchemeBuilder.Register(&NamespaceManagement{}, &NamespaceManagementList{})
60+
}

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
creationTimestamp: null
5+
name: argocd-operator-namespacemanagement-editor-role
6+
rules:
7+
- apiGroups:
8+
- argoproj.io
9+
resources:
10+
- namespacemanagements
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
- apiGroups:
20+
- argoproj.io
21+
resources:
22+
- namespacemanagements/status
23+
verbs:
24+
- get

0 commit comments

Comments
 (0)