Skip to content

chore!: remove deprecated items from coder_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 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 16 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
elaborate example
  • Loading branch information
matifali committed Jul 3, 2024
commit 001c185bb4c5ab7d19d846aff2246c197a3604a2
46 changes: 43 additions & 3 deletions docs/data-sources/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,51 @@ Use this data source to get information for the active workspace build.
## Example Usage

```terraform
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elaborated example usage. If its too much happy to simply it.

data "coder_workspace" "dev" {
provider "coder" {}

provider "docker" {}

data "coder_workspace" "me" {}

data "coder_workspace_owner" "me" {}

resource "coder_agent" "dev" {
arch = "amd64"
os = "linux"
dir = "/workspace"
}

resource "kubernetes_pod" "dev" {
count = data.coder_workspace.dev.transition == "start" ? 1 : 0
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
}
}
```

Expand Down
2 changes: 0 additions & 2 deletions docs/data-sources/workspace_owner.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Use this data source to fetch information about the workspace owner.
```terraform
provider "coder" {}

data "coder_workspace" "me" {}

data "coder_workspace_owner" "me" {}

resource "coder_agent" "dev" {
Expand Down
46 changes: 43 additions & 3 deletions examples/data-sources/coder_workspace/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
data "coder_workspace" "dev" {
provider "coder" {}

provider "docker" {}

data "coder_workspace" "me" {}

data "coder_workspace_owner" "me" {}

resource "coder_agent" "dev" {
arch = "amd64"
os = "linux"
dir = "/workspace"
}

resource "kubernetes_pod" "dev" {
count = data.coder_workspace.dev.transition == "start" ? 1 : 0
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
}
}
2 changes: 0 additions & 2 deletions examples/data-sources/coder_workspace_owner/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
provider "coder" {}

data "coder_workspace" "me" {}

data "coder_workspace_owner" "me" {}

resource "coder_agent" "dev" {
Expand Down
Loading