Skip to content

Commit 58b423e

Browse files
authored
Merge pull request #82 from arangodb-managed/OAS-7161
OAS-7161 | add flag to enable / disable platform auth
2 parents 4e94bee + 5abafeb commit 58b423e

File tree

4 files changed

+86
-5
lines changed

4 files changed

+86
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/arangodb-managed/terraform-provider-oasis
22

33
require (
4-
github.com/arangodb-managed/apis v0.79.15
4+
github.com/arangodb-managed/apis v0.79.17
55
github.com/arangodb-managed/log-helper v0.2.5
66
github.com/gogo/protobuf v1.3.2
77
github.com/hashicorp/terraform-plugin-docs v0.8.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/
3131
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
3232
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
3333
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
34-
github.com/arangodb-managed/apis v0.79.15 h1:d7/VE3+zm0HshaV9Dx16XTpyNKfggwQxu70WoVJbOyk=
35-
github.com/arangodb-managed/apis v0.79.15/go.mod h1:ZlvA803MmUI3m6ijvaAYKKaWgLJq8bBZZuq8uyZo2PY=
34+
github.com/arangodb-managed/apis v0.79.17 h1:U8prEbReMiuG7h+4KY8V0tpkJBotN/Np3ptO9iQz9fU=
35+
github.com/arangodb-managed/apis v0.79.17/go.mod h1:ZlvA803MmUI3m6ijvaAYKKaWgLJq8bBZZuq8uyZo2PY=
3636
github.com/arangodb-managed/log-helper v0.2.5 h1:Kg3+0bDVFhEgyjMhIbCIj9hejgN2VaD4Cw/JQ4ARsd4=
3737
github.com/arangodb-managed/log-helper v0.2.5/go.mod h1:G17ASSd3Edday3i1QREGefyLJ2TduHxxFsOaqoigurE=
3838
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=

internal/resource_deployment.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
deplDisableScheduledRootPasswordRotationFieldName = "disable_scheduled_root_password_rotation"
6161
deplLockedFieldName = "locked"
6262
deplDeploymentProfileIDFieldName = "deployment_profile_id"
63+
deplIsPlatformAuthEnabled = "is_platform_authentication_enabled"
6364
)
6465

6566
func resourceDeployment() *schema.Resource {
@@ -257,6 +258,13 @@ func resourceDeployment() *schema.Resource {
257258
Description: "Deployment Resource Deployment Profile ID field",
258259
Optional: true,
259260
},
261+
262+
deplIsPlatformAuthEnabled: {
263+
Type: schema.TypeBool,
264+
Description: "Deployment Resource Deployment Is Platform Authentication Enabled field",
265+
Optional: true,
266+
Default: false,
267+
},
260268
},
261269
}
262270
}
@@ -431,6 +439,7 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
431439
scheduledRootPasswordRotationDisabled bool
432440
locked bool
433441
deploymentProfileID string
442+
isPlatformAuthenticationEnabled bool
434443
)
435444
if v, ok := d.GetOk(deplNameFieldName); ok {
436445
name = v.(string)
@@ -492,6 +501,10 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
492501
deploymentProfileID = v.(string)
493502
}
494503

504+
if v, ok := d.GetOk(deplIsPlatformAuthEnabled); ok {
505+
isPlatformAuthenticationEnabled = v.(bool)
506+
}
507+
495508
return &data.Deployment{
496509
Name: name,
497510
Description: description,
@@ -513,6 +526,7 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
513526
IsScheduledRootPasswordRotationEnabled: !scheduledRootPasswordRotationDisabled,
514527
Locked: locked,
515528
DeploymentProfileId: deploymentProfileID,
529+
IsPlatformAuthenticationEnabled: isPlatformAuthenticationEnabled,
516530
}, nil
517531
}
518532

@@ -648,6 +662,7 @@ func flattenDeployment(depl *data.Deployment) map[string]interface{} {
648662
deplDiskPerformanceFieldName: depl.GetDiskPerformanceId(),
649663
deplDisableScheduledRootPasswordRotationFieldName: !depl.GetIsScheduledRootPasswordRotationEnabled(),
650664
deplLockedFieldName: depl.GetLocked(),
665+
deplIsPlatformAuthEnabled: depl.GetIsPlatformAuthenticationEnabled(),
651666
}
652667
if notificationSetting != nil {
653668
result[deplNotificationConfigurationFieldName] = notificationSetting

internal/resource_deployment_test.go

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,68 @@ func TestFlattenDeploymentResource(t *testing.T) {
129129
deplDisableScheduledRootPasswordRotationFieldName: true,
130130
deplLockedFieldName: false,
131131
deplDeploymentProfileIDFieldName: deploymentProfileTestID,
132+
deplIsPlatformAuthEnabled: false,
133+
}
134+
assert.Equal(t, expected, flattened)
135+
}
136+
137+
// TestFlattenDeploymentResourcePlatformAuthentication tests the Oasis Deployment flattening with PlatformAuthentication set to true.
138+
func TestFlattenDeploymentResourcePlatformAuthentication(t *testing.T) {
139+
depl := &data.Deployment{
140+
Name: "test-name",
141+
Description: "test-desc",
142+
ProjectId: "123456789",
143+
RegionId: "gcp-europe-west4",
144+
Version: "3.9.1",
145+
Certificates: &data.Deployment_CertificateSpec{
146+
CaCertificateId: "certificate-id",
147+
},
148+
IpallowlistId: "ip-allowlist",
149+
DisableFoxxAuthentication: true,
150+
Model: &data.Deployment_ModelSpec{
151+
Model: "oneshard",
152+
NodeSizeId: "a8",
153+
NodeCount: 3,
154+
NodeDiskSize: 32,
155+
},
156+
IsScheduledRootPasswordRotationEnabled: true,
157+
Locked: true,
158+
IsPlatformAuthenticationEnabled: true,
159+
}
160+
flattened := flattenDeployment(depl)
161+
expected := map[string]interface{}{
162+
deplProjectFieldName: "123456789",
163+
deplNameFieldName: "test-name",
164+
deplDescriptionFieldName: "test-desc",
165+
deplLocationFieldName: []interface{}{
166+
map[string]interface{}{
167+
deplLocationRegionFieldName: "gcp-europe-west4",
168+
},
169+
},
170+
deplVersionFieldName: []interface{}{
171+
map[string]interface{}{
172+
deplVersionDbVersionFieldName: "3.9.1",
173+
},
174+
},
175+
deplSecurityFieldName: []interface{}{
176+
map[string]interface{}{
177+
deplSecurityCaCertificateFieldName: "certificate-id",
178+
deplSecurityIpAllowlistFieldName: "ip-allowlist",
179+
deplSecurityDisableFoxxAuthenticationFieldName: true,
180+
},
181+
},
182+
deplConfigurationFieldName: []interface{}{
183+
map[string]interface{}{
184+
deplConfigurationModelFieldName: "oneshard",
185+
deplConfigurationNodeSizeIdFieldName: "a8",
186+
deplConfigurationNodeCountFieldName: 3,
187+
deplConfigurationNodeDiskSizeFieldName: 32,
188+
},
189+
},
190+
deplDiskPerformanceFieldName: "", // Not set
191+
deplDisableScheduledRootPasswordRotationFieldName: false,
192+
deplLockedFieldName: true,
193+
deplIsPlatformAuthEnabled: true,
132194
}
133195
assert.Equal(t, expected, flattened)
134196
}
@@ -188,6 +250,7 @@ func TestFlattenDeploymentResourceDisableFoxxAuth(t *testing.T) {
188250
deplDiskPerformanceFieldName: "", // Not set
189251
deplDisableScheduledRootPasswordRotationFieldName: false,
190252
deplLockedFieldName: true,
253+
deplIsPlatformAuthEnabled: false,
191254
}
192255
assert.Equal(t, expected, flattened)
193256
}
@@ -255,6 +318,7 @@ func TestFlattenDeploymentResourceNotificationSettings(t *testing.T) {
255318
deplDiskPerformanceFieldName: "",
256319
deplDisableScheduledRootPasswordRotationFieldName: true,
257320
deplLockedFieldName: true,
321+
deplIsPlatformAuthEnabled: false,
258322
}
259323
assert.Equal(t, expected, flattened)
260324
}
@@ -381,7 +445,8 @@ func TestExpandingDeploymentResourceDisableFoxxAuth(t *testing.T) {
381445
},
382446
},
383447
deplDisableScheduledRootPasswordRotationFieldName: false,
384-
deplLockedFieldName: true,
448+
deplLockedFieldName: true,
449+
deplIsPlatformAuthEnabled: false,
385450
}
386451
s := resourceDeployment().Schema
387452
resourceData := schema.TestResourceDataRaw(t, s, raw)
@@ -440,7 +505,8 @@ func TestExpandDeploymentOverrideProjectID(t *testing.T) {
440505
},
441506
},
442507
deplDisableScheduledRootPasswordRotationFieldName: true,
443-
deplLockedFieldName: true,
508+
deplLockedFieldName: true,
509+
deplIsPlatformAuthEnabled: false,
444510
}
445511
s := resourceDeployment().Schema
446512
resourceData := schema.TestResourceDataRaw(t, s, raw)

0 commit comments

Comments
 (0)