diff --git a/e2e/framework/command.go b/e2e/framework/command.go index d017b267e..7ac6dec1f 100644 --- a/e2e/framework/command.go +++ b/e2e/framework/command.go @@ -124,6 +124,15 @@ func (f *Framework) DevPodProviderOptionsCheckNamespaceDescription(ctx context.C return nil } +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 { baseArgs := []string{"provider", "use", provider} err := f.ExecCommand(ctx, false, true, "", append(baseArgs, extraArgs...)) diff --git a/e2e/tests/provider/provider.go b/e2e/tests/provider/provider.go index 9f05e72d9..7ffa504cc 100644 --- a/e2e/tests/provider/provider.go +++ b/e2e/tests/provider/provider.go @@ -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) + }) }) }) diff --git a/pkg/workspace/provider.go b/pkg/workspace/provider.go index 810ee311c..ad4ac20c2 100644 --- a/pkg/workspace/provider.go +++ b/pkg/workspace/provider.go @@ -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 }