Skip to content

Commit

Permalink
use standard variable naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursnerdly committed Dec 17, 2024
1 parent ca539a6 commit 791d7d8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions cyral/internal/policy/set/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package policyset

const (
policySetResourceName = "cyral_policy_set"
policySetDataSourceName = policySetResourceName
resourceName = "cyral_policy_set"
dataSourceName = resourceName
)
8 changes: 4 additions & 4 deletions cyral/internal/policy/set/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 4 additions & 4 deletions cyral/internal/policy/set/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions cyral/internal/policy/set/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ 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,
Update: updatePolicySet,
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,
},
Expand Down
8 changes: 4 additions & 4 deletions cyral/internal/policy/set/schema_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion cyral/internal/policy/wizard/constants.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package wizard

const (
policyWizardsDataSourceName = "cyral_policy_wizards"
dataSourceName = "cyral_policy_wizards"
)
8 changes: 4 additions & 4 deletions cyral/internal/policy/wizard/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
4 changes: 2 additions & 2 deletions cyral/internal/policy/wizard/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions cyral/internal/policy/wizard/schema_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}
Expand Down

0 comments on commit 791d7d8

Please sign in to comment.