From 791d7d8ac22ddf53f05a492c3d9bca04b0be07f7 Mon Sep 17 00:00:00 2001 From: Deepak Gupta Date: Tue, 17 Dec 2024 09:48:56 -0500 Subject: [PATCH] use standard variable naming convention --- cyral/internal/policy/set/constants.go | 4 ++-- cyral/internal/policy/set/datasource.go | 8 ++++---- cyral/internal/policy/set/model.go | 8 ++++---- cyral/internal/policy/set/resource.go | 14 +++++++------- cyral/internal/policy/set/schema_loader.go | 8 ++++---- cyral/internal/policy/wizard/constants.go | 2 +- cyral/internal/policy/wizard/datasource.go | 8 ++++---- cyral/internal/policy/wizard/model.go | 4 ++-- cyral/internal/policy/wizard/schema_loader.go | 4 ++-- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/cyral/internal/policy/set/constants.go b/cyral/internal/policy/set/constants.go index 0b588850..cceefe56 100644 --- a/cyral/internal/policy/set/constants.go +++ b/cyral/internal/policy/set/constants.go @@ -1,6 +1,6 @@ package policyset const ( - policySetResourceName = "cyral_policy_set" - policySetDataSourceName = policySetResourceName + resourceName = "cyral_policy_set" + dataSourceName = resourceName ) diff --git a/cyral/internal/policy/set/datasource.go b/cyral/internal/policy/set/datasource.go index c2a3575f..844c5077 100644 --- a/cyral/internal/policy/set/datasource.go +++ b/cyral/internal/policy/set/datasource.go @@ -7,16 +7,16 @@ import ( "github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype" ) -var policySetDataSourceContextHandler = core.ContextHandler{ - ResourceName: policySetDataSourceName, +var dsContextHandler = core.ContextHandler{ + ResourceName: dataSourceName, ResourceType: resourcetype.DataSource, Read: readPolicySet, } -func policySetDataSourceSchema() *schema.Resource { +func dataSourceSchema() *schema.Resource { return &schema.Resource{ Description: "This data source provides information about a policy set.", - ReadContext: policySetDataSourceContextHandler.ReadContext, + ReadContext: dsContextHandler.ReadContext, Schema: map[string]*schema.Schema{ "id": { Description: "Identifier for the policy set.", diff --git a/cyral/internal/policy/set/model.go b/cyral/internal/policy/set/model.go index 37c3d251..fc1941f8 100644 --- a/cyral/internal/policy/set/model.go +++ b/cyral/internal/policy/set/model.go @@ -47,8 +47,8 @@ func scopeToMap(s *msg.Scope) []map[string]interface{} { } } -// updatePolicySetSchema writes the policy set data to the schema -func updatePolicySetSchema(ps *msg.PolicySet, d *schema.ResourceData) error { +// updateSchema writes the policy set data to the schema +func updateSchema(ps *msg.PolicySet, d *schema.ResourceData) error { if err := d.Set("id", ps.GetId()); err != nil { return fmt.Errorf("error setting 'id' field: %w", err) } @@ -141,7 +141,7 @@ func readPolicySet(ctx context.Context, cl *client.Client, rd *schema.ResourceDa if err != nil { return err } - return updatePolicySetSchema(resp.GetPolicySet(), rd) + return updateSchema(resp.GetPolicySet(), rd) } func updatePolicySet(ctx context.Context, cl *client.Client, rd *schema.ResourceData) error { @@ -155,7 +155,7 @@ func updatePolicySet(ctx context.Context, cl *client.Client, rd *schema.Resource if err != nil { return err } - return updatePolicySetSchema(resp.GetPolicySet(), rd) + return updateSchema(resp.GetPolicySet(), rd) } func deletePolicySet(ctx context.Context, cl *client.Client, rd *schema.ResourceData) error { diff --git a/cyral/internal/policy/set/resource.go b/cyral/internal/policy/set/resource.go index b6afa0b1..459d0a1c 100644 --- a/cyral/internal/policy/set/resource.go +++ b/cyral/internal/policy/set/resource.go @@ -9,8 +9,8 @@ import ( "github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype" ) -var policySetResourceContextHandler = core.ContextHandler{ - ResourceName: policySetResourceName, +var resourceContextHandler = core.ContextHandler{ + ResourceName: resourceName, ResourceType: resourcetype.Resource, Create: createPolicySet, Read: readPolicySet, @@ -18,13 +18,13 @@ var policySetResourceContextHandler = core.ContextHandler{ Delete: deletePolicySet, } -func policySetResourceSchema() *schema.Resource { +func resourceSchema() *schema.Resource { return &schema.Resource{ Description: "This resource allows management of policy sets in the Cyral platform.", - CreateContext: policySetResourceContextHandler.CreateContext, - ReadContext: policySetResourceContextHandler.ReadContext, - UpdateContext: policySetResourceContextHandler.UpdateContext, - DeleteContext: policySetResourceContextHandler.DeleteContext, + CreateContext: resourceContextHandler.CreateContext, + ReadContext: resourceContextHandler.ReadContext, + UpdateContext: resourceContextHandler.UpdateContext, + DeleteContext: resourceContextHandler.DeleteContext, Importer: &schema.ResourceImporter{ StateContext: importPolicySetStateContext, }, diff --git a/cyral/internal/policy/set/schema_loader.go b/cyral/internal/policy/set/schema_loader.go index b39644d3..37d4a9f3 100644 --- a/cyral/internal/policy/set/schema_loader.go +++ b/cyral/internal/policy/set/schema_loader.go @@ -13,14 +13,14 @@ func (p *packageSchema) Schemas() []*core.SchemaDescriptor { return []*core.SchemaDescriptor{ { - Name: policySetDataSourceName, + Name: dataSourceName, Type: core.DataSourceSchemaType, - Schema: policySetDataSourceSchema, + Schema: dataSourceSchema, }, { - Name: policySetResourceName, + Name: resourceName, Type: core.ResourceSchemaType, - Schema: policySetResourceSchema, + Schema: resourceSchema, }, } } diff --git a/cyral/internal/policy/wizard/constants.go b/cyral/internal/policy/wizard/constants.go index ed6d062a..b8f73ed6 100644 --- a/cyral/internal/policy/wizard/constants.go +++ b/cyral/internal/policy/wizard/constants.go @@ -1,5 +1,5 @@ package wizard const ( - policyWizardsDataSourceName = "cyral_policy_wizards" + dataSourceName = "cyral_policy_wizards" ) diff --git a/cyral/internal/policy/wizard/datasource.go b/cyral/internal/policy/wizard/datasource.go index 631f8560..993c7f07 100644 --- a/cyral/internal/policy/wizard/datasource.go +++ b/cyral/internal/policy/wizard/datasource.go @@ -7,16 +7,16 @@ import ( "github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype" ) -var policyWizardsDataSourceContextHandler = core.ContextHandler{ - ResourceName: policyWizardsDataSourceName, +var dsContextHandler = core.ContextHandler{ + ResourceName: dataSourceName, ResourceType: resourcetype.DataSource, Read: readPolicyWizards, } -func policyWizardsDataSourceSchema() *schema.Resource { +func dataSourceSchema() *schema.Resource { return &schema.Resource{ Description: "This data source provides information policy wizards", - ReadContext: policyWizardsDataSourceContextHandler.ReadContext, + ReadContext: dsContextHandler.ReadContext, Schema: map[string]*schema.Schema{ "wizard_id": { Description: "id of the policy wizard of interest.", diff --git a/cyral/internal/policy/wizard/model.go b/cyral/internal/policy/wizard/model.go index 8eaf3b96..d7eebc0d 100644 --- a/cyral/internal/policy/wizard/model.go +++ b/cyral/internal/policy/wizard/model.go @@ -36,7 +36,7 @@ func readPolicyWizards(ctx context.Context, cl *client.Client, rd *schema.Resour } wizardList = resp.GetPolicyWizards() } - updatePolicyWizardsSchema(wizardList, rd) + updateSchema(wizardList, rd) return nil } @@ -56,7 +56,7 @@ func wizardToMap(wiz *msg.PolicyWizard) map[string]any { } } -func updatePolicyWizardsSchema(wizards []*msg.PolicyWizard, rd *schema.ResourceData) { +func updateSchema(wizards []*msg.PolicyWizard, rd *schema.ResourceData) { wizardList := make([]any, 0, len(wizards)) for _, wiz := range wizards { wizardList = append(wizardList, wizardToMap(wiz)) diff --git a/cyral/internal/policy/wizard/schema_loader.go b/cyral/internal/policy/wizard/schema_loader.go index 558a9e64..25c77562 100644 --- a/cyral/internal/policy/wizard/schema_loader.go +++ b/cyral/internal/policy/wizard/schema_loader.go @@ -12,9 +12,9 @@ func (p *packageSchema) Name() string { func (p *packageSchema) Schemas() []*core.SchemaDescriptor { return []*core.SchemaDescriptor{ { - Name: policyWizardsDataSourceName, + Name: dataSourceName, Type: core.DataSourceSchemaType, - Schema: policyWizardsDataSourceSchema, + Schema: dataSourceSchema, }, } }