Skip to content

Commit

Permalink
fix: GetApps doesn't need to preserve its clone directory so can
Browse files Browse the repository at this point in the history
always be temporary.

Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
  • Loading branch information
abayer authored and jenkins-x-bot committed Jan 13, 2020
1 parent 7cd7cb2 commit a915485
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 7 additions & 8 deletions pkg/apps/gitops.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,14 @@ func (o *GitOpsOptions) DeleteApp(app string, alias string, autoMerge bool) erro

// GetApps retrieves all the apps information for the given appNames from the repository and / or the CRD API
func (o *GitOpsOptions) GetApps(appNames map[string]bool, expandFn func([]string) (*v1.AppList, error)) (*v1.AppList, error) {
dir := o.EnvironmentCloneDir
if dir == "" {
tmpDir, err := ioutil.TempDir("", "get-apps-")
if err != nil {
return nil, err
}
defer os.RemoveAll(tmpDir)
dir = tmpDir
// AddApp, DeleteApp, and UpgradeApps delegate selecting/creating the directory to clone in to environments/gitops.go's
// Create function, but here we need to create the directory explicitly. since we aren't calling Create, because we're
// not creating a pull request.
dir, err := ioutil.TempDir("", "get-apps-")
if err != nil {
return nil, err
}
defer os.RemoveAll(dir)

gitInfo, err := gits.ParseGitURL(o.DevEnv.Spec.Source.URL)
if err != nil {
Expand Down
4 changes: 0 additions & 4 deletions pkg/cmd/get/get_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ type GetAppsOptions struct {
ShowStatus bool
GitOps bool
DevEnv *v1.Environment

// Used for testing
CloneDir string
}

type appsResult struct {
Expand Down Expand Up @@ -155,7 +152,6 @@ func (o *GetAppsOptions) Run() error {
}
installOptions.GitProvider = gitProvider
installOptions.Gitter = o.Git()
installOptions.EnvironmentCloneDir = o.CloneDir
}

apps, err := installOptions.GetApps(o.Args)
Expand Down

0 comments on commit a915485

Please sign in to comment.