Skip to content

Commit 68be860

Browse files
authored
feat: added slugs to project groups (#42)
1 parent 248a755 commit 68be860

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
lines changed

docs/data-sources/project_groups.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Read-Only:
4545
- `description` (String) The description of this project group.
4646
- `id` (String) The unique ID for this resource.
4747
- `name` (String) The name of this resource.
48+
- `slug` (String) The unique slug of this project group
4849
- `space_id` (String) The space ID associated with this project group.
4950

5051

docs/resources/project_group.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ resource "octopusdeploy_project_group" "example" {
2929
### Optional
3030

3131
- `description` (String) The description of this project group.
32+
- `slug` (String) The unique slug of this project group
3233
- `space_id` (String) The space ID associated with this project group.
3334

3435
### Read-Only

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.0
55
toolchain go1.24.5
66

77
require (
8-
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.77.0
8+
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.78.0
99
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v1.0.1
1010
github.com/google/uuid v1.6.0
1111
github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
1818
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
1919
github.com/OctopusDeploy/go-octodiff v1.0.0 h1:U+ORg6azniwwYo+O44giOw6TiD5USk8S4VDhOQ0Ven0=
2020
github.com/OctopusDeploy/go-octodiff v1.0.0/go.mod h1:Mze0+EkOWTgTmi8++fyUc6r0aLZT7qD9gX+31t8MmIU=
21-
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.77.0 h1:zzoZ7DlFEGuQvk488acV9iNrDjOnvlE0SOJgd6NnwOE=
22-
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.77.0/go.mod h1:ZCOnCz9ae/uuOk7AIQ9NzjnzFbuN8Q7H3oj2Eq4QSgQ=
21+
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.78.0 h1:UCp+9nLGfpcM5sHLM0C5lyEFsmSqSp7Z/rEAuiK3Zs0=
22+
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.78.0/go.mod h1:ZCOnCz9ae/uuOk7AIQ9NzjnzFbuN8Q7H3oj2Eq4QSgQ=
2323
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v1.0.1 h1:rQjwRQ9Q3EV0FDxRRMMc3X0vto9u3nCNAqe8Tk6p4Yk=
2424
github.com/OctopusSolutionsEngineering/OctopusTerraformTestFramework v1.0.1/go.mod h1:MpwQ4jw7ugTju/whAqtxf5vFxVPV0jBvHp8X4TKBhE8=
2525
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg=

octopusdeploy_framework/datasource_project_groups.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func getNestedGroupAttributes() map[string]attr.Type {
3535
"id": types.StringType,
3636
"space_id": types.StringType,
3737
"name": types.StringType,
38+
"slug": types.StringType,
3839
"description": types.StringType,
3940
}
4041
}
@@ -47,7 +48,7 @@ func (p *projectGroupsDataSource) Schema(_ context.Context, _ datasource.SchemaR
4748
resp.Schema = schemas.ProjectGroupSchema{}.GetDatasourceSchema()
4849
}
4950

50-
func (p *projectGroupsDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
51+
func (p *projectGroupsDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
5152
p.Config = DataSourceConfiguration(req, resp)
5253
}
5354

@@ -97,15 +98,13 @@ func (p *projectGroupsDataSource) Read(ctx context.Context, req datasource.ReadR
9798
g.ID = types.StringValue(projectGroup.ID)
9899
g.SpaceID = types.StringValue(projectGroup.SpaceID)
99100
g.Name = types.StringValue(projectGroup.Name)
101+
g.Slug = types.StringValue(projectGroup.Slug)
100102
g.Description = types.StringValue(projectGroup.Description)
101103
newGroups = append(newGroups, g)
102104
}
103105

104106
util.DatasourceResultCount(ctx, "project groups", len(newGroups))
105107

106-
for _, projectGroup := range newGroups {
107-
tflog.Debug(ctx, "mapped group "+projectGroup.Name.ValueString())
108-
}
109108
g, _ := types.ListValueFrom(ctx, types.ObjectType{AttrTypes: getNestedGroupAttributes()}, newGroups)
110109

111110
data.ProjectGroups = g

octopusdeploy_framework/resource_project_group.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (r *projectGroupTypeResource) Update(ctx context.Context, req resource.Upda
9595
group.Name = data.Name.ValueString()
9696
group.Description = data.Description.ValueString()
9797
group.SpaceID = data.SpaceID.ValueString()
98+
group.Slug = data.Slug.ValueString()
9899

99100
updatedProjectGroup, err := projectgroups.Update(r.Config.Client, *group)
100101
if err != nil {
@@ -125,4 +126,5 @@ func updateProjectGroup(data *schemas.ProjectGroupTypeResourceModel, group *proj
125126
data.Name = types.StringValue(group.Name)
126127
data.SpaceID = types.StringValue(group.SpaceID)
127128
data.Description = types.StringValue(group.Description)
129+
data.Slug = types.StringValue(group.Slug)
128130
}

octopusdeploy_framework/schemas/project_group.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (p ProjectGroupSchema) GetDatasourceSchema() datasourceSchema.Schema {
3333
"id": GetIdDatasourceSchema(true),
3434
"space_id": GetSpaceIdDatasourceSchema(description, true),
3535
"name": GetReadonlyNameDatasourceSchema(),
36+
"slug": GetSlugDatasourceSchema(projectGroupDescription, true),
3637
"description": GetDescriptionDatasourceSchema(projectGroupDescription),
3738
},
3839
},
@@ -45,6 +46,7 @@ func (p ProjectGroupSchema) GetResourceSchema() resourceSchema.Schema {
4546
return resourceSchema.Schema{
4647
Attributes: map[string]resourceSchema.Attribute{
4748
"id": GetIdResourceSchema(),
49+
"slug": GetSlugResourceSchema(projectGroupDescription),
4850
"space_id": GetSpaceIdResourceSchema(projectGroupDescription),
4951
"name": GetNameResourceSchema(true),
5052
"description": GetDescriptionResourceSchema(projectGroupDescription),
@@ -54,6 +56,7 @@ func (p ProjectGroupSchema) GetResourceSchema() resourceSchema.Schema {
5456

5557
type ProjectGroupTypeResourceModel struct {
5658
Name types.String `tfsdk:"name"`
59+
Slug types.String `tfsdk:"slug"`
5760
SpaceID types.String `tfsdk:"space_id"`
5861
Description types.String `tfsdk:"description"`
5962

0 commit comments

Comments
 (0)