Skip to content

Commit ca432b7

Browse files
committed
Merge remote-tracking branch 'origin/main' into refactoring-deployment-app-name-usage
2 parents 8d34a07 + 17c870c commit ca432b7

File tree

77 files changed

+5859
-559
lines changed

Some content is hidden

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

77 files changed

+5859
-559
lines changed

.gitbook.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,5 @@ redirects:
126126
user-guide/creating-application/workflow/ci-pipeline2: user-guide/creating-application/workflow/ci-pipeline.md
127127
user-guide/clusters: user-guide/resource-browser.md
128128
usage/clusters: user-guide/resource-browser.md
129-
global-configurations/authorization/sso-login/okta: user-guide/global-configurations/authorization/sso/okta.md
129+
global-configurations/authorization/sso-login/okta: user-guide/global-configurations/authorization/sso/okta.md
130+
usage/applications/creating-application/ci-pipeline/ci-build-pre-post-plugins: user-guide/creating-application/workflow/ci-build-pre-post-plugins.md

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
.env
55
/cmd/external-app/devtron-ea
66
devtron
7-
/vendor/github.com/argoproj/argo-cd/assets

Wire.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ import (
7575
"github.com/devtron-labs/devtron/cel"
7676
"github.com/devtron-labs/devtron/client/argocdServer"
7777
"github.com/devtron-labs/devtron/client/argocdServer/application"
78+
"github.com/devtron-labs/devtron/client/argocdServer/certificate"
7879
cluster2 "github.com/devtron-labs/devtron/client/argocdServer/cluster"
7980
"github.com/devtron-labs/devtron/client/argocdServer/connection"
81+
repocreds "github.com/devtron-labs/devtron/client/argocdServer/repocreds"
8082
repository2 "github.com/devtron-labs/devtron/client/argocdServer/repository"
8183
session2 "github.com/devtron-labs/devtron/client/argocdServer/session"
8284
"github.com/devtron-labs/devtron/client/cron"
@@ -973,6 +975,9 @@ func InitializeApp() (*App, error) {
973975
imageDigestPolicy.NewImageDigestPolicyServiceImpl,
974976
wire.Bind(new(imageDigestPolicy.ImageDigestPolicyService), new(*imageDigestPolicy.ImageDigestPolicyServiceImpl)),
975977

978+
certificate.NewServiceClientImpl,
979+
wire.Bind(new(certificate.Client), new(*certificate.ServiceClientImpl)),
980+
976981
appStoreRestHandler.AppStoreWireSet,
977982

978983
cel.NewCELServiceImpl,
@@ -983,6 +988,9 @@ func InitializeApp() (*App, error) {
983988

984989
common.NewDeploymentConfigServiceImpl,
985990
wire.Bind(new(common.DeploymentConfigService), new(*common.DeploymentConfigServiceImpl)),
991+
992+
repocreds.NewServiceClientImpl,
993+
wire.Bind(new(repocreds.ServiceClient), new(*repocreds.ServiceClientImpl)),
986994
)
987995
return &App{}, nil
988996
}

api/bean/gitOps/GitOpsConfig.go

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,30 @@
1616

1717
package gitOps
1818

19-
import "time"
19+
import (
20+
"github.com/devtron-labs/devtron/api/bean"
21+
"time"
22+
)
2023

2124
type GitOpsConfigDto struct {
22-
Id int `json:"id,omitempty"`
23-
Provider string `json:"provider" validate:"oneof=GITLAB GITHUB AZURE_DEVOPS BITBUCKET_CLOUD"`
24-
Username string `json:"username"`
25-
Token string `json:"token"`
26-
GitLabGroupId string `json:"gitLabGroupId"`
27-
GitHubOrgId string `json:"gitHubOrgId"`
28-
Host string `json:"host"`
29-
Active bool `json:"active"`
30-
AzureProjectName string `json:"azureProjectName"`
31-
BitBucketWorkspaceId string `json:"bitBucketWorkspaceId"`
32-
BitBucketProjectKey string `json:"bitBucketProjectKey"`
33-
AllowCustomRepository bool `json:"allowCustomRepository"`
25+
Id int `json:"id,omitempty"`
26+
Provider string `json:"provider" validate:"oneof=GITLAB GITHUB AZURE_DEVOPS BITBUCKET_CLOUD"`
27+
Username string `json:"username"`
28+
Token string `json:"token"`
29+
GitLabGroupId string `json:"gitLabGroupId"`
30+
GitHubOrgId string `json:"gitHubOrgId"`
31+
Host string `json:"host"`
32+
Active bool `json:"active"`
33+
AzureProjectName string `json:"azureProjectName"`
34+
BitBucketWorkspaceId string `json:"bitBucketWorkspaceId"`
35+
BitBucketProjectKey string `json:"bitBucketProjectKey"`
36+
AllowCustomRepository bool `json:"allowCustomRepository"`
37+
EnableTLSVerification bool `json:"enableTLSVerification"`
38+
TLSConfig *bean.TLSConfig `json:"tlsConfig"`
39+
40+
IsCADataPresent bool `json:"isCADataPresent"`
41+
IsTLSCertDataPresent bool `json:"isTLSCertDataPresent"`
42+
IsTLSKeyDataPresent bool `json:"isTLSKeyDataPresent"`
3443

3544
// TODO refactoring: create different struct for internal fields
3645
GitRepoName string `json:"-"`

api/bean/tlsConfig.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package bean
2+
3+
type TLSConfig struct {
4+
CaData string `json:"caData"`
5+
TLSCertData string `json:"tlsCertData"`
6+
TLSKeyData string `json:"tlsKeyData"`
7+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package certificate
2+
3+
import (
4+
"context"
5+
"errors"
6+
"github.com/argoproj/argo-cd/v2/pkg/apiclient/certificate"
7+
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
8+
"github.com/devtron-labs/devtron/client/argocdServer/connection"
9+
"github.com/devtron-labs/devtron/util/argo"
10+
"go.uber.org/zap"
11+
"google.golang.org/grpc"
12+
"time"
13+
)
14+
15+
type Client interface {
16+
ListCertificates(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error)
17+
CreateCertificate(ctx context.Context, query *certificate.RepositoryCertificateCreateRequest) (*v1alpha1.RepositoryCertificateList, error)
18+
DeleteCertificate(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error)
19+
}
20+
21+
type ServiceClientImpl struct {
22+
logger *zap.SugaredLogger
23+
argoCDConnectionManager connection.ArgoCDConnectionManager
24+
argoUserService argo.ArgoUserService
25+
}
26+
27+
func NewServiceClientImpl(
28+
logger *zap.SugaredLogger,
29+
argoCDConnectionManager connection.ArgoCDConnectionManager,
30+
argoUserService argo.ArgoUserService) *ServiceClientImpl {
31+
return &ServiceClientImpl{
32+
logger: logger,
33+
argoCDConnectionManager: argoCDConnectionManager,
34+
argoUserService: argoUserService,
35+
}
36+
}
37+
38+
func (c *ServiceClientImpl) getService(ctx context.Context) (certificate.CertificateServiceClient, error) {
39+
token, ok := ctx.Value("token").(string)
40+
if !ok {
41+
return nil, errors.New("Unauthorized")
42+
}
43+
conn := c.argoCDConnectionManager.GetConnection(token)
44+
//defer conn.Close()
45+
return certificate.NewCertificateServiceClient(conn), nil
46+
}
47+
48+
func (c *ServiceClientImpl) ListCertificates(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error) {
49+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
50+
defer cancel()
51+
client, err := c.getService(ctx)
52+
if err != nil {
53+
return nil, err
54+
}
55+
return client.ListCertificates(ctx, query)
56+
}
57+
58+
func (c *ServiceClientImpl) CreateCertificate(ctx context.Context, query *certificate.RepositoryCertificateCreateRequest) (*v1alpha1.RepositoryCertificateList, error) {
59+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
60+
defer cancel()
61+
client, err := c.getService(ctx)
62+
if err != nil {
63+
return nil, err
64+
}
65+
return client.CreateCertificate(ctx, query)
66+
}
67+
68+
func (c *ServiceClientImpl) DeleteCertificate(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error) {
69+
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
70+
defer cancel()
71+
client, err := c.getService(ctx)
72+
if err != nil {
73+
return nil, err
74+
}
75+
return client.DeleteCertificate(ctx, query, opts...)
76+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2020-2024. Devtron Inc.
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 repository
18+
19+
import (
20+
"context"
21+
"errors"
22+
repocreds "github.com/argoproj/argo-cd/v2/pkg/apiclient/repocreds"
23+
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
24+
argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean"
25+
"github.com/devtron-labs/devtron/client/argocdServer/connection"
26+
"go.uber.org/zap"
27+
)
28+
29+
type ServiceClient interface {
30+
CreateRepoCreds(ctx context.Context, query *repocreds.RepoCredsCreateRequest) (*v1alpha1.RepoCreds, error)
31+
}
32+
33+
type ServiceClientImpl struct {
34+
logger *zap.SugaredLogger
35+
argoCDConnectionManager connection.ArgoCDConnectionManager
36+
}
37+
38+
func NewServiceClientImpl(logger *zap.SugaredLogger, argoCDConnectionManager connection.ArgoCDConnectionManager) *ServiceClientImpl {
39+
return &ServiceClientImpl{
40+
logger: logger,
41+
argoCDConnectionManager: argoCDConnectionManager,
42+
}
43+
}
44+
45+
func (r ServiceClientImpl) getService(ctx context.Context) (repocreds.RepoCredsServiceClient, error) {
46+
token, ok := ctx.Value("token").(string)
47+
if !ok {
48+
return nil, errors.New("Unauthorized")
49+
}
50+
conn := r.argoCDConnectionManager.GetConnection(token)
51+
//defer conn.Close()
52+
return repocreds.NewRepoCredsServiceClient(conn), nil
53+
}
54+
55+
func (r ServiceClientImpl) CreateRepoCreds(ctx context.Context, query *repocreds.RepoCredsCreateRequest) (*v1alpha1.RepoCreds, error) {
56+
ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutSlow)
57+
defer cancel()
58+
client, err := r.getService(ctx)
59+
if err != nil {
60+
return nil, err
61+
}
62+
return client.CreateRepositoryCredentials(ctx, query)
63+
}

client/argocdServer/repository/Repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type ServiceClient interface {
3636
GetAppDetails(ctx context.Context, query *repository2.RepoAppDetailsQuery) (*apiclient.RepoAppDetailsResponse, error)
3737
// Create creates a repo
3838
Create(ctx context.Context, query *repository2.RepoCreateRequest) (*v1alpha1.Repository, error)
39-
// Update updates a repo
39+
// Create creates a repo
4040
Update(ctx context.Context, query *repository2.RepoUpdateRequest) (*v1alpha1.Repository, error)
4141
// Delete deletes a repo
4242
Delete(ctx context.Context, query *repository2.RepoQuery) (*repository2.RepoResponse, error)

client/gitSensor/GitSensorGrpcClient.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,19 @@ func (client *GrpcApiClientImpl) SaveGitProvider(ctx context.Context, provider *
114114
}
115115
// map req
116116
req := &pb.GitProvider{
117-
Id: int64(provider.Id),
118-
Name: provider.Name,
119-
Url: provider.Url,
120-
UserName: provider.UserName,
121-
Password: provider.Password,
122-
AccessToken: provider.AccessToken,
123-
SshPrivateKey: provider.SshPrivateKey,
124-
AuthMode: string(provider.AuthMode),
125-
Active: provider.Active,
117+
Id: int64(provider.Id),
118+
Name: provider.Name,
119+
Url: provider.Url,
120+
UserName: provider.UserName,
121+
Password: provider.Password,
122+
SshPrivateKey: provider.SshPrivateKey,
123+
AccessToken: provider.AccessToken,
124+
AuthMode: string(provider.AuthMode),
125+
Active: provider.Active,
126+
TlsCert: provider.TlsCert,
127+
TlsKey: provider.TlsKey,
128+
CaCert: provider.CaCert,
129+
EnableTLSVerification: provider.EnableTlsVerification,
126130
}
127131

128132
// fetch

client/gitSensor/GitSensorRestClient.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,19 @@ type GitMaterial struct {
9090
CloningMode string
9191
}
9292
type GitProvider struct {
93-
Id int
94-
Name string
95-
Url string
96-
UserName string
97-
Password string
98-
SshPrivateKey string
99-
AccessToken string
100-
Active bool
101-
AuthMode repository.AuthMode
93+
Id int
94+
Name string
95+
Url string
96+
UserName string
97+
Password string
98+
SshPrivateKey string
99+
AccessToken string
100+
Active bool
101+
AuthMode repository.AuthMode
102+
EnableTlsVerification bool
103+
CaCert string
104+
TlsCert string
105+
TlsKey string
102106
}
103107

104108
type GitCommit struct {

cmd/external-app/wire_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)