Skip to content

Commit 012fdb7

Browse files
committed
Add in acceptance tests
1 parent 367c20c commit 012fdb7

File tree

2 files changed

+354
-17
lines changed

2 files changed

+354
-17
lines changed

internal/provider/resource_tfe_hyok_configuration.go

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,23 @@ func (r *resourceTFEHYOKConfiguration) Create(ctx context.Context, req resource.
220220
}
221221

222222
var azureOIDCConfig *tfe.AzureOIDCConfiguration
223-
if plan.VaultOIDCConfigurationID.ValueString() != "" {
223+
if plan.AzureOIDCConfigurationID.ValueString() != "" {
224224
azureOIDCConfig = &tfe.AzureOIDCConfiguration{ID: plan.AzureOIDCConfigurationID.ValueString()}
225225
}
226226

227-
options := tfe.HYOKConfigurationsCreateOptions{
228-
KEKID: plan.KEKID.ValueString(),
229-
Name: plan.Name.ValueString(),
230-
KMSOptions: &tfe.KMSOptions{
227+
var kmsOptions *tfe.KMSOptions
228+
if plan.KMSOptions != nil {
229+
kmsOptions = &tfe.KMSOptions{
231230
KeyRegion: plan.KMSOptions.KeyRegion.ValueString(),
232231
KeyLocation: plan.KMSOptions.KeyLocation.ValueString(),
233232
KeyRingID: plan.KMSOptions.KeyRingID.ValueString(),
234-
},
233+
}
234+
}
235+
236+
options := tfe.HYOKConfigurationsCreateOptions{
237+
KEKID: plan.KEKID.ValueString(),
238+
Name: plan.Name.ValueString(),
239+
KMSOptions: kmsOptions,
235240
OIDCConfiguration: &tfe.OIDCConfigurationTypeChoice{
236241
AWSOIDCConfiguration: awsOIDCConfig,
237242
GCPOIDCConfiguration: gcpOIDCConfig,
@@ -295,15 +300,20 @@ func (r *resourceTFEHYOKConfiguration) Update(ctx context.Context, req resource.
295300
return
296301
}
297302

298-
options := tfe.HYOKConfigurationsUpdateOptions{
299-
Name: plan.Name.ValueStringPointer(),
300-
KEKID: plan.KEKID.ValueStringPointer(),
301-
KMSOptions: &tfe.KMSOptions{
303+
var kmsOptions *tfe.KMSOptions
304+
if plan.KMSOptions != nil {
305+
kmsOptions = &tfe.KMSOptions{
302306
KeyRegion: plan.KMSOptions.KeyRegion.ValueString(),
303307
KeyLocation: plan.KMSOptions.KeyLocation.ValueString(),
304308
KeyRingID: plan.KMSOptions.KeyRingID.ValueString(),
305-
},
306-
AgentPool: &tfe.AgentPool{ID: plan.AgentPoolID.ValueString()},
309+
}
310+
}
311+
312+
options := tfe.HYOKConfigurationsUpdateOptions{
313+
Name: plan.Name.ValueStringPointer(),
314+
KEKID: plan.KEKID.ValueStringPointer(),
315+
KMSOptions: kmsOptions,
316+
AgentPool: &tfe.AgentPool{ID: plan.AgentPoolID.ValueString()},
307317
}
308318

309319
hyokID := state.ID.ValueString()
@@ -340,10 +350,13 @@ func (r *resourceTFEHYOKConfiguration) Delete(ctx context.Context, req resource.
340350
}
341351

342352
func modelFromTFEHYOKConfiguration(p *tfe.HYOKConfiguration) modelTFEHYOKConfiguration {
343-
kmsOptions := modelTFEKMSOptions{
344-
KeyRegion: types.StringValue(p.KMSOptions.KeyRegion),
345-
KeyLocation: types.StringValue(p.KMSOptions.KeyLocation),
346-
KeyRingID: types.StringValue(p.KMSOptions.KeyRingID),
353+
var kmsOptions *modelTFEKMSOptions
354+
if p.KMSOptions != nil {
355+
kmsOptions = &modelTFEKMSOptions{
356+
KeyRegion: types.StringValue(p.KMSOptions.KeyRegion),
357+
KeyLocation: types.StringValue(p.KMSOptions.KeyLocation),
358+
KeyRingID: types.StringValue(p.KMSOptions.KeyRingID),
359+
}
347360
}
348361

349362
model := modelTFEHYOKConfiguration{
@@ -352,7 +365,7 @@ func modelFromTFEHYOKConfiguration(p *tfe.HYOKConfiguration) modelTFEHYOKConfigu
352365
KEKID: types.StringValue(p.KEKID),
353366
Organization: types.StringValue(p.Organization.Name),
354367
AgentPoolID: types.StringValue(p.AgentPool.ID),
355-
KMSOptions: &kmsOptions,
368+
KMSOptions: kmsOptions,
356369
}
357370

358371
if p.OIDCConfiguration.AWSOIDCConfiguration != nil {

0 commit comments

Comments
 (0)