types

package
v0.30.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 31, 2023 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDiskSize added in v0.24.0

func FormatDiskSize(size DiskSize) string

FormatDiskSize turns a number of bytes into a disk size string.

func HAResourceIDValidator added in v0.30.0

func HAResourceIDValidator() validator.String

HAResourceIDValidator returns a new HA resource identifier validator.

func HAResourceStateValidator added in v0.30.0

func HAResourceStateValidator() validator.String

HAResourceStateValidator returns a new HA resource state validator.

func HAResourceTypeValidator added in v0.30.0

func HAResourceTypeValidator() validator.String

HAResourceTypeValidator returns a new HA resource type validator.

func StrPtr added in v0.24.0

func StrPtr(s string) *string

StrPtr returns a pointer to a string.

Types

type CustomBool

type CustomBool bool

CustomBool allows a JSON boolean value to also be an integer.

func BoolPtr added in v0.24.0

func BoolPtr(s bool) *CustomBool

BoolPtr returns a pointer to a bool.

func (*CustomBool) FromValue added in v0.30.0

func (r *CustomBool) FromValue(tfValue types.Bool)

FromValue sets the numeric boolean based on the value of a Terraform attribute.

func (CustomBool) MarshalJSON

func (r CustomBool) MarshalJSON() ([]byte, error)

MarshalJSON converts a boolean to a JSON value.

func (CustomBool) Pointer

func (r CustomBool) Pointer() *CustomBool

Pointer returns a pointers.

func (*CustomBool) PointerBool

func (r *CustomBool) PointerBool() *bool

PointerBool returns a pointer to a boolean.

func (CustomBool) ToValue added in v0.30.0

func (r CustomBool) ToValue() types.Bool

ToValue returns a Terraform attribute value.

func (*CustomBool) UnmarshalJSON

func (r *CustomBool) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON value to a boolean.

type CustomCommaSeparatedList

type CustomCommaSeparatedList []string

CustomCommaSeparatedList allows a JSON string to also be a string array.

func (*CustomCommaSeparatedList) MarshalJSON

func (r *CustomCommaSeparatedList) MarshalJSON() ([]byte, error)

MarshalJSON converts a boolean to a JSON value.

func (*CustomCommaSeparatedList) UnmarshalJSON

func (r *CustomCommaSeparatedList) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON value to a boolean.

type CustomInt

type CustomInt int

CustomInt allows a JSON integer value to also be a string.

func (*CustomInt) UnmarshalJSON

func (r *CustomInt) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON value to an integer.

type CustomLineBreakSeparatedList

type CustomLineBreakSeparatedList []string

CustomLineBreakSeparatedList allows a multiline JSON string to also be a string array.

func (*CustomLineBreakSeparatedList) MarshalJSON

func (r *CustomLineBreakSeparatedList) MarshalJSON() ([]byte, error)

MarshalJSON converts a boolean to a JSON value.

func (*CustomLineBreakSeparatedList) UnmarshalJSON

func (r *CustomLineBreakSeparatedList) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON value to a boolean.

type CustomPrivileges

type CustomPrivileges []string

CustomPrivileges allows a JSON object of privileges to also be a string array.

func (*CustomPrivileges) MarshalJSON

func (r *CustomPrivileges) MarshalJSON() ([]byte, error)

MarshalJSON converts a boolean to a JSON value.

func (*CustomPrivileges) UnmarshalJSON

func (r *CustomPrivileges) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON value to a boolean.

type CustomTimestamp

type CustomTimestamp time.Time

CustomTimestamp allows a JSON boolean value to also be a unix timestamp.

func (CustomTimestamp) MarshalJSON

func (r CustomTimestamp) MarshalJSON() ([]byte, error)

MarshalJSON converts a timestamp to a JSON value.

func (*CustomTimestamp) UnmarshalJSON

func (r *CustomTimestamp) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a JSON value to a timestamp.

type DiskSize added in v0.24.0

type DiskSize int64

DiskSize allows a JSON integer value to also be a string. This is mapped to `<DiskSize>` data type in Proxmox API. Represents a disk size in bytes.

func DiskSizeFromGigabytes added in v0.24.0

func DiskSizeFromGigabytes(size int) DiskSize

DiskSizeFromGigabytes creates a DiskSize from gigabytes.

func ParseDiskSize added in v0.24.0

func ParseDiskSize(size string) (DiskSize, error)

ParseDiskSize parses a disk size string into a number of bytes.

func (DiskSize) InGigabytes added in v0.24.0

func (r DiskSize) InGigabytes() int

InGigabytes returns the disk size in gigabytes.

func (DiskSize) InMegabytes added in v0.24.0

func (r DiskSize) InMegabytes() int

InMegabytes returns the disk size in megabytes.

func (DiskSize) MarshalJSON added in v0.24.0

func (r DiskSize) MarshalJSON() ([]byte, error)

MarshalJSON marshals a disk size into a Proxmox API `<DiskSize>` string.

func (DiskSize) String added in v0.24.0

func (r DiskSize) String() string

String returns the string representation of the disk size.

func (*DiskSize) UnmarshalJSON added in v0.24.0

func (r *DiskSize) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a disk size from a Proxmox API `<DiskSize>` string.

type HAResourceID added in v0.30.0

type HAResourceID struct {
	Type HAResourceType // The type of this HA resource.
	Name string         // The name of the element the HA resource refers to.
}

HAResourceID represents a HA resource identifier, composed of a resource type and identifier.

func ParseHAResourceID added in v0.30.0

func ParseHAResourceID(input string) (HAResourceID, error)

ParseHAResourceID parses a string that represents a HA resource identifier into a value of `HAResourceID`.

func (HAResourceID) EncodeValues added in v0.30.0

func (rid HAResourceID) EncodeValues(key string, v *url.Values) error

EncodeValues encodes a HA resource ID field into an URL-encoded set of values.

func (HAResourceID) MarshalJSON added in v0.30.0

func (rid HAResourceID) MarshalJSON() ([]byte, error)

MarshalJSON marshals a HA resource identifier into JSON value.

func (HAResourceID) String added in v0.30.0

func (rid HAResourceID) String() string

String converts a HAResourceID value into a string.

func (HAResourceID) ToValue added in v0.30.0

func (rid HAResourceID) ToValue() types.String

ToValue converts a HA resource ID into a Terraform value.

func (*HAResourceID) UnmarshalJSON added in v0.30.0

func (rid *HAResourceID) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a Proxmox HA resource identifier.

type HAResourceState added in v0.30.0

type HAResourceState int

HAResourceState represents the requested state of a HA resource.

const (
	// HAResourceStateStarted indicates that a HA resource should be started.
	HAResourceStateStarted HAResourceState = 0
	// HAResourceStateStopped indicates that a HA resource should be stopped, but that it should still be relocated
	// on node failure.
	HAResourceStateStopped HAResourceState = 1
	// HAResourceStateDisabled indicates that a HA resource should be stopped. No relocation should occur on node failure.
	HAResourceStateDisabled HAResourceState = 2
	// HAResourceStateIgnored indicates that a HA resource is not managed by the cluster resource manager. No relocation
	// or status change will occur.
	HAResourceStateIgnored HAResourceState = 3
)

func ParseHAResourceState added in v0.30.0

func ParseHAResourceState(input string) (HAResourceState, error)

ParseHAResourceState converts the string representation of a HA resource state into the corresponding enum value. An error is returned if the input string does not match any known state. This function also parses the `enabled` value which is an alias for `started`.

func (HAResourceState) EncodeValues added in v0.30.0

func (s HAResourceState) EncodeValues(key string, v *url.Values) error

EncodeValues encodes a HA resource state field into an URL-encoded set of values.

func (HAResourceState) MarshalJSON added in v0.30.0

func (s HAResourceState) MarshalJSON() ([]byte, error)

MarshalJSON marshals a HA resource state into JSON value.

func (HAResourceState) String added in v0.30.0

func (s HAResourceState) String() string

String converts a HAResourceState value into a string.

func (HAResourceState) ToValue added in v0.30.0

func (s HAResourceState) ToValue() types.String

ToValue converts a HA resource state into a Terraform value.

func (*HAResourceState) UnmarshalJSON added in v0.30.0

func (s *HAResourceState) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a Proxmox HA resource state.

type HAResourceType added in v0.30.0

type HAResourceType int

HAResourceType represents the type of a HA resource.

const (
	// HAResourceTypeVM indicates that a HA resource refers to a virtual machine.
	HAResourceTypeVM HAResourceType = 0
	// HAResourceTypeContainer indicates that a HA resource refers to a container.
	HAResourceTypeContainer HAResourceType = 1
)

func ParseHAResourceType added in v0.30.0

func ParseHAResourceType(input string) (HAResourceType, error)

ParseHAResourceType converts the string representation of a HA resource type into the corresponding enum value. An error is returned if the input string does not match any known type.

func (HAResourceType) EncodeValues added in v0.30.0

func (t HAResourceType) EncodeValues(key string, v *url.Values) error

EncodeValues encodes a HA resource type field into an URL-encoded set of values.

func (HAResourceType) MarshalJSON added in v0.30.0

func (t HAResourceType) MarshalJSON() ([]byte, error)

MarshalJSON marshals a HA resource type into JSON value.

func (HAResourceType) String added in v0.30.0

func (t HAResourceType) String() string

String converts a HAResourceType value into a string.

func (HAResourceType) ToValue added in v0.30.0

func (t HAResourceType) ToValue() types.String

ToValue converts a HA resource type into a Terraform value.

func (*HAResourceType) UnmarshalJSON added in v0.30.0

func (t *HAResourceType) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a Proxmox HA resource type.

type IPAddrType

type IPAddrType struct {
	basetypes.StringType
}

IPAddrType is a type that represents an IP address.

func (IPAddrType) Equal

func (t IPAddrType) Equal(o attr.Type) bool

Equal returns true if the two types are equal.

func (IPAddrType) String

func (t IPAddrType) String() string

String returns a string representation of the type.

func (IPAddrType) Validate

func (t IPAddrType) Validate(_ context.Context, value tftypes.Value, valuePath path.Path) diag.Diagnostics

Validate ensures the value is valid IP address.

func (IPAddrType) ValueFromString

ValueFromString converts a string value to a StringValuable.

func (IPAddrType) ValueFromTerraform

func (t IPAddrType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

ValueFromTerraform converts a Terraform value to a StringValuable.

func (IPAddrType) ValueType

func (t IPAddrType) ValueType(_ context.Context) attr.Value

ValueType returns the underlying value type.

type IPAddrValue

type IPAddrValue struct {
	basetypes.StringValue
}

IPAddrValue is a type that represents an IP address value.

func NewIPAddrPointerValue

func NewIPAddrPointerValue(value *string) IPAddrValue

NewIPAddrPointerValue returns a new IPAddrValue from a string pointer.

func (IPAddrValue) Equal

func (v IPAddrValue) Equal(o attr.Value) bool

Equal returns true if the two values are equal.

func (IPAddrValue) Type

func (v IPAddrValue) Type(_ context.Context) attr.Type

Type returns the type of the value.

type IPCIDRType

type IPCIDRType struct {
	basetypes.StringType
}

IPCIDRType is a type that represents an IP address in CIDR notation.

func (IPCIDRType) Equal

func (t IPCIDRType) Equal(o attr.Type) bool

Equal returns true if the two types are equal.

func (IPCIDRType) String

func (t IPCIDRType) String() string

String returns a string representation of the type.

func (IPCIDRType) Validate

func (t IPCIDRType) Validate(_ context.Context, value tftypes.Value, valuePath path.Path) diag.Diagnostics

Validate ensures the value is valid IP address in CIDR notation.

func (IPCIDRType) ValueFromString

ValueFromString converts a string value to a StringValuable.

func (IPCIDRType) ValueFromTerraform

func (t IPCIDRType) ValueFromTerraform(ctx context.Context, in tftypes.Value) (attr.Value, error)

ValueFromTerraform converts a Terraform value to a StringValuable.

func (IPCIDRType) ValueType

func (t IPCIDRType) ValueType(_ context.Context) attr.Value

ValueType returns the underlying value type.

type IPCIDRValue

type IPCIDRValue struct {
	basetypes.StringValue
}

IPCIDRValue is a type that represents an IP address in CIDR notation.

func NewIPCIDRPointerValue

func NewIPCIDRPointerValue(value *string) IPCIDRValue

NewIPCIDRPointerValue returns a new IPCIDRValue from a string pointer.

func (IPCIDRValue) Equal

func (v IPCIDRValue) Equal(o attr.Value) bool

Equal returns true if the two values are equal.

func (IPCIDRValue) Type

func (v IPCIDRValue) Type(_ context.Context) attr.Type

Type returns the type of the value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL