Skip to content

Commit

Permalink
Enable the use of files for components and don't fail on same repo
Browse files Browse the repository at this point in the history
- Fixes #301
  • Loading branch information
redhatrises committed Jun 14, 2018
1 parent d4d39a8 commit 8f9893f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
8 changes: 7 additions & 1 deletion pkg/cli/get/resources/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ func (g *vcsAndLocalFSGetter) copyLocalResource(resourceSource string,
resourceDestination string, recursively bool) error {
var err error
log.Printf("Attempting to copy local resource %s into %s\n", resourceSource, resourceDestination)
if recursively {
fi, err := os.Stat(resourceSource)
if err != nil {
log.Printf("%s\t%s", fi, resourceDestination)
os.Exit(1)
return err
}
if recursively && fi.IsDir() {
log.Printf("Copying local resource %s recursively into %s\n",
resourceSource, resourceDestination)
err = g.FSUtil.CopyAll(resourceSource, resourceDestination)
Expand Down
24 changes: 20 additions & 4 deletions tools/vcs/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package vcs
import (
"fmt"
"log"
"os"
"path/filepath"

"github.com/Masterminds/vcs"
)
Expand All @@ -30,16 +32,30 @@ type Manager struct{}

// Clone will clone the repo to a specified location and then checkout the repo at the particular revision.
func (m Manager) Clone(url string, revision string, dir string) error {
var files []string

log.Printf("Initializing repo %s into %s\n", url, dir)
repo, err := vcs.NewRepo(url, dir)
if err != nil {
return fmt.Errorf(errorContainer, repoInitFailed, url, revision, dir, err.Error())
}
log.Printf("Cloning %s into %s\n", url, dir)
err = repo.Get()
if err != nil {
return fmt.Errorf(errorContainer, repoCloneFailed, url, revision, dir, err.Error())
patherr := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
files = append(files, path)
return nil
})
if patherr != nil {
panic(patherr)
}
if len(files) == 1 {
log.Printf("Cloning %s into %s\n", url, dir)
err = repo.Get()
if err != nil {
return fmt.Errorf(errorContainer, repoCloneFailed, url, revision, dir, err.Error())
}
} else {
log.Printf("Repository already exists. Skipping....")
}

if revision != "" {
log.Printf("Checking out revision %s for repo %s\n", revision, url)
err = repo.UpdateVersion(revision)
Expand Down

0 comments on commit 8f9893f

Please sign in to comment.