MCPcopy Create free account
hub / github.com/dagger/dagger / DecodeInput

Method DecodeInput

dagql/builtins.go:299–325  ·  view source on GitHub ↗
(val any)

Source from the content-addressed store, hash-verified

297}
298
299func (d DynamicArrayInput) DecodeInput(val any) (Input, error) {
300 switch x := val.(type) {
301 case []any:
302 arr := DynamicArrayInput{
303 Elem: d.Elem,
304 }
305 decoder := d.Elem.Decoder()
306 for _, elem := range x {
307 decoded, err := decoder.DecodeInput(elem)
308 if err != nil {
309 return nil, err
310 }
311 arr.Values = append(arr.Values, decoded)
312 }
313 return arr, nil
314 case string: // default
315 var vals []any
316 dec := json.NewDecoder(strings.NewReader(x))
317 dec.UseNumber()
318 if err := dec.Decode(&vals); err != nil {
319 return nil, fmt.Errorf("decode %q: %w", x, err)
320 }
321 return d.DecodeInput(vals)
322 default:
323 return nil, fmt.Errorf("expected array, got %T", val)
324 }
325}
326
327var _ Input = DynamicArrayInput{}
328

Callers

nothing calls this directly

Calls 3

DecoderMethod · 0.65
DecodeInputMethod · 0.65
DecodeMethod · 0.45

Tested by

no test coverage detected