Skip to content

Commit

Permalink
fix: respect ARGOCD_GIT_MODULES_ENABLED in the appset controller (#10285
Browse files Browse the repository at this point in the history
) (#10287)

* fix: respect ARGOCD_GIT_MODULES_ENABLED in the appset controller (#10285)

Signed-off-by: CI <michael@crenshaw.dev>

* remove duplicate line

Signed-off-by: CI <michael@crenshaw.dev>

Signed-off-by: CI <michael@crenshaw.dev>
  • Loading branch information
crenshaw-dev committed Aug 12, 2022
1 parent 5ed749e commit f071b29
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 11 additions & 9 deletions applicationset/services/repo_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ type RepositoryDB interface {
}

type argoCDService struct {
repositoriesDB RepositoryDB
storecreds git.CredsStore
repositoriesDB RepositoryDB
storecreds git.CredsStore
submoduleEnabled bool
}

type Repos interface {
Expand All @@ -32,11 +33,12 @@ type Repos interface {
GetDirectories(ctx context.Context, repoURL string, revision string) ([]string, error)
}

func NewArgoCDService(db db.ArgoDB, gitCredStore git.CredsStore, repoServerAddress string) Repos {
func NewArgoCDService(db db.ArgoDB, gitCredStore git.CredsStore, submoduleEnabled bool) Repos {

return &argoCDService{
repositoriesDB: db.(RepositoryDB),
storecreds: gitCredStore,
repositoriesDB: db.(RepositoryDB),
storecreds: gitCredStore,
submoduleEnabled: submoduleEnabled,
}
}

Expand All @@ -52,7 +54,7 @@ func (a *argoCDService) GetFiles(ctx context.Context, repoURL string, revision s
return nil, err
}

err = checkoutRepo(gitRepoClient, revision)
err = checkoutRepo(gitRepoClient, revision, a.submoduleEnabled)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -86,7 +88,7 @@ func (a *argoCDService) GetDirectories(ctx context.Context, repoURL string, revi
return nil, err
}

err = checkoutRepo(gitRepoClient, revision)
err = checkoutRepo(gitRepoClient, revision, a.submoduleEnabled)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -128,7 +130,7 @@ func (a *argoCDService) GetDirectories(ctx context.Context, repoURL string, revi

}

func checkoutRepo(gitRepoClient git.Client, revision string) error {
func checkoutRepo(gitRepoClient git.Client, revision string, submoduleEnabled bool) error {
err := gitRepoClient.Init()
if err != nil {
return fmt.Errorf("Error during initializing repo: %w", err)
Expand All @@ -143,7 +145,7 @@ func checkoutRepo(gitRepoClient git.Client, revision string) error {
if err != nil {
return fmt.Errorf("Error during fetching commitSHA: %w", err)
}
err = gitRepoClient.Checkout(commitSHA, true)
err = gitRepoClient.Checkout(commitSHA, submoduleEnabled)
if err != nil {
return fmt.Errorf("Error during repo checkout: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/argoproj/argo-cd/v2/applicationset/utils"
"github.com/argoproj/argo-cd/v2/common"
"github.com/argoproj/argo-cd/v2/reposerver/askpass"
"github.com/argoproj/argo-cd/v2/util/env"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
Expand All @@ -37,6 +38,11 @@ import (
argosettings "github.com/argoproj/argo-cd/v2/util/settings"
)

// TODO: load this using Cobra. https://github.com/argoproj/argo-cd/issues/10157
func getSubmoduleEnabled() bool {
return env.ParseBoolFromEnv(common.EnvGitSubmoduleEnabled, true)
}

func NewCommand() *cobra.Command {
var (
clientConfig clientcmd.ClientConfig
Expand Down Expand Up @@ -136,7 +142,7 @@ func NewCommand() *cobra.Command {
terminalGenerators := map[string]generators.Generator{
"List": generators.NewListGenerator(),
"Clusters": generators.NewClusterGenerator(mgr.GetClient(), context.Background(), k8sClient, namespace),
"Git": generators.NewGitGenerator(services.NewArgoCDService(argoCDDB, askPassServer, argocdRepoServer)),
"Git": generators.NewGitGenerator(services.NewArgoCDService(argoCDDB, askPassServer, getSubmoduleEnabled())),
"SCMProvider": generators.NewSCMProviderGenerator(mgr.GetClient()),
"ClusterDecisionResource": generators.NewDuckTypeGenerator(context.Background(), dynamicClient, k8sClient, namespace),
"PullRequest": generators.NewPullRequestGenerator(mgr.GetClient()),
Expand Down

0 comments on commit f071b29

Please sign in to comment.