Documentation ¶
Index ¶
- Constants
- func CheckError(err error, msg string)
- func Cleanup(clients *K8sClients, namespace string, resources []Resource) error
- func CreateFile(path string) (afero.File, error)
- func CreateResource(gvr schema.GroupVersionResource, clients *K8sClients, res Resource) error
- func Deploy(clients *K8sClients, namespace string, resources []Resource, ...) error
- func ExtractYAMLFiles(paths []string) ([]string, error)
- func FromGVKtoGVR(discoveryClient discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
- func GetChecksum(content []byte) string
- func GetMiaAnnotation(name string) string
- func GetResource(gvr schema.GroupVersionResource, clients *K8sClients, res Resource) (*unstructured.Unstructured, error)
- func IsNotUsingSemver(target *Resource) (bool, error)
- func ListResources(gvr schema.GroupVersionResource, clients *K8sClients) (*unstructured.UnstructuredList, error)
- func MakeResources(filePaths []string, namespace string, clients *K8sClients) ([]Resource, []Resource, error)
- func MkdirAll(name string) error
- func NewResourcesFromBuffer(stream []byte) ([]Resource, []Resource, error)
- func NewResourcesFromFile(filepath string) ([]Resource, []Resource, error)
- func PatchResource(gvr schema.GroupVersionResource, clients *K8sClients, res Resource, ...) error
- func ReadFile(filename string) ([]byte, error)
- func RemoveAll(path string) error
- func WriteFile(filename string, data []byte) error
- func WriteYamlsToDisk(objs map[string]runtime.Object, outputDirectory string)
- type ApplyFunction
- type DeployConfig
- type K8sClients
- type Options
- type RealSupportedResourcesGetter
- type Resource
- type ResourceList
- type ResourceNamespace
- type SupportedResourcesGetter
Constants ¶
const CustomResourceDefinitionName = "CustomResourceDefinition"
const (
StdinToken = "-"
)
Variables ¶
This section is empty.
Functions ¶
func Cleanup ¶
func Cleanup(clients *K8sClients, namespace string, resources []Resource) error
Cleanup removes the resources no longer deployed and updates the secret in the cluster with the updated set of resources
func CreateFile ¶
CreateFile create a new file in path
func CreateResource ¶
func CreateResource(gvr schema.GroupVersionResource, clients *K8sClients, res Resource) error
CreateResource handles the creation of a k8s resource when not already present on the cluster
func Deploy ¶
func Deploy(clients *K8sClients, namespace string, resources []Resource, deployConfig DeployConfig, supportedResourcesGetter SupportedResourcesGetter, apply ApplyFunction) error
Deploy ensures namespace existence and applies the resources to the cluster
func ExtractYAMLFiles ¶
ExtractYAMLFiles return array of YAML filenames from array of files and directories
func FromGVKtoGVR ¶
func FromGVKtoGVR(discoveryClient discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (schema.GroupVersionResource, error)
func GetChecksum ¶
GetChecksum is used to calculate a checksum using an array of bytes
func GetMiaAnnotation ¶
GetMiaAnnotation is used to get an annotation name following a pattern used in mia-platform
func GetResource ¶
func GetResource(gvr schema.GroupVersionResource, clients *K8sClients, res Resource) (*unstructured.Unstructured, error)
GetResource returns the identified resource if present on the cluster if the resource does not exist, returns a NotFound error
func IsNotUsingSemver ¶
IsNotUsingSemver is used to check if a resoure is following semver or not
func ListResources ¶
func ListResources(gvr schema.GroupVersionResource, clients *K8sClients) (*unstructured.UnstructuredList, error)
ListResources returns the list of resources with the given GVR across all namespaces. If no resource exists, returns a NotFound error
func MakeResources ¶
func MakeResources(filePaths []string, namespace string, clients *K8sClients) ([]Resource, []Resource, error)
MakeResources takes a filepath/buffer. It returns two arrays of resources, respectively for CRDs and other kinds, to allow the implementation of the 2-step apply.
func NewResourcesFromBuffer ¶
NewResourcesFromBuffer exposes the createResourcesFromBuffer function setting the filepath to "buffer"
func NewResourcesFromFile ¶
NewResourcesFromFile creates new Resources from a file at `filepath`. It returns two arrays of resources, respectively for CRDs and other kinds, to allow the implementation of the 2-step apply. Supports multiple documents inside a single file
func PatchResource ¶
func PatchResource(gvr schema.GroupVersionResource, clients *K8sClients, res Resource, onClusterObj *unstructured.Unstructured) error
PatchResource patches a resource that already exists on the cluster and needs to be updated
Types ¶
type ApplyFunction ¶
type ApplyFunction func(clients *K8sClients, res Resource, deployConfig DeployConfig) error
func DecorateApplyFunction ¶
func DecorateApplyFunction(apply ApplyFunction, decorators ...func(ApplyFunction) ApplyFunction) ApplyFunction
DecorateApplyFunction allows to generate an apply function with a generic number of decorators before calling the actual apply
func DecorateDefaultApplyFunction ¶
func DecorateDefaultApplyFunction(decorators ...func(ApplyFunction) ApplyFunction) ApplyFunction
DecorateDefaultApplyFunction allows to decorate the default apply function
type DeployConfig ¶
DeployConfig are all the specific configurations used in deploy phase
type K8sClients ¶
type K8sClients struct {
// contains filtered or unexported fields
}
func FakeK8sClients ¶
func FakeK8sClients() *K8sClients
FakeK8sClients returns a struct of fake k8s clients for testing purposes
func InitRealK8sClients ¶
func InitRealK8sClients(opts *Options) *K8sClients
InitRealK8sClients initializes a K8sClients struct from given CLI options, to be used for the deployment process
type Options ¶
type Options struct { Config *genericclioptions.ConfigFlags CertificateAuthority string ClientCertificate string ClientKey string Cluster string Context string Kubeconfig string InsecureSkipTLSVerify bool Namespace string Server string Token string User string }
Options global option struct
type RealSupportedResourcesGetter ¶
type RealSupportedResourcesGetter struct{}
RealSupportedResourcesGetter is a type to identify the real getter function for the supported resources dictionary
func (RealSupportedResourcesGetter) GetSupportedResourcesDictionary ¶
func (supportedResourcesGetter RealSupportedResourcesGetter) GetSupportedResourcesDictionary(discovery discovery.DiscoveryInterface) (map[schema.GroupVersionKind]metav1.APIResource, error)
GetSupportedResourcesDictionary exposes the getSupportedResourcesDictionary function for the real getter
type Resource ¶
type Resource struct { Filepath string GroupVersionKind *schema.GroupVersionKind Object unstructured.Unstructured Namespaced ResourceNamespace }
func SortResourcesByKind ¶
SortResourcesByKind Results are sorted by 'ordering', keeping order of items with equal kind/priority
type ResourceList ¶
type ResourceList struct { Kind *schema.GroupVersionKind `json:"kind"` Resources []string `json:"resources"` }
type ResourceNamespace ¶ added in v0.1.1
type ResourceNamespace int8
const ( None ResourceNamespace = iota True False )
type SupportedResourcesGetter ¶
type SupportedResourcesGetter interface {
GetSupportedResourcesDictionary(discovery discovery.DiscoveryInterface) (map[schema.GroupVersionKind]metav1.APIResource, error)
}
SupportedResourcesGetter is a type for handling real and mock dictionaries of supported resources