Skip to content

Commit ffc074a

Browse files
feat: Add subagent_id attribute to devcontainer resource
- Add computed subagent_id attribute to devcontainer resource - Generate unique UUID for subagent identification - Add tests verifying subagent_id is a valid UUID - Update documentation with new attribute
1 parent c9f205f commit ffc074a

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

docs/resources/devcontainer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ Define a Dev Container the agent should know of and attempt to autostart.
3030
### Read-Only
3131

3232
- `id` (String) The ID of this resource.
33+
- `subagent_id` (String) The ID of the subagent created for this Dev Container.

provider/devcontainer.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ func devcontainerResource() *schema.Resource {
1717
CreateContext: func(_ context.Context, rd *schema.ResourceData, _ interface{}) diag.Diagnostics {
1818
rd.SetId(uuid.NewString())
1919

20+
// Generate a unique subagent ID for this dev container.
21+
if err := rd.Set("subagent_id", uuid.NewString()); err != nil {
22+
return diag.FromErr(err)
23+
}
24+
2025
return nil
2126
},
2227
ReadContext: schema.NoopContext,
@@ -41,6 +46,11 @@ func devcontainerResource() *schema.Resource {
4146
ForceNew: true,
4247
Optional: true,
4348
},
49+
"subagent_id": {
50+
Type: schema.TypeString,
51+
Description: "The ID of the subagent created for this Dev Container.",
52+
Computed: true,
53+
},
4454
},
4555
}
4656
}

provider/devcontainer_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"regexp"
55
"testing"
66

7+
"github.com/google/uuid"
78
"github.com/stretchr/testify/require"
89

910
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -39,6 +40,11 @@ func TestDevcontainer(t *testing.T) {
3940
} {
4041
require.Equal(t, expected, script.Primary.Attributes[key])
4142
}
43+
// Verify subagent_id is a valid UUID.
44+
subagentID := script.Primary.Attributes["subagent_id"]
45+
require.NotEmpty(t, subagentID)
46+
_, err := uuid.Parse(subagentID)
47+
require.NoError(t, err, "subagent_id should be a valid UUID")
4248
return nil
4349
},
4450
}},
@@ -72,6 +78,11 @@ func TestDevcontainerNoConfigPath(t *testing.T) {
7278
} {
7379
require.Equal(t, expected, script.Primary.Attributes[key])
7480
}
81+
// Verify subagent_id is a valid UUID.
82+
subagentID := script.Primary.Attributes["subagent_id"]
83+
require.NotEmpty(t, subagentID)
84+
_, err := uuid.Parse(subagentID)
85+
require.NoError(t, err, "subagent_id should be a valid UUID")
7586
return nil
7687
},
7788
}},

0 commit comments

Comments
 (0)