Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
Open
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
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "golang build env",
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like these devcontainer files were added to the commit, you may want to update the .gitignore

"dockerComposeFile" : [
"docker-compose.yml"
],
"service" : "dev_env",
"workspaceFolder": "/src",
"forwardPorts": [
0
],
"extensions": [
"ms-azuretools.vscode-docker"
]
}
43 changes: 43 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.8"
name: terraform-provider-octopusdeploy
services:

sql_server:
image: mcr.microsoft.com/mssql/server:2022-latest
environment:
ACCEPT_EULA: Y
MSSQL_SA_PASSWORD: MyVeryStrongPassword123!
healthcheck:
test: [ "CMD", "/opt/mssql-tools/bin/sqlcmd", "-U", "sa", "-P", "MyVeryStrongPassword123!", "-Q", "select 1"]
interval: 10s
retries: 10
ports:
- 8433:1433

octopus:
depends_on:
sql_server:
condition: service_healthy
image: octopusdeploy/octopusdeploy
environment:
ACCEPT_EULA: "Y"
ADMIN_USERNAME: admin
ADMIN_PASSWORD: "P@ssw0rd!"
ADMIN_API_KEY: API-L2GV2ELTCZDRANT1OQO045GPZHXFGWR
Copy link
Contributor

Choose a reason for hiding this comment

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

If you copied this API key from a "real" octopus server you may want to revoke the key given its now appeared publicly

DB_CONNECTION_STRING: Server=sql_server;Database=octopus;User Id=sa;Password=MyVeryStrongPassword123!
ports:
- 8080:8080

dev_env:
depends_on:
sql_server:
condition: service_healthy
octopus:
condition: service_started
build:
context: .
dockerfile: dockerfile
command: sleep infinity
volumes:
- ../:/src

8 changes: 8 additions & 0 deletions .devcontainer/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM hashicorp/terraform

COPY --from=golang /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"

RUN apk add --no-cache make

ENTRYPOINT [ ]
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ terraform/**/terrform.tfstate
terraform/**/.terraform/*

# Ignore the test results file
results.xml
results.xml

## test container stuff
**/*/terraform.lock*
.devcontainer/integration_tests/
1 change: 1 addition & 0 deletions octopusdeploy/data_source_tag_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func dataSourceTagSetsRead(ctx context.Context, d *schema.ResourceData, m interf
}

flattenedTagSets := []interface{}{}

for _, tagSet := range existingTagSets.Items {
flattenedTagSets = append(flattenedTagSets, flattenTagSet(tagSet))
}
Expand Down
57 changes: 55 additions & 2 deletions octopusdeploy/schema_tag_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,41 @@ func expandTagSet(d *schema.ResourceData) *tagsets.TagSet {
return tagSet
}

func flattenTag(tag *tagsets.Tag) map[string]interface{} {
if tag == nil {
return nil
}

return map[string]interface{}{
"canonical_tag_name": tag.CanonicalTagName,
"color": tag.Color,
"description": tag.Description,
"name": tag.Name,
"sort_order": tag.SortOrder,
}

}

func flattenTagSet(tagSet *tagsets.TagSet) map[string]interface{} {
if tagSet == nil {
return nil
}

flattened_tags := []interface{}{}

for _, tag := range tagSet.Tags {
flattened_tags = append(flattened_tags, flattenTag(tag))
}

return map[string]interface{}{
"description": tagSet.Description,
"id": tagSet.GetID(),
"name": tagSet.Name,
"sort_order": tagSet.SortOrder,
"space_id": tagSet.SpaceID,
}
}
"tags": flattened_tags,
}}


func getTagSetDataSchema() map[string]*schema.Schema {
dataSchema := getTagSetSchema()
Expand All @@ -62,13 +84,44 @@ func getTagSetDataSchema() map[string]*schema.Schema {
}
}

func getTagSchemaForTagSet() map[string]*schema.Schema {
Copy link
Author

Choose a reason for hiding this comment

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

the getTagSchema() from schema_tag.go has a few extra values that is not needed here.

return map[string]*schema.Schema{
"canonical_tag_name": {
Computed: true,
Type: schema.TypeString,
},
"color": {
Required: true,
Type: schema.TypeString,
},
"description": getDescriptionSchema("tag"),
"name": getNameSchema(true),
"sort_order": {
Computed: true,
Optional: true,
Type: schema.TypeInt,
},
}
}

func getTagSetSchema() map[string]*schema.Schema {
tagSchema := getTagSchemaForTagSet()
setDataSchema(&tagSchema)


return map[string]*schema.Schema{
"description": getDescriptionSchema("tag set"),
"id": getIDSchema(),
"name": getNameSchema(true),
"sort_order": getSortOrderSchema(),
"space_id": getSpaceIDSchema(),
"tags": {
Computed: true,
Description: "A list of tags within the tagset",
Elem: &schema.Resource{Schema: tagSchema},
Optional: true,
Type: schema.TypeList,
},
}
}

Expand Down