diff --git a/docs/resources/devcontainer.md b/docs/resources/devcontainer.md index 06d7f6f..0ebc49a 100644 --- a/docs/resources/devcontainer.md +++ b/docs/resources/devcontainer.md @@ -30,3 +30,4 @@ Define a Dev Container the agent should know of and attempt to autostart. ### Read-Only - `id` (String) The ID of this resource. +- `subagent_id` (String) The ID of the subagent created for this Dev Container. diff --git a/provider/devcontainer.go b/provider/devcontainer.go index 81a3119..b2c16eb 100644 --- a/provider/devcontainer.go +++ b/provider/devcontainer.go @@ -17,6 +17,10 @@ func devcontainerResource() *schema.Resource { CreateContext: func(_ context.Context, rd *schema.ResourceData, _ interface{}) diag.Diagnostics { rd.SetId(uuid.NewString()) + if err := rd.Set("subagent_id", uuid.NewString()); err != nil { + return diag.FromErr(err) + } + return nil }, ReadContext: schema.NoopContext, @@ -41,6 +45,11 @@ func devcontainerResource() *schema.Resource { ForceNew: true, Optional: true, }, + "subagent_id": { + Type: schema.TypeString, + Description: "The ID of the subagent created for this Dev Container.", + Computed: true, + }, }, } } diff --git a/provider/devcontainer_test.go b/provider/devcontainer_test.go index 784cfb0..be1a3d9 100644 --- a/provider/devcontainer_test.go +++ b/provider/devcontainer_test.go @@ -4,6 +4,7 @@ import ( "regexp" "testing" + "github.com/google/uuid" "github.com/stretchr/testify/require" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -39,6 +40,10 @@ func TestDevcontainer(t *testing.T) { } { require.Equal(t, expected, script.Primary.Attributes[key]) } + subagentID := script.Primary.Attributes["subagent_id"] + require.NotEmpty(t, subagentID) + _, err := uuid.Parse(subagentID) + require.NoError(t, err, "subagent_id should be a valid UUID") return nil }, }}, @@ -72,6 +77,10 @@ func TestDevcontainerNoConfigPath(t *testing.T) { } { require.Equal(t, expected, script.Primary.Attributes[key]) } + subagentID := script.Primary.Attributes["subagent_id"] + require.NotEmpty(t, subagentID) + _, err := uuid.Parse(subagentID) + require.NoError(t, err, "subagent_id should be a valid UUID") return nil }, }},