From a488c89faef5d5a1e404e81fafafb749230e80c5 Mon Sep 17 00:00:00 2001 From: Jon Langevin Date: Sun, 10 May 2026 02:25:42 -0400 Subject: [PATCH] fix(wfctl): load plugin step schemas --- cmd/wfctl/main_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++ cmd/wfctl/validate.go | 1 + 2 files changed, 47 insertions(+) diff --git a/cmd/wfctl/main_test.go b/cmd/wfctl/main_test.go index 0bc72375..1e485a8f 100644 --- a/cmd/wfctl/main_test.go +++ b/cmd/wfctl/main_test.go @@ -389,3 +389,49 @@ func TestRunValidatePluginDirCapabilities(t *testing.T) { schema.UnregisterModuleType("step.caps_validate_testonly") }) } + +func TestRunValidatePluginDirLoadsStepSchemas(t *testing.T) { + pluginsDir := t.TempDir() + pluginSubdir := filepath.Join(pluginsDir, "my-ext-plugin-step-schema") + if err := os.MkdirAll(pluginSubdir, 0o755); err != nil { + t.Fatal(err) + } + manifest := `{ + "name": "my-ext-plugin-step-schema", + "version": "1.0.0", + "moduleTypes": ["custom.step_schema_validate_testonly"], + "stepSchemas": [ + { + "type": "step.schema_validate_testonly", + "description": "test-only plugin step schema", + "configFields": [ + {"key": "target", "type": "string", "required": true} + ] + } + ] + }` + if err := os.WriteFile(filepath.Join(pluginSubdir, "plugin.json"), []byte(manifest), 0o644); err != nil { + t.Fatal(err) + } + reg := schema.GetStepSchemaRegistry() + if reg.Get("step.schema_validate_testonly") != nil { + t.Fatal("step.schema_validate_testonly should not exist before loading") + } + + dir := t.TempDir() + path := writeTestConfig(t, dir, "workflow.yaml", ` +modules: + - name: ext-mod + type: custom.step_schema_validate_testonly +`) + if err := runValidate([]string{"--plugin-dir", pluginsDir, path}); err != nil { + t.Fatalf("expected valid config with --plugin-dir, got: %v", err) + } + if got := reg.Get("step.schema_validate_testonly"); got == nil { + t.Fatal("expected runValidate --plugin-dir to load plugin step schema") + } + t.Cleanup(func() { + schema.UnregisterModuleType("custom.step_schema_validate_testonly") + reg.Unregister("step.schema_validate_testonly") + }) +} diff --git a/cmd/wfctl/validate.go b/cmd/wfctl/validate.go index efcac251..450725b7 100644 --- a/cmd/wfctl/validate.go +++ b/cmd/wfctl/validate.go @@ -52,6 +52,7 @@ Options: if err := schema.LoadPluginTypesFromDir(*pluginDir); err != nil { return fmt.Errorf("failed to load plugins from %s: %w", *pluginDir, err) } + schema.LoadPluginStepSchemasFromDir(*pluginDir) } // Collect files to validate