Skip to content

Commit

Permalink
fix: push should now also work when performed in component directory
Browse files Browse the repository at this point in the history
Also, now exclude all files starting with `.`
  • Loading branch information
metacosm committed Oct 18, 2019
1 parent 1020659 commit e088a2a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pkg/hal/cli/component/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ var (
pushExample = ktemplates.Examples(` # Deploy the components client-sb, backend-sb
%[1]s -c client-sb,backend-sb`)
excludedFileNames = map[string]bool{
"target": true,
".git": true,
".DS_Store": true,
".idea": true,
"target": true,
}
)

Expand Down Expand Up @@ -73,17 +70,27 @@ func (o *pushOptions) Run() error {
return fmt.Errorf("couldn't find binary to push: %s", binaryPath)
}
if !o.binary {
// first check execution context: if we're executing in the component's directory, we don't need to prepend it to the file
currentDir, err := os.Getwd()
if err != nil {
return err
}
isInComponentDir := filepath.Base(currentDir) == o.GetTargetedComponentName()

// generate tar
// naively exclude target from files to be tarred
children, err := ioutil.ReadDir(o.GetTargetedComponentPath())
toTar := make([]string, 0, len(children))
if err != nil {
return err
}
for _, child := range children {
name := child.Name()
if !excludedFileNames[name] {
toTar = append(toTar, filepath.Join(o.GetTargetedComponentName(), name))
if !strings.HasPrefix(name, ".") && !excludedFileNames[name] {
fileName := name
if !isInComponentDir {
fileName = filepath.Join(o.GetTargetedComponentName(), name)
}
toTar = append(toTar, fileName)
}
}

Expand Down

0 comments on commit e088a2a

Please sign in to comment.