resource

package
v0.0.0-...-50abef9 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2019 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateClientConfigFromRESTConfig

func GenerateClientConfigFromRESTConfig(name string, restConfig *rest.Config) *configapi.Config

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) Info

func (r *Helper) Info(obj []byte) (*Info, error)

Info determines the name/namespace and type of the passed in resource bytes

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

func (r *Helper) Serialize(obj runtime.Object, scheme *runtime.Scheme) ([]byte, error)

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.

type Info

type Info struct {
	Name       string
	Namespace  string
	APIVersion string
	Kind       string
	Resource   string
}

Info contains information obtained from a resource submitted to the Apply function

Jump to

Keyboard shortcuts

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