numorstring

package
v0.0.0-...-bce6247 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// Default forwarding, i.e. best effort.
	DF = "DF" //  DSCP value 0

	// Expedited Forwarding
	EF = "EF" // DSCP value 46

	// Assured Forwarding
	AF11 = "AF11" // DSCP value 10
	AF12 = "AF12" // DSCP value 12
	AF13 = "AF13" // DSCP value 14

	AF21 = "AF21" // DSCP value 18
	AF22 = "AF22" // DSCP value 20
	AF23 = "AF23" // DSCP value 22

	AF31 = "AF31" // DSCP value 26
	AF32 = "AF32" // DSCP value 28
	AF33 = "AF33" // DSCP value 30

	AF41 = "AF41" // DSCP value 34
	AF42 = "AF42" // DSCP value 36
	AF43 = "AF43" // DSCP value 38

	// Class selectors, defined in RFC for backward compatibility with IP precedence.
	CS0 = "CS0" // DSCP value 0, similar to DF
	CS1 = "CS1" // DSCP value 8
	CS2 = "CS2" // DSCP value 16
	CS3 = "CS3" // DSCP value 24
	CS4 = "CS4" // DSCP value 32
	CS5 = "CS5" // DSCP value 40
	CS6 = "CS6" // DSCP value 48
)
View Source
const (
	ProtocolUDP     = "UDP"
	ProtocolTCP     = "TCP"
	ProtocolICMP    = "ICMP"
	ProtocolICMPv6  = "ICMPv6"
	ProtocolSCTP    = "SCTP"
	ProtocolUDPLite = "UDPLite"

	ProtocolUDPV1  = "udp"
	ProtocolTCPV1  = "tcp"
	ProtocolSCTPV1 = "sctp"
)

Variables

View Source
var (
	AllDSCPValues = map[string]uint8{
		DF: 0,
		EF: 46,

		AF11: 10, AF12: 12, AF13: 14,
		AF21: 18, AF22: 20, AF23: 22,
		AF31: 26, AF32: 28, AF33: 30,
		AF41: 34, AF42: 36, AF43: 38,

		CS0: 0, CS1: 8, CS2: 16,
		CS3: 24, CS4: 32, CS5: 40,
		CS6: 48,
	}
)

Functions

This section is empty.

Types

type ASNumber

type ASNumber uint32

func ASNumberFromString

func ASNumberFromString(s string) (ASNumber, error)

ASNumberFromString creates an ASNumber struct from a string value. The string value may simply be a number or may be the ASN in dotted notation.

func (ASNumber) String

func (a ASNumber) String() string

String returns the string value, or the Itoa of the uint value.

func (*ASNumber) UnmarshalJSON

func (a *ASNumber) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller uinterface.

type DSCP

type DSCP Uint8OrString

+kubebuilder:validation:Type=integer +kubebuilder:validation:XIntOrString +kubebuilder:validation:Pattern=`^.*`

func DSCPFromInt

func DSCPFromInt(v uint8) DSCP

DSCPFromInt creates a DSCP struct from an integer value.

func DSCPFromString

func DSCPFromString(s string) DSCP

DSCPFromString creates a DSCP struct from a string value.

func (DSCP) MarshalJSON

func (d DSCP) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (DSCP) OpenAPISchemaFormat

func (DSCP) OpenAPISchemaFormat() string

OpenAPISchemaFormat 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 (DSCP) OpenAPISchemaType

func (DSCP) 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 (DSCP) String

func (d DSCP) String() string

String returns the string value, or the Itoa of the int value.

func (*DSCP) ToUint8

func (d *DSCP) ToUint8() uint8

func (*DSCP) UnmarshalJSON

func (d *DSCP) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

func (*DSCP) Validate

func (d *DSCP) Validate() error

type NumOrStringType

type NumOrStringType int

Type represents the stored type of Int32OrString.

const (
	NumOrStringNum    NumOrStringType = iota // The structure holds a number.
	NumOrStringString                        // The structure holds a string.
)

type Port

type Port struct {
	MinPort  uint16 `json:"minPort,omitempty"`
	MaxPort  uint16 `json:"maxPort,omitempty"`
	PortName string `json:"portName" validate:"omitempty,portName"`
}

Port represents either a range of numeric ports or a named port.

  • For a named port, set the PortName, leaving MinPort and MaxPort as 0.
  • For a port range, set MinPort and MaxPort to the (inclusive) port numbers. Set PortName to "".
  • For a single port, set MinPort = MaxPort and PortName = "".

func NamedPort

func NamedPort(name string) Port

func PortFromRange

func PortFromRange(minPort, maxPort uint16) (Port, error)

PortFromRange creates a Port struct representing a range of ports.

func PortFromString

func PortFromString(s string) (Port, error)

PortFromString creates a Port struct from its string representation. A port may either be single value "1234", a range of values "100:200" or a named port: "name".

func SinglePort

func SinglePort(port uint16) Port

SinglePort creates a Port struct representing a single port.

func (Port) MarshalJSON

func (p Port) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (Port) OpenAPISchemaFormat

func (Port) OpenAPISchemaFormat() string

OpenAPISchemaFormat 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 (Port) OpenAPISchemaType

func (Port) 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 (Port) String

func (p Port) String() string

String returns the string value. If the min and max port are the same this returns a single string representation of the port number, otherwise if returns a colon separated range of ports.

func (*Port) UnmarshalJSON

func (p *Port) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

type Protocol

type Protocol Uint8OrString

func ProtocolFromInt

func ProtocolFromInt(p uint8) Protocol

ProtocolFromInt creates a Protocol struct from an integer value.

func ProtocolFromString

func ProtocolFromString(p string) Protocol

ProtocolFromString creates a Protocol struct from a string value.

func ProtocolFromStringV1

func ProtocolFromStringV1(p string) Protocol

ProtocolFromStringV1 creates a Protocol struct from a string value (for the v1 API)

func ProtocolV3FromProtocolV1

func ProtocolV3FromProtocolV1(p Protocol) Protocol

ProtocolV3FromProtocolV1 creates a v3 Protocol from a v1 Protocol, while handling case conversion.

func (Protocol) MarshalJSON

func (p Protocol) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (Protocol) NumValue

func (p Protocol) NumValue() (uint8, error)

NumValue returns the NumVal if type Int, or if it is a String, will attempt a conversion to int.

func (Protocol) OpenAPISchemaFormat

func (Protocol) OpenAPISchemaFormat() string

OpenAPISchemaFormat 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 (Protocol) OpenAPISchemaType

func (Protocol) 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 (Protocol) String

func (p Protocol) String() string

String returns the string value, or the Itoa of the int value.

func (Protocol) SupportsPorts

func (p Protocol) SupportsPorts() bool

SupportsProtocols returns whether this protocol supports ports. This returns true if the numerical or string version of the protocol indicates TCP (6), UDP (17), or SCTP (132).

func (Protocol) ToV1

func (p Protocol) ToV1() Protocol

String returns the string value, or the Itoa of the int value.

func (*Protocol) UnmarshalJSON

func (p *Protocol) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

type Uint8OrString

type Uint8OrString struct {
	Type   NumOrStringType `json:"type"`
	NumVal uint8           `json:"numVal"`
	StrVal string          `json:"strVal"`
}

UInt8OrString is a type that can hold an uint8 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 name or number.

func (Uint8OrString) MarshalJSON

func (i Uint8OrString) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (Uint8OrString) NumValue

func (i Uint8OrString) NumValue() (uint8, error)

NumValue returns the NumVal if type Int, or if it is a String, will attempt a conversion to int.

func (Uint8OrString) OpenAPISchemaFormat

func (Uint8OrString) OpenAPISchemaFormat() string

OpenAPISchemaFormat 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 (Uint8OrString) OpenAPISchemaType

func (Uint8OrString) 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 (Uint8OrString) String

func (i Uint8OrString) String() string

String returns the string value, or the Itoa of the int value.

func (*Uint8OrString) UnmarshalJSON

func (i *Uint8OrString) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

Jump to

Keyboard shortcuts

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