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

fix: reverting acd token fetch logic #5614

Merged
merged 2 commits into from
Aug 5, 2024
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
7 changes: 0 additions & 7 deletions pkg/gitops/GitOpsConfigService.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,6 @@ func (impl *GitOpsConfigServiceImpl) createGitOpsConfig(ctx context.Context, req

if model.EnableTLSVerification {

acdToken, err := impl.argoUserService.GetLatestDevtronArgoCdUserToken()
if err != nil {
impl.logger.Errorw("error in getting acd token", "err", err)
return nil, err
}
ctx = context.WithValue(ctx, "token", acdToken)

err = impl.gitOperationService.UpdateGitHostUrlByProvider(request)
if err != nil {
return nil, err
Expand Down
14 changes: 4 additions & 10 deletions util/argo/ArgoUserService.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package argo

import (
"context"
"errors"
"fmt"
"github.com/argoproj/argo-cd/v2/pkg/apiclient/account"
"github.com/devtron-labs/authenticator/client"
Expand All @@ -30,7 +29,6 @@ import (
"github.com/devtron-labs/devtron/pkg/deployment/gitOps/config"
"github.com/devtron-labs/devtron/pkg/module"
util2 "github.com/devtron-labs/devtron/util"
"github.com/go-pg/pg"
"go.uber.org/zap"
"golang.org/x/crypto/bcrypt"
apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -211,19 +209,15 @@ func (impl *ArgoUserServiceImpl) createNewArgoCdTokenForDevtron(username, passwo

// note: this function also called for no gitops case, where apps are installed via helm
func (impl *ArgoUserServiceImpl) GetLatestDevtronArgoCdUserToken() (string, error) {

moduleInfo, err := impl.moduleService.GetModuleInfo(module.ModuleNameArgoCd)
if err != nil && !errors.Is(err, pg.ErrNoRows) {
gitOpsConfigurationStatus, err := impl.gitOpsConfigReadService.IsGitOpsConfigured()
if err != nil {
impl.logger.Errorw("error while checking if gitOps is configured", "err", err)
return "", err
}
if moduleInfo == nil {
return "", errors.New("argocd module not installed")
}
if moduleInfo.Status != connection.ModuleStatusInstalled {
if !gitOpsConfigurationStatus.IsGitOpsConfigured {
//here acd token only required in context for argo cd calls
return "", nil
}

k8sClient, err := impl.k8sUtil.GetClientForInCluster()
if err != nil {
impl.logger.Errorw("error in getting k8s client for default cluster", "err", err)
Expand Down
Loading