-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor remaining resources and data sources (#522)
* Refactor cyral_integration_* * Remove dead code * Refactor cyral_policy * Refactor cyral_user_account * Refactor cyral_policy_rule and fix error in cyral_service_account * Refactor cyral_role and cyral_rego_policy_instance * Deprecate cyral_saml_configuration and improve deprecation messages * Refactor cyral_sidecar_instance, cyral_sidecar_instance_stats and cyral_system_info * Improve package names;refactor cyral_sidecar_health, cyral_permission * Fix error handlers to avoid states getting out-of-sync * Update cyral/internal/regopolicy/schema_loader.go Co-authored-by: Victor Moraes <[email protected]> --------- Co-authored-by: Victor Moraes <[email protected]>
- Loading branch information
Showing
130 changed files
with
2,365 additions
and
1,899 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...a_source_cyral_saml_configuration_test.go → ...a_source_cyral_saml_configuration_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package samlconfiguration_test | ||
package deprecated_test | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package awsiam | ||
|
||
const ( | ||
resourceName = "cyral_integration_aws_iam" | ||
|
||
AWSIAMIntegrationNameKey = "name" | ||
AWSIAMIntegratioNDescriptionKey = "description" | ||
AWSIAMIntegrationARNsKey = "role_arns" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package awsiam | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
type AWSIAMIntegrationWrapper struct { | ||
Integration *AWSIAMIntegration `json:"iamIntegration"` | ||
} | ||
|
||
type AWSIAMIntegration struct { | ||
ID string `json:"id,omitempty"` | ||
Name string `json:"name"` | ||
Description string `json:"description"` | ||
IAMRoleARNs []string `json:"iamRoleARNs"` | ||
} | ||
|
||
func (wrapper AWSIAMIntegrationWrapper) WriteToSchema(d *schema.ResourceData) error { | ||
integration := wrapper.Integration | ||
|
||
d.SetId(integration.ID) | ||
|
||
if err := d.Set(AWSIAMIntegrationNameKey, integration.Name); err != nil { | ||
return fmt.Errorf("error setting '%s': %w", AWSIAMIntegrationNameKey, err) | ||
} | ||
|
||
if err := d.Set(AWSIAMIntegratioNDescriptionKey, integration.Description); err != nil { | ||
return fmt.Errorf("error setting '%s': %w", AWSIAMIntegratioNDescriptionKey, err) | ||
} | ||
|
||
if err := d.Set(AWSIAMIntegrationARNsKey, integration.IAMRoleARNs); err != nil { | ||
return fmt.Errorf("error setting '%s': %w", AWSIAMIntegrationARNsKey, err) | ||
} | ||
return nil | ||
} | ||
|
||
func (wrapper *AWSIAMIntegrationWrapper) ReadFromSchema(d *schema.ResourceData) error { | ||
wrapper.Integration = &AWSIAMIntegration{} | ||
|
||
wrapper.Integration.Name = d.Get(AWSIAMIntegrationNameKey).(string) | ||
wrapper.Integration.Description = d.Get(AWSIAMIntegratioNDescriptionKey).(string) | ||
|
||
arns := d.Get(AWSIAMIntegrationARNsKey).([]interface{}) | ||
stringARNs := make([]string, 0, len(arns)) | ||
for _, arn := range arns { | ||
stringARNs = append(stringARNs, arn.(string)) | ||
} | ||
|
||
wrapper.Integration.IAMRoleARNs = stringARNs | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package awsiam | ||
|
||
import "github.com/cyralinc/terraform-provider-cyral/cyral/core" | ||
|
||
type packageSchema struct { | ||
} | ||
|
||
func (p *packageSchema) Name() string { | ||
return "integration.awsiam" | ||
} | ||
|
||
func (p *packageSchema) Schemas() []*core.SchemaDescriptor { | ||
return []*core.SchemaDescriptor{ | ||
{ | ||
Name: resourceName, | ||
Type: core.ResourceSchemaType, | ||
Schema: resourceSchema, | ||
}, | ||
} | ||
} | ||
|
||
func PackageSchema() core.PackageSchema { | ||
return &packageSchema{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package confextension | ||
|
||
const ( | ||
authorizationPurpose = "authorization" | ||
builtinCategory = "builtin" | ||
|
||
PagerDutyTemplateType = "pagerduty" | ||
DuoMFATemplateType = "duoMfa" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package mfaduo | ||
|
||
const ( | ||
resourceName = "cyral_integration_mfa_duo" | ||
) |
17 changes: 6 additions & 11 deletions
17
...duo/resource_cyral_integration_mfa_duo.go → ...egration/confextension/mfaduo/resource.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.