Skip to content

Commit 3ddee6d

Browse files
feat(appset): Add support for self-signed TLS / Certificates for Gitlab Scm Provider (#14348) (#14462)
* Add support for self-signed TLS / Certificates for Gitlab Scm Provider * Add support for self-signed TLS / Certificates for Gitlab Pull Request * Add TLS configuration for SCM and Pull request Gitlab Provider * rebase with master * add params to argocd-cmd-params-cm and docs * fix generated manifests * Address comments for docs * Add test cases to validate insecure mode and ca cert combinations * simplify (#24) --------- Signed-off-by: ishitasequeira <[email protected]> Signed-off-by: Michael Crenshaw <[email protected]> Co-authored-by: Michael Crenshaw <[email protected]>
1 parent 53c582b commit 3ddee6d

34 files changed

+1060
-701
lines changed

applicationset/controllers/applicationset_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type ApplicationSetReconciler struct {
8686
ArgoCDNamespace string
8787
ApplicationSetNamespaces []string
8888
EnableProgressiveSyncs bool
89+
SCMRootCAPath string
8990
}
9091

9192
// +kubebuilder:rbac:groups=argoproj.io,resources=applicationsets,verbs=get;list;watch;create;update;patch;delete

applicationset/controllers/applicationset_controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ import (
2626
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2727
"sigs.k8s.io/controller-runtime/pkg/event"
2828

29-
"github.com/argoproj/argo-cd/v2/applicationset/generators"
30-
"github.com/argoproj/argo-cd/v2/applicationset/utils"
3129
"github.com/argoproj/gitops-engine/pkg/health"
3230
"github.com/argoproj/gitops-engine/pkg/sync/common"
3331

32+
"github.com/argoproj/argo-cd/v2/applicationset/generators"
33+
"github.com/argoproj/argo-cd/v2/applicationset/utils"
34+
3435
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
3536
appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned/fake"
3637
"github.com/argoproj/argo-cd/v2/util/collections"

applicationset/controllers/requeue_after_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/argoproj/argo-cd/v2/applicationset/generators"
9-
"github.com/argoproj/argo-cd/v2/applicationset/services/mocks"
10-
argov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
118
"github.com/stretchr/testify/assert"
129
corev1 "k8s.io/api/core/v1"
1310
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -17,6 +14,10 @@ import (
1714
kubefake "k8s.io/client-go/kubernetes/fake"
1815
"k8s.io/client-go/tools/record"
1916
"sigs.k8s.io/controller-runtime/pkg/client/fake"
17+
18+
"github.com/argoproj/argo-cd/v2/applicationset/generators"
19+
"github.com/argoproj/argo-cd/v2/applicationset/services/mocks"
20+
argov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
2021
)
2122

2223
func TestRequeueAfter(t *testing.T) {
@@ -59,9 +60,9 @@ func TestRequeueAfter(t *testing.T) {
5960
"List": generators.NewListGenerator(),
6061
"Clusters": generators.NewClusterGenerator(k8sClient, ctx, appClientset, "argocd"),
6162
"Git": generators.NewGitGenerator(mockServer),
62-
"SCMProvider": generators.NewSCMProviderGenerator(fake.NewClientBuilder().WithObjects(&corev1.Secret{}).Build(), generators.SCMAuthProviders{}),
63+
"SCMProvider": generators.NewSCMProviderGenerator(fake.NewClientBuilder().WithObjects(&corev1.Secret{}).Build(), generators.SCMAuthProviders{}, ""),
6364
"ClusterDecisionResource": generators.NewDuckTypeGenerator(ctx, fakeDynClient, appClientset, "argocd"),
64-
"PullRequest": generators.NewPullRequestGenerator(k8sClient, generators.SCMAuthProviders{}),
65+
"PullRequest": generators.NewPullRequestGenerator(k8sClient, generators.SCMAuthProviders{}, ""),
6566
}
6667

6768
nestedGenerators := map[string]generators.Generator{

applicationset/generators/cluster.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ func (g *ClusterGenerator) GetTemplate(appSetGenerator *argoappsetv1alpha1.Appli
6161
return &appSetGenerator.Clusters.Template
6262
}
6363

64-
func (g *ClusterGenerator) GenerateParams(
65-
appSetGenerator *argoappsetv1alpha1.ApplicationSetGenerator, appSet *argoappsetv1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
64+
func (g *ClusterGenerator) GenerateParams(appSetGenerator *argoappsetv1alpha1.ApplicationSetGenerator, appSet *argoappsetv1alpha1.ApplicationSet) ([]map[string]interface{}, error) {
6665

6766
if appSetGenerator == nil {
6867
return nil, EmptyAppSetGeneratorError

applicationset/generators/duck_type_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package generators
33
import (
44
"context"
55
"fmt"
6+
"testing"
67

78
"github.com/stretchr/testify/assert"
89
corev1 "k8s.io/api/core/v1"
@@ -15,8 +16,6 @@ import (
1516
"sigs.k8s.io/controller-runtime/pkg/client"
1617

1718
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
18-
19-
"testing"
2019
)
2120

2221
const resourceApiVersion = "mallard.io/v1"

applicationset/generators/generator_spec_processor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"fmt"
55
"reflect"
66

7-
"github.com/argoproj/argo-cd/v2/applicationset/utils"
87
"github.com/jeremywohl/flatten"
98

9+
"github.com/argoproj/argo-cd/v2/applicationset/utils"
10+
1011
"k8s.io/apimachinery/pkg/labels"
1112

1213
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"

applicationset/generators/generator_spec_processor_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/argoproj/argo-cd/v2/applicationset/services/mocks"
87
log "github.com/sirupsen/logrus"
98
"github.com/stretchr/testify/assert"
109
"github.com/stretchr/testify/require"
1110
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1211
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1312

13+
"github.com/argoproj/argo-cd/v2/applicationset/services/mocks"
14+
1415
argov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
1516

1617
"github.com/stretchr/testify/mock"

applicationset/generators/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import (
55
"fmt"
66
"time"
77

8-
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
98
"sigs.k8s.io/yaml"
9+
10+
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
1011
)
1112

1213
var _ Generator = (*ListGenerator)(nil)

applicationset/generators/pull_request.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ type PullRequestGenerator struct {
2525
client client.Client
2626
selectServiceProviderFunc func(context.Context, *argoprojiov1alpha1.PullRequestGenerator, *argoprojiov1alpha1.ApplicationSet) (pullrequest.PullRequestService, error)
2727
auth SCMAuthProviders
28+
scmRootCAPath string
2829
}
2930

30-
func NewPullRequestGenerator(client client.Client, auth SCMAuthProviders) Generator {
31+
func NewPullRequestGenerator(client client.Client, auth SCMAuthProviders, scmRootCAPath string) Generator {
3132
g := &PullRequestGenerator{
32-
client: client,
33-
auth: auth,
33+
client: client,
34+
auth: auth,
35+
scmRootCAPath: scmRootCAPath,
3436
}
3537
g.selectServiceProviderFunc = g.selectServiceProvider
3638
return g
@@ -126,7 +128,7 @@ func (g *PullRequestGenerator) selectServiceProvider(ctx context.Context, genera
126128
if err != nil {
127129
return nil, fmt.Errorf("error fetching Secret token: %v", err)
128130
}
129-
return pullrequest.NewGitLabService(ctx, token, providerConfig.API, providerConfig.Project, providerConfig.Labels, providerConfig.PullRequestState)
131+
return pullrequest.NewGitLabService(ctx, token, providerConfig.API, providerConfig.Project, providerConfig.Labels, providerConfig.PullRequestState, g.scmRootCAPath, providerConfig.Insecure)
130132
}
131133
if generatorConfig.Gitea != nil {
132134
providerConfig := generatorConfig.Gitea

applicationset/generators/scm_provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,18 @@ type SCMProviderGenerator struct {
2626
// Testing hooks.
2727
overrideProvider scm_provider.SCMProviderService
2828
SCMAuthProviders
29+
scmRootCAPath string
2930
}
3031

3132
type SCMAuthProviders struct {
3233
GitHubApps github_app_auth.Credentials
3334
}
3435

35-
func NewSCMProviderGenerator(client client.Client, providers SCMAuthProviders) Generator {
36+
func NewSCMProviderGenerator(client client.Client, providers SCMAuthProviders, scmRootCAPath string) Generator {
3637
return &SCMProviderGenerator{
3738
client: client,
3839
SCMAuthProviders: providers,
40+
scmRootCAPath: scmRootCAPath,
3941
}
4042
}
4143

@@ -85,7 +87,7 @@ func (g *SCMProviderGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha
8587
if err != nil {
8688
return nil, fmt.Errorf("error fetching Gitlab token: %v", err)
8789
}
88-
provider, err = scm_provider.NewGitlabProvider(ctx, providerConfig.Gitlab.Group, token, providerConfig.Gitlab.API, providerConfig.Gitlab.AllBranches, providerConfig.Gitlab.IncludeSubgroups)
90+
provider, err = scm_provider.NewGitlabProvider(ctx, providerConfig.Gitlab.Group, token, providerConfig.Gitlab.API, providerConfig.Gitlab.AllBranches, providerConfig.Gitlab.IncludeSubgroups, providerConfig.Gitlab.Insecure, g.scmRootCAPath)
8991
if err != nil {
9092
return nil, fmt.Errorf("error initializing Gitlab service: %v", err)
9193
}

0 commit comments

Comments
 (0)