Documentation
¶
Index ¶
- Variables
- func CreateClusterHosts[T Host, H any, HS any, U any](ctx context.Context, utilsHostService CmpHostService[T, H, HS, U], ...) ([]HS, diag.Diagnostics)
- func ExpandBackupWindow(ctx context.Context, bw types.Object, diags *diag.Diagnostics) *timeofday.TimeOfDay
- func ExpandBoolWrapper(_ context.Context, b types.Bool, _ *diag.Diagnostics) *wrapperspb.BoolValue
- func ExpandClusterMaintenanceWindow[V any, VW any, VA any, WD ~int32, T ..., W weeklyMaintenanceWindow[VW, WD], ...](ctx context.Context, mw types.Object, diags *diag.Diagnostics) T
- func ExpandEnvironment[T ~int32](_ context.Context, e types.String, diags *diag.Diagnostics) T
- func ExpandFolderId(ctx context.Context, f types.String, providerConfig *config.State, ...) string
- func ExpandInt64Wrapper(ctx context.Context, in types.Int64, diags *diag.Diagnostics) *wrapperspb.Int64Value
- func ExpandLabels(ctx context.Context, labels types.Map, diags *diag.Diagnostics) map[string]string
- func ExpandResources[V any, T resourceModel[V]](ctx context.Context, o types.Object, diags *diag.Diagnostics) T
- func ExpandSecurityGroupIds(ctx context.Context, sg types.Set, diags *diag.Diagnostics) []string
- func FlattenBackupWindowStart(ctx context.Context, bws *timeofday.TimeOfDay, diags *diag.Diagnostics) types.Object
- func FlattenBoolWrapper(ctx context.Context, wb *wrapperspb.BoolValue, diags *diag.Diagnostics) types.Bool
- func FlattenInt64Wrapper(ctx context.Context, pgBrpd *wrapperspb.Int64Value, diags *diag.Diagnostics) types.Int64
- func FlattenMaintenanceWindow[V any, VW any, VA any, WD ~int32, W weeklyMaintenanceWindow[VW, WD], ...](ctx context.Context, mw T, diags *diag.Diagnostics) types.Object
- func FlattenMapString(ctx context.Context, ms map[string]string, diags *diag.Diagnostics) types.Map
- func FlattenResources[V any, T resourceModel[V]](ctx context.Context, r T, diags *diag.Diagnostics) types.Object
- func FlattenSetString(ctx context.Context, ss []string, diags *diag.Diagnostics) types.Set
- func GetAttrNamesSetFromMap(o types.Map, diags *diag.Diagnostics) map[string]struct{}
- func GetClusterIdForDatasource(ctx context.Context, providerConfig *provider_config.Config, ...) (string, diag.Diagnostics)
- func GetUserConfig(ctx context.Context, c interface{}, confAttrName string, ...) interface{}
- func IsAttrZeroValue(val attr.Value, diags *diag.Diagnostics) bool
- func ReadHosts[T Host, H ProtoHost, HS any, U any](ctx context.Context, sdk *ycsdk.SDK, diags *diag.Diagnostics, ...) map[string]T
- func UpdateClusterHosts[T Host, H any, HS any, U any](ctx context.Context, sdk *ycsdk.SDK, diagnostics *diag.Diagnostics, ...)
- func UpdateClusterHostsWithShards[T HostWithShard, H any, HS ProtoHostWithShard, U any](ctx context.Context, sdk *ycsdk.SDK, diagnostics *diag.Diagnostics, ...)
- type BackupWindow
- type CmpHostService
- type Host
- type HostApiService
- type HostApiServiceWithShards
- type HostWithShard
- type MaintenanceWindow
- type ProtoHost
- type ProtoHostWithShard
- type Resource
- type SettingsAttributeInfoProvider
- type SettingsMapType
- func (t SettingsMapType) Equal(o attr.Type) bool
- func (t SettingsMapType) String() string
- func (t SettingsMapType) ValueFromMap(ctx context.Context, in basetypes.MapValue) (basetypes.MapValuable, diag.Diagnostics)
- func (t SettingsMapType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)
- func (t SettingsMapType) ValueType(ctx context.Context) attr.Value
- type SettingsMapValue
- func NewSettingsMapNull() SettingsMapValue
- func NewSettingsMapUnknown() SettingsMapValue
- func NewSettingsMapValue(elements map[string]attr.Value, p SettingsAttributeInfoProvider) (SettingsMapValue, diag.Diagnostics)
- func NewSettingsMapValueMust(elements map[string]attr.Value, p SettingsAttributeInfoProvider) SettingsMapValue
Constants ¶
This section is empty.
Variables ¶
var BackupWindowType = types.ObjectType{ AttrTypes: map[string]attr.Type{ "hours": types.Int64Type, "minutes": types.Int64Type, }, }
var MaintenanceWindowType = types.ObjectType{ AttrTypes: map[string]attr.Type{ "type": types.StringType, "day": types.StringType, "hour": types.Int64Type, }, }
var ResourceType = types.ObjectType{ AttrTypes: map[string]attr.Type{ "resource_preset_id": types.StringType, "disk_type_id": types.StringType, "disk_size": types.Int64Type, }, }
Functions ¶
func CreateClusterHosts ¶
func CreateClusterHosts[T Host, H any, HS any, U any](ctx context.Context, utilsHostService CmpHostService[T, H, HS, U], hostSpecs basetypes.MapValue) ([]HS, diag.Diagnostics)
CreateClusterHosts is a method called during the host creation process. It converts hosts from their model representation to specifications suitable for use with the createHosts method. Finally, return the list of host specifications ready for creation and any diagnostic information collected.
func ExpandBackupWindow ¶
func ExpandBoolWrapper ¶
func ExpandBoolWrapper(_ context.Context, b types.Bool, _ *diag.Diagnostics) *wrapperspb.BoolValue
func ExpandEnvironment ¶
func ExpandFolderId ¶
func ExpandInt64Wrapper ¶
func ExpandInt64Wrapper(ctx context.Context, in types.Int64, diags *diag.Diagnostics) *wrapperspb.Int64Value
func ExpandLabels ¶
func ExpandResources ¶
func ExpandSecurityGroupIds ¶
func FlattenBoolWrapper ¶
func FlattenBoolWrapper(ctx context.Context, wb *wrapperspb.BoolValue, diags *diag.Diagnostics) types.Bool
func FlattenInt64Wrapper ¶
func FlattenInt64Wrapper(ctx context.Context, pgBrpd *wrapperspb.Int64Value, diags *diag.Diagnostics) types.Int64
func FlattenMapString ¶
func FlattenResources ¶
func FlattenSetString ¶
func GetAttrNamesSetFromMap ¶
func GetAttrNamesSetFromMap(o types.Map, diags *diag.Diagnostics) map[string]struct{}
func GetClusterIdForDatasource ¶
func GetClusterIdForDatasource(ctx context.Context, providerConfig *provider_config.Config, config tfsdk.Config) (string, diag.Diagnostics)
GetClusterIdForDatasource retrieves the cluster ID for a given datasource. It accepts either a direct cluster ID or resolves it using the name attribute.
func GetUserConfig ¶
func GetUserConfig(ctx context.Context, c interface{}, confAttrName string, diags *diag.Diagnostics) interface{}
GetUserConfig extracts UserConfig from a cluster config struct by protobuf tag
c must be a valid ClusterConfigStructure
func IsAttrZeroValue ¶
func IsAttrZeroValue(val attr.Value, diags *diag.Diagnostics) bool
func ReadHosts ¶
func ReadHosts[T Host, H ProtoHost, HS any, U any]( ctx context.Context, sdk *ycsdk.SDK, diags *diag.Diagnostics, utilsHostService CmpHostService[T, H, HS, U], hostsApiService HostApiService[H, HS, U], stateHosts basetypes.MapValue, cid string, ) map[string]T
The ReadHosts method is used to update the state of hosts.
1. Map hosts from api to hosts in state by fqdn 2. Map hosts from api to hosts in state without fqdn by equal attributes 3. Add hosts from api to state if not mapped
func UpdateClusterHosts ¶
func UpdateClusterHosts[T Host, H any, HS any, U any]( ctx context.Context, sdk *ycsdk.SDK, diagnostics *diag.Diagnostics, utilsHostService CmpHostService[T, H, HS, U], hostsApiService HostApiService[H, HS, U], cid string, plan, state types.Map, )
UpdateClusterHosts Method to update hosts within a cluster 1) Substitute labels using modifyStateDependsPlan
- Utilize modifyStateDependsPlan to adjust labels in the state to match those intended in the plan.
- This aims to prevent redundant host creation/deletion by better aligning the current state with the plan.
2) Calculate changes for Hosts
- Determine which hosts need to be created, updated, or deleted by comparing current state with the desired plan.
3) Create remaining hosts 4) Update existing hosts 5) Delete remaining hosts
func UpdateClusterHostsWithShards ¶
func UpdateClusterHostsWithShards[T HostWithShard, H any, HS ProtoHostWithShard, U any]( ctx context.Context, sdk *ycsdk.SDK, diagnostics *diag.Diagnostics, utilsHostService CmpHostService[T, H, HS, U], hostsApiService HostApiServiceWithShards[H, HS, U], cid string, plan, state types.Map, )
UpdateClusterHostsWithShards Method to update hosts and shards within a cluster 1) Substitute labels using modifyStateDependsPlan
- Utilize modifyStateDependsPlan to adjust labels in the state to match those intended in the plan.
- This aims to prevent redundant host creation/deletion by better aligning the current state with the plan.
2) Calculate changes for Hosts
- Determine which hosts need to be created, updated, or deleted by comparing current state with the desired plan.
3) Calculate changes for Shards
- Analyze differences in shard configurations between the current state and desired plan to decide which shards require creation or deletion.
4) Clean up host changes based on shard changes
- Adjust host change operations to reflect shard changes accurately, avoiding unnecessary actions. For example, if a shard is being deleted, associated hosts will also be removed.
5) Create new shards 6) Create remaining hosts 7) Update existing hosts 8) Delete shards 9) Delete remaining hosts
Types ¶
type BackupWindow ¶
type CmpHostService ¶
type CmpHostService[T Host, ProtoHost any, ProtoHostSpec any, UpdateSpec any] interface { // FullyMatch performs a complete comparison of all fields in two host models, similar to an equals method. // It also handles cases where fields may be unknown, ensuring robust comparison for complete state verification. FullyMatch(plan T, state T) bool // PartialMatch compares fields that cannot be changed by update methods. // It is designed to handle situations with unknown fields, focusing on attributes that must remain consistent. PartialMatch(plan T, state T) bool // GetChanges determines the differences between two host models. // If immutable fields have been changed, it returns an error. // If there are no changes, it returns nil; otherwise, it gathers an UpdateSpec to send to the API. GetChanges(plan T, state T) (*UpdateSpec, diag.Diagnostics) // ConvertToProto converts a host model to a specification suitable for host creation. // This method transforms the terraform model type to the `ProtoHostSpec` type used in API operations. ConvertToProto(T) ProtoHostSpec // ConvertFromProto converts an API-returned structure to the host model. // This method is essential for integrating responses into the terraform state model. ConvertFromProto(ProtoHost) T }
CmpHostService is an interface for implementing common parsing methods for host models. T - Represents the host model within Terraform, likely detailing configuration and state as defined in Terraform templates. PortoHost - Refers to the protobuf type returned by a listHosts API call. It represents how hosts are structured in API communications. ProtoHostSpec - Is the protobuf type used for creating a host. It specifies the properties and configurations needed for API host creation. UpdateSpec - The protobuf type used for updating hosts, detailing the necessary changes.
type HostApiService ¶
type HostApiService[ProtoHost any, ProtoHostSpec any, UpdateSpec any] interface { ListHosts(ctx context.Context, sdk *ycsdk.SDK, diag *diag.Diagnostics, cid string) []ProtoHost CreateHosts(ctx context.Context, sdk *ycsdk.SDK, diag *diag.Diagnostics, cid string, specs []ProtoHostSpec) UpdateHosts(ctx context.Context, sdk *ycsdk.SDK, diag *diag.Diagnostics, cid string, specs []*UpdateSpec) DeleteHosts(ctx context.Context, sdk *ycsdk.SDK, diag *diag.Diagnostics, cid string, fqdns []string) }
HostApiService is an interface that defines methods for API operations involving hosts. It is parameterized with types `ProtoHost`, `ProtoHostSpec`, and `UpdateSpec`
type HostApiServiceWithShards ¶
type HostApiServiceWithShards[ProtoHost any, ProtoHostSpec any, UpdateSpec any] interface { HostApiService[ProtoHost, ProtoHostSpec, UpdateSpec] CreateShard(ctx context.Context, sdk *ycsdk.SDK, diag *diag.Diagnostics, cid, shardName string, hostSpecs []ProtoHostSpec) DeleteShard(ctx context.Context, sdk *ycsdk.SDK, diag *diag.Diagnostics, cid, shardName string) }
HostApiService is an interface that defines methods for API operations involving hosts with shards. It is parameterized with types `ProtoHost`, `ProtoHostSpec`, and `UpdateSpec`
type HostWithShard ¶
type MaintenanceWindow ¶
type ProtoHostWithShard ¶
type ProtoHostWithShard interface {
GetShardName() string
}
type SettingsMapType ¶
SettingsMapType type is based on the example in the terraform plugin framerwork documentation https://developer.hashicorp.com/terraform/plugin/framework/handling-data/types/custom
Type is add-on to the string map for the mapping to primitive fields (Numbers, Bool, String) Used to configure Postgresql settings.
func NewSettingsMapType ¶
func NewSettingsMapType(p SettingsAttributeInfoProvider) SettingsMapType
func (SettingsMapType) Equal ¶
func (t SettingsMapType) Equal(o attr.Type) bool
Equal compare MsSettingsMapType with provided type
func (SettingsMapType) String ¶
func (t SettingsMapType) String() string
func (SettingsMapType) ValueFromMap ¶
func (t SettingsMapType) ValueFromMap(ctx context.Context, in basetypes.MapValue) (basetypes.MapValuable, diag.Diagnostics)
ValueFromMap used to get MsSettingsMapType from a map value
func (SettingsMapType) ValueFromTerraform ¶
func (t SettingsMapType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)
ValueFromTerraform is a basic implementation of getting MsSettingsMapType value from terraform value
From example: https://developer.hashicorp.com/terraform/plugin/framework/handling-data/types/custom
type SettingsMapValue ¶
func NewSettingsMapNull ¶
func NewSettingsMapNull() SettingsMapValue
func NewSettingsMapUnknown ¶
func NewSettingsMapUnknown() SettingsMapValue
func NewSettingsMapValue ¶
func NewSettingsMapValue(elements map[string]attr.Value, p SettingsAttributeInfoProvider) (SettingsMapValue, diag.Diagnostics)
NewMsSettingsMapValue creates MsSettingsMapValue from map[string]attr.Value, where attr.Value is a primitive value
func NewSettingsMapValueMust ¶
func NewSettingsMapValueMust(elements map[string]attr.Value, p SettingsAttributeInfoProvider) SettingsMapValue
func (SettingsMapValue) Equal ¶
func (v SettingsMapValue) Equal(o attr.Value) bool
Compare map values and elements values inside
func (SettingsMapValue) PrimitiveElements ¶
func (v SettingsMapValue) PrimitiveElements(ctx context.Context, diags *diag.Diagnostics) map[string]attr.Value
PrimitiveElements is necessary to get primitive values map from a MsSettingsMapValue