Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
Duration represents a time duration that can be marshaled/unmarshaled as a string in JSON. It supports both numeric values (interpreted as nanoseconds) and string values (e.g., "5m", "1h30m").
func (Duration) MarshalJSON ¶
MarshalJSON marshals the Duration to a JSON string representation (e.g., "5m30s").
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON value to Duration. It accepts both numeric values (interpreted as nanoseconds) and string values (e.g., "5m", "1h30m").
type Percentage ¶
Percentage represents a percentage value that can be represented with or without a % suffix. It stores both the numeric value and whether it originally had a % suffix.
func (Percentage) Int ¶
func (p Percentage) Int() int
Int returns the numeric value of the percentage.
func (Percentage) MarshalJSON ¶
func (p Percentage) MarshalJSON() ([]byte, error)
MarshalJSON marshals the Percentage to a JSON string representation.
func (Percentage) String ¶
func (p Percentage) String() string
String returns the string representation of the percentage. If HasSuffix is true, it includes the % suffix.
func (*Percentage) UnmarshalJSON ¶
func (p *Percentage) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals a JSON string to Percentage. It accepts both plain numbers (e.g., "50") and percentage strings (e.g., "50%").
type Replicas ¶
Replicas represents a replica count that can be either an absolute number or a percentage. When IsPercentage is true, Number represents a percentage value.
func (Replicas) Calculate ¶
Calculate returns the actual replica count based on the total replicas. If the replica is a percentage, it calculates the ceiling of (Number * total / 100). If Number is 0, it returns the defaultValue. If IsPercentage is false, it returns the Number directly.
func (Replicas) MarshalJSON ¶
MarshalJSON marshals the Replicas to a JSON string representation.
func (Replicas) String ¶
String returns the string representation of the replicas. If IsPercentage is true, it includes the % suffix.
func (*Replicas) UnmarshalJSON ¶
UnmarshalJSON unmarshals a JSON value to Replicas. It accepts numeric values, string numbers (e.g., "5"), and percentage strings (e.g., "50%").