Documentation ¶
Index ¶
- func GetAny[T any](i IProperty) (T, bool, error)
- func GetMap[T any](i IProperty) (map[string]T, bool, error)
- func GetObject[T any](i IProperty) (T, bool, error)
- func GetSet[T comparable](i IProperty) (sets.Set[T], bool, error)
- func GetSlice[T any](i IProperty) ([]T, bool, error)
- func PropertiesField(name string) *otherBuilder
- func SchemasField(name string) *otherBuilder
- func ValuesField(name string) *otherBuilder
- type IProperty
- type Properties
- type Property
- func AnyProperty(v any) Property
- func BoolProperty(v bool) Property
- func DurationProperty(v time.Duration) Property
- func Float32Property(v float32) Property
- func Float64Property(v float64) Property
- func Int16Property(v int16) Property
- func Int32Property(v int32) Property
- func Int64Property(v int64) Property
- func Int8Property(v int8) Property
- func IntProperty(v int) Property
- func MapProperty[T any](v map[string]T) Property
- func ObjectProperty[T any](v T) Property
- func SetProperty[T comparable](v sets.Set[T]) Property
- func SliceProperty[T any](v []T) Property
- func StringProperty(v string) Property
- func Uint16Property(v uint16) Property
- func Uint32Property(v uint32) Property
- func Uint64Property(v uint64) Property
- func Uint8Property(v uint8) Property
- func UintProperty(v uint) Property
- func (i Property) Cty() (cty.Type, cty.Value, error)
- func (i Property) GetBool() (bool, bool, error)
- func (i Property) GetDuration() (time.Duration, bool, error)
- func (i Property) GetFloat32() (float32, bool, error)
- func (i Property) GetFloat64() (float64, bool, error)
- func (i Property) GetInt() (int, bool, error)
- func (i Property) GetInt16() (int16, bool, error)
- func (i Property) GetInt32() (int32, bool, error)
- func (i Property) GetInt64() (int64, bool, error)
- func (i Property) GetInt8() (int8, bool, error)
- func (i Property) GetNumber() (any, bool, error)
- func (i Property) GetString() (string, bool, error)
- func (i Property) GetType() Type
- func (i Property) GetUint() (uint, bool, error)
- func (i Property) GetUint16() (uint16, bool, error)
- func (i Property) GetUint32() (uint32, bool, error)
- func (i Property) GetUint64() (uint64, bool, error)
- func (i Property) GetUint8() (uint8, bool, error)
- func (i Property) GetValue() Value
- type Schema
- func AnySchema(n string, d any) Schema
- func BoolSchema(n string, d *bool) Schema
- func DurationSchema(n string, d *time.Duration) Schema
- func Float32Schema(n string, d *float32) Schema
- func Float64Schema(n string, d *float64) Schema
- func GuessSchema(n, t string, d any) (Schema, error)
- func Int16Schema(n string, d *int16) Schema
- func Int32Schema(n string, d *int32) Schema
- func Int64Schema(n string, d *int64) Schema
- func Int8Schema(n string, d *int8) Schema
- func IntSchema(n string, d *int) Schema
- func MapSchema[T any](n string, d map[string]T) Schema
- func ObjectSchema[T any](n string, d T) Schema
- func SetSchema[T comparable](n string, d []T) Schema
- func SliceSchema[T any](n string, d []T) Schema
- func StringSchema(n string, d *string) Schema
- func Uint16Schema(n string, d *uint16) Schema
- func Uint32Schema(n string, d *uint32) Schema
- func Uint64Schema(n string, d *uint64) Schema
- func Uint8Schema(n string, d *uint8) Schema
- func UintSchema(n string, d *uint) Schema
- func (i Schema) WithDescription(d string) Schema
- func (i Schema) WithGroup(g string) Schema
- func (i Schema) WithHidden() Schema
- func (i Schema) WithLabel(l string) Schema
- func (i Schema) WithOptions(o ...Value) Schema
- func (i Schema) WithRequired() Schema
- func (i Schema) WithSensitive() Schema
- func (i Schema) WithShowIf(s string) Schema
- func (i Schema) WithValue(expr []byte) Schema
- type Schemas
- type Type
- type Value
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAny ¶
GetAny returns the underlay value as the given generic type, if not found or parse error, returns false.
func GetMap ¶
GetMap returns the underlay value as a string map with the given generic type, if not found or parse error, returns false.
func GetObject ¶
GetObject returns the underlay value as a T object with the given generic type, if not found or parse error, returns false.
func GetSet ¶
GetSet returns the underlay value as a set with the given generic type, if not found or parse error, returns false.
func GetSlice ¶
GetSlice returns the underlay value as a slice with the given generic type, if not found or parse error, returns false.
func PropertiesField ¶
func PropertiesField(name string) *otherBuilder
PropertiesField returns a new ent.Field with type Properties.
func SchemasField ¶
func SchemasField(name string) *otherBuilder
SchemasField returns a new ent.Field with type Schemas.
func ValuesField ¶
func ValuesField(name string) *otherBuilder
ValuesField returns a new ent.Field with type Values.
Types ¶
type IProperty ¶
type IProperty interface { // GetType returns the Type of the property. GetType() Type // GetValue returns the Value of the property. GetValue() Value // GetNumber returns the underlay value as a number, // if not found, returns false. GetNumber() (any, bool, error) // GetUint64 returns the underlay value as uint64, // if not found, returns false. GetUint64() (uint64, bool, error) // GetUint32 returns the underlay value as uint32, // if not found, returns false. GetUint32() (uint32, bool, error) // GetUint16 returns the underlay value as uint16, // if not found, returns false. GetUint16() (uint16, bool, error) // GetUint8 returns the underlay value as uint8, // if not found, returns false. GetUint8() (uint8, bool, error) // GetUint returns the underlay value as uint, // if not found, returns false. GetUint() (uint, bool, error) // GetInt64 returns the underlay value as int64, // if not found, returns false. GetInt64() (int64, bool, error) // GetInt32 returns the underlay value as int32, // if not found, returns false. GetInt32() (int32, bool, error) // GetInt16 returns the underlay value as int16, // if not found, returns false. GetInt16() (int16, bool, error) // GetInt8 returns the underlay value as int8, // if not found, returns false. GetInt8() (int8, bool, error) // GetInt returns the underlay value as int, // if not found, returns false. GetInt() (int, bool, error) // GetFloat64 returns the underlay value as float64, // if not found, returns false. GetFloat64() (float64, bool, error) // GetFloat32 returns the underlay value as float32, // if not found, returns false. GetFloat32() (float32, bool, error) // GetDuration returns the underlay value as time.Duration, // if not found, returns false. GetDuration() (time.Duration, bool, error) // GetBool returns the underlay value as bool, // if not found, returns false. GetBool() (bool, bool, error) // GetString returns the underlay value as string, // if not found, returns false. GetString() (string, bool, error) // Cty returns the cty.Type and cty.Value of this value. Cty() (cty.Type, cty.Value, error) }
IProperty holds the functions of the property.
type Properties ¶
Properties holds the Property collection in map, the key of map is the name of Property, stores into json.
func (Properties) TypedValues ¶
func (i Properties) TypedValues() (m map[string]any, err error)
TypedValues returns a map stores the typed value.
func (Properties) Value ¶
func (i Properties) Value() (driver.Value, error)
Value implements driver.Valuer.
func (Properties) Values ¶
func (i Properties) Values() Values
Values returns a map stores the underlay value.
type Property ¶
type Property struct { // Type specifies the type of this property. Type Type `json:"type"` // Value specifies the value of this property. Value Value `json:"value,omitempty"` }
Property holds the type and underlay value of the property.
func BoolProperty ¶
BoolProperty wraps bool value into a property.
func DurationProperty ¶
DurationProperty wraps time.Duration value into a property.
func Float32Property ¶
Float32Property wraps float32 value into a property.
func Float64Property ¶
Float64Property wraps float64 value into a property.
func Int16Property ¶
Int16Property wraps int16 value into a property.
func Int32Property ¶
Int32Property wraps int32 value into a property.
func Int64Property ¶
Int64Property wraps int64 value into a property.
func Int8Property ¶
Int8Property wraps int8 value into a property.
func MapProperty ¶
MapProperty wraps map value into a property.
func ObjectProperty ¶
ObjectProperty wraps object value into a property.
func SetProperty ¶
func SetProperty[T comparable](v sets.Set[T]) Property
SetProperty wraps set value into a property.
func SliceProperty ¶
SliceProperty wraps slice value into a property.
func StringProperty ¶
StringProperty wraps string value into a property.
func Uint16Property ¶
Uint16Property wraps uint16 value into a property.
func Uint32Property ¶
Uint32Property wraps uint32 value into a property.
func Uint64Property ¶
Uint64Property wraps uint64 value into a property.
func Uint8Property ¶
Uint8Property wraps uint8 value into a property.
func UintProperty ¶
UintProperty wraps uint value into a property.
type Schema ¶
type Schema struct { // Name specifies the name of this property. Name string `json:"name"` // Description specifies the description of this property. Description string `json:"description,omitempty"` // Type specifies the type of this property. Type Type `json:"type"` // Default specifies the default value of this property. Default Value `json:"default,omitempty"` // Value argument takes an expression whose result is to generate value. Value []byte `json:"value,omitempty"` // Required indicates this property is required or not. Required bool `json:"required,omitempty"` // Sensitive indicates this property is sensitive or not. Sensitive bool `json:"sensitive,omitempty"` // Label specifies the UI label of this property. Label string `json:"label,omitempty"` // Group specifies the UI group of this property, // combines multiple levels with a slash. Group string `json:"group,omitempty"` // Options specifies available options of this property when the type is string. Options []Value `json:"options,omitempty"` // ShowIf specifies to show this property if the condition is true, // e.g. ShowIf: foo=bar. ShowIf string `json:"showIf,omitempty"` // Hidden specifies the field should be hidden or not, // default is visible. Hidden bool `json:"hidden,omitempty"` }
Schema holds the schema of the property.
func DurationSchema ¶
DurationSchema returns time.Duration schema.
func Float32Schema ¶
Float32Schema returns float32 schema.
func Float64Schema ¶
Float64Schema returns float64 schema.
func GuessSchema ¶
GuessSchema guesses the schema with the given type and data, returns any schema if blank type and nil data(in fact, terraform validation must not let this pass), returns implied type schema if data is not nil, returns parsed type schema if type is not blank.
func SetSchema ¶
func SetSchema[T comparable](n string, d []T) Schema
SetSchema returns sets.Set[T] schema.
func StringSchema ¶
StringSchema returns string schema.
func Uint16Schema ¶
Uint16Schema returns uint16 schema.
func Uint32Schema ¶
Uint32Schema returns uint32 schema.
func Uint64Schema ¶
Uint64Schema returns uint64 schema.
func (Schema) WithDescription ¶
WithDescription indicates the description of schema.
func (Schema) WithHidden ¶
WithHidden indicates the schema is hidden.
func (Schema) WithOptions ¶
WithOptions indicates the options of schema.
func (Schema) WithRequired ¶
WithRequired indicates the schema is required.
func (Schema) WithSensitive ¶
WithSensitive indicates the schema is sensitive.
func (Schema) WithShowIf ¶
WithShowIf indicates the condition of schema.
type Schemas ¶
type Schemas []Schema
Schemas holds the Schema collection in slice, stores into json.
type Type ¶
Type indicates the type of property, supported types described as below.
| Definition | JSON Output | | ----------------------------- | ----------------------------- | | any | "dynamic" | | | | | string | "string" | | | | | number | "number" | | | | | bool | "bool" | | | | | map(any) | [ | | | "map", | | | "dynamic" | | | ] | | map(string) | [ | | | "map", | | | "string" | | | ] | | | | | list(string) | [ | | | "list", | | | "string" | | | ] | | | | | list(object({ | [ | | a = string | "list", | | b = number | [ | | c = bool | "object", | | })) | { | | | "a":"string", | | | "b":"number", | | | "c":"bool" | | | } | | | ] | | | ] | | | | | object({ | [ | | a = string | "object", | | b = number | { | | c = bool | "a":"string", | | }) | "b":"number", | | | "c":"bool" | | | } | | | ] | | | | | object({ | [ | | a = string | "object", | | b = list(object({ | { | | c = bool | "a":"string", | | })) | "b":[ | | }) | "list", | | | [ | | | "object", | | | { | | | "c":"bool" | | | } | | | ] | | | ] | | | } | | | ] | | | | | tuple([string, bool, number]) | [ | | | "tuple", | | | [ | | | "string", | | | "bool", | | | "number" | | | ] | | | ] |
type Values ¶
Values holds the Value collection in map, the key of map is the name of Property, stores into json.
func (Values) StringTypesWith ¶
StringTypesWith is similar with TypesWith, but returns the property type in string.
func (Values) TypesWith ¶
TypesWith aligns the property name and type with the given property.Schemas.
func (Values) ValidateWith ¶
ValidateWith validates the property value with the given schemas.