Skip to content

Commit

Permalink
update plugin schema with src and type keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleader committed Oct 26, 2023
1 parent 0e9e558 commit 5d9d4f6
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
78 changes: 74 additions & 4 deletions internal/step/plugin/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,91 @@ type pluginProvider struct {
func (p *pluginProvider) Register(_ step.Registry) {
}

var DeploymentTypes = map[string]struct{}{
"image": struct{}{},
"python": struct{}{},
}

func KeysString(m map[string]struct{}) string {
keys := make([]string, 0, len(m))
for k := range m {
keys = append(keys, k)
}
return "[" + strings.Join(keys, ", ") + "]"
}

type Plugin struct {
Src string
Type string
}

//func (p *pluginProvider) ProviderSchema() *schema.TypedScopeSchema[*Plugin] {
// return schema.NewTypedScopeSchema[*Plugin](
// schema.NewStructMappedObjectSchema[*Plugin](
// "Plugin",
// map[string]*schema.PropertySchema{
// "src": schema.NewPropertySchema(
// schema.NewStringSchema(schema.PointerTo[int64](1), nil, nil),
// schema.NewDisplayValue(
// schema.PointerTo("Source"),
// schema.PointerTo("Source file to be executed."), nil),
// true,
// nil,
// nil,
// nil,
// nil,
// []string{"\"quay.io/arcaflow/example-plugin:latest\""},
// ),
// "type": schema.NewPropertySchema(
// schema.NewStringSchema(schema.PointerTo[int64](1), nil, nil),
// schema.NewDisplayValue(
// schema.PointerTo("Type"),
// schema.PointerTo(
// fmt.Sprintf("Deployment type %s",
// fmt.Sprintf(KeysString(DeploymentTypes)))),
// nil,
// ),
// true,
// nil,
// nil,
// nil,
// nil,
// []string{"docker"},
// ),
// },
// ),
// )
//}

func (p *pluginProvider) ProviderSchema() map[string]*schema.PropertySchema {
return map[string]*schema.PropertySchema{
"plugin": schema.NewPropertySchema(
"src": schema.NewPropertySchema(
schema.NewStringSchema(schema.PointerTo[int64](1), nil, nil),
schema.NewDisplayValue(
schema.PointerTo("Source"),
schema.PointerTo("Source file to be executed."), nil),
true,
nil,
nil,
nil,
nil,
[]string{"\"quay.io/arcaflow/example-plugin:latest\""},
),
"type": schema.NewPropertySchema(
schema.NewStringSchema(schema.PointerTo[int64](1), nil, nil),
schema.NewDisplayValue(
schema.PointerTo("Plugin"),
schema.PointerTo("Plugin container image to run. This image must be an Arcaflow-compatible container."),
schema.PointerTo("Type"),
schema.PointerTo(
fmt.Sprintf("Deployment type %s",
fmt.Sprintf(KeysString(DeploymentTypes)))),
nil,
),
true,
nil,
nil,
nil,
nil,
[]string{"\"quay.io/arcaflow/example-plugin:latest\""},
[]string{"docker"},
),
}
}
Expand Down
3 changes: 2 additions & 1 deletion internal/step/plugin/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ func TestProvider_Utility(t *testing.T) {
stepSchema := map[string]any{
"plugin": map[string]string{
"src": "simulation",
"type": "image"},
"type": "image",
},
}
byteSchema := map[string][]byte{}

Expand Down

0 comments on commit 5d9d4f6

Please sign in to comment.