Skip to content

fix: Regenerate agent token on each run #51

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

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/resources/agent.md
Original file line number Diff line number Diff line change
@@ -55,6 +55,6 @@ resource "kubernetes_pod" "dev" {

- `id` (String) The ID of this resource.
- `init_script` (String) Run this script on startup of an instance to initialize the agent.
- `token` (String) Set the environment variable "CODER_AGENT_TOKEN" with this token to authenticate an agent.
- `token` (String, Sensitive) Set the environment variable "CODER_AGENT_TOKEN" with this token to authenticate an agent.


1 change: 1 addition & 0 deletions docs/resources/metadata.md
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ resource "coder_metadata" "pod_info" {
### Optional

- `hide` (Boolean) Hide the resource from the UI.
- `icon` (String) A URL to an icon that will display in the dashboard. View built-in icons here: https://github.com/coder/coder/tree/main/site/static/icon. Use a built-in icon with `data.coder_workspace.me.access_url + "/icons/<path>"`.

### Read-Only

7 changes: 6 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -213,7 +213,11 @@ func New() *schema.Provider {
}
return updateInitScript(resourceData, i)
},
ReadContext: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics {
ReadWithoutTimeout: func(c context.Context, resourceData *schema.ResourceData, i interface{}) diag.Diagnostics {
err := resourceData.Set("token", uuid.NewString())
if err != nil {
return diag.FromErr(err)
}
return updateInitScript(resourceData, i)
},
DeleteContext: func(c context.Context, rd *schema.ResourceData, i interface{}) diag.Diagnostics {
@@ -267,6 +271,7 @@ func New() *schema.Provider {
},
"token": {
ForceNew: true,
Sensitive: true,
Description: `Set the environment variable "CODER_AGENT_TOKEN" with this token to authenticate an agent.`,
Type: schema.TypeString,
Computed: true,