Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading