Repository navigation
docs: Added guide for secrets - #4822
Conversation
There was a problem hiding this comment.
This feels quite clunky. Is there a better way? @dolanor
There was a problem hiding this comment.
Do you mean the code example feels clunky?
There was a problem hiding this comment.
Yes, because we are reading the file into a string, then writing the string back to a file.
There was a problem hiding this comment.
Yes, I agree.
I hope I can fix file.secret, then, it would feel more natural: file -> file.
But for now, it is best used with setSecret.
A good example could be to get some secret SSH key from a Vault for example to be able to push a commit via git.
So you would access vault, get the SSH key out of it, create a secret out of it with setSecret and mount it as a file on the container that would do a git push to some ulterior git repository that handles deploy, for example.
There was a problem hiding this comment.
Maybe we should ask @jpadams if he has some users that have some workflow using git in later pipeline stage?
There was a problem hiding this comment.
I added the setSecret API so we could avoid leaking plaintext info with the file.Secret() API.
I believe there is a way we could actually make it safe and make it a 1st level API again.
This guide would be impacted, but it can come in an ulterior update as this one is already good and could be published as is as I haven't fixed the file.Secret() implementation yet.
The other BIG advantage of using setSecret is that we don't have to pass by the hostenv or file. It allows us to fetch secrets from external system (like Vault, GCP secret manager, etc).
I think an example using that would be more interesting.
I created a demo with that here: https://github.com/dolanor/demos/blob/main/secret/gcp/main.go
I asked @kpenfound if he could help creating some extra demos (Vault being the priority IMHO)
I think having some sort of table showing what API happens on the host vs what API happens on the pipeline could also help.
| medium | host | pipeline |
|---|---|---|
| file | file.secret() | WithMountedSecret |
| env | host.EnvVariable() | WithSecretVariable |
| any | setSecret() |
Also, indicating that once something is a secret, it can be a file (mounted secret) or a secret env (secret variable), wherever it came from. Maybe a diagram could help? (feel free to modify this one or create a new one altogether 😄 )
flowchart LR
subgraph pipeline
p([container])
p --> ms[mounted secret]
p --> es[env secret]
end
subgraph Host
he[host.envVariable.secret] -->|secret| p
fs[file.secret] -->|secret| p
ss(setSecret) -->|secret| p
end
There was a problem hiding this comment.
Do you mean the code example feels clunky?
|
@dolanor can you please check the error messages in https://github.com/dagger/dagger/actions/runs/4547116749/jobs/8016599454?pr=4822 and suggest code improvements? |
dolanor
left a comment
There was a problem hiding this comment.
Excellent work. The last part is the table that would need fixing because I think it might confuse people that only 1 "host" API can only inject in 1 "pipeline" API: file -> file, env -> env. But as long as it is a secret, it can be an env or a mounted secret.
|
@dolanor does the change suggested in #4822 (comment) block merge? |
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Co-authored-by: Tanguy ⧓ Herrmann <[email protected]> Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Co-authored-by: Helder Correia <[email protected]> Signed-off-by: vikram-dagger <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
|
@vikram-dagger There were more instances of the indented |
Co-authored-by: Helder Correia <[email protected]> Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
@helderco corrected, please re-check and approve if OK |
Signed-off-by: vikram-dagger <[email protected]>
helderco
left a comment
There was a problem hiding this comment.
We need this 🙌
Just a few quick fixes.
|
I'm gonna fix the snippets. |
Co-authored-by: Helder Correia <[email protected]> Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: Vikram Vaswani <[email protected]>
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
|
I rephrased the explanations but mostly removed the reference to |
Signed-off-by: Tanguy ⧓ Herrmann <[email protected]>
Signed-off-by: jffarge <[email protected]>
Modified secret URI (all). Signed-off-by: Vikram Vaswani <[email protected]>
|
This was such a big & important group effort - well done for shipping it! 🚀 https://docs.dagger.io/723462/use-secrets/ reads really well. I especially liked the multi-language aspect of it. This must have been the hardest part to get right. It's great to see so much valuable information in a single place, for all SDKs! A couple of thoughts:
Leaving this with you @dolanor @vikram-dagger @d3rp3tt3 @mircubed |
|
We talked about it in our 1on1, and you clearly have a point as people come with this new tool with assumption that might be wrong based on their experience with Docker or Kubernetes. Build Secrets from Buildkit don't leave any trace, either as secret variables or as secret env. Not in the build history, nor in the image itself, nor in the cache. And the idea to also put some env variable as secrets because we don't want them to stick around in the image is a good idea. cc: @vikram-dagger |
This commit adds a guide about using secrets.
Closes https://github.com/dagger/dagger.io/issues/1971