cyralinc / terraform-provider-cyral

Cyral Terraform Provider
https://registry.terraform.io/providers/cyralinc/cyral/latest
Apache License 2.0
13 stars 3 forks source link

Refactor remaining resources and data sources #522

Closed wcmjunior closed 7 months ago

wcmjunior commented 7 months ago

Description of the change

Refactor the following resources and data sources:

Type of change

Checklists

Development

Code review

Testing

Besides running acceptance tests (see results below), I also ran the following manual tests for each changed resource:

  1. Created resource using previous version of the provider and upgraded to make sure no changes are pointed in a next terraform apply;
  2. Created resource with the new version of the provider, deleted the resource manually via API and ran terraform apply again. The provider successfully suggested the creation of a new resource and did not error out.
  3. Created resource with the new version of the provider, deleted the resource manually via API and ran terraform destroy. The provider successfully remove the resource from the state completing the destroy command without erroring out.

Acceptance test results:


make local/test
go test github.com/cyralinc/terraform-provider-cyral/... -v -race -timeout 20m
?       github.com/cyralinc/terraform-provider-cyral    [no test files]
?       github.com/cyralinc/terraform-provider-cyral/cyral/core [no test files]
?       github.com/cyralinc/terraform-provider-cyral/cyral/core/types/operationtype     [no test files]
?       github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype      [no test files]
=== RUN   TestNewClient_WhenTLSSkipVerifyIsEnabled_ThenInsecureSkipVerifyIsTrue
--- PASS: TestNewClient_WhenTLSSkipVerifyIsEnabled_ThenInsecureSkipVerifyIsTrue (0.00s)
=== RUN   TestNewClient_WhenTLSSkipVerifyIsDisabled_ThenInsecureSkipVerifyIsFalse
--- PASS: TestNewClient_WhenTLSSkipVerifyIsDisabled_ThenInsecureSkipVerifyIsFalse (0.00s)
=== RUN   TestNewClient_WhenClientIDIsEmpty_ThenThrowError
--- PASS: TestNewClient_WhenClientIDIsEmpty_ThenThrowError (0.00s)
=== RUN   TestNewClient_WhenClientSecretIsEmpty_ThenThrowError
--- PASS: TestNewClient_WhenClientSecretIsEmpty_ThenThrowError (0.00s)
=== RUN   TestNewClient_WhenControlPlaneIsEmpty_ThenThrowError
--- PASS: TestNewClient_WhenControlPlaneIsEmpty_ThenThrowError (0.00s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/client       (cached)
?       github.com/cyralinc/terraform-provider-cyral/cyral/internal/datalabel/classificationrule        [no test files]
?       github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/confextension   [no test files]
=== RUN   TestAccDatalabelDataSource
=== PAUSE TestAccDatalabelDataSource
=== RUN   TestAccDatalabelResource
--- PASS: TestAccDatalabelResource (5.12s)
=== CONT  TestAccDatalabelDataSource
--- PASS: TestAccDatalabelDataSource (25.11s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/datalabel   31.670s
=== RUN   TestAccSidecarInstanceIDsDataSource
=== PAUSE TestAccSidecarInstanceIDsDataSource
=== RUN   TestIntegrationsData_GetValue_Default
--- PASS: TestIntegrationsData_GetValue_Default (0.00s)
=== RUN   TestIntegrationsData_GetValue_Splunk
--- PASS: TestIntegrationsData_GetValue_Splunk (0.00s)
=== RUN   TestAccDatadogIntegrationResource
=== PAUSE TestAccDatadogIntegrationResource
=== RUN   TestAccELKIntegrationResource
=== PAUSE TestAccELKIntegrationResource
=== RUN   TestAccIdPIntegrationResource
=== PAUSE TestAccIdPIntegrationResource
=== RUN   TestAccLogstashIntegrationResource
=== PAUSE TestAccLogstashIntegrationResource
=== RUN   TestAccLookerIntegrationResource
=== PAUSE TestAccLookerIntegrationResource
=== RUN   TestAccSplunkIntegrationResource
=== PAUSE TestAccSplunkIntegrationResource
=== RUN   TestAccSumoLogicIntegrationResource
=== PAUSE TestAccSumoLogicIntegrationResource
=== CONT  TestAccSumoLogicIntegrationResource
=== CONT  TestAccSidecarInstanceIDsDataSource
=== CONT  TestAccSplunkIntegrationResource
=== CONT  TestAccLogstashIntegrationResource
=== CONT  TestAccIdPIntegrationResource
=== CONT  TestAccELKIntegrationResource
=== CONT  TestAccDatadogIntegrationResource
=== CONT  TestAccLookerIntegrationResource
--- PASS: TestAccELKIntegrationResource (12.54s)
--- PASS: TestAccDatadogIntegrationResource (12.81s)
--- PASS: TestAccSumoLogicIntegrationResource (12.85s)
--- PASS: TestAccSplunkIntegrationResource (13.10s)
--- PASS: TestAccLookerIntegrationResource (14.31s)
--- PASS: TestAccSidecarInstanceIDsDataSource (14.74s)
--- PASS: TestAccLogstashIntegrationResource (18.95s)
--- PASS: TestAccIdPIntegrationResource (50.09s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/deprecated  51.896s
=== RUN   TestIntegrationAWSIAMAuthN
=== PAUSE TestIntegrationAWSIAMAuthN
=== CONT  TestIntegrationAWSIAMAuthN
--- PASS: TestIntegrationAWSIAMAuthN (19.98s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/awsiam  22.153s
=== RUN   TestAccDuoMFAIntegrationResource
=== PAUSE TestAccDuoMFAIntegrationResource
=== CONT  TestAccDuoMFAIntegrationResource
--- PASS: TestAccDuoMFAIntegrationResource (8.60s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/confextension/mfaduo    11.151s
=== RUN   TestAccPagerDutyIntegrationResource
=== PAUSE TestAccPagerDutyIntegrationResource
=== CONT  TestAccPagerDutyIntegrationResource
--- PASS: TestAccPagerDutyIntegrationResource (9.19s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/confextension/pagerduty 11.715s
=== RUN   TestAccHCVaultIntegrationResource
=== PAUSE TestAccHCVaultIntegrationResource
=== CONT  TestAccHCVaultIntegrationResource
--- PASS: TestAccHCVaultIntegrationResource (8.74s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/hcvault 11.594s
=== RUN   TestAccIntegrationIdPSAMLDataSource
=== PAUSE TestAccIntegrationIdPSAMLDataSource
=== RUN   TestAccIntegrationIdPSAMLResource
=== PAUSE TestAccIntegrationIdPSAMLResource
=== CONT  TestAccIntegrationIdPSAMLResource
=== CONT  TestAccIntegrationIdPSAMLDataSource
--- PASS: TestAccIntegrationIdPSAMLResource (29.79s)
--- PASS: TestAccIntegrationIdPSAMLDataSource (30.82s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/idpsaml 34.057s
=== RUN   TestAccIntegrationIdPSAMLDraftResource
=== PAUSE TestAccIntegrationIdPSAMLDraftResource
=== CONT  TestAccIntegrationIdPSAMLDraftResource
--- PASS: TestAccIntegrationIdPSAMLDraftResource (15.10s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/idpsaml/draft   18.705s
=== RUN   TestAccLoggingIntegrationDataSource
=== PAUSE TestAccLoggingIntegrationDataSource
=== RUN   TestAccLogsIntegrationResourceCloudWatch
=== PAUSE TestAccLogsIntegrationResourceCloudWatch
=== RUN   TestAccLogsIntegrationResourceDataDog
=== PAUSE TestAccLogsIntegrationResourceDataDog
=== RUN   TestAccLogsIntegrationResourceElk
=== PAUSE TestAccLogsIntegrationResourceElk
=== RUN   TestAccLogsIntegrationResourceElkEmptyEsCredentials
=== PAUSE TestAccLogsIntegrationResourceElkEmptyEsCredentials
=== RUN   TestAccLogsIntegrationResourceSplunk
=== PAUSE TestAccLogsIntegrationResourceSplunk
=== RUN   TestAccLogsIntegrationResourceSumologic
=== PAUSE TestAccLogsIntegrationResourceSumologic
=== RUN   TestAccLogsIntegrationResourceFluentbit
=== PAUSE TestAccLogsIntegrationResourceFluentbit
=== CONT  TestAccLogsIntegrationResourceCloudWatch
=== CONT  TestAccLogsIntegrationResourceElkEmptyEsCredentials
=== CONT  TestAccLogsIntegrationResourceDataDog
=== CONT  TestAccLogsIntegrationResourceSplunk
=== CONT  TestAccLogsIntegrationResourceElk
=== CONT  TestAccLogsIntegrationResourceSumologic
=== CONT  TestAccLoggingIntegrationDataSource
=== CONT  TestAccLogsIntegrationResourceFluentbit
--- PASS: TestAccLogsIntegrationResourceFluentbit (12.14s)
--- PASS: TestAccLogsIntegrationResourceDataDog (13.49s)
--- PASS: TestAccLogsIntegrationResourceElk (13.56s)
--- PASS: TestAccLogsIntegrationResourceSumologic (13.92s)
--- PASS: TestAccLogsIntegrationResourceCloudWatch (15.05s)
--- PASS: TestAccLogsIntegrationResourceSplunk (15.06s)
--- PASS: TestAccLogsIntegrationResourceElkEmptyEsCredentials (15.43s)
--- PASS: TestAccLoggingIntegrationDataSource (17.24s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/logging 20.929s
=== RUN   TestAccSlackAlertsIntegrationResource
=== PAUSE TestAccSlackAlertsIntegrationResource
=== CONT  TestAccSlackAlertsIntegrationResource
--- PASS: TestAccSlackAlertsIntegrationResource (9.78s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/slack   13.833s
=== RUN   TestAccMsTeamsIntegrationResource
=== PAUSE TestAccMsTeamsIntegrationResource
=== CONT  TestAccMsTeamsIntegrationResource
--- PASS: TestAccMsTeamsIntegrationResource (8.07s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/integration/teams   9.499s
=== RUN   TestAccPermissionDataSource
=== PAUSE TestAccPermissionDataSource
=== CONT  TestAccPermissionDataSource
--- PASS: TestAccPermissionDataSource (4.33s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/permission  5.750s
=== RUN   TestAccPolicyResource
=== PAUSE TestAccPolicyResource
=== CONT  TestAccPolicyResource
--- PASS: TestAccPolicyResource (10.57s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/policy      12.249s
=== RUN   TestAccPolicyRuleResource
=== PAUSE TestAccPolicyRuleResource
=== RUN   TestPolicyRuleResourceUpgradeV0
--- PASS: TestPolicyRuleResourceUpgradeV0 (0.00s)
=== CONT  TestAccPolicyRuleResource
--- PASS: TestAccPolicyRuleResource (21.31s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/policy/rule 22.762s
=== RUN   TestAccRegoPolicyInstanceResource
=== PAUSE TestAccRegoPolicyInstanceResource
=== CONT  TestAccRegoPolicyInstanceResource
--- PASS: TestAccRegoPolicyInstanceResource (10.03s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/regopolicy  11.468s
=== RUN   TestAccRepositoryDataSource
=== PAUSE TestAccRepositoryDataSource
=== RUN   TestAccRepositoryResource
=== PAUSE TestAccRepositoryResource
=== CONT  TestAccRepositoryDataSource
=== CONT  TestAccRepositoryResource
--- PASS: TestAccRepositoryDataSource (16.41s)
--- PASS: TestAccRepositoryResource (21.99s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository  23.433s
=== RUN   TestAccRepositoryAccessGatewayResource
=== PAUSE TestAccRepositoryAccessGatewayResource
=== CONT  TestAccRepositoryAccessGatewayResource
--- PASS: TestAccRepositoryAccessGatewayResource (26.52s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/accessgateway    27.948s
=== RUN   TestAccRepositoryAccessRulesResource
=== PAUSE TestAccRepositoryAccessRulesResource
=== CONT  TestAccRepositoryAccessRulesResource
--- PASS: TestAccRepositoryAccessRulesResource (17.80s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/accessrules      19.560s
=== RUN   TestAccRepositoryBindingResource
=== PAUSE TestAccRepositoryBindingResource
=== CONT  TestAccRepositoryBindingResource
--- PASS: TestAccRepositoryBindingResource (15.44s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/binding  17.096s
=== RUN   TestAccRepositoryConfAnalysisResource
=== PAUSE TestAccRepositoryConfAnalysisResource
=== RUN   TestRepositoryConfAnalysisResourceUpgradeV0
--- PASS: TestRepositoryConfAnalysisResourceUpgradeV0 (0.00s)
=== CONT  TestAccRepositoryConfAnalysisResource
--- PASS: TestAccRepositoryConfAnalysisResource (9.72s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/confanalysis     11.140s
=== RUN   TestAccRepositoryConfAuthResource
=== PAUSE TestAccRepositoryConfAuthResource
=== RUN   TestRepositoryConfAuthResourceUpgradeV0
--- PASS: TestRepositoryConfAuthResourceUpgradeV0 (0.00s)
=== CONT  TestAccRepositoryConfAuthResource
--- PASS: TestAccRepositoryConfAuthResource (17.10s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/confauth 18.531s
=== RUN   TestAccRepositoryDatamapResource
=== PAUSE TestAccRepositoryDatamapResource
=== CONT  TestAccRepositoryDatamapResource
--- PASS: TestAccRepositoryDatamapResource (22.61s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/datamap  24.032s
=== RUN   TestAccRepositoryNetworkAccessPolicyResource
=== PAUSE TestAccRepositoryNetworkAccessPolicyResource
=== CONT  TestAccRepositoryNetworkAccessPolicyResource
--- PASS: TestAccRepositoryNetworkAccessPolicyResource (22.21s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/network  23.634s
=== RUN   TestAccRepositoryUserAccountResource
=== PAUSE TestAccRepositoryUserAccountResource
=== CONT  TestAccRepositoryUserAccountResource
--- PASS: TestAccRepositoryUserAccountResource (44.60s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/repository/useraccount      46.058s
=== RUN   TestAccRoleDataSource
=== PAUSE TestAccRoleDataSource
=== RUN   TestAccRoleResource
=== PAUSE TestAccRoleResource
=== CONT  TestAccRoleResource
=== CONT  TestAccRoleDataSource
--- PASS: TestAccRoleDataSource (8.38s)
--- PASS: TestAccRoleResource (18.85s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/role        20.289s
=== RUN   TestAccRoleSSOGroupsResource
=== PAUSE TestAccRoleSSOGroupsResource
=== RUN   TestRoleSSOGroupsResourceUpgradeV0
--- PASS: TestRoleSSOGroupsResourceUpgradeV0 (0.00s)
=== CONT  TestAccRoleSSOGroupsResource
--- PASS: TestAccRoleSSOGroupsResource (15.36s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/role/ssogroups      16.791s
=== RUN   TestAccSAMLCertificateDataSource
=== PAUSE TestAccSAMLCertificateDataSource
=== CONT  TestAccSAMLCertificateDataSource
--- PASS: TestAccSAMLCertificateDataSource (4.46s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/samlcertificate     5.888s
=== RUN   TestAccSAMLConfigurationDataSource
=== PAUSE TestAccSAMLConfigurationDataSource
=== CONT  TestAccSAMLConfigurationDataSource
--- PASS: TestAccSAMLConfigurationDataSource (8.58s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/samlconfiguration   10.009s
=== RUN   TestAccServiceAccountResource
=== PAUSE TestAccServiceAccountResource
=== CONT  TestAccServiceAccountResource
--- PASS: TestAccServiceAccountResource (20.62s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/serviceaccount      22.056s
=== RUN   TestAccSidecarBoundPortsDataSource
=== PAUSE TestAccSidecarBoundPortsDataSource
=== RUN   TestAccSidecarIDDataSource
=== PAUSE TestAccSidecarIDDataSource
=== RUN   TestAccSidecarResource
=== PAUSE TestAccSidecarResource
=== CONT  TestAccSidecarResource
=== CONT  TestAccSidecarIDDataSource
=== CONT  TestAccSidecarBoundPortsDataSource
--- PASS: TestAccSidecarIDDataSource (8.55s)
--- PASS: TestAccSidecarBoundPortsDataSource (16.76s)
--- PASS: TestAccSidecarResource (24.54s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/sidecar     25.973s
=== RUN   TestAccSidecarCredentialsResource
=== PAUSE TestAccSidecarCredentialsResource
=== CONT  TestAccSidecarCredentialsResource
--- PASS: TestAccSidecarCredentialsResource (6.33s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/sidecar/credentials 8.069s
=== RUN   TestAccSidecarHealthDataSource
=== PAUSE TestAccSidecarHealthDataSource
=== CONT  TestAccSidecarHealthDataSource
--- PASS: TestAccSidecarHealthDataSource (6.80s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/sidecar/health      8.228s
=== RUN   TestAccSidecarInstanceStatsDataSource
=== PAUSE TestAccSidecarInstanceStatsDataSource
=== RUN   TestAccSidecarInstanceDataSource
=== PAUSE TestAccSidecarInstanceDataSource
=== CONT  TestAccSidecarInstanceStatsDataSource
=== CONT  TestAccSidecarInstanceDataSource
--- PASS: TestAccSidecarInstanceStatsDataSource (5.43s)
--- PASS: TestAccSidecarInstanceDataSource (7.81s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/sidecar/instance    9.232s
=== RUN   TestAccSidecarListenerDataSource
=== PAUSE TestAccSidecarListenerDataSource
=== RUN   TestSidecarListenerResource
=== PAUSE TestSidecarListenerResource
=== CONT  TestAccSidecarListenerDataSource
=== CONT  TestSidecarListenerResource
--- PASS: TestAccSidecarListenerDataSource (18.79s)
--- PASS: TestSidecarListenerResource (34.76s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/sidecar/listener    36.216s
testing: warning: no tests to run
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/sweep       1.386s [no tests to run]
=== RUN   TestAccSystemInfoDataSource
=== PAUSE TestAccSystemInfoDataSource
=== CONT  TestAccSystemInfoDataSource
--- PASS: TestAccSystemInfoDataSource (3.84s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/systeminfo  5.263s
=== RUN   TestAccAccessTokenSettingsResource
=== PAUSE TestAccAccessTokenSettingsResource
=== CONT  TestAccAccessTokenSettingsResource
--- PASS: TestAccAccessTokenSettingsResource (13.79s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/internal/tokensettings       15.205s
=== RUN   TestAccProvider
--- PASS: TestAccProvider (0.00s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/provider     1.310s
=== RUN   TestElementsMatch
--- PASS: TestElementsMatch (0.00s)
PASS
ok      github.com/cyralinc/terraform-provider-cyral/cyral/utils        (cached)```
sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Issues
9 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
5.2% Duplication on New Code

See analysis details on SonarCloud