Documentation ¶
Overview ¶
Package utils contains multiple utility functions used across the Redpanda's terraform codebase
Package utils contains multiple utility functions used across the Redpanda's terraform codebase
Package utils contains multiple utility functions used across the Redpanda's terraform codebase
Index ¶
- Constants
- func AreWeDoneYet(ctx context.Context, op *controlplanev1beta2.Operation, timeout time.Duration, ...) error
- func CloudProviderToString(provider controlplanev1beta2.CloudProvider) string
- func ClusterTypeToString(provider controlplanev1beta2.Cluster_Type) string
- func ConnectionTypeToString(t controlplanev1beta2.Cluster_ConnectionType) string
- func DeserializeGrpcError(err error) string
- func FindTopicByName(ctx context.Context, topicName string, ...) (*dataplanev1alpha2.ListTopicsResponse_Topic, error)
- func FindUserByName(ctx context.Context, name string, ...) (*dataplanev1alpha2.ListUsersResponse_User, error)
- func GenerateProtobufDiffAndUpdateMask[P interface{ ... }, T any](newMessage, oldMessage P) (*T, *fieldmaskpb.FieldMask)
- func Int32ToNumber(i int32) types.Number
- func IsNotFound(err error) bool
- func MapToCreateTopicConfiguration(cfg types.Map) ([]*dataplanev1alpha2.CreateTopicRequest_Topic_Config, error)
- func MapToSetTopicConfiguration(cfg types.Map) ([]*dataplanev1alpha2.SetTopicConfigurationsRequest_SetConfiguration, error)
- func NumberToInt32(n types.Number) *int32
- func Retry(ctx context.Context, timeout time.Duration, f func() *RetryError) error
- func RetryGetCluster(ctx context.Context, timeout time.Duration, clusterID string, ...) (*controlplanev1beta2.Cluster, error)
- func SplitSchemeDefPort(url, def string) (string, error)
- func StringSliceToTypeList(elements []string) types.List
- func StringToCloudProvider(p string) (controlplanev1beta2.CloudProvider, error)
- func StringToClusterType(p string) (controlplanev1beta2.Cluster_Type, error)
- func StringToConnectionType(s string) controlplanev1beta2.Cluster_ConnectionType
- func StringToStringPointer(s string) *string
- func StringToUserMechanism(s string) dataplanev1alpha2.SASLMechanism
- func TopicConfigurationToMap(cfg []*dataplanev1alpha2.Topic_Configuration) (types.Map, error)
- func TrimmedStringValue(s string) types.String
- func TypeListToStringSlice(t types.List) []string
- func TypeMapToStringMap(tags types.Map) map[string]string
- func UserMechanismToString(m *dataplanev1alpha2.SASLMechanism) string
- type ByocClient
- type ByocClientConfig
- type DefaultBoolValue
- type NotFoundError
- type RetryError
- type TimeoutError
Constants ¶
const CloudProviderStringAws = "aws"
CloudProviderStringAws is the string representation of the CLOUD_PROVIDER_AWS enum
const CloudProviderStringAzure = "azure"
CloudProviderStringAzure is the string representation of the CLOUD_PROVIDER_AZURE enum
const CloudProviderStringGcp = "gcp"
CloudProviderStringGcp is the string representation of the CLOUD_PROVIDER_GCP enum
Variables ¶
This section is empty.
Functions ¶
func AreWeDoneYet ¶
func AreWeDoneYet(ctx context.Context, op *controlplanev1beta2.Operation, timeout time.Duration, client controlplanev1beta2grpc.OperationServiceClient) error
AreWeDoneYet checks an operation's state until one of completion, failure or timeout is reached.
func CloudProviderToString ¶
func CloudProviderToString(provider controlplanev1beta2.CloudProvider) string
CloudProviderToString returns the cloud provider string based on the controlplanev1beta2's CloudProvider code.
func ClusterTypeToString ¶
func ClusterTypeToString(provider controlplanev1beta2.Cluster_Type) string
ClusterTypeToString returns the cloud cluster type string based on the controlplanev1beta2's Cluster_Type code.
func ConnectionTypeToString ¶
func ConnectionTypeToString(t controlplanev1beta2.Cluster_ConnectionType) string
ConnectionTypeToString returns the cloud cluster connection type string based on the controlplanev1beta2's Cluster_ConnectionType code.
func DeserializeGrpcError ¶ added in v0.10.0
DeserializeGrpcError err.Error() if it is a standard error. If it is a GRPC error, it returns status and codes for sure and details if they're set. Mild formatting to put details on a separate line for readability
func FindTopicByName ¶
func FindTopicByName(ctx context.Context, topicName string, client dataplanev1alpha2grpc.TopicServiceClient) (*dataplanev1alpha2.ListTopicsResponse_Topic, error)
FindTopicByName searches for a topic by name using the provided client.
func FindUserByName ¶
func FindUserByName(ctx context.Context, name string, client dataplanev1alpha2grpc.UserServiceClient) (*dataplanev1alpha2.ListUsersResponse_User, error)
FindUserByName searches for a user by name using the provided client
func GenerateProtobufDiffAndUpdateMask ¶ added in v0.10.0
func GenerateProtobufDiffAndUpdateMask[P interface { *T proto.Message }, T any](newMessage, oldMessage P) (*T, *fieldmaskpb.FieldMask)
GenerateProtobufDiffAndUpdateMask takes two proto.Message objects and calculates the diff in toplevel fields between them. It returns a new proto.Message object with only the differing values and a fieldmaskpb.FieldMask object with the names of the differing fields. If there are no differing fields, it returns a proto.Message object with no fields set and a FieldMask with an empty Paths slice.
func Int32ToNumber ¶
Int32ToNumber converts an int32 to a types.Number
func IsNotFound ¶
IsNotFound checks if the passed error is a NotFoundError or a GRPC NotFound error
func MapToCreateTopicConfiguration ¶
func MapToCreateTopicConfiguration(cfg types.Map) ([]*dataplanev1alpha2.CreateTopicRequest_Topic_Config, error)
MapToCreateTopicConfiguration converts a cfg map to a slice of dataplanev1alpha2.CreateTopicRequest_Topic_Config
func MapToSetTopicConfiguration ¶ added in v0.5.0
func MapToSetTopicConfiguration(cfg types.Map) ([]*dataplanev1alpha2.SetTopicConfigurationsRequest_SetConfiguration, error)
MapToSetTopicConfiguration converts a cfg map to a slice of dataplanev1alpha2.SetTopicConfigurationsRequest_SetConfiguration
func NumberToInt32 ¶
NumberToInt32 converts a types.Number to an *int32
func Retry ¶ added in v0.10.0
Retry will retry a function with a delay between each invocation until it no longer returns an error, the timeout is reached, or the context is cancelled. It uses exponential backoff between each call of the function, up to a max of 1 minute, and resets the delay whenever the function returns an error with a different string. Similar to https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/retry#RetryContext
func RetryGetCluster ¶ added in v0.10.0
func RetryGetCluster(ctx context.Context, timeout time.Duration, clusterID string, client *cloud.ControlPlaneClientSet, f func(*controlplanev1beta2.Cluster) *RetryError) (*controlplanev1beta2.Cluster, error)
RetryGetCluster will retry a function, passing in the latest state of the given cluster id, until it either no longer returns an error or times out
func SplitSchemeDefPort ¶
SplitSchemeDefPort splits the schema from the url and return url+port. If there is no port, we use the provided default.
func StringSliceToTypeList ¶ added in v0.10.0
StringSliceToTypeList safely converts a string slice into a Terraform types.List
func StringToCloudProvider ¶
func StringToCloudProvider(p string) (controlplanev1beta2.CloudProvider, error)
StringToCloudProvider returns the controlplanev1beta2's CloudProvider code based on the input string.
func StringToClusterType ¶
func StringToClusterType(p string) (controlplanev1beta2.Cluster_Type, error)
StringToClusterType returns the controlplanev1beta2's Cluster_Type code based on the input string.
func StringToConnectionType ¶
func StringToConnectionType(s string) controlplanev1beta2.Cluster_ConnectionType
StringToConnectionType returns the controlplanev1beta2's Cluster_ConnectionType code based on the input string.
func StringToStringPointer ¶
StringToStringPointer converts a string to a pointer to a string
func StringToUserMechanism ¶
func StringToUserMechanism(s string) dataplanev1alpha2.SASLMechanism
StringToUserMechanism converts a string to a dataplanev1alpha2.SASLMechanism
func TopicConfigurationToMap ¶
func TopicConfigurationToMap(cfg []*dataplanev1alpha2.Topic_Configuration) (types.Map, error)
TopicConfigurationToMap converts a slice of dataplanev1alpha2.Topic_Configuration to a slice of models.TopicConfiguration
func TrimmedStringValue ¶
TrimmedStringValue returns the string value of a types.String with the quotes removed. This is necessary as terraform has a tendency to slap these bad boys in at random which causes the API to fail
func TypeListToStringSlice ¶
TypeListToStringSlice converts a types.List to a []string, stripping surrounding quotes for each element.
func TypeMapToStringMap ¶ added in v0.7.0
TypeMapToStringMap converts a types.Map to a map[string]string
func UserMechanismToString ¶
func UserMechanismToString(m *dataplanev1alpha2.SASLMechanism) string
UserMechanismToString converts a dataplanev1alpha2.SASLMechanism to a string
Types ¶
type ByocClient ¶ added in v0.10.0
type ByocClient struct {
// contains filtered or unexported fields
}
ByocClient holds the information and clients needed to download and interact with the rpk byoc plugin.
func NewByocClient ¶ added in v0.10.0
func NewByocClient(conf ByocClientConfig) *ByocClient
NewByocClient creates a new ByocClient.
type ByocClientConfig ¶ added in v0.10.0
type ByocClientConfig struct { AuthToken string AzureSubscriptionID string GcpProject string InternalAPIURL string AzureClientID string AzureClientSecret string AzureTenantID string GoogleCredentials string GoogleCredentialsBase64 string }
ByocClientConfig represents the options that must be passed to NewByocClient.
type DefaultBoolValue ¶
DefaultBoolValue follows the TF framework bool type.
func (*DefaultBoolValue) DefaultBool ¶
func (d *DefaultBoolValue) DefaultBool(_ context.Context, _ defaults.BoolRequest, resp *defaults.BoolResponse)
DefaultBool sets the default bool value in resp.PlanValue.
func (*DefaultBoolValue) Description ¶
func (d *DefaultBoolValue) Description(_ context.Context) string
Description return the description string.
func (*DefaultBoolValue) MarkdownDescription ¶
func (d *DefaultBoolValue) MarkdownDescription(_ context.Context) string
MarkdownDescription returns the markdown description string.
type NotFoundError ¶ added in v0.10.0
type NotFoundError struct {
Message string
}
NotFoundError represents a resource that couldn't be found
func (NotFoundError) Error ¶ added in v0.10.0
func (e NotFoundError) Error() string
Error returns the error message
type RetryError ¶ added in v0.10.0
RetryError is the required return type of functions passed to Retry
func NonRetryableError ¶ added in v0.10.0
func NonRetryableError(err error) *RetryError
NonRetryableError is a helper to create a RetryError that's _not_ retryable
func RetryableError ¶ added in v0.10.0
func RetryableError(err error) *RetryError
RetryableError is a helper to create a RetryError that's retryable
type TimeoutError ¶ added in v0.10.0
TimeoutError is returned when Retry times out
func (*TimeoutError) Error ¶ added in v0.10.0
func (err *TimeoutError) Error() string
func (*TimeoutError) Unwrap ¶ added in v0.10.0
func (err *TimeoutError) Unwrap() error