Skip to content

Commit

Permalink
Removed the db modifications and repoName prepared from appName and c…
Browse files Browse the repository at this point in the history
…harName
  • Loading branch information
share2kanna committed Jun 14, 2024
1 parent 464c2dd commit 3938b09
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion capten/agent/internal/api/app_config_sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package api

import (
"context"
"strings"

"github.com/kube-tarian/kad/capten/common-pkg/credential"
"github.com/kube-tarian/kad/capten/common-pkg/pb/agentpb"
Expand All @@ -24,6 +25,8 @@ func (a *Agent) ConfigureAppSSO(ctx context.Context,
}, nil
}

a.prepareRepoName(appConfig)

if err := credential.StoreAppOauthCredential(ctx, req.ReleaseName, req.ClientId, req.ClientSecret); err != nil {
a.log.Errorf("failed to store oauth credential for app %s, %v", req.ReleaseName, err)
return &agentpb.ConfigureAppSSOResponse{
Expand Down Expand Up @@ -55,7 +58,6 @@ func (a *Agent) ConfigureAppSSO(ctx context.Context,

ssoOverwriteBytes, _ := yaml.Marshal(ssoOverwriteMapping)
overrideValuesBytes, _ := yaml.Marshal(overrideValuesMapping)
appConfig.Config.RepoName = "tools"
updateAppConfig, marshaledOverrideValues, err := populateTemplateValues(appConfig, overrideValuesBytes, ssoOverwriteBytes, a.log)
if err != nil {
a.log.Errorf("failed to populate template values for app %s, %v", req.ReleaseName, err)
Expand Down Expand Up @@ -84,6 +86,16 @@ func (a *Agent) ConfigureAppSSO(ctx context.Context,
}, nil
}

func (a *Agent) prepareRepoName(appConfig *agentpb.SyncAppData) {
repoInfo := strings.Split(appConfig.Config.AppName, "/")

if len(repoInfo) != 2 {
a.log.Infof("App don't have repo name %s, using chartName as repoName", appConfig.Config.AppName)
repoInfo = []string{appConfig.Config.ChartName, appConfig.Config.AppName}
}
appConfig.Config.RepoName = repoInfo[0]
}

func (a *Agent) upgradeAppWithWorkflow(req *model.ApplicationInstallRequest,
appConfig *agentpb.SyncAppData) {
wd := workers.NewDeployment(a.tc, a.log)
Expand Down

0 comments on commit 3938b09

Please sign in to comment.