7
7
8
8
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/cfclient"
9
9
"github.com/codefresh-io/terraform-provider-codefresh/codefresh/internal/datautil"
10
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
10
11
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
11
12
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
12
13
funk "github.com/thoas/go-funk"
@@ -96,7 +97,12 @@ The tags for which to apply the permission. Supports two custom tags:
96
97
},
97
98
},
98
99
},
99
- CustomizeDiff : resourcePermissionCustomDiff ,
100
+ CustomizeDiff : customdiff .All (
101
+ resourcePermissionCustomDiff ,
102
+ customdiff .ForceNewIfChange ("related_resource" , func (ctx context.Context , oldValue , newValue , meta interface {}) bool {
103
+ return true
104
+ }),
105
+ ),
100
106
}
101
107
}
102
108
@@ -206,6 +212,11 @@ func mapPermissionToResource(permission *cfclient.Permission, d *schema.Resource
206
212
return err
207
213
}
208
214
215
+ err = d .Set ("related_resource" , permission .RelatedResource )
216
+ if err != nil {
217
+ return err
218
+ }
219
+
209
220
err = d .Set ("tags" , permission .Tags )
210
221
if err != nil {
211
222
return err
@@ -224,11 +235,12 @@ func mapResourceToPermission(d *schema.ResourceData) *cfclient.Permission {
224
235
tags = []string {"*" , "untagged" }
225
236
}
226
237
permission := & cfclient.Permission {
227
- ID : d .Id (),
228
- Team : d .Get ("team" ).(string ),
229
- Action : d .Get ("action" ).(string ),
230
- Resource : d .Get ("resource" ).(string ),
231
- Tags : tags ,
238
+ ID : d .Id (),
239
+ Team : d .Get ("team" ).(string ),
240
+ Action : d .Get ("action" ).(string ),
241
+ Resource : d .Get ("resource" ).(string ),
242
+ RelatedResource : d .Get ("related_resource" ).(string ),
243
+ Tags : tags ,
232
244
}
233
245
234
246
return permission
0 commit comments