Skip to content

Commit eb3a25d

Browse files
authored
Merge branch 'argoproj-labs:master' into master
2 parents 1bc199c + 8338071 commit eb3a25d

5 files changed

Lines changed: 36 additions & 29 deletions

File tree

controllers/argocd/argocd_controller.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ import (
3737

3838
errs "errors"
3939

40-
configv1 "github.com/openshift/api/config/v1"
4140
rbacv1 "k8s.io/api/rbac/v1"
4241
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4342
ctrl "sigs.k8s.io/controller-runtime"
4443
"sigs.k8s.io/controller-runtime/pkg/client"
4544
logr "sigs.k8s.io/controller-runtime/pkg/log"
4645
"sigs.k8s.io/controller-runtime/pkg/reconcile"
46+
47+
tlsProfile "github.com/argoproj-labs/argocd-operator/pkg/tlsprofile"
4748
)
4849

4950
type tokenRenewalTimer struct {
@@ -104,19 +105,11 @@ type ReconcileArgoCD struct {
104105
// Key: ArgoCD namespace, Value: time.Duration
105106
dexTokenRequeueAfter sync.Map
106107
// CentralTLSConfigProfile specifies the TLS configuration profile in the cluster.
107-
CentralTLSConfigProfile TLSConfigProfile
108+
CentralTLSConfigProfile tlsProfile.TLSConfigProfile
108109
}
109110

110111
var log = logr.Log.WithName("controller_argocd")
111112

112-
type TLSConfigProfile struct {
113-
DisableClusterTLSProfile bool
114-
// MinVersion specifies the minimum TLS version configured in cluster.
115-
MinVersion configv1.TLSProtocolVersion
116-
// Ciphers specifies the list of supported TLS cipher suites in cluster.
117-
Ciphers []string
118-
}
119-
120113
// Map to keep track of running Argo CD instances using their namespaces as key and phase as value
121114
// This map will be used for the performance metrics purposes
122115
// Important note: This assumes that each instance only contains one Argo CD instance

controllers/argocd/deployment.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1"
2828
"github.com/argoproj-labs/argocd-operator/common"
2929
"github.com/argoproj-labs/argocd-operator/controllers/argoutil"
30+
tlsProfile "github.com/argoproj-labs/argocd-operator/pkg/tlsprofile"
3031

3132
appsv1 "k8s.io/api/apps/v1"
3233
corev1 "k8s.io/api/core/v1"
@@ -220,7 +221,7 @@ func getArgoImportVolumes(cr *argoprojv1alpha1.ArgoCDExport) []corev1.Volume {
220221
return volumes
221222
}
222223

223-
func getArgoRedisArgs(useTLS bool, centralTLSConfig TLSConfigProfile) []string {
224+
func getArgoRedisArgs(useTLS bool, centralTLSConfig tlsProfile.TLSConfigProfile) []string {
224225
args := make([]string, 0)
225226

226227
args = append(args, "--save", "")
@@ -243,7 +244,7 @@ func getArgoRedisArgs(useTLS bool, centralTLSConfig TLSConfigProfile) []string {
243244
}
244245

245246
// BuildRedisArgsFromClusterTLSProfile builds arguments for redis deployment based on central tls config.
246-
func BuildRedisArgsFromClusterTLSProfile(centralTLSConfig TLSConfigProfile) []string {
247+
func BuildRedisArgsFromClusterTLSProfile(centralTLSConfig tlsProfile.TLSConfigProfile) []string {
247248
if centralTLSConfig.DisableClusterTLSProfile {
248249
return nil
249250
}
@@ -1259,7 +1260,7 @@ func (r *ReconcileArgoCD) reconcileServerDeployment(cr *argoproj.ArgoCD, useTLSF
12591260
}
12601261

12611262
// BuildTLSArgsFromClusterTLSProfile builds the command line arguments for the ArgoCD components based on the cluster's TLS profile configuration.
1262-
func BuildTLSArgsFromClusterTLSProfile(centralTLSConfig TLSConfigProfile) []string {
1263+
func BuildTLSArgsFromClusterTLSProfile(centralTLSConfig tlsProfile.TLSConfigProfile) []string {
12631264
var args []string
12641265
if centralTLSConfig.DisableClusterTLSProfile {
12651266
return nil

controllers/argocd/deployment_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/argoproj-labs/argocd-operator/common"
2424
"github.com/argoproj-labs/argocd-operator/controllers/argoutil"
25+
tlsProfile "github.com/argoproj-labs/argocd-operator/pkg/tlsprofile"
2526

2627
"github.com/google/go-cmp/cmp"
2728
"github.com/stretchr/testify/assert"
@@ -3140,21 +3141,21 @@ func TestReconcileArgoCD_reconcileRedisDeployment_customLabelsAndAnnotations(t *
31403141
func TestBuildRedisArgs(t *testing.T) {
31413142
tests := []struct {
31423143
name string
3143-
centralTLS TLSConfigProfile
3144+
centralTLS tlsProfile.TLSConfigProfile
31443145
expected []string
31453146
wantErr bool
31463147
}{
31473148
{
31483149
name: "central TLS config with invalid min version",
3149-
centralTLS: TLSConfigProfile{
3150+
centralTLS: tlsProfile.TLSConfigProfile{
31503151
MinVersion: configv1.TLSProtocolVersion("INVALID"),
31513152
},
31523153
expected: nil,
31533154
wantErr: false,
31543155
},
31553156
{
31563157
name: "central TLS config with tls 1.2",
3157-
centralTLS: TLSConfigProfile{
3158+
centralTLS: tlsProfile.TLSConfigProfile{
31583159
MinVersion: configv1.VersionTLS12,
31593160
Ciphers: []string{
31603161
"ECDHE-RSA-AES128-GCM-SHA256",
@@ -3172,7 +3173,7 @@ func TestBuildRedisArgs(t *testing.T) {
31723173
},
31733174
{
31743175
name: "central TLS config with tls 1.3",
3175-
centralTLS: TLSConfigProfile{
3176+
centralTLS: tlsProfile.TLSConfigProfile{
31763177
MinVersion: configv1.VersionTLS13,
31773178
Ciphers: []string{
31783179
"TLS_AES_128_GCM_SHA256",
@@ -3188,7 +3189,7 @@ func TestBuildRedisArgs(t *testing.T) {
31883189
},
31893190
{
31903191
name: "central TLS config only version",
3191-
centralTLS: TLSConfigProfile{
3192+
centralTLS: tlsProfile.TLSConfigProfile{
31923193
MinVersion: configv1.VersionTLS12,
31933194
},
31943195
expected: []string{
@@ -3199,7 +3200,7 @@ func TestBuildRedisArgs(t *testing.T) {
31993200
},
32003201
{
32013202
name: "central TLS config only ciphers",
3202-
centralTLS: TLSConfigProfile{
3203+
centralTLS: tlsProfile.TLSConfigProfile{
32033204
Ciphers: []string{
32043205
"ECDHE-RSA-AES256-GCM-SHA384",
32053206
},
@@ -3214,7 +3215,7 @@ func TestBuildRedisArgs(t *testing.T) {
32143215
},
32153216
{
32163217
name: "central TLS config with unmapped cipher",
3217-
centralTLS: TLSConfigProfile{
3218+
centralTLS: tlsProfile.TLSConfigProfile{
32183219
MinVersion: configv1.VersionTLS12,
32193220
Ciphers: []string{
32203221
"INVALID",
@@ -3241,21 +3242,21 @@ func TestBuildRedisArgs(t *testing.T) {
32413242
func TestBuildTLSArgs(t *testing.T) {
32423243
tests := []struct {
32433244
name string
3244-
centralTLS TLSConfigProfile
3245+
centralTLS tlsProfile.TLSConfigProfile
32453246
expected []string
32463247
wantErr bool
32473248
}{
32483249
{
32493250
name: "disable central tls config",
3250-
centralTLS: TLSConfigProfile{
3251+
centralTLS: tlsProfile.TLSConfigProfile{
32513252
DisableClusterTLSProfile: true,
32523253
},
32533254
expected: nil,
32543255
wantErr: false,
32553256
},
32563257
{
32573258
name: "central TLS config with min version only",
3258-
centralTLS: TLSConfigProfile{
3259+
centralTLS: tlsProfile.TLSConfigProfile{
32593260
MinVersion: configv1.VersionTLS12,
32603261
},
32613262
expected: []string{
@@ -3266,7 +3267,7 @@ func TestBuildTLSArgs(t *testing.T) {
32663267
},
32673268
{
32683269
name: "central TLS config with ciphers only",
3269-
centralTLS: TLSConfigProfile{
3270+
centralTLS: tlsProfile.TLSConfigProfile{
32703271
Ciphers: []string{
32713272
"ECDHE-RSA-AES128-GCM-SHA256",
32723273
},
@@ -3279,7 +3280,7 @@ func TestBuildTLSArgs(t *testing.T) {
32793280
},
32803281
{
32813282
name: "central TLS config with version and ciphers",
3282-
centralTLS: TLSConfigProfile{
3283+
centralTLS: tlsProfile.TLSConfigProfile{
32833284
MinVersion: configv1.VersionTLS13,
32843285
Ciphers: []string{
32853286
"TLS_AES_128_GCM_SHA256",
@@ -3315,7 +3316,7 @@ func TestArgoCDServerAndRepoServerDeploymentArgs(t *testing.T) {
33153316
sch := makeTestReconcilerScheme(argoproj.AddToScheme)
33163317
cl := makeTestReconcilerClient(sch, resObjs, subresObjs, runtimeObjs)
33173318
r := makeTestReconciler(cl, sch, testclient.NewSimpleClientset())
3318-
r.CentralTLSConfigProfile = TLSConfigProfile{
3319+
r.CentralTLSConfigProfile = tlsProfile.TLSConfigProfile{
33193320
DisableClusterTLSProfile: false,
33203321
MinVersion: configv1.VersionTLS12,
33213322
Ciphers: []string{

controllers/argocd/image_updater_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"k8s.io/apimachinery/pkg/util/intstr"
1212

1313
"github.com/argoproj-labs/argocd-operator/controllers/argoutil"
14+
tlsProfile "github.com/argoproj-labs/argocd-operator/pkg/tlsprofile"
1415

1516
"github.com/stretchr/testify/assert"
1617
"github.com/stretchr/testify/require"
@@ -969,12 +970,12 @@ func TestReconcileImageUpdaterControllerEnabled_PrunesStaleNamespaceRBAC(t *test
969970
func TestReconcileImageUpdaterDeployment_TLSArgs(t *testing.T) {
970971
tests := []struct {
971972
name string
972-
centralTLS TLSConfigProfile
973+
centralTLS tlsProfile.TLSConfigProfile
973974
expectedArgs []string
974975
}{
975976
{
976977
name: "central tls profile",
977-
centralTLS: TLSConfigProfile{
978+
centralTLS: tlsProfile.TLSConfigProfile{
978979
DisableClusterTLSProfile: false,
979980
MinVersion: configv1.VersionTLS12,
980981
Ciphers: []string{
@@ -991,7 +992,7 @@ func TestReconcileImageUpdaterDeployment_TLSArgs(t *testing.T) {
991992
},
992993
{
993994
name: "Disable cluster tls profile",
994-
centralTLS: TLSConfigProfile{
995+
centralTLS: tlsProfile.TLSConfigProfile{
995996
DisableClusterTLSProfile: true,
996997
},
997998
expectedArgs: []string{},

pkg/tlsprofile/profile.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package tlsprofile
2+
3+
import configv1 "github.com/openshift/api/config/v1"
4+
5+
type TLSConfigProfile struct {
6+
DisableClusterTLSProfile bool
7+
// MinVersion specifies the minimum TLS version configured in cluster.
8+
MinVersion configv1.TLSProtocolVersion
9+
// Ciphers specifies the list of supported TLS cipher suites in cluster.
10+
Ciphers []string
11+
}

0 commit comments

Comments
 (0)