- Notifications
You must be signed in to change notification settings - Fork22
chore!: remove deprecated items fromcoder_workspace
data source#255
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.
Changes fromall commits
d14d6ee
1da8ba7
4d5b168
4dbf571
c7ce74a
d38e383
ff0131f
c916802
f604605
f4a4746
28d764d
396eaff
4ede0cd
001c185
7337eac
025afb1
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -13,11 +13,51 @@ Use this data source to get information for the active workspace build. | ||
## Example Usage | ||
```terraform | ||
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. Elaborated example usage. If its too much happy to simply it. | ||
provider "coder" {} | ||
provider "docker" {} | ||
data "coder_workspace" "me" {} | ||
data "coder_workspace_owner" "me" {} | ||
resource "coder_agent" "dev" { | ||
arch = "amd64" | ||
os = "linux" | ||
dir = "/workspace" | ||
} | ||
resource "docker_container" "workspace" { | ||
count = data.coder_workspace.me.start_count | ||
image = docker_image.main.name | ||
# Uses lower() to avoid Docker restriction on container names. | ||
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}" | ||
# Hostname makes the shell more user friendly: coder@my-workspace:~$ | ||
hostname = data.coder_workspace.me.name | ||
# Use the docker gateway if the access URL is 127.0.0.1 | ||
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")] | ||
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"] | ||
host { | ||
host = "host.docker.internal" | ||
ip = "host-gateway" | ||
} | ||
# Add labels in Docker to keep track of orphan resources. | ||
labels { | ||
label = "coder.owner" | ||
value = data.coder_workspace_owner.me.name | ||
} | ||
labels { | ||
label = "coder.owner_id" | ||
value = data.coder_workspace_owner.me.id | ||
} | ||
labels { | ||
label = "coder.workspace_id" | ||
value = data.coder_workspace.me.id | ||
} | ||
labels { | ||
label = "coder.workspace_name" | ||
value = data.coder_workspace.me.name | ||
} | ||
} | ||
``` | ||
@@ -30,13 +70,6 @@ resource "kubernetes_pod" "dev" { | ||
- `access_url` (String) The access URL of the Coder deployment provisioning this workspace. | ||
- `id` (String) UUID of the workspace. | ||
- `name` (String) Name of the workspace. | ||
- `start_count` (Number) A computed count based on `transition` state. If `start`, count will equal 1. | ||
- `template_id` (String) ID of the workspace's template. | ||
- `template_name` (String) Name of the workspace's template. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -15,14 +15,12 @@ Use this data source to fetch information about the workspace owner. | ||
```terraform | ||
provider "coder" {} | ||
data "coder_workspace_owner" "me" {} | ||
resource "coder_agent" "dev" { | ||
arch = "amd64" | ||
os = "linux" | ||
dir ="/workspace" | ||
env = { | ||
OIDC_TOKEN : data.coder_workspace_owner.me.oidc_access_token, | ||
} | ||
@@ -36,7 +34,7 @@ resource "coder_env" "git_author_name" { | ||
} | ||
resource "coder_env" "git_author_email" { | ||
agent_id =coder_agent.dev.id | ||
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. there was no var defined so used the already defined agent. | ||
name = "GIT_AUTHOR_EMAIL" | ||
value = data.coder_workspace_owner.me.email | ||
count = data.coder_workspace_owner.me.email != "" ? 1 : 0 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,46 @@ | ||
provider "coder" {} | ||
provider "docker" {} | ||
data "coder_workspace" "me" {} | ||
data "coder_workspace_owner" "me" {} | ||
resource "coder_agent" "dev" { | ||
arch = "amd64" | ||
os = "linux" | ||
dir = "/workspace" | ||
} | ||
resource "docker_container" "workspace" { | ||
count = data.coder_workspace.me.start_count | ||
image = docker_image.main.name | ||
# Uses lower() to avoid Docker restriction on container names. | ||
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}" | ||
# Hostname makes the shell more user friendly: coder@my-workspace:~$ | ||
hostname = data.coder_workspace.me.name | ||
# Use the docker gateway if the access URL is 127.0.0.1 | ||
entrypoint = ["sh", "-c", replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")] | ||
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"] | ||
host { | ||
host = "host.docker.internal" | ||
ip = "host-gateway" | ||
} | ||
# Add labels in Docker to keep track of orphan resources. | ||
labels { | ||
label = "coder.owner" | ||
value = data.coder_workspace_owner.me.name | ||
} | ||
labels { | ||
label = "coder.owner_id" | ||
value = data.coder_workspace_owner.me.id | ||
} | ||
labels { | ||
label = "coder.workspace_id" | ||
value = data.coder_workspace.me.id | ||
} | ||
labels { | ||
label = "coder.workspace_name" | ||
value = data.coder_workspace.me.name | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -71,25 +71,18 @@ func TestIntegration(t *testing.T) { | ||
name: "test-data-source", | ||
minVersion: "v0.0.0", | ||
expectedOutput: map[string]string{ | ||
Comment on lines -81 to -87 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. removed all owner related items from the integration test. We already have a separate integration test for | ||
"provisioner.arch": runtime.GOARCH, | ||
"provisioner.id": `[a-zA-Z0-9-]+`, | ||
"provisioner.os": runtime.GOOS, | ||
"workspace.access_port": `\d+`, | ||
"workspace.access_url": `https?://\D+:\d+`, | ||
"workspace.id": `[a-zA-z0-9-]+`, | ||
"workspace.name": `test-data-source`, | ||
"workspace.start_count": `1`, | ||
"workspace.template_id": `[a-zA-Z0-9-]+`, | ||
"workspace.template_name": `test-data-source`, | ||
"workspace.template_version": `.+`, | ||
"workspace.transition": `start`, | ||
}, | ||
}, | ||
{ | ||
@@ -103,13 +96,6 @@ func TestIntegration(t *testing.T) { | ||
"workspace.access_url": `https?://\D+:\d+`, | ||
"workspace.id": `[a-zA-z0-9-]+`, | ||
"workspace.name": ``, | ||
"workspace.start_count": `1`, | ||
"workspace.template_id": `[a-zA-Z0-9-]+`, | ||
"workspace.template_name": `workspace-owner`, | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.