Skip to content

Commit

Permalink
Match bundleDir globbing match directories only
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuildthecloud committed Sep 4, 2020
1 parent f6c8c50 commit 18bcbc1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion modules/cli/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
"regexp"

Expand Down Expand Up @@ -34,6 +35,19 @@ type Options struct {
Labels map[string]string
}

func globDirs(baseDir string) (result []string, err error) {
paths, err := filepath.Glob(baseDir)
if err != nil {
return nil, err
}
for _, path := range paths {
if s, err := os.Stat(path); err == nil && s.IsDir() {
result = append(result, path)
}
}
return
}

func Apply(ctx context.Context, client *client.Getter, name string, baseDirs []string, opts *Options) error {
if opts == nil {
opts = &Options{}
Expand All @@ -45,7 +59,7 @@ func Apply(ctx context.Context, client *client.Getter, name string, baseDirs []s

foundBundle := false
for i, baseDir := range baseDirs {
matches, err := filepath.Glob(baseDir)
matches, err := globDirs(baseDir)
if err != nil {
return fmt.Errorf("invalid path glob %s: %w", baseDir, err)
}
Expand Down

0 comments on commit 18bcbc1

Please sign in to comment.