-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathchannel.go
More file actions
125 lines (119 loc) · 4.74 KB
/
Copy pathchannel.go
File metadata and controls
125 lines (119 loc) · 4.74 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package schemas
import (
"github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy_framework/util"
resourceSchema "github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/types"
)
const ChannelResourceDescription = "channel"
type ChannelSchema struct{}
type ChannelModel struct {
Description types.String `tfsdk:"description"`
EphemeralEnvironmentNameTemplate types.String `tfsdk:"ephemeral_environment_name_template"`
IsDefault types.Bool `tfsdk:"is_default"`
LifecycleId types.String `tfsdk:"lifecycle_id"`
Name types.String `tfsdk:"name"`
ParentEnvironmentID types.String `tfsdk:"parent_environment_id"`
ProjectId types.String `tfsdk:"project_id"`
CustomFieldDefinitions types.List `tfsdk:"custom_field_definitions"`
Rule types.List `tfsdk:"rule"`
SpaceId types.String `tfsdk:"space_id"`
TenantTags types.Set `tfsdk:"tenant_tags"`
Type types.String `tfsdk:"type"`
ResourceModel
}
func (c ChannelSchema) GetResourceSchema() resourceSchema.Schema {
return resourceSchema.Schema{
Description: util.GetResourceSchemaDescription(ChannelResourceDescription),
Attributes: map[string]resourceSchema.Attribute{
"id": GetIdResourceSchema(),
"description": GetDescriptionResourceSchema(ChannelResourceDescription),
"ephemeral_environment_name_template": resourceSchema.StringAttribute{
Description: "The name template for ephemeral environments created from this channel.",
Optional: true,
},
"is_default": resourceSchema.BoolAttribute{
Description: "Indicates whether this is the default channel for the associated project.",
Optional: true,
},
"lifecycle_id": resourceSchema.StringAttribute{
Description: "The lifecycle ID associated with this channel.",
Optional: true,
},
"name": GetNameResourceSchema(true),
"parent_environment_id": resourceSchema.StringAttribute{
Description: "The parent environment ID for ephemeral environments.",
Optional: true,
},
"project_id": resourceSchema.StringAttribute{
Description: "The project ID associated with this channel.",
Required: true,
},
"custom_field_definitions": resourceSchema.ListNestedAttribute{
Description: "A list of custom field definitions for this channel. Maximum of 10.",
Optional: true,
NestedObject: resourceSchema.NestedAttributeObject{
Attributes: map[string]resourceSchema.Attribute{
"field_name": resourceSchema.StringAttribute{
Required: true,
Description: "The name of the custom field.",
},
"description": resourceSchema.StringAttribute{
Required: true,
Description: "The description of the custom field.",
},
},
},
},
"space_id": GetSpaceIdResourceSchema(ChannelResourceDescription),
"tenant_tags": resourceSchema.SetAttribute{
Description: "A set of tenant tags associated with this channel.",
Optional: true,
ElementType: types.StringType,
},
"type": resourceSchema.StringAttribute{
Description: "The type of channel. Valid values are `\"Lifecycle\"` or `\"EphemeralEnvironment\"`. Defaults to `\"Lifecycle\"`.",
Optional: true,
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
},
Blocks: map[string]resourceSchema.Block{
"rule": resourceSchema.ListNestedBlock{
Description: "A list of rules associated with this channel.",
NestedObject: resourceSchema.NestedBlockObject{
Attributes: map[string]resourceSchema.Attribute{
"id": resourceSchema.StringAttribute{
Description: "The ID associated with this channel rule.",
Computed: true,
Optional: true,
},
"tag": resourceSchema.StringAttribute{
Optional: true,
},
"version_range": resourceSchema.StringAttribute{
Optional: true,
},
},
Blocks: map[string]resourceSchema.Block{
"action_package": resourceSchema.ListNestedBlock{
NestedObject: resourceSchema.NestedBlockObject{
Attributes: map[string]resourceSchema.Attribute{
"deployment_action": resourceSchema.StringAttribute{
Optional: true,
},
"package_reference": resourceSchema.StringAttribute{
Optional: true,
},
},
},
},
},
},
},
},
}
}