Skip to content

Commit

Permalink
feat: added env variable to skip gitops validation on create/update (#…
Browse files Browse the repository at this point in the history
…3956)

* feat: added env variable to skip gitops validation on create/update

* feat: updated API response

* feat: reverted API response changes

* handled panic on CD pipeline save
  • Loading branch information
Ash-exp committed Sep 25, 2023
1 parent 0ec6d11 commit cd1c4d3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/app/AppService.go
Original file line number Diff line number Diff line change
Expand Up @@ -1698,7 +1698,7 @@ func (impl *AppServiceImpl) CreateGitopsRepo(app *app.App, userId int32) (gitops
gitOpsRepoName := impl.chartTemplateService.GetGitOpsRepoName(app.AppName)
chartGitAttr, err = impl.chartTemplateService.CreateGitRepositoryForApp(gitOpsRepoName, chart.ReferenceTemplate, chart.ChartVersion, userId)
if err != nil {
impl.logger.Errorw("error in pushing chart to git ", "path", chartGitAttr.ChartLocation, "err", err)
impl.logger.Errorw("error in pushing chart to git ", "gitOpsRepoName", gitOpsRepoName, "err", err)
return "", nil, err
}
return gitOpsRepoName, chartGitAttr, nil
Expand Down
6 changes: 6 additions & 0 deletions pkg/gitops/GitOpsConfigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ type DetailedErrorGitOpsConfigResponse struct {
type GitOpsConfigServiceImpl struct {
randSource rand.Source
logger *zap.SugaredLogger
globalEnvVariables *util2.GlobalEnvVariables
gitOpsRepository repository.GitOpsConfigRepository
K8sUtil *util4.K8sUtil
aCDAuthConfig *util3.ACDAuthConfig
Expand All @@ -103,12 +104,14 @@ type GitOpsConfigServiceImpl struct {
}

func NewGitOpsConfigServiceImpl(Logger *zap.SugaredLogger,
globalEnvVariables *util2.GlobalEnvVariables,
gitOpsRepository repository.GitOpsConfigRepository, K8sUtil *util4.K8sUtil, aCDAuthConfig *util3.ACDAuthConfig,
clusterService cluster.ClusterService, envService cluster.EnvironmentService, versionService argocdServer.VersionService,
gitFactory *util.GitFactory, chartTemplateService util.ChartTemplateService, argoUserService argo.ArgoUserService, clusterServiceCD cluster2.ServiceClient) *GitOpsConfigServiceImpl {
return &GitOpsConfigServiceImpl{
randSource: rand.NewSource(time.Now().UnixNano()),
logger: Logger,
globalEnvVariables: globalEnvVariables,
gitOpsRepository: gitOpsRepository,
K8sUtil: K8sUtil,
aCDAuthConfig: aCDAuthConfig,
Expand Down Expand Up @@ -684,6 +687,9 @@ func (impl *GitOpsConfigServiceImpl) GetGitOpsConfigActive() (*bean2.GitOpsConfi
}

func (impl *GitOpsConfigServiceImpl) GitOpsValidateDryRun(config *bean2.GitOpsConfigDto) DetailedErrorGitOpsConfigResponse {
if impl.globalEnvVariables.SkipGitOpsValidation {
return DetailedErrorGitOpsConfigResponse{}
}
if config.Token == "" {
model, err := impl.gitOpsRepository.GetGitOpsConfigById(config.Id)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion util/GlobalConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import (
)

type GlobalEnvVariables struct {
GitOpsRepoPrefix string `env:"GITOPS_REPO_PREFIX" envDefault:""`
GitOpsRepoPrefix string `env:"GITOPS_REPO_PREFIX" envDefault:""`
SkipGitOpsValidation bool `env:"SKIP_GITOPS_VALIDATION" envDefault:"false"`
}

func GetGlobalEnvVariables() (*GlobalEnvVariables, error) {
Expand Down
2 changes: 1 addition & 1 deletion wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd1c4d3

Please sign in to comment.