Skip to content

Commit

Permalink
Merge pull request #354 from kube-tarian/fix-crossplane-sync
Browse files Browse the repository at this point in the history
fix cross plane synch issue
  • Loading branch information
vramk23 authored Dec 27, 2023
2 parents 794ec88 + a600344 commit 45e5ec4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
15 changes: 9 additions & 6 deletions capten/common-pkg/plugins/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ func NewClient() *GitClient {
}

func (g *GitClient) Clone(directory, url, token string) error {
r, err := git.PlainClone(directory, false, &git.CloneOptions{
Auth: &http.BasicAuth{
Username: "dummy", // yes, this can be anything except an empty string
Password: token,
},
opt := &git.CloneOptions{
URL: url,
Progress: os.Stdout,
InsecureSkipTLS: true,
})
}
if len(token) != 0 {
opt.Auth = &http.BasicAuth{
Username: "dummy", // yes, this can be anything except an empty string
Password: token,
}
}

r, err := git.PlainClone(directory, false, opt)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion capten/config-worker/internal/app_config/app_git_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func (ca *AppGitConfigHelper) CloneTemplateRepo(repoURL string) (templateDir str
return
}

if err = ca.gitClient.Clone(templateDir, repoURL, ""); err != nil {
gitClient := git.NewClient()
if err = gitClient.Clone(templateDir, repoURL, ""); err != nil {
os.RemoveAll(templateDir)
err = fmt.Errorf("failed to Clone template repo, err: %v", err)
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ func readCrossPlanePluginConfig(pluginFile string) (*crossplanePluginConfig, err

func (cp *CrossPlaneApp) configureProjectAndApps(ctx context.Context, req *model.CrossplaneUseCase) (status string, err error) {
logger.Infof("cloning default templates %s to project %s", cp.pluginConfig.TemplateGitRepo, req.RepoURL)
templateRepo, err := cp.helper.CloneTemplateRepo(cp.pluginConfig.TemplateGitRepo)
if err != nil {
return string(agentmodel.WorkFlowStatusFailed), errors.WithMessage(err, "failed to clone repos")
}
defer os.RemoveAll(templateRepo)

customerRepo, err := cp.helper.CloneUserRepo(ctx, req.RepoURL, req.VaultCredIdentifier)
if err != nil {
return string(agentmodel.WorkFlowStatusFailed), errors.WithMessage(err, "failed to clone repos")
return string(agentmodel.WorkFlowStatusFailed), errors.WithMessagef(err, "failed to clone repo %s", req.RepoURL)
}
logger.Infof("cloned default templates to project %s", req.RepoURL)

defer os.RemoveAll(customerRepo)

logger.Infof("cloned project %s", req.RepoURL)
templateRepo, err := cp.helper.CloneTemplateRepo(cp.pluginConfig.TemplateGitRepo)
if err != nil {
return string(agentmodel.WorkFlowStatusFailed), errors.WithMessagef(err, "failed to clone repo %s", cp.pluginConfig.TemplateGitRepo)
}
defer os.RemoveAll(templateRepo)

err = cp.synchProviders(req, templateRepo, customerRepo)
if err != nil {
return string(agentmodel.WorkFlowStatusFailed), errors.WithMessage(err, "failed to update configs to repo")
Expand Down
2 changes: 1 addition & 1 deletion charts/kad/crossplane_plugin_config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"templateGitRepo": "https://github.com/intelops/capten-templates",
"crossplaneConfigSyncPath": "infra",
"providerConfigSyncPath": "infra/crossplane/crossplane-config",
"providerConfigSyncPath": "infra/crossplane/providers",
"providerPackages": {
"aws": "xpkg.upbound.io/crossplane-contrib/provider-aws:v0.33.0",
"gcp": "xpkg.upbound.io/crossplane-contrib/provider-gcp:v0.22.0"
Expand Down

0 comments on commit 45e5ec4

Please sign in to comment.