-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for a "token-only" injection annotation #77
Conversation
The annotation `"vault.hashicorp.com/agent-inject-token": "true"` results in a `token` file containing the `lookup-self` token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes and this is ready for merge! Thanks @tvoran!
agent-inject/agent/config.go
Outdated
@@ -8,6 +8,8 @@ import ( | |||
|
|||
const ( | |||
DefaultTemplate = "{{ with secret \"%s\" }}{{ range $k, $v := .Data }}{{ $k }}: {{ $v }}\n{{ end }}{{ end }}" | |||
TokenTemplate = `{{ with secret "auth/token/lookup-self" }}{{ .Data.id }}{{ end }}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small request: add a newline to the end of the .Data.id
line (like the default template) because if you were to look at it in the container:
/vault/secrets $ ls
ca.cert db-creds server.cert server.key token
/vault/secrets $ cat token
s.gXuAjfknTq0dK1i5s5rsjxpI/vault/secrets $
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in d9dcbcd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it's literally writing the \n
characters, not a new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c2a7199
agent-inject/agent/annotations.go
Outdated
@@ -35,6 +35,10 @@ const ( | |||
// If not provided, a default generic template is used. | |||
AnnotationAgentInjectTemplate = "vault.hashicorp.com/agent-inject-template" | |||
|
|||
// AnnotationAgentInjectToken is the annotation key for injecting the token | |||
// from auth/token/lookup-self | |||
AnnotationAgentInjectToken = "vault.hashicorp.com/agent-inject-token-only" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if vault.hashicorp.com/agent-inject-token-only
is confusing: it suggests that we're only going to render a token. Maybe this should be renamed to agent-inject-share-token
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just agent-inject-token
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in d9dcbcd
{ | ||
"valid inject-token-only", | ||
map[string]string{ | ||
"vault.hashicorp.com/agent-inject-token-only": "true", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use the annotation variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in d9dcbcd
agent-inject-token-only --> agent-inject-token using annotation and config variables in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM!
this might be a dumb question, my apologies. is the |
The annotation "vault.hashicorp.com/agent-inject-token": "true" results in a token file containing the lookup-self token.
The annotation
"vault.hashicorp.com/agent-inject-token": "true"
results in a
token
file containing thelookup-self
token.Resolves #16