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

Method DecodeInput

dagql/types.go:1248–1274  ·  view source on GitHub ↗
(val any)

Source from the content-addressed store, hash-verified

1246var _ InputDecoder = ArrayInput[Input]{}
1247
1248func (a ArrayInput[I]) DecodeInput(val any) (Input, error) {
1249 switch x := val.(type) {
1250 case []any:
1251 var zero I
1252 decoder := zero.Decoder()
1253
1254 arr := make(ArrayInput[I], len(x))
1255 for i, val := range x {
1256 elem, err := decoder.DecodeInput(val)
1257 if err != nil {
1258 return nil, fmt.Errorf("ArrayInput.New[%d]: %w", i, err)
1259 }
1260 arr[i] = elem.(I) // TODO sus
1261 }
1262 return arr, nil
1263 case string: // default
1264 var vals []any
1265 dec := json.NewDecoder(strings.NewReader(x))
1266 dec.UseNumber()
1267 if err := dec.Decode(&vals); err != nil {
1268 return nil, fmt.Errorf("decode %q: %w", x, err)
1269 }
1270 return a.DecodeInput(vals)
1271 default:
1272 return nil, fmt.Errorf("cannot create ArrayInput from %T", x)
1273 }
1274}
1275
1276func (i ArrayInput[S]) ToLiteral() call.Literal {
1277 lits := make([]call.Literal, 0, len(i))

Callers

nothing calls this directly

Calls 3

DecoderMethod · 0.65
DecodeInputMethod · 0.65
DecodeMethod · 0.45

Tested by

no test coverage detected