The kubragen2.data module

class kubragen2.data.Data

Base class to represent data that can be disabled by a flag. The get_value() function allows for dynamic code generation if needed.

get_value() → Any

Returns the value of the data.

Returns

the data value

is_enabled() → bool

Whether the data is enabled. If not, it will be removed by BuildData().

kubragen2.data.DataGetValue(value: Any, raise_if_disabled: bool = False) → Any

Returns the value. If value is an instance of Data, call its get_value() method, or return None if not enabled.

Parameters
  • value – the value to check

  • raise_if_disabled – whether to raise an exception if the value is disabled.

Returns

the value

Raises

InvalidParamError – if value is disabled

kubragen2.data.DataIsNone(value: Any) → bool

Checks if the value is None. If value is an instance of Data, check its is_enabled() method.

Parameters

value – the value to check for None

Returns

whether the value is None or disabled

class kubragen2.data.DisabledData

A Data class that is always disabled.

get_value() → Any

Returns the value of the data.

Returns

the data value

is_enabled() → bool

Whether the data is enabled. If not, it will be removed by BuildData().

class kubragen2.data.ValueConfiguration(value_path: str)

Value configuration

class kubragen2.data.ValueData(value: Any = None, enabled: bool = True, disabled_if_none: bool = False)

A Data class with constant values.

Parameters
  • value – the value to return in get_value()

  • enabled – whether the data is enabled

  • disabled_if_none – set enabled=False if value is None

get_value() → Any

Returns the value of the data.

Returns

the data value

is_enabled() → bool

Whether the data is enabled. If not, it will be removed by BuildData().