Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(coder-attach): add coder_external_agent resource#424

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

Merged
kacpersaw merged 2 commits intomainfromkacpersaw/feat-coder-attach
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
24 changes: 24 additions & 0 deletionsdocs/resources/external_agent.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "coder_external_agent Resource - terraform-provider-coder"
subcategory: ""
description: |-
Define an external agent to be used in a workspace.
---

# coder_external_agent (Resource)

Define an external agent to be used in a workspace.



<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `agent_id` (String) The `id` property of a `coder_agent` resource to associate with.

### Read-Only

- `id` (String) The ID of this resource.
31 changes: 31 additions & 0 deletionsprovider/external_agent.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
package provider

import (
"context"

"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func externalAgentResource() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,

Description: "Define an external agent to be used in a workspace.",
CreateContext: func(ctx context.Context, rd *schema.ResourceData, _ interface{}) diag.Diagnostics {
rd.SetId(uuid.NewString())
return nil
},
ReadContext: schema.NoopContext,
DeleteContext: schema.NoopContext,
Schema: map[string]*schema.Schema{
"agent_id": {
Type: schema.TypeString,
Description: "The `id` property of a `coder_agent` resource to associate with.",
ForceNew: true,
Required: true,
},
},
}
}
49 changes: 49 additions & 0 deletionsprovider/external_agent_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
package provider_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/stretchr/testify/require"
)

func TestExternalAgent(t *testing.T) {
t.Parallel()

t.Run("OK", func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Should also have a test that links this resource to acoder_agent.

t.Parallel()

resource.Test(t, resource.TestCase{
ProviderFactories: coderFactory(),
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: `
provider "coder" {
}

resource "coder_agent" "dev" {
os = "linux"
arch = "amd64"
}

resource "coder_external_agent" "dev" {
agent_id = coder_agent.dev.id
}
`,
Check: func(state *terraform.State) error {
require.Len(t, state.Modules, 1)
require.Len(t, state.Modules[0].Resources, 2)

agentResource := state.Modules[0].Resources["coder_agent.dev"]
require.NotNil(t, agentResource)
externalAgentResource := state.Modules[0].Resources["coder_external_agent.dev"]
require.NotNil(t, externalAgentResource)

require.Equal(t, agentResource.Primary.Attributes["id"], externalAgentResource.Primary.Attributes["agent_id"])
return nil
},
}},
})
})
}
1 change: 1 addition & 0 deletionsprovider/provider.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,6 +74,7 @@ func New() *schema.Provider {
"coder_script": scriptResource(),
"coder_env": envResource(),
"coder_devcontainer": devcontainerResource(),
"coder_external_agent": externalAgentResource(),
},
}
}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp