Skip to content

Commit

Permalink
fix: input without options no longer hitting panic (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
graza-io authored Feb 16, 2024
1 parent 7481b0f commit aca5cf9
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions internal/primitive/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,22 +462,24 @@ func (ip *Input) Run(ctx context.Context, input modconfig.Input) (*modconfig.Out
prompt = p
}

for _, o := range input[schema.AttributeTypeOptions].([]any) {
opt := o.(map[string]any)
option := InputIntegrationResponseOption{}
if l, ok := opt[schema.AttributeTypeLabel].(string); ok {
option.Label = &l
}
if v, ok := opt[schema.AttributeTypeValue].(string); ok {
option.Value = &v
if helpers.IsNil(option.Label) {
option.Label = &v
if options, ok := input[schema.AttributeTypeOptions].([]any); ok {
for _, o := range options {
opt := o.(map[string]any)
option := InputIntegrationResponseOption{}
if l, ok := opt[schema.AttributeTypeLabel].(string); ok {
option.Label = &l
}
if v, ok := opt[schema.AttributeTypeValue].(string); ok {
option.Value = &v
if helpers.IsNil(option.Label) {
option.Label = &v
}
}
if s, ok := opt[schema.AttributeTypeSelected].(bool); ok {
option.Selected = &s
}
resOptions = append(resOptions, option)
}
if s, ok := opt[schema.AttributeTypeSelected].(bool); ok {
option.Selected = &s
}
resOptions = append(resOptions, option)
}

if notifier, ok := input[schema.AttributeTypeNotifier].(map[string]any); ok {
Expand Down

0 comments on commit aca5cf9

Please sign in to comment.