- Notifications
You must be signed in to change notification settings - Fork22
feat: Add auth property to coder_agent_script#5
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionsdocs/data-sources/agent_script.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionsdocs/data-sources/workspace.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 1 addition & 9 deletionsdocs/resources/agent.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
48 changes: 27 additions & 21 deletionsinternal/provider/provider.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -65,6 +65,8 @@ func New() *schema.Provider { | ||
transition = "start" | ||
} | ||
rd.Set("transition", transition) | ||
rd.Set("username", os.Getenv("CODER_WORKSPACE_USERNAME")) | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. thoughts on | ||
rd.Set("name", os.Getenv("CODER_WORKSPACE_NAME")) | ||
return nil | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
@@ -73,6 +75,16 @@ func New() *schema.Provider { | ||
Computed: true, | ||
Description: `Either "start" or "stop". Use this to start/stop resources with "count".`, | ||
}, | ||
"username": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Username of the workspace owner.", | ||
}, | ||
"name": { | ||
Type: schema.TypeString, | ||
Computed: true, | ||
Description: "Name of the workspace.", | ||
}, | ||
}, | ||
}, | ||
"coder_agent_script": { | ||
@@ -82,6 +94,10 @@ func New() *schema.Provider { | ||
if !valid { | ||
return diag.Errorf("config was unexpected type %q", reflect.TypeOf(i).String()) | ||
} | ||
auth, valid := resourceData.Get("auth").(string) | ||
if !valid { | ||
return diag.Errorf("auth was unexpected type %q", reflect.TypeOf(resourceData.Get("auth"))) | ||
} | ||
operatingSystem, valid := resourceData.Get("os").(string) | ||
if !valid { | ||
return diag.Errorf("os was unexpected type %q", reflect.TypeOf(resourceData.Get("os"))) | ||
@@ -97,6 +113,7 @@ func New() *schema.Provider { | ||
script := os.Getenv(fmt.Sprintf("CODER_AGENT_SCRIPT_%s_%s", operatingSystem, arch)) | ||
if script != "" { | ||
script = strings.ReplaceAll(script, "${ACCESS_URL}", accessURL.String()) | ||
script = strings.ReplaceAll(script, "${AUTH_TYPE}", auth) | ||
} | ||
err = resourceData.Set("value", script) | ||
if err != nil { | ||
@@ -106,6 +123,13 @@ func New() *schema.Provider { | ||
return nil | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"auth": { | ||
Type: schema.TypeString, | ||
Default: "token", | ||
Optional: true, | ||
Description: `The authentication type the agent will use. Must be one of: "token", "google-instance-identity", "aws-instance-identity", "azure-instance-identity".`, | ||
ValidateFunc: validation.StringInSlice([]string{"token", "google-instance-identity", "aws-instance-identity", "azure-instance-identity"}, false), | ||
}, | ||
"os": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
@@ -144,29 +168,11 @@ func New() *schema.Provider { | ||
return nil | ||
}, | ||
Schema: map[string]*schema.Schema{ | ||
"instance_id": { | ||
ForceNew: true, | ||
Description: "An instance ID from a provisioned instance to enable zero-trust agent authentication.", | ||
Optional: true, | ||
Type: schema.TypeString, | ||
}, | ||
"env": { | ||
ForceNew: true, | ||
8 changes: 2 additions & 6 deletionsinternal/provider/provider_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.