k8sutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: LGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPointer

func BoolPointer(b bool) *bool

func ContainsString

func ContainsString(slice []string, s string) bool

func EmptyTypedFloatSlice

func EmptyTypedFloatSlice(f ...float64) []interface{}

func EmptyTypedStrSlice

func EmptyTypedStrSlice(s ...string) []interface{}

func GetAPIServerCertSANs

func GetAPIServerCertSANs(c *devopsv1.Cluster) []string

GetAPIServerCertSANs returns extra APIServer's certSANs need to pass kubeadm

func GetIndexedIP

func GetIndexedIP(subnet string, index int) (net.IP, error)

func GetNodeCIDRMaskSize

func GetNodeCIDRMaskSize(clusterCIDR string, maxNodePodNum int32) (int32, error)

func GetServiceCIDRAndNodeCIDRMaskSize

func GetServiceCIDRAndNodeCIDRMaskSize(clusterCIDR string, maxClusterServiceNum int32, maxNodePodNum int32) (string, int32, error)

func GroupVersionKindsHasKind

func GroupVersionKindsHasKind(gvks []schema.GroupVersionKind, kind string) bool

GroupVersionKindsHasKind returns whether the following gvk slice contains the kind given as a parameter

func Int64Pointer

func Int64Pointer(i int64) *int64

func IntPointer

func IntPointer(i int32) *int32

func IntstrPointer

func IntstrPointer(i int) *intstr.IntOrString

func IsObjectChanged

func IsObjectChanged(oldObj, newObj runtime.Object, ignoreStatusChange bool) (bool, error)

IsObjectChanged checks whether there is an actual difference between the two objects

func LoadObjs

func LoadObjs(f io.Reader) ([]client.Object, error)

func MarshalToYaml

func MarshalToYaml(obj runtime.Object, gv schema.GroupVersion) ([]byte, error)

MarshalToYaml marshals an object into yaml.

func MarshalToYamlForCodecs

func MarshalToYamlForCodecs(obj runtime.Object, gv schema.GroupVersion, codecs serializer.CodecFactory) ([]byte, error)

MarshalToYamlForCodecs marshals an object into yaml using the specified codec TODO: Is specifying the gv really needed here? TODO: Can we support json out of the box easily here?

func MergeMultipleStringMaps

func MergeMultipleStringMaps(stringMaps ...map[string]string) map[string]string

func MergeStringMaps

func MergeStringMaps(l map[string]string, l2 map[string]string) map[string]string

func ObjectMeta

func ObjectMeta(name string, labels map[string]string, obj runtime.Object) metav1.ObjectMeta

func PointerToBool

func PointerToBool(flag *bool) bool

func PointerToInt32

func PointerToInt32(i *int32) int32

func PointerToString

func PointerToString(s *string) string

func Reconcile

func Reconcile(log logr.Logger, cli client.Client, desired client.Object, desiredState DesiredState) error

func ReconcileCRDs

func ReconcileCRDs(cfg *rest.Config, crds []*apiextensionsv1.CustomResourceDefinition) error

nolint ReconcileCRDs crds apply must before manager cache start, so crds apply need use raw kubernetes client

func ReconcileNamespaceLabelsIgnoreNotFound

func ReconcileNamespaceLabelsIgnoreNotFound(log logr.Logger, cli client.Client, namespace string, labels map[string]string, labelsToRemove []string) error

ReconcileNamespaceLabelsIgnoreNotFound patches namespaces by adding/removing labels, returns without error if namespace is not found

func RemoveNonYAMLLines

func RemoveNonYAMLLines(yms string) string

func RemoveString

func RemoveString(slice []string, s string) (result []string)

func StrPointer

func StrPointer(s string) *string

func UnmarshalFromYaml

func UnmarshalFromYaml(buffer []byte, gv schema.GroupVersion) (runtime.Object, error)

UnmarshalFromYaml unmarshals yaml into an object.

func UnmarshalFromYamlForCodecs

func UnmarshalFromYamlForCodecs(buffer []byte, gv schema.GroupVersion, codecs serializer.CodecFactory) (runtime.Object, error)

UnmarshalFromYamlForCodecs unmarshals yaml into an object using the specified codec TODO: Is specifying the gv really needed here? TODO: Can we support json out of the box easily here?

Types

type DesiredState

type DesiredState string
const (
	DesiredStatePresent DesiredState = "present"
	DesiredStateAbsent  DesiredState = "absent"
)

Jump to

Keyboard shortcuts

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