Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/resources/devcontainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
9 changes: 9 additions & 0 deletions provider/devcontainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
},
}
}
9 changes: 9 additions & 0 deletions provider/devcontainer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
},
}},
Expand Down Expand Up @@ -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
},
}},
Expand Down