Skip to content

Commit b45af83

Browse files
Sync monorepo state at "Prepare ucconfig for new release" (#68)
Syncing from userclouds/userclouds@9d7916997cb9480f7c778381286b2d6d54bf1513
1 parent 20443f3 commit b45af83

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

genprovider/internal/resources/resource.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ func (r *<< .StructName >>) Create(ctx context.Context, req resource.CreateReque
223223
224224
<<- if eq .CreateResponseModel .JSONClientModelName >>
225225
created := apiResp
226+
<<- if eq .StructName "AccessPolicyResource" >>
227+
// TODO: (GH #3563) this is a temporary workaround for enums compositeunion/compositeintersection being renamed
228+
if created.PolicyType != nil {
229+
if *created.PolicyType == "compositeunion" {
230+
*created.PolicyType = "composite_or"
231+
} else if *created.PolicyType == "compositeintersection" {
232+
*created.PolicyType = "composite_and"
233+
}
234+
}
235+
<<- end >>
226236
<<- else if not .CreateResponseBodyUsesArray >>
227237
created := *apiResp.<< .CreateResponseDataPropertyName >>
228238
<<- else >>
@@ -267,6 +277,16 @@ func (r *<< .StructName >>) Read(ctx context.Context, req resource.ReadRequest,
267277
}
268278
<<- if eq .ReadResponseModel .JSONClientModelName >>
269279
current := apiResp
280+
<<- if eq .StructName "AccessPolicyResource" >>
281+
// TODO: (GH #3563) this is a temporary workaround for enums compositeunion/compositeintersection being renamed
282+
if current.PolicyType != nil {
283+
if *current.PolicyType == "compositeunion" {
284+
*current.PolicyType = "composite_or"
285+
} else if *current.PolicyType == "compositeintersection" {
286+
*current.PolicyType = "composite_and"
287+
}
288+
}
289+
<<- end >>
270290
<<- else >>
271291
current := *apiResp.<< .ReadResponseDataPropertyName >>
272292
<<- end >>
@@ -329,6 +349,16 @@ func (r *<< .StructName >>) Update(ctx context.Context, req resource.UpdateReque
329349
}
330350
<<- if eq .UpdateResponseModel .JSONClientModelName >>
331351
updated := apiResp
352+
<<- if eq .StructName "AccessPolicyResource" >>
353+
// TODO: (GH #3563) this is a temporary workaround for enums compositeunion/compositeintersection being renamed
354+
if updated.PolicyType != nil {
355+
if *updated.PolicyType == "compositeunion" {
356+
*updated.PolicyType = "composite_or"
357+
} else if *updated.PolicyType == "compositeintersection" {
358+
*updated.PolicyType = "composite_and"
359+
}
360+
}
361+
<<- end >>
332362
<<- else >>
333363
updated := *apiResp.<< .UpdateResponseDataPropertyName >>
334364
<<- end >>

internal/provider/tokenizer/access_policy_resource_generated.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ func (r *AccessPolicyResource) Create(ctx context.Context, req resource.CreateRe
113113
return
114114
}
115115
created := apiResp
116+
// TODO: (GH #3563) this is a temporary workaround for enums compositeunion/compositeintersection being renamed
117+
if created.PolicyType != nil {
118+
if *created.PolicyType == "compositeunion" {
119+
*created.PolicyType = "composite_or"
120+
} else if *created.PolicyType == "compositeintersection" {
121+
*created.PolicyType = "composite_and"
122+
}
123+
}
116124
createdTF, err := PolicyAccessPolicyJSONClientModelToTF(&created)
117125
if err != nil {
118126
resp.Diagnostics.AddError("Error converting userclouds_access_policy response JSON to Terraform state", err.Error())
@@ -149,6 +157,14 @@ func (r *AccessPolicyResource) Read(ctx context.Context, req resource.ReadReques
149157
return
150158
}
151159
current := apiResp
160+
// TODO: (GH #3563) this is a temporary workaround for enums compositeunion/compositeintersection being renamed
161+
if current.PolicyType != nil {
162+
if *current.PolicyType == "compositeunion" {
163+
*current.PolicyType = "composite_or"
164+
} else if *current.PolicyType == "compositeintersection" {
165+
*current.PolicyType = "composite_and"
166+
}
167+
}
152168

153169
newState, err := PolicyAccessPolicyJSONClientModelToTF(&current)
154170
if err != nil {
@@ -201,6 +217,14 @@ func (r *AccessPolicyResource) Update(ctx context.Context, req resource.UpdateRe
201217
return
202218
}
203219
updated := apiResp
220+
// TODO: (GH #3563) this is a temporary workaround for enums compositeunion/compositeintersection being renamed
221+
if updated.PolicyType != nil {
222+
if *updated.PolicyType == "compositeunion" {
223+
*updated.PolicyType = "composite_or"
224+
} else if *updated.PolicyType == "compositeintersection" {
225+
*updated.PolicyType = "composite_and"
226+
}
227+
}
204228

205229
newState, err := PolicyAccessPolicyJSONClientModelToTF(&updated)
206230
if err != nil {

0 commit comments

Comments
 (0)