Documentation ¶
Index ¶
- func GenerateClientConfigFromRESTConfig(name string, restConfig *rest.Config) *configapi.Config
- type ApplyResult
- type Helper
- func NewHelper(kubeconfig []byte, logger log.FieldLogger) *Helper
- func NewHelperFromRESTConfig(restConfig *rest.Config, logger log.FieldLogger) *Helper
- func NewHelperWithMetrics(kubeconfig []byte, controllerName string, remote bool, logger log.FieldLogger) *Helper
- func NewHelperWithMetricsFromRESTConfig(restConfig *rest.Config, controllerName string, logger log.FieldLogger) *Helper
- func (r *Helper) Apply(obj []byte) (ApplyResult, error)
- func (r *Helper) ApplyRuntimeObject(obj runtime.Object, scheme *runtime.Scheme) (ApplyResult, error)
- func (r *Helper) Info(obj []byte) (*Info, error)
- func (r *Helper) Patch(name types.NamespacedName, kind, apiVersion string, patch []byte, ...) error
- func (r *Helper) Serialize(obj runtime.Object, scheme *runtime.Scheme) ([]byte, error)
- type Info
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateClientConfigFromRESTConfig ¶
GenerateClientConfigFromRESTConfig generates a new kubeconfig using a given rest.Config. The rest.Config may come from in-cluster config (as in a pod) or an existing kubeconfig.
Types ¶
type ApplyResult ¶
type ApplyResult string
ApplyResult indicates what type of change was performed by calling the Apply function
var ( // ConfiguredApplyResult is returned when a patch was submitted ConfiguredApplyResult ApplyResult = "configured" // UnchangedApplyResult is returned when no change occurred UnchangedApplyResult ApplyResult = "unchanged" // CreatedApplyResult is returned when a resource was created CreatedApplyResult ApplyResult = "created" // UnknownApplyResult is returned when the resulting action could not be determined UnknownApplyResult ApplyResult = "unknown" )
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper contains configuration for apply and patch operations
func NewHelper ¶
func NewHelper(kubeconfig []byte, logger log.FieldLogger) *Helper
NewHelper returns a new object that allows apply and patch operations
func NewHelperFromRESTConfig ¶
func NewHelperFromRESTConfig(restConfig *rest.Config, logger log.FieldLogger) *Helper
NewHelperFromRESTConfig returns a new object that allows apply and patch operations
func NewHelperWithMetrics ¶
func NewHelperWithMetrics(kubeconfig []byte, controllerName string, remote bool, logger log.FieldLogger) *Helper
NewHelperWithMetrics returns a new object that allows apply and patch operations, with metrics tracking enabled.
func NewHelperWithMetricsFromRESTConfig ¶
func NewHelperWithMetricsFromRESTConfig(restConfig *rest.Config, controllerName string, logger log.FieldLogger) *Helper
NewHelperWithMetricsFromRESTConfig returns a new object that allows apply and patch operations, with metrics tracking enabled.
func (*Helper) Apply ¶
func (r *Helper) Apply(obj []byte) (ApplyResult, error)
Apply applies the given resource bytes to the target cluster specified by kubeconfig
func (*Helper) ApplyRuntimeObject ¶
func (r *Helper) ApplyRuntimeObject(obj runtime.Object, scheme *runtime.Scheme) (ApplyResult, error)
ApplyRuntimeObject serializes an object and applies it to the target cluster specified by the kubeconfig.
func (*Helper) Patch ¶
func (r *Helper) Patch(name types.NamespacedName, kind, apiVersion string, patch []byte, patchType string) error
Patch invokes the kubectl patch command with the given resource, patch and patch type
func (*Helper) Serialize ¶
Serialize uses a custom JSON extension to properly determine whether metav1.Time should be serialized or not. In cases where a metav1.Time is labeled as 'omitempty', the default json marshaler still outputs a "null" value because it is considered a struct. The json-iterator/go marshaler will first check whether a value is empty and if its tag says 'omitempty' it will not output it. This is needed for us to prevent patching from happening unnecessarily when applying resources that don't have a timeCreated timestamp. With the default serializer, they output a `timeCreated: null` which always causes a mismatch with whatever's already in the server.