Skip to content

Commit

Permalink
Merge pull request #88 from arangodb-managed/OAS-7760
Browse files Browse the repository at this point in the history
OAS-7760 | Add support for setting drop_vst_support field
  • Loading branch information
forgems authored Oct 27, 2023
2 parents 690d486 + 5b27f10 commit 314f264
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/arangodb-managed/terraform-provider-oasis
go 1.20

require (
github.com/arangodb-managed/apis v0.81.4
github.com/arangodb-managed/apis v0.83.1
github.com/arangodb-managed/log-helper v0.2.5
github.com/gogo/protobuf v1.3.2
github.com/hashicorp/terraform-plugin-docs v0.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/arangodb-managed/apis v0.81.4 h1:KGB4XHRSXIhdmKkIqwcL+OFTUG48CIQENinoHdArOqA=
github.com/arangodb-managed/apis v0.81.4/go.mod h1:ZlvA803MmUI3m6ijvaAYKKaWgLJq8bBZZuq8uyZo2PY=
github.com/arangodb-managed/apis v0.83.1 h1:Os+gxplikZDRFcpuO4Lk60qfrYHj8BInuOj955I3W2o=
github.com/arangodb-managed/apis v0.83.1/go.mod h1:ZlvA803MmUI3m6ijvaAYKKaWgLJq8bBZZuq8uyZo2PY=
github.com/arangodb-managed/log-helper v0.2.5 h1:Kg3+0bDVFhEgyjMhIbCIj9hejgN2VaD4Cw/JQ4ARsd4=
github.com/arangodb-managed/log-helper v0.2.5/go.mod h1:G17ASSd3Edday3i1QREGefyLJ2TduHxxFsOaqoigurE=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
Expand Down
16 changes: 16 additions & 0 deletions internal/resource_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const (
deplLockedFieldName = "locked"
deplDeploymentProfileIDFieldName = "deployment_profile_id"
deplIsPlatformAuthEnabled = "is_platform_authentication_enabled"
deplDropVSTSupportFieldName = "drop_vst_support"
)

func resourceDeployment() *schema.Resource {
Expand Down Expand Up @@ -265,6 +266,12 @@ func resourceDeployment() *schema.Resource {
Optional: true,
Default: false,
},
deplDropVSTSupportFieldName: {
Type: schema.TypeBool,
Description: "Deployment Resource Deployment Drop VST Support field",
Optional: true,
Default: false,
},
},
}
}
Expand Down Expand Up @@ -440,6 +447,7 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
locked bool
deploymentProfileID string
isPlatformAuthenticationEnabled bool
dropVSTSupport bool
)
if v, ok := d.GetOk(deplNameFieldName); ok {
name = v.(string)
Expand Down Expand Up @@ -504,6 +512,9 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
if v, ok := d.GetOk(deplIsPlatformAuthEnabled); ok {
isPlatformAuthenticationEnabled = v.(bool)
}
if v, ok := d.GetOk(deplDropVSTSupportFieldName); ok {
dropVSTSupport = v.(bool)
}

return &data.Deployment{
Name: name,
Expand All @@ -527,6 +538,7 @@ func expandDeploymentResource(d *schema.ResourceData, defaultProject string) (*d
Locked: locked,
DeploymentProfileId: deploymentProfileID,
IsPlatformAuthenticationEnabled: isPlatformAuthenticationEnabled,
DropVstSupport: dropVSTSupport,
}, nil
}

Expand Down Expand Up @@ -663,6 +675,7 @@ func flattenDeployment(depl *data.Deployment) map[string]interface{} {
deplDisableScheduledRootPasswordRotationFieldName: !depl.GetIsScheduledRootPasswordRotationEnabled(),
deplLockedFieldName: depl.GetLocked(),
deplIsPlatformAuthEnabled: depl.GetIsPlatformAuthenticationEnabled(),
deplDropVSTSupportFieldName: depl.GetDropVstSupport(),
}
if notificationSetting != nil {
result[deplNotificationConfigurationFieldName] = notificationSetting
Expand Down Expand Up @@ -808,6 +821,9 @@ func resourceDeploymentUpdate(ctx context.Context, d *schema.ResourceData, m int
if d.HasChange(deplLockedFieldName) {
depl.Locked = d.Get(deplLockedFieldName).(bool)
}
if d.HasChange(deplDropVSTSupportFieldName) {
depl.DropVstSupport = d.Get(deplDropVSTSupportFieldName).(bool)
}

if d.HasChange(deplDeploymentProfileIDFieldName) {
return diag.FromErr(errors.New("deployment profile id cannot be changed"))
Expand Down
130 changes: 130 additions & 0 deletions internal/resource_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func TestFlattenDeploymentResource(t *testing.T) {
deplLockedFieldName: false,
deplDeploymentProfileIDFieldName: deploymentProfileTestID,
deplIsPlatformAuthEnabled: false,
deplDropVSTSupportFieldName: false,
}
assert.Equal(t, expected, flattened)
}
Expand Down Expand Up @@ -191,6 +192,69 @@ func TestFlattenDeploymentResourcePlatformAuthentication(t *testing.T) {
deplDisableScheduledRootPasswordRotationFieldName: false,
deplLockedFieldName: true,
deplIsPlatformAuthEnabled: true,
deplDropVSTSupportFieldName: false,
}
assert.Equal(t, expected, flattened)
}

// TestFlattenDeploymentResourceDropVSTSupport tests the Oasis Deployment flattening with DropVSTSupport set to true.
func TestFlattenDeploymentResourceDropVSTSupport(t *testing.T) {
depl := &data.Deployment{
Name: "test-name",
Description: "test-desc",
ProjectId: "123456789",
RegionId: "gcp-europe-west4",
Version: "3.9.1",
Certificates: &data.Deployment_CertificateSpec{
CaCertificateId: "certificate-id",
},
IpallowlistId: "ip-allowlist",
DisableFoxxAuthentication: true,
Model: &data.Deployment_ModelSpec{
Model: "oneshard",
NodeSizeId: "a8",
NodeCount: 3,
NodeDiskSize: 32,
},
IsScheduledRootPasswordRotationEnabled: true,
Locked: true,
DropVstSupport: true,
}
flattened := flattenDeployment(depl)
expected := map[string]interface{}{
deplProjectFieldName: "123456789",
deplNameFieldName: "test-name",
deplDescriptionFieldName: "test-desc",
deplLocationFieldName: []interface{}{
map[string]interface{}{
deplLocationRegionFieldName: "gcp-europe-west4",
},
},
deplVersionFieldName: []interface{}{
map[string]interface{}{
deplVersionDbVersionFieldName: "3.9.1",
},
},
deplSecurityFieldName: []interface{}{
map[string]interface{}{
deplSecurityCaCertificateFieldName: "certificate-id",
deplSecurityIpAllowlistFieldName: "ip-allowlist",
deplSecurityDisableFoxxAuthenticationFieldName: true,
},
},
deplConfigurationFieldName: []interface{}{
map[string]interface{}{
deplConfigurationModelFieldName: "oneshard",
deplConfigurationNodeSizeIdFieldName: "a8",
deplConfigurationNodeCountFieldName: 3,
deplConfigurationNodeDiskSizeFieldName: 32,
},
},
deplDiskPerformanceFieldName: "", // Not set
deplDisableScheduledRootPasswordRotationFieldName: false,
deplLockedFieldName: true,
deplIsPlatformAuthEnabled: false,
deplDropVSTSupportFieldName: true,
}
assert.Equal(t, expected, flattened)
}
Expand Down Expand Up @@ -251,6 +315,7 @@ func TestFlattenDeploymentResourceDisableFoxxAuth(t *testing.T) {
deplDisableScheduledRootPasswordRotationFieldName: false,
deplLockedFieldName: true,
deplIsPlatformAuthEnabled: false,
deplDropVSTSupportFieldName: false,
}
assert.Equal(t, expected, flattened)
}
Expand Down Expand Up @@ -319,6 +384,7 @@ func TestFlattenDeploymentResourceNotificationSettings(t *testing.T) {
deplDisableScheduledRootPasswordRotationFieldName: true,
deplLockedFieldName: true,
deplIsPlatformAuthEnabled: false,
deplDropVSTSupportFieldName: false,
}
assert.Equal(t, expected, flattened)
}
Expand Down Expand Up @@ -393,6 +459,70 @@ func TestExpandingDeploymentResource(t *testing.T) {
assert.Equal(t, depl, expandedDepl)
}

// TestExpandingDeploymentResourceDropVSTSupport tests the Oasis Deployment expansion with DropVSTSupport set to true.
func TestExpandingDeploymentResourceDropVSTSupport(t *testing.T) {
depl := &data.Deployment{
Name: "test-name",
Description: "test-desc",
ProjectId: "123456789",
RegionId: "gcp-europe-west4",
Version: "3.9.1",
Certificates: &data.Deployment_CertificateSpec{
CaCertificateId: "certificate-id",
},
IpallowlistId: "ip-allowlist",
DisableFoxxAuthentication: true,
Model: &data.Deployment_ModelSpec{
Model: "oneshard",
NodeSizeId: "a8",
NodeCount: 3,
NodeDiskSize: 32,
},
IsScheduledRootPasswordRotationEnabled: true,
Locked: true,
DropVstSupport: true,
}
raw := map[string]interface{}{
deplProjectFieldName: "123456789",
deplNameFieldName: "test-name",
deplDescriptionFieldName: "test-desc",
deplLocationFieldName: []interface{}{
map[string]interface{}{
deplLocationRegionFieldName: "gcp-europe-west4",
},
},
deplVersionFieldName: []interface{}{
map[string]interface{}{
deplVersionDbVersionFieldName: "3.9.1",
},
},
deplSecurityFieldName: []interface{}{
map[string]interface{}{
deplSecurityCaCertificateFieldName: "certificate-id",
deplSecurityIpAllowlistFieldName: "ip-allowlist",
deplSecurityDisableFoxxAuthenticationFieldName: true,
},
},
deplConfigurationFieldName: []interface{}{
map[string]interface{}{
deplConfigurationModelFieldName: "oneshard",
deplConfigurationNodeSizeIdFieldName: "a8",
deplConfigurationNodeCountFieldName: 3,
deplConfigurationNodeDiskSizeFieldName: 32,
},
},
deplDisableScheduledRootPasswordRotationFieldName: false,
deplLockedFieldName: true,
deplIsPlatformAuthEnabled: false,
deplDropVSTSupportFieldName: true,
}
s := resourceDeployment().Schema
resourceData := schema.TestResourceDataRaw(t, s, raw)
expandedDepl, err := expandDeploymentResource(resourceData, "123456789")
assert.NoError(t, err)
assert.Equal(t, depl, expandedDepl)
}

// TestExpandingDeploymentResourceDisableFoxxAuth tests the Oasis Deployment expansion with DisableFoxxAuthentication set to true.
func TestExpandingDeploymentResourceDisableFoxxAuth(t *testing.T) {
depl := &data.Deployment{
Expand Down

0 comments on commit 314f264

Please sign in to comment.