#10697: default secrets
1 messages ยท Page 1 of 1 (latest)
https://github.com/dagger/dagger/pull/10697
Today I worked on cleaning up the implementation, and supporting more types, thanks to #1397531863915958293
I am having an issue though, my cleaner implementation introduces a regression that I can't track down...
@small monolith I seem to have broken my default argument injection logic by generalizing from only support Secret, to supporting any object type...
This is the "secret-only" code that works:
var secretID core.SecretID
if err := srv.Select(ctx, srv.Root(), &secretID,
dagql.Selector{
Field: "secret",
Args: []dagql.NamedInput{{Name: "uri", Valudagql.NewString(argValue)}},
},
dagql.Selector{
Field: "id",
},
); err != nil {
return err
}
secretIDJSON, err := json.Marshal(secretID)
if err != nil {
return err
}
arg.DefaultValue = secretIDJSON
And the generalized version, that doesn't:
var (
newDefault any
newDefaultJSON []byte
)
// eg. "secret", "gitRef", "directory"...
typename := arg.TypeDef.ToType().Name()
typename = strings.ToLower(typename[0:1]) + typename[1:]
if err := srv.Select(ctx, srv.Root(), &newDefault,
dagql.Selector{
Field: "address",
Args: []dagql.NamedInput{{
Name: "value",
Value: dagql.NewString(prettyValue),
}},
},
dagql.Selector{
Field: strings.ToLower(typename),
},
dagql.Selector{
Field: "id",
},
); err != nil {
return err
}
newDefaultJSON, err = json.Marshal(newDefault)
if err != nil {
return err
}
arg.DefaultValue = newDefaultJSON
@vagrant verge ๐ this is the context..
Maybe I should make newDefault a string instead of a any?
I don't know if that's even relevant
ah yeah you're probably getting a dagql.Result[T] of some sort back. you could try dagql.AnyResult instead of any and then calling Unwrap() on it
i'm still learning the ropes of this brave new anything-is-idable world, but i think that might work
I'm trying a version where I select into a string, then assign the string result to the any
๐ญ didn't work
trying that