Using the SDK natively, ie usage of container mounting a file, how can I take the output from some code, make sure it's a dagger.Secret, then use the dagger secret content as the filecount to dagger.Directory.WithNewFile? All examples I've found are focused on secret input, but I want to treat the contents of something I'm generating as a secret so it's not not persisted, logged, and protected.
What copilot resorted to ๐
// Use container to create file without logging sensitive content
fileContainer := dag.Container().
From("alpine:latest").
WithSecretVariable("YAML_CONTENT", dag.SetSecret("some-yaml", string(b))).
WithExec([]string{"mkdir", "-p", "/output"}).
WithExec([]string{"sh", "-c", "echo \"$YAML_CONTENT\" > /output/some-yaml.values.yaml"})
dir := fileContainer.Directory("/output")
f := dir.File("some-yaml.values.yaml")
return f, nil
What I'm trying to do in general.
secretContent := dagger.SetSecret("secretcontent", secretsdkvault.RetrieveSecret("foo"))
dir := dag.Directory().WithNewFile("some-yaml.values.yaml", secretContent)
Not yet clear on proper way to handle this so I ensure safe logging, but still output some secret generated content as a file.
not sure I have any solution then with current restrictions so might have to run this outside
gotcha, thus why I still had to run