multitype

package
v0.110.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

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 Parse

func Parse(val string) *BoolOrString

Parse the given string

func (*BoolOrString) Bool added in v0.30.0

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 added in v0.30.0

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) Fuzz

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

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) 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