Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cmd/wfctl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})
}
1 change: 1 addition & 0 deletions cmd/wfctl/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading