Skip to content

Commit

Permalink
Add missed changes and bypass linter error
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredoconnell committed Sep 12, 2024
1 parent 542d665 commit bd386db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions workflow/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,31 @@ const YamlOneOfTag = "!oneof"

func buildOneOfExpressions(data yaml.Node, path []string) (any, error) {
if data.Type() != yaml.TypeIDMap {
return nil, fmt.Errorf("!oneof found on non-map node at %s; expected a map with a list of options and the discriminator ", strings.Join(path, " -> "))
return nil, fmt.Errorf(
"!oneof found on non-map node at %s; expected a map with a list of options and the discriminator ",
strings.Join(path, " -> "))
}
discriminatorNode, found := data.MapKey(YamlDiscriminatorKey)
if !found {
return nil, fmt.Errorf("key %q not present within !oneof at %q", YamlDiscriminatorKey, strings.Join(path, " -> "))
return nil, fmt.Errorf("key %q not present within %s at %q",
YamlDiscriminatorKey, YamlOneOfTag, strings.Join(path, " -> "))
}
if discriminatorNode.Type() != yaml.TypeIDString {
return nil, fmt.Errorf("%q within !oneof should be a string; got %s", discriminatorNode.Type(), YamlDiscriminatorKey)
return nil, fmt.Errorf("%q within %s should be a string; got %s",
YamlDiscriminatorKey, YamlOneOfTag, discriminatorNode.Type())
}
discriminator := discriminatorNode.Value()
if len(discriminator) == 0 {
return nil, fmt.Errorf("%q within %s is empty", YamlDiscriminatorKey, YamlOneOfTag)
}
oneOfOptionsNode, found := data.MapKey(YamlOneOfKey)
if !found {
return nil, fmt.Errorf("key %q not present within !oneof at %q", YamlOneOfKey, strings.Join(path, " -> "))
return nil, fmt.Errorf("key %q not present within %s at %q",
YamlOneOfKey, YamlOneOfTag, strings.Join(path, " -> "))
}
if oneOfOptionsNode.Type() != yaml.TypeIDMap {
return nil, fmt.Errorf("%q within !oneof should be a map; got %s", YamlOneOfKey, discriminatorNode.Type())
return nil, fmt.Errorf("%q within %q should be a map; got %s",
YamlOneOfKey, YamlOneOfTag, discriminatorNode.Type())
}
options := map[string]any{}
for _, optionNodeKey := range oneOfOptionsNode.MapKeys() {
Expand All @@ -87,7 +97,6 @@ func buildOneOfExpressions(data yaml.Node, path []string) (any, error) {
}
}

discriminator := discriminatorNode.Value()
return &infer.OneOfExpression{
Discriminator: discriminator,
Options: options,
Expand Down
2 changes: 1 addition & 1 deletion workflow/yaml_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package workflow
package workflow //nolint:testpackage // Tests internal functions for unit testing.

import (
"go.arcalot.io/assert"
Expand Down

0 comments on commit bd386db

Please sign in to comment.