multitype

package
v1.82.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolOrString

type BoolOrString struct {
	Type    BoolOrStringType `protobuf:"varbool,1,opt,name=type,casttype=Type" json:"-"`
	BoolVal bool             `protobuf:"varbool,2,opt,name=boolVal" json:"-"`
	StrVal  string           `protobuf:"bytes,3,opt,name=strVal" json:"-"`
}

BoolOrString is a type that can hold an bool or a string. When used in JSON or YAML marshalling and unmarshalling, it produces or consumes the inner type. This allows you to have, for example, a JSON field that can accept a booolean string or raw bool.

+protobuf=true +protobuf.options.(gogoproto.goproto_stringer)=false +k8s:openapi-gen=true +kubebuilder:validation:Type=BoolString

func FromBool

func FromBool(val bool) BoolOrString

FromBool creates an BoolOrString object with a bool value.

func FromString

func FromString(val string) BoolOrString

FromString creates an BoolOrString object with a string value.

func (*BoolOrString) Bool

func (boolstr *BoolOrString) Bool() (bool, error)

Bool returns bool val, if strValu is parsed returns parsed value else false with parse error

func (*BoolOrString) BoolOrDefaultFalse

func (boolstr *BoolOrString) BoolOrDefaultFalse() bool

BoolOrDefaultFalse returns bool val, if strValu is parsed returns parsed value else false as default when parse error

func (*BoolOrString) Boolean

func (boolstr *BoolOrString) Boolean() (bool, error)

Converts string to boolean if needed and returns its value

func (*BoolOrString) Fuzz

func (boolstr *BoolOrString) Fuzz(c fuzz.Continue)

func (*BoolOrString) IsEmpty

func (boolstr *BoolOrString) IsEmpty() bool

Returns true if type is String and the value is the empty string

func (BoolOrString) MarshalJSON

func (boolstr BoolOrString) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (BoolOrString) MarshalYAML

func (boolstr BoolOrString) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaller interface https://godoc.org/gopkg.in/yaml.v3#Marshaler

func (BoolOrString) NewWithSameType

func (v BoolOrString) NewWithSameType(newValue string) (BoolOrString, error)

Convert a string value into a BoolOrString with the same type as v

func (BoolOrString) OpenAPISchemaFormat

func (BoolOrString) OpenAPISchemaFormat() string

OpenAPISchemaFormat is used by the kube-openapi generator when constructing the OpenAPI spec of this type.

func (BoolOrString) OpenAPISchemaType

func (BoolOrString) OpenAPISchemaType() []string

OpenAPISchemaType is used by the kube-openapi generator when constructing the OpenAPI spec of this type.

See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators

func (*BoolOrString) String

func (boolstr *BoolOrString) String() string

String returns the string value, '1' for true, or '0' for false.

func (*BoolOrString) UnmarshalJSON

func (boolstr *BoolOrString) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller boolerface.

type BoolOrStringType

type BoolOrStringType int

Type represents the stored type of BoolOrString.

const (
	String BoolOrStringType = iota // The BoolOrString holds a string.
	Bool                           // The BoolOrString holds an bool.
)

type QuotedBool

type QuotedBool string

QuotedBool is a string type that can also unmarshal raw yaml bools.

+protobuf=true +protobuf.options.(gogoproto.goproto_stringer)=false +k8s:openapi-gen=true +kubebuilder:validation:Type=QuotedBool

func (QuotedBool) OpenAPISchemaFormat

func (QuotedBool) OpenAPISchemaFormat() string

OpenAPISchemaFormat is used by the kube-openapi generator when constructing the OpenAPI spec of this type.

func (QuotedBool) OpenAPISchemaType

func (QuotedBool) OpenAPISchemaType() []string

OpenAPISchemaType is used by the kube-openapi generator when constructing the OpenAPI spec of this type.

See: https://github.com/kubernetes/kube-openapi/tree/master/pkg/generators

func (*QuotedBool) UnmarshalJSON

func (b *QuotedBool) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

func (*QuotedBool) UnmarshalYAML

func (b *QuotedBool) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalJSON implements the yaml.Unmarshaller interface.

Jump to

Keyboard shortcuts

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