Skip to content

Commit 2485cc0

Browse files
committed
feat: Add switch for Route and Service for Principal
Assisted by: Cursor Signed-off-by: Jayendra Parsai <[email protected]>
1 parent ec9f0aa commit 2485cc0

File tree

15 files changed

+952
-20
lines changed

15 files changed

+952
-20
lines changed

api/v1alpha1/argocd_conversion.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,8 @@ func ConvertAlphaToBetaPrincipalServer(src *PrincipalServerSpec) *v1beta1.Princi
786786
KeepAliveMinInterval: src.KeepAliveMinInterval,
787787
Image: src.Image,
788788
Env: src.Env,
789+
Service: v1beta1.ArgoCDAgentPrincipalServiceSpec(src.Service),
790+
Route: v1beta1.ArgoCDAgentPrincipalRouteSpec(src.Route),
789791
}
790792
}
791793
return dst
@@ -802,6 +804,8 @@ func ConvertBetaToAlphaPrincipalServer(src *v1beta1.PrincipalServerSpec) *Princi
802804
KeepAliveMinInterval: src.KeepAliveMinInterval,
803805
Image: src.Image,
804806
Env: src.Env,
807+
Service: ArgoCDAgentPrincipalServiceSpec(src.Service),
808+
Route: ArgoCDAgentPrincipalRouteSpec(src.Route),
805809
}
806810
}
807811
return dst

api/v1alpha1/argocd_conversion_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
v1 "k8s.io/api/networking/v1"
1010
resourcev1 "k8s.io/apimachinery/pkg/api/resource"
1111
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12+
"k8s.io/utils/ptr"
1213
"sigs.k8s.io/controller-runtime/pkg/conversion"
1314

1415
v1beta1 "github.com/argoproj-labs/argocd-operator/api/v1beta1"
@@ -529,6 +530,12 @@ func TestAlphaToBetaConversion(t *testing.T) {
529530
Enabled: &enabled,
530531
Server: &PrincipalServerSpec{
531532
Auth: "mtls:CN=([^,]+)",
533+
Service: ArgoCDAgentPrincipalServiceSpec{
534+
Type: corev1.ServiceTypeClusterIP,
535+
},
536+
Route: ArgoCDAgentPrincipalRouteSpec{
537+
Enabled: ptr.To(true),
538+
},
532539
},
533540
},
534541
}
@@ -540,6 +547,12 @@ func TestAlphaToBetaConversion(t *testing.T) {
540547
Enabled: &enabled,
541548
Server: &v1beta1.PrincipalServerSpec{
542549
Auth: "mtls:CN=([^,]+)",
550+
Service: v1beta1.ArgoCDAgentPrincipalServiceSpec{
551+
Type: corev1.ServiceTypeClusterIP,
552+
},
553+
Route: v1beta1.ArgoCDAgentPrincipalRouteSpec{
554+
Enabled: ptr.To(true),
555+
},
543556
},
544557
},
545558
}
@@ -563,6 +576,12 @@ func TestAlphaToBetaConversion(t *testing.T) {
563576
LogFormat: "text",
564577
Image: "quay.io/user/argocd-agent:v1",
565578
KeepAliveMinInterval: "30s",
579+
Service: ArgoCDAgentPrincipalServiceSpec{
580+
Type: corev1.ServiceTypeLoadBalancer,
581+
},
582+
Route: ArgoCDAgentPrincipalRouteSpec{
583+
Enabled: ptr.To(false),
584+
},
566585
},
567586
Redis: &PrincipalRedisSpec{
568587
ServerAddress: "redis:6379",
@@ -606,6 +625,12 @@ func TestAlphaToBetaConversion(t *testing.T) {
606625
LogFormat: "text",
607626
KeepAliveMinInterval: "30s",
608627
Image: "quay.io/user/argocd-agent:v1",
628+
Service: v1beta1.ArgoCDAgentPrincipalServiceSpec{
629+
Type: corev1.ServiceTypeLoadBalancer,
630+
},
631+
Route: v1beta1.ArgoCDAgentPrincipalRouteSpec{
632+
Enabled: ptr.To(false),
633+
},
609634
},
610635
Redis: &v1beta1.PrincipalRedisSpec{
611636
ServerAddress: "redis:6379",
@@ -760,6 +785,12 @@ func TestBetaToAlphaConversion(t *testing.T) {
760785
Enabled: &enabled,
761786
Server: &v1beta1.PrincipalServerSpec{
762787
Auth: "mtls:CN=([^,]+)",
788+
Service: v1beta1.ArgoCDAgentPrincipalServiceSpec{
789+
Type: corev1.ServiceTypeNodePort,
790+
},
791+
Route: v1beta1.ArgoCDAgentPrincipalRouteSpec{
792+
Enabled: ptr.To(true),
793+
},
763794
},
764795
},
765796
}
@@ -771,6 +802,12 @@ func TestBetaToAlphaConversion(t *testing.T) {
771802
Enabled: &enabled,
772803
Server: &PrincipalServerSpec{
773804
Auth: "mtls:CN=([^,]+)",
805+
Service: ArgoCDAgentPrincipalServiceSpec{
806+
Type: corev1.ServiceTypeNodePort,
807+
},
808+
Route: ArgoCDAgentPrincipalRouteSpec{
809+
Enabled: ptr.To(true),
810+
},
774811
},
775812
},
776813
}
@@ -797,6 +834,12 @@ func TestBetaToAlphaConversion(t *testing.T) {
797834
Env: []corev1.EnvVar{
798835
{Name: "TEST_ENV", Value: "test-value"},
799836
},
837+
Service: v1beta1.ArgoCDAgentPrincipalServiceSpec{
838+
Type: corev1.ServiceTypeExternalName,
839+
},
840+
Route: v1beta1.ArgoCDAgentPrincipalRouteSpec{
841+
Enabled: ptr.To(false),
842+
},
800843
},
801844
Redis: &v1beta1.PrincipalRedisSpec{
802845
ServerAddress: "redis:6379",
@@ -843,6 +886,12 @@ func TestBetaToAlphaConversion(t *testing.T) {
843886
Env: []corev1.EnvVar{
844887
{Name: "TEST_ENV", Value: "test-value"},
845888
},
889+
Service: ArgoCDAgentPrincipalServiceSpec{
890+
Type: corev1.ServiceTypeExternalName,
891+
},
892+
Route: ArgoCDAgentPrincipalRouteSpec{
893+
Enabled: ptr.To(false),
894+
},
846895
},
847896
Redis: &PrincipalRedisSpec{
848897
ServerAddress: "redis:6379",

api/v1alpha1/argocd_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,14 @@ type PrincipalServerSpec struct {
10671067

10681068
// Env lets you specify environment for principal pods
10691069
Env []corev1.EnvVar `json:"env,omitempty"`
1070+
1071+
// Service defines the options for the Service backing the ArgoCD Agent component.
1072+
// If not set, type ClusterIP will be used by default.
1073+
Service ArgoCDAgentPrincipalServiceSpec `json:"service,omitempty"`
1074+
1075+
// Route defines the options for the Route backing the ArgoCD Agent component.
1076+
// Route is disabled only when explicitly configured with Enabled: false
1077+
Route ArgoCDAgentPrincipalRouteSpec `json:"route,omitempty"`
10701078
}
10711079

10721080
type PrincipalRedisSpec struct {
@@ -1123,6 +1131,20 @@ type PrincipalTLSSpec struct {
11231131
InsecureGenerate *bool `json:"insecureGenerate,omitempty"`
11241132
}
11251133

1134+
// ArgoCDAgentPrincipalServiceSpec defines the options for the Service backing the ArgoCD Agent Principal component.
1135+
type ArgoCDAgentPrincipalServiceSpec struct {
1136+
// Type is the ServiceType to use for the Service resource.
1137+
// If not set, type ClusterIP will be used by default.
1138+
Type corev1.ServiceType `json:"type"`
1139+
}
1140+
1141+
// ArgoCDAgentPrincipalRouteSpec defines the options for the Route backing the ArgoCD Agent Principal component.
1142+
type ArgoCDAgentPrincipalRouteSpec struct {
1143+
// Enabled will toggle the creation of the OpenShift Route, ignored in case of non OpenShift cluster.
1144+
// Route is disabled only when explicitly configured with false
1145+
Enabled *bool `json:"enabled,omitempty"`
1146+
}
1147+
11261148
func (a *PrincipalSpec) IsEnabled() bool {
11271149
return a.Enabled != nil && *a.Enabled
11281150
}

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 37 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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,14 @@ type PrincipalServerSpec struct {
12261226

12271227
// Env lets you specify environment for principal pods
12281228
Env []corev1.EnvVar `json:"env,omitempty"`
1229+
1230+
// Service defines the options for the Service backing the ArgoCD Agent component.
1231+
// If not set, type ClusterIP will be used by default.
1232+
Service ArgoCDAgentPrincipalServiceSpec `json:"service,omitempty"`
1233+
1234+
// Route defines the options for the Route backing the ArgoCD Agent component.
1235+
// Route is disabled only when explicitly configured with Enabled: false
1236+
Route ArgoCDAgentPrincipalRouteSpec `json:"route,omitempty"`
12291237
}
12301238

12311239
type PrincipalRedisSpec struct {
@@ -1282,6 +1290,20 @@ type PrincipalTLSSpec struct {
12821290
InsecureGenerate *bool `json:"insecureGenerate,omitempty"`
12831291
}
12841292

1293+
// ArgoCDAgentPrincipalServiceSpec defines the options for the Service backing the ArgoCD Agent Principalcomponent.
1294+
type ArgoCDAgentPrincipalServiceSpec struct {
1295+
// Type is the ServiceType to use for the Service resource.
1296+
// If not set, type ClusterIP will be used by default.
1297+
Type corev1.ServiceType `json:"type"`
1298+
}
1299+
1300+
// ArgoCDAgentPrincipalRouteSpec defines the options for the Route backing the ArgoCD Agent Principal component.
1301+
type ArgoCDAgentPrincipalRouteSpec struct {
1302+
// Enabled will toggle the creation of the OpenShift Route, ignored in case of non OpenShift cluster.
1303+
// Route is disabled only when explicitly configured with false
1304+
Enabled *bool `json:"enabled,omitempty"`
1305+
}
1306+
12851307
func (a *PrincipalSpec) IsEnabled() bool {
12861308
return a.Enabled != nil && *a.Enabled
12871309
}

api/v1beta1/zz_generated.deepcopy.go

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

bundle/manifests/argoproj.io_argocds.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,30 @@ spec:
674674
description: LogLevel refers to the log level used by
675675
the Principal component.
676676
type: string
677+
route:
678+
description: |-
679+
Route defines the options for the Route backing the ArgoCD Agent component.
680+
Route is disabled only when explicitly configured with Enabled: false
681+
properties:
682+
enabled:
683+
description: |-
684+
Enabled will toggle the creation of the OpenShift Route, ignored in case of non OpenShift cluster.
685+
Route is disabled only when explicitly configured with false
686+
type: boolean
687+
type: object
688+
service:
689+
description: |-
690+
Service defines the options for the Service backing the ArgoCD Agent component.
691+
If not set, type ClusterIP will be used by default.
692+
properties:
693+
type:
694+
description: |-
695+
Type is the ServiceType to use for the Service resource.
696+
If not set, type ClusterIP will be used by default.
697+
type: string
698+
required:
699+
- type
700+
type: object
677701
type: object
678702
tls:
679703
description: TLS defines the TLS options for the Principal
@@ -10640,6 +10664,30 @@ spec:
1064010664
description: LogLevel refers to the log level used by
1064110665
the Principal component.
1064210666
type: string
10667+
route:
10668+
description: |-
10669+
Route defines the options for the Route backing the ArgoCD Agent component.
10670+
Route is disabled only when explicitly configured with Enabled: false
10671+
properties:
10672+
enabled:
10673+
description: |-
10674+
Enabled will toggle the creation of the OpenShift Route, ignored in case of non OpenShift cluster.
10675+
Route is disabled only when explicitly configured with false
10676+
type: boolean
10677+
type: object
10678+
service:
10679+
description: |-
10680+
Service defines the options for the Service backing the ArgoCD Agent component.
10681+
If not set, type ClusterIP will be used by default.
10682+
properties:
10683+
type:
10684+
description: |-
10685+
Type is the ServiceType to use for the Service resource.
10686+
If not set, type ClusterIP will be used by default.
10687+
type: string
10688+
required:
10689+
- type
10690+
type: object
1064310691
type: object
1064410692
tls:
1064510693
description: TLS defines the TLS options for the Principal

0 commit comments

Comments
 (0)