Skip to content

Commit

Permalink
fix(cli): exclude non directories and DS_Store from
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbreuninger committed Jan 2, 2024
1 parent d40693f commit fb9680c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
10 changes: 10 additions & 0 deletions e2e/framework/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ func (f *Framework) DevPodProviderOptionsCheckNamespaceDescription(ctx context.C
return fmt.Errorf("did not found value %s in devpod provider options output. error: %s", searchStr, err.Error())
}
return nil

Check failure on line 125 in e2e/framework/command.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
}

func (f *Framework) DevPodProviderList(ctx context.Context, extraArgs ...string) error {
baseArgs := []string{"provider", "list"}
err := f.ExecCommand(ctx, false, true, "", append(baseArgs, extraArgs...))
if err != nil {
return fmt.Errorf("devpod provider list failed: %s", err.Error())
}
return nil
}

func (f *Framework) DevPodProviderUse(ctx context.Context, provider string, extraArgs ...string) error {
Expand Down
35 changes: 35 additions & 0 deletions e2e/tests/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,40 @@ var _ = DevPodDescribe("devpod provider test suite", func() {
err = f.DevPodProviderUse(context.Background(), "provider2")
framework.ExpectError(err)
})

ginkgo.It("should list all providers", func() {
tempDir, err := framework.CopyToTempDir("tests/provider/testdata/simple-k8s-provider")
framework.ExpectNoError(err)
ginkgo.DeferCleanup(framework.CleanupTempDir, initialDir, tempDir)

f := framework.NewDefaultFramework(initialDir + "/bin")

// Ensure that provider 1 is deleted
err = f.DevPodProviderDelete(ctx, "provider1", "--ignore-not-found")
framework.ExpectNoError(err)

// Add provider 1
err = f.DevPodProviderAdd(ctx, tempDir+"/provider1.yaml")
framework.ExpectNoError(err)
// Ensure provider 1 exists
err = f.DevPodProviderUse(context.Background(), "provider1")
framework.ExpectNoError(err)

// Add .DS_Store file to tempDir
err = os.Mkdir(tempDir+"/.DS_Store", 0755)
framework.ExpectNoError(err)

// List providers
err = f.DevPodProviderList(context.Background())
framework.ExpectNoError(err)

// Cleanup: delete provider 1
err = f.DevPodProviderDelete(ctx, "provider1")
framework.ExpectNoError(err)

// Cleanup: ensure provider 1 is deleted
err = f.DevPodProviderUse(context.Background(), "provider1")
framework.ExpectError(err)
})
})
})
2 changes: 1 addition & 1 deletion pkg/workspace/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func LoadAllProviders(devPodConfig *config.Config, log log.Logger) (map[string]*
}

for _, entry := range entries {
if retProviders[entry.Name()] != nil {
if retProviders[entry.Name()] != nil || !entry.IsDir() || strings.HasPrefix(entry.Name(), ".DS_Store") {
continue
}

Expand Down

0 comments on commit fb9680c

Please sign in to comment.