package intstr
import "k8s.io/apimachinery/pkg/util/intstr"
Index ¶
- Variables
- func GetScaledValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error)
- func GetValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error)
- type IntOrString
- func FromInt(val int) IntOrString
- func FromInt32(val int32) IntOrString
- func FromString(val string) IntOrString
- func Parse(val string) IntOrString
- func ValueOrDefault(intOrPercent *IntOrString, defaultValue IntOrString) *IntOrString
- func (*IntOrString) Descriptor() ([]byte, []int)
- func (intstr *IntOrString) IntValue() int
- func (m *IntOrString) Marshal() (dAtA []byte, err error)
- func (intstr IntOrString) MarshalCBOR() ([]byte, error)
- func (intstr IntOrString) MarshalJSON() ([]byte, error)
- func (m *IntOrString) MarshalTo(dAtA []byte) (int, error)
- func (m *IntOrString) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (IntOrString) OpenAPISchemaFormat() string
- func (IntOrString) OpenAPISchemaType() []string
- func (IntOrString) OpenAPIV3OneOfTypes() []string
- func (*IntOrString) ProtoMessage()
- func (intstr *IntOrString) RandFill(c randfill.Continue)
- func (m *IntOrString) Reset()
- func (m *IntOrString) Size() (n int)
- func (intstr *IntOrString) String() string
- func (m *IntOrString) Unmarshal(dAtA []byte) error
- func (intstr *IntOrString) UnmarshalCBOR(value []byte) error
- func (intstr *IntOrString) UnmarshalJSON(value []byte) error
- func (m *IntOrString) XXX_DiscardUnknown()
- func (m *IntOrString) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *IntOrString) XXX_Merge(src proto.Message)
- func (m *IntOrString) XXX_Size() int
- func (m *IntOrString) XXX_Unmarshal(b []byte) error
- type Type
Variables ¶
var ( ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group") )
Functions ¶
func GetScaledValueFromIntOrPercent ¶
func GetScaledValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error)
GetScaledValueFromIntOrPercent is meant to replace GetValueFromIntOrPercent. This method returns a scaled value from an IntOrString type. If the IntOrString is a percentage string value it's treated as a percentage and scaled appropriately in accordance to the total, if it's an int value it's treated as a simple value and if it is a string value which is either non-numeric or numeric but lacking a trailing '%' it returns an error.
func GetValueFromIntOrPercent ¶
func GetValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error)
GetValueFromIntOrPercent was deprecated in favor of GetScaledValueFromIntOrPercent. This method was treating all int as a numeric value and all strings with or without a percent symbol as a percentage value. Deprecated
Types ¶
type IntOrString ¶
type IntOrString struct { Type Type `protobuf:"varint,1,opt,name=type,casttype=Type"` IntVal int32 `protobuf:"varint,2,opt,name=intVal"` StrVal string `protobuf:"bytes,3,opt,name=strVal"` }
IntOrString is a type that can hold an int32 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. TODO: Rename to Int32OrString
+protobuf=true +protobuf.options.(gogoproto.goproto_stringer)=false +k8s:openapi-gen=true
func FromInt ¶
func FromInt(val int) IntOrString
FromInt creates an IntOrString object with an int32 value. It is your responsibility not to call this method with a value greater than int32. Deprecated: use FromInt32 instead.
func FromInt32 ¶
func FromInt32(val int32) IntOrString
FromInt32 creates an IntOrString object with an int32 value.
func FromString ¶
func FromString(val string) IntOrString
FromString creates an IntOrString object with a string value.
func Parse ¶
func Parse(val string) IntOrString
Parse the given string and try to convert it to an int32 integer before setting it as a string value.
func ValueOrDefault ¶
func ValueOrDefault(intOrPercent *IntOrString, defaultValue IntOrString) *IntOrString
func (*IntOrString) Descriptor ¶
func (*IntOrString) Descriptor() ([]byte, []int)
func (*IntOrString) IntValue ¶
func (intstr *IntOrString) IntValue() int
IntValue returns the IntVal if type Int, or if it is a String, will attempt a conversion to int, returning 0 if a parsing error occurs.
func (*IntOrString) Marshal ¶
func (m *IntOrString) Marshal() (dAtA []byte, err error)
func (IntOrString) MarshalCBOR ¶
func (intstr IntOrString) MarshalCBOR() ([]byte, error)
func (IntOrString) MarshalJSON ¶
func (intstr IntOrString) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaller interface.
func (*IntOrString) MarshalTo ¶
func (m *IntOrString) MarshalTo(dAtA []byte) (int, error)
func (*IntOrString) MarshalToSizedBuffer ¶
func (m *IntOrString) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (IntOrString) OpenAPISchemaFormat ¶
func (IntOrString) OpenAPISchemaFormat() string
OpenAPISchemaFormat is used by the kube-openapi generator when constructing the OpenAPI spec of this type.
func (IntOrString) OpenAPISchemaType ¶
func (IntOrString) 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 (IntOrString) OpenAPIV3OneOfTypes ¶
func (IntOrString) OpenAPIV3OneOfTypes() []string
OpenAPIV3OneOfTypes is used by the kube-openapi generator when constructing the OpenAPI v3 spec of this type.
func (*IntOrString) ProtoMessage ¶
func (*IntOrString) ProtoMessage()
func (*IntOrString) RandFill ¶
func (intstr *IntOrString) RandFill(c randfill.Continue)
RandFill satisfies randfill.NativeSelfFiller
func (*IntOrString) Reset ¶
func (m *IntOrString) Reset()
func (*IntOrString) Size ¶
func (m *IntOrString) Size() (n int)
func (*IntOrString) String ¶
func (intstr *IntOrString) String() string
String returns the string value, or the Itoa of the int value.
func (*IntOrString) Unmarshal ¶
func (m *IntOrString) Unmarshal(dAtA []byte) error
func (*IntOrString) UnmarshalCBOR ¶
func (intstr *IntOrString) UnmarshalCBOR(value []byte) error
func (*IntOrString) UnmarshalJSON ¶
func (intstr *IntOrString) UnmarshalJSON(value []byte) error
UnmarshalJSON implements the json.Unmarshaller interface.
func (*IntOrString) XXX_DiscardUnknown ¶
func (m *IntOrString) XXX_DiscardUnknown()
func (*IntOrString) XXX_Marshal ¶
func (m *IntOrString) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*IntOrString) XXX_Merge ¶
func (m *IntOrString) XXX_Merge(src proto.Message)
func (*IntOrString) XXX_Size ¶
func (m *IntOrString) XXX_Size() int
func (*IntOrString) XXX_Unmarshal ¶
func (m *IntOrString) XXX_Unmarshal(b []byte) error
type Type ¶
type Type int64
Type represents the stored type of IntOrString.
const ( Int Type = iota // The IntOrString holds an int. String // The IntOrString holds a string. )
Source Files ¶
generated.pb.go instr_fuzz.go intstr.go
- Version
- v0.33.0 (latest)
- Published
- Apr 11, 2025
- Platform
- linux/amd64
- Imports
- 13 packages
- Last checked
- 3 hours ago –
Tools for package owners.