-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathschema_tag.go
54 lines (49 loc) · 1.41 KB
/
schema_tag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package octopusdeploy
import (
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandTag(tag map[string]interface{}) octopusdeploy.Tag {
return octopusdeploy.Tag{
CanonicalTagName: tag["canonical_tag_name"].(string),
Color: tag["color"].(string),
Description: tag["description"].(string),
ID: tag["id"].(string),
Name: tag["name"].(string),
SortOrder: tag["sort_order"].(int),
}
}
func flattenTags(tags []octopusdeploy.Tag) []map[string]interface{} {
var flattenedTags = make([]map[string]interface{}, len(tags))
for key, tag := range tags {
flattenedTags[key] = map[string]interface{}{
"canonical_tag_name": tag.CanonicalTagName,
"color": tag.Color,
"description": tag.Description,
"id": tag.ID,
"name": tag.Name,
"sort_order": tag.SortOrder,
}
}
return flattenedTags
}
func getTagsSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"canonical_tag_name": {
Computed: true,
Optional: true,
Type: schema.TypeString,
},
"color": {
Required: true,
Type: schema.TypeString,
},
"description": getDescriptionSchema(),
"id": getIDSchema(),
"name": getNameSchema(true),
"sort_order": {
Optional: true,
Type: schema.TypeInt,
},
}
}