Skip to content

Commit

Permalink
Merge pull request #79 from pivotal-david-osullivan/binding_bug
Browse files Browse the repository at this point in the history
Fixed bug which created bindings from hidden files/dirs
  • Loading branch information
hone authored Oct 5, 2021
2 parents 8496ef4 + d29fc72 commit da83146
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ func NewBindingsFromPath(path string) (Bindings, error) {

bindings := Bindings{}
for _, file := range files {
if strings.HasPrefix(filepath.Base(file), ".") {
// ignore hidden files
continue
}
binding, err := NewBindingFromPath(file)
if err != nil {
return nil, fmt.Errorf("unable to create new binding from %s\n%w", file, err)
Expand Down
8 changes: 8 additions & 0 deletions platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func testPlatform(t *testing.T, context spec.G, it spec.S) {
Expect(os.MkdirAll(filepath.Join(path, "bravo", "secret"), 0755)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, "bravo", "secret", "test-secret-key"), []byte("test-secret-value"), 0600)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, "bravo", "secret", "test-secret-key-trimmed"), []byte(" test-secret-value-trimmed \n"), 0600)).To(Succeed())

Expect(os.MkdirAll(filepath.Join(path, ".hidden", "metadata"), 0755)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, ".hidden", "metadata", "kind"), []byte("test-kind"), 0600)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, ".hiddenFile"), []byte("test-kind"), 0600)).To(Succeed())
})

context("Binding", func() {
Expand Down Expand Up @@ -205,6 +209,10 @@ func testPlatform(t *testing.T, context spec.G, it spec.S) {
Expect(ioutil.WriteFile(filepath.Join(path, "bravo", "type"), []byte("test-type"), 0600)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, "bravo", "provider"), []byte("test-provider"), 0600)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, "bravo", "test-secret-key"), []byte("test-secret-value"), 0600)).To(Succeed())

Expect(os.MkdirAll(filepath.Join(path, ".hidden", "metadata"), 0755)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, ".hidden", "metadata", "kind"), []byte("test-kind"), 0600)).To(Succeed())
Expect(ioutil.WriteFile(filepath.Join(path, ".hiddenFile"), []byte("test-kind"), 0600)).To(Succeed())
})

context("Binding", func() {
Expand Down

0 comments on commit da83146

Please sign in to comment.