-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
5,572 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,3 @@ | |
.env | ||
/cmd/external-app/devtron-ea | ||
devtron | ||
/vendor/github.com/argoproj/argo-cd/assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package bean | ||
|
||
type TLSConfig struct { | ||
CaData string `json:"caData"` | ||
TLSCertData string `json:"tlsCertData"` | ||
TLSKeyData string `json:"tlsKeyData"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package certificate | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"github.com/argoproj/argo-cd/v2/pkg/apiclient/certificate" | ||
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" | ||
"github.com/devtron-labs/devtron/client/argocdServer/connection" | ||
"github.com/devtron-labs/devtron/util/argo" | ||
"go.uber.org/zap" | ||
"google.golang.org/grpc" | ||
"time" | ||
) | ||
|
||
type Client interface { | ||
ListCertificates(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error) | ||
CreateCertificate(ctx context.Context, query *certificate.RepositoryCertificateCreateRequest) (*v1alpha1.RepositoryCertificateList, error) | ||
DeleteCertificate(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error) | ||
} | ||
|
||
type ServiceClientImpl struct { | ||
logger *zap.SugaredLogger | ||
argoCDConnectionManager connection.ArgoCDConnectionManager | ||
argoUserService argo.ArgoUserService | ||
} | ||
|
||
func NewServiceClientImpl( | ||
logger *zap.SugaredLogger, | ||
argoCDConnectionManager connection.ArgoCDConnectionManager, | ||
argoUserService argo.ArgoUserService) *ServiceClientImpl { | ||
return &ServiceClientImpl{ | ||
logger: logger, | ||
argoCDConnectionManager: argoCDConnectionManager, | ||
argoUserService: argoUserService, | ||
} | ||
} | ||
|
||
func (c *ServiceClientImpl) getService(ctx context.Context) (certificate.CertificateServiceClient, error) { | ||
token, ok := ctx.Value("token").(string) | ||
if !ok { | ||
return nil, errors.New("Unauthorized") | ||
} | ||
conn := c.argoCDConnectionManager.GetConnection(token) | ||
//defer conn.Close() | ||
return certificate.NewCertificateServiceClient(conn), nil | ||
} | ||
|
||
func (c *ServiceClientImpl) ListCertificates(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error) { | ||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second) | ||
defer cancel() | ||
client, err := c.getService(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client.ListCertificates(ctx, query) | ||
} | ||
|
||
func (c *ServiceClientImpl) CreateCertificate(ctx context.Context, query *certificate.RepositoryCertificateCreateRequest) (*v1alpha1.RepositoryCertificateList, error) { | ||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second) | ||
defer cancel() | ||
client, err := c.getService(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client.CreateCertificate(ctx, query) | ||
} | ||
|
||
func (c *ServiceClientImpl) DeleteCertificate(ctx context.Context, query *certificate.RepositoryCertificateQuery, opts ...grpc.CallOption) (*v1alpha1.RepositoryCertificateList, error) { | ||
ctx, cancel := context.WithTimeout(ctx, 10*time.Second) | ||
defer cancel() | ||
client, err := c.getService(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client.DeleteCertificate(ctx, query, opts...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2020-2024. Devtron Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package repository | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
repocreds "github.com/argoproj/argo-cd/v2/pkg/apiclient/repocreds" | ||
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" | ||
argoApplication "github.com/devtron-labs/devtron/client/argocdServer/bean" | ||
"github.com/devtron-labs/devtron/client/argocdServer/connection" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type ServiceClient interface { | ||
CreateRepoCreds(ctx context.Context, query *repocreds.RepoCredsCreateRequest) (*v1alpha1.RepoCreds, error) | ||
} | ||
|
||
type ServiceClientImpl struct { | ||
logger *zap.SugaredLogger | ||
argoCDConnectionManager connection.ArgoCDConnectionManager | ||
} | ||
|
||
func NewServiceClientImpl(logger *zap.SugaredLogger, argoCDConnectionManager connection.ArgoCDConnectionManager) *ServiceClientImpl { | ||
return &ServiceClientImpl{ | ||
logger: logger, | ||
argoCDConnectionManager: argoCDConnectionManager, | ||
} | ||
} | ||
|
||
func (r ServiceClientImpl) getService(ctx context.Context) (repocreds.RepoCredsServiceClient, error) { | ||
token, ok := ctx.Value("token").(string) | ||
if !ok { | ||
return nil, errors.New("Unauthorized") | ||
} | ||
conn := r.argoCDConnectionManager.GetConnection(token) | ||
//defer conn.Close() | ||
return repocreds.NewRepoCredsServiceClient(conn), nil | ||
} | ||
|
||
func (r ServiceClientImpl) CreateRepoCreds(ctx context.Context, query *repocreds.RepoCredsCreateRequest) (*v1alpha1.RepoCreds, error) { | ||
ctx, cancel := context.WithTimeout(ctx, argoApplication.TimeoutSlow) | ||
defer cancel() | ||
client, err := r.getService(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client.CreateRepositoryCredentials(ctx, query) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.