Skip to content

Commit

Permalink
rename GenericContextHandler to ContextHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursnerdly committed Dec 7, 2024
1 parent e6c1471 commit 1d8f41f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (

type ResourceMethod func(context.Context, *client.Client, *schema.ResourceData) error

// GenericContextHandler can be used by resource implementations to ensure that
// ContextHandler can be used by resource implementations to ensure that
// the recommended best practices are consistently followed (e.g., handling of
// 404 errors, following a create/update with a get etc). The resource implementation
// needs to supply functions that implement the basic CRUD operations on the resource
// using gRPC or whatever else. Note that if REST APIs are used, it is recommended
// to use the DefaultContextHandler instead.
type GenericContextHandler struct {
type ContextHandler struct {
ResourceName string
ResourceType resourcetype.ResourceType
Create ResourceMethod
Expand All @@ -39,7 +39,7 @@ type method struct {
errorHandler func(context.Context, *schema.ResourceData, error) error
}

func (gch *GenericContextHandler) handleResourceNotFoundError(
func (gch *ContextHandler) handleResourceNotFoundError(
ctx context.Context, rd *schema.ResourceData, err error,
) error {
var isNotFoundError bool
Expand All @@ -64,7 +64,7 @@ func (gch *GenericContextHandler) handleResourceNotFoundError(
}

// CreateContext is used to create a resource instance.
func (gch *GenericContextHandler) CreateContext(
func (gch *ContextHandler) CreateContext(
ctx context.Context,
rd *schema.ResourceData,
pd any,
Expand All @@ -86,7 +86,7 @@ func (gch *GenericContextHandler) CreateContext(
}

// UpdateContext is used to update a resource instance.
func (gch *GenericContextHandler) UpdateContext(
func (gch *ContextHandler) UpdateContext(
ctx context.Context,
rd *schema.ResourceData,
pd any,
Expand All @@ -108,7 +108,7 @@ func (gch *GenericContextHandler) UpdateContext(
}

// ReadContext is used to read a resource instance.
func (gch *GenericContextHandler) ReadContext(
func (gch *ContextHandler) ReadContext(
ctx context.Context,
rd *schema.ResourceData,
pd any,
Expand All @@ -126,7 +126,7 @@ func (gch *GenericContextHandler) ReadContext(
}

// DeleteContext is used to delete a resource instance.
func (gch *GenericContextHandler) DeleteContext(
func (gch *ContextHandler) DeleteContext(
ctx context.Context,
rd *schema.ResourceData,
pd any,
Expand All @@ -143,7 +143,7 @@ func (gch *GenericContextHandler) DeleteContext(
)
}

func (gch *GenericContextHandler) executeMethods(
func (gch *ContextHandler) executeMethods(
ctx context.Context, c *client.Client, rd *schema.ResourceData, methods []method,
) diag.Diagnostics {
for _, m := range methods {
Expand Down
2 changes: 1 addition & 1 deletion cyral/internal/policy/v2/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/cyralinc/terraform-provider-cyral/cyral/core/types/resourcetype"
)

var dsContextHandler = core.GenericContextHandler{
var dsContextHandler = core.ContextHandler{
ResourceName: dataSourceName,
ResourceType: resourcetype.DataSource,
Read: readPolicy,
Expand Down
2 changes: 1 addition & 1 deletion cyral/internal/policy/v2/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/cyralinc/terraform-provider-cyral/cyral/utils"
)

var resourceContextHandler = core.GenericContextHandler{
var resourceContextHandler = core.ContextHandler{
ResourceName: resourceName,
ResourceType: resourcetype.Resource,
Create: createPolicy,
Expand Down

0 comments on commit 1d8f41f

Please sign in to comment.