@@ -113,7 +113,7 @@ func resourceWorkflowJobTemplateCreate(ctx context.Context, d *schema.ResourceDa
113
113
client := m .(* awx.AWX )
114
114
awxService := client .WorkflowJobTemplateService
115
115
116
- result , err := awxService . CreateWorkflowJobTemplate ( map [string ]interface {}{
116
+ payload := map [string ]interface {}{
117
117
"name" : d .Get ("name" ).(string ),
118
118
"description" : d .Get ("description" ).(string ),
119
119
"organization" : d .Get ("organization_id" ).(int ),
@@ -122,14 +122,23 @@ func resourceWorkflowJobTemplateCreate(ctx context.Context, d *schema.ResourceDa
122
122
"survey_enabled" : d .Get ("survey_enabled" ).(bool ),
123
123
"allow_simultaneous" : d .Get ("allow_simultaneous" ).(bool ),
124
124
"ask_variables_on_launch" : d .Get ("ask_variables_on_launch" ).(bool ),
125
- "limit" : d .Get ("limit" ).(string ),
126
125
"scm_branch" : d .Get ("scm_branch" ).(string ),
127
126
"ask_inventory_on_launch" : d .Get ("ask_inventory_on_launch" ).(bool ),
128
127
"ask_scm_branch_on_launch" : d .Get ("ask_scm_branch_on_launch" ).(bool ),
129
128
"ask_limit_on_launch" : d .Get ("ask_limit_on_launch" ).(bool ),
130
129
"webhook_service" : d .Get ("webhook_service" ).(string ),
131
130
"webhook_credential" : d .Get ("webhook_credential" ).(string ),
132
- }, map [string ]string {})
131
+ }
132
+
133
+ // Workaround limitation mentioned in https://github.com/ansible/awx/issues/12991
134
+ limit := d .Get ("limit" ).(string )
135
+ if limit == "" {
136
+ payload ["limit" ] = nil
137
+ } else {
138
+ payload ["limit" ] = limit
139
+ }
140
+
141
+ result , err := awxService .CreateWorkflowJobTemplate (payload , map [string ]string {})
133
142
if err != nil {
134
143
log .Printf ("Fail to Create Template %v" , err )
135
144
diags = append (diags , diag.Diagnostic {
@@ -156,7 +165,7 @@ func resourceWorkflowJobTemplateUpdate(ctx context.Context, d *schema.ResourceDa
156
165
return utils .DiagNotFound ("job Workflow template" , id , err )
157
166
}
158
167
159
- if _ , err := client . WorkflowJobTemplateService . UpdateWorkflowJobTemplate ( id , map [string ]interface {}{
168
+ payload := map [string ]interface {}{
160
169
"name" : d .Get ("name" ).(string ),
161
170
"description" : d .Get ("description" ).(string ),
162
171
"organization" : d .Get ("organization_id" ).(int ),
@@ -165,14 +174,23 @@ func resourceWorkflowJobTemplateUpdate(ctx context.Context, d *schema.ResourceDa
165
174
"survey_enabled" : d .Get ("survey_enabled" ).(bool ),
166
175
"allow_simultaneous" : d .Get ("allow_simultaneous" ).(bool ),
167
176
"ask_variables_on_launch" : d .Get ("ask_variables_on_launch" ).(bool ),
168
- "limit" : d .Get ("limit" ).(string ),
169
177
"scm_branch" : d .Get ("scm_branch" ).(string ),
170
178
"ask_inventory_on_launch" : d .Get ("ask_inventory_on_launch" ).(bool ),
171
179
"ask_scm_branch_on_launch" : d .Get ("ask_scm_branch_on_launch" ).(bool ),
172
180
"ask_limit_on_launch" : d .Get ("ask_limit_on_launch" ).(bool ),
173
181
"webhook_service" : d .Get ("webhook_service" ).(string ),
174
182
"webhook_credential" : d .Get ("webhook_credential" ).(string ),
175
- }, map [string ]string {}); err != nil {
183
+ }
184
+
185
+ // Workaround limitation mentioned in https://github.com/ansible/awx/issues/12991
186
+ limit := d .Get ("limit" ).(string )
187
+ if limit == "" {
188
+ payload ["limit" ] = nil
189
+ } else {
190
+ payload ["limit" ] = limit
191
+ }
192
+
193
+ if _ , err := client .WorkflowJobTemplateService .UpdateWorkflowJobTemplate (id , payload , map [string ]string {}); err != nil {
176
194
return utils .DiagUpdate ("Job Workflow template" , d .Get ("name" ).(string ), err )
177
195
}
178
196
@@ -232,8 +250,19 @@ func setWorkflowJobTemplateResourceData(d *schema.ResourceData, r *awx.WorkflowJ
232
250
if err := d .Set ("ask_variables_on_launch" , r .AskVariablesOnLaunch ); err != nil {
233
251
fmt .Println ("Error setting ask_variables_on_launch" , err )
234
252
}
235
- if err := d .Set ("limit" , r .Limit ); err != nil {
236
- fmt .Println ("Error setting limit" , err )
253
+ // Workaround limitation mentioned in https://github.com/ansible/awx/issues/12991
254
+ if r .Limit != nil {
255
+ if limitStr , ok := r .Limit .(string ); ok {
256
+ if err := d .Set ("limit" , limitStr ); err != nil {
257
+ fmt .Println ("Error setting limit" , err )
258
+ }
259
+ } else {
260
+ fmt .Println ("Error converting limit to string" )
261
+ }
262
+ } else {
263
+ if err := d .Set ("limit" , "" ); err != nil {
264
+ fmt .Println ("Error setting limit" , err )
265
+ }
237
266
}
238
267
if err := d .Set ("scm_branch" , r .ScmBranch ); err != nil {
239
268
fmt .Println ("Error setting scm_branch" , err )
0 commit comments