-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oneof Outputs for Graceful Handling of Disabled Steps (#207)
* Progress towards oneof outputs * Got oneof yaml logic working * Finish graceful handling of disabled steps It is only waiting for the dependency on the DAG to be updatd * Added unit tests, and updated dependency * Fix linter errors * Remove stale comment * Use type switch in infer * Moved code out of large function * Panic after failing to resolve OR group * Remove unused nolint directive * Improve field name
- Loading branch information
1 parent
0d85d08
commit 213a0df
Showing
12 changed files
with
1,151 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package infer | ||
|
||
import ( | ||
"fmt" | ||
"go.flow.arcalot.io/pluginsdk/schema" | ||
) | ||
|
||
// OneOfExpression stores the discriminator, and a key-value pair of all possible oneof values. | ||
// The keys are the value for the discriminator, and the values are the YAML inputs, which can be | ||
// inferred within the infer class. | ||
type OneOfExpression struct { | ||
Discriminator string | ||
Options map[string]any | ||
NodePath string | ||
} | ||
|
||
func (o *OneOfExpression) String() string { | ||
return fmt.Sprintf("{OneOf Expression; Discriminator: %s; Options: %v}", o.Discriminator, o.Options) | ||
} | ||
|
||
// Type returns the OneOf type. Calculates the types of all possible oneof options for this. | ||
func (o *OneOfExpression) Type( | ||
internalDataModel schema.Scope, | ||
functions map[string]schema.Function, | ||
workflowContext map[string][]byte, | ||
) (schema.Type, error) { | ||
schemas := map[string]schema.Object{} | ||
// Gets the type for all options. | ||
for optionID, data := range o.Options { | ||
inferredType, err := Type(data, internalDataModel, functions, workflowContext) | ||
if err != nil { | ||
return nil, err | ||
} | ||
inferredObjectType, isObject := inferredType.(schema.Object) | ||
if !isObject { | ||
return nil, fmt.Errorf("type of OneOf option is not an object; got %T", inferredType) | ||
} | ||
schemas[optionID] = inferredObjectType | ||
} | ||
return schema.NewOneOfStringSchema[any](schemas, o.Discriminator, false), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.