@@ -29,90 +29,116 @@ func resourceSentryIssueAlert() *schema.Resource {
29
29
StateContext : schema .ImportStatePassthroughContext ,
30
30
},
31
31
32
- Schema : map [string ]* schema.Schema {
33
- "organization" : {
34
- Description : "The slug of the organization the issue alert belongs to." ,
35
- Type : schema .TypeString ,
36
- Required : true ,
32
+ Schema : resourceSentryIssueAlertSchema (),
33
+ SchemaVersion : 1 ,
34
+ StateUpgraders : []schema.StateUpgrader {
35
+ {
36
+ Type : resourceSentryIssueAlertResourceV0 ().CoreConfigSchema ().ImpliedType (),
37
+ Upgrade : resourceSentryIssueAlertStateUpgradeV0 ,
38
+ Version : 0 ,
37
39
},
38
- "project" : {
39
- Description : "The slug of the project to create the issue alert for." ,
40
- Type : schema .TypeString ,
41
- Required : true ,
42
- },
43
- "name" : {
44
- Description : "The issue alert name." ,
45
- Type : schema .TypeString ,
46
- Required : true ,
47
- },
48
- "conditions" : {
49
- Description : "List of conditions." ,
50
- Type : schema .TypeList ,
51
- Required : true ,
52
- Elem : & schema.Schema {
53
- Type : schema .TypeMap ,
54
- },
55
- DiffSuppressFunc : SuppressEquivalentJSONDiffs ,
56
- },
57
- "filters" : {
58
- Description : "List of filters." ,
59
- Type : schema .TypeList ,
60
- Optional : true ,
61
- Elem : & schema.Schema {
62
- Type : schema .TypeMap ,
63
- },
64
- DiffSuppressFunc : SuppressEquivalentJSONDiffs ,
65
- },
66
- "actions" : {
67
- Description : "List of actions." ,
68
- Type : schema .TypeList ,
69
- Required : true ,
70
- Elem : & schema.Schema {
71
- Type : schema .TypeMap ,
72
- },
73
- DiffSuppressFunc : SuppressEquivalentJSONDiffs ,
74
- },
75
- "action_match" : {
76
- Description : "Trigger actions when an event is captured by Sentry and `any` or `all` of the specified conditions happen." ,
77
- Type : schema .TypeString ,
78
- Required : true ,
79
- ValidateFunc : validation .StringInSlice ([]string {"all" , "any" }, false ),
80
- },
81
- "filter_match" : {
82
- Description : "Trigger actions if `all`, `any`, or `none` of the specified filters match." ,
83
- Type : schema .TypeString ,
84
- Required : true ,
85
- ValidateFunc : validation .StringInSlice ([]string {"all" , "any" , "none" }, false ),
86
- },
87
- "frequency" : {
88
- Description : "Perform actions at most once every `X` minutes for this issue. Defaults to `30`." ,
89
- Type : schema .TypeInt ,
90
- Required : true ,
40
+ },
41
+ }
42
+ }
43
+
44
+ func resourceSentryIssueAlertSchema () map [string ]* schema.Schema {
45
+ return map [string ]* schema.Schema {
46
+ "organization" : {
47
+ Description : "The slug of the organization the issue alert belongs to." ,
48
+ Type : schema .TypeString ,
49
+ Required : true ,
50
+ },
51
+ "project" : {
52
+ Description : "The slug of the project to create the issue alert for." ,
53
+ Type : schema .TypeString ,
54
+ Required : true ,
55
+ },
56
+ "name" : {
57
+ Description : "The issue alert name." ,
58
+ Type : schema .TypeString ,
59
+ Required : true ,
60
+ },
61
+ "conditions" : {
62
+ Description : "List of conditions." ,
63
+ Type : schema .TypeList ,
64
+ Required : true ,
65
+ Elem : & schema.Schema {
66
+ Type : schema .TypeMap ,
91
67
},
92
- "environment" : {
93
- Description : "Perform issue alert in a specific environment." ,
94
- Type : schema .TypeString ,
95
- Optional : true ,
96
- Computed : true ,
68
+ DiffSuppressFunc : SuppressEquivalentJSONDiffs ,
69
+ },
70
+ "filters" : {
71
+ Description : "List of filters." ,
72
+ Type : schema .TypeList ,
73
+ Optional : true ,
74
+ Elem : & schema.Schema {
75
+ Type : schema .TypeMap ,
97
76
},
98
- "projects" : {
99
- Deprecated : "Use `project` (singular) instead." ,
100
- Description : "Use `project` (singular) instead." ,
101
- Type : schema . TypeList ,
102
- Computed : true ,
103
- Elem : & schema. Schema {
104
- Type : schema .TypeString ,
105
- } ,
77
+ DiffSuppressFunc : SuppressEquivalentJSONDiffs ,
78
+ } ,
79
+ "actions" : {
80
+ Description : "List of actions." ,
81
+ Type : schema . TypeList ,
82
+ Required : true ,
83
+ Elem : & schema.Schema {
84
+ Type : schema . TypeMap ,
106
85
},
107
- "internal_id" : {
108
- Description : "The internal ID for this issue alert." ,
109
- Type : schema .TypeString ,
110
- Computed : true ,
86
+ DiffSuppressFunc : SuppressEquivalentJSONDiffs ,
87
+ },
88
+ "action_match" : {
89
+ Description : "Trigger actions when an event is captured by Sentry and `any` or `all` of the specified conditions happen." ,
90
+ Type : schema .TypeString ,
91
+ Required : true ,
92
+ ValidateFunc : validation .StringInSlice ([]string {"all" , "any" }, false ),
93
+ },
94
+ "filter_match" : {
95
+ Description : "Trigger actions if `all`, `any`, or `none` of the specified filters match." ,
96
+ Type : schema .TypeString ,
97
+ Required : true ,
98
+ ValidateFunc : validation .StringInSlice ([]string {"all" , "any" , "none" }, false ),
99
+ },
100
+ "frequency" : {
101
+ Description : "Perform actions at most once every `X` minutes for this issue. Defaults to `30`." ,
102
+ Type : schema .TypeInt ,
103
+ Required : true ,
104
+ },
105
+ "environment" : {
106
+ Description : "Perform issue alert in a specific environment." ,
107
+ Type : schema .TypeString ,
108
+ Optional : true ,
109
+ Computed : true ,
110
+ },
111
+ "projects" : {
112
+ Deprecated : "Use `project` (singular) instead." ,
113
+ Description : "Use `project` (singular) instead." ,
114
+ Type : schema .TypeList ,
115
+ Computed : true ,
116
+ Elem : & schema.Schema {
117
+ Type : schema .TypeString ,
111
118
},
112
119
},
120
+ "internal_id" : {
121
+ Description : "The internal ID for this issue alert." ,
122
+ Type : schema .TypeString ,
123
+ Computed : true ,
124
+ },
113
125
}
114
126
}
115
127
128
+ func resourceSentryIssueAlertResourceV0 () * schema.Resource {
129
+ return & schema.Resource {
130
+ Schema : resourceSentryIssueAlertSchema (),
131
+ }
132
+ }
133
+
134
+ func resourceSentryIssueAlertStateUpgradeV0 (ctx context.Context , rawState map [string ]interface {}, meta interface {}) (map [string ]interface {}, error ) {
135
+ id := rawState ["id" ].(string )
136
+ org := rawState ["organization" ].(string )
137
+ project := rawState ["project" ].(string )
138
+ rawState ["id" ] = buildThreePartID (org , project , id )
139
+ return rawState , nil
140
+ }
141
+
116
142
func resourceSentryIssueAlertObject (d * schema.ResourceData ) * sentry.IssueAlert {
117
143
alert := & sentry.IssueAlert {
118
144
Name : sentry .String (d .Get ("name" ).(string )),
0 commit comments