kube

package
v0.0.1-alpha4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrUpdateCattleHelmChart

func CreateOrUpdateCattleHelmChart(helmChart helmv1.HelmChart, namespaces ...string) (*helmv1.HelmChart, error)

CreateOrUpdateCattleHelmChart creates or updates a Helm chart. It automatically handles resource version conflicts.

func DeleteCattleHelmChart

func DeleteCattleHelmChart(namespace string, name string) error

DeleteCattleHelmChart deletes a Helm chart by name and namespace.

func GetChartReleaseHistory

func GetChartReleaseHistory(namespace, releaseName string) ([]*release.Release, error)

func GetKubernetesConfig

func GetKubernetesConfig() (*rest.Config, error)

GetKubernetesConfig returns Kubernetes configuration It tries to read from KUBECONFIG, fallback to default kubeconfig path, or use in-cluster config

func GetNamespaces

func GetNamespaces() ([]string, error)

GetNamespaces returns a list of kubernetes namespaces

func ListCattleHelmCharts

func ListCattleHelmCharts(namespaces ...string) ([]helmv1.HelmChart, error)

ListCattleHelmCharts lists Helm charts in the specified namespaces. If no namespace is provided, charts in all namespaces are listed.

func ListHelmChartReleases

func ListHelmChartReleases(namespace string) ([]*release.Release, error)

ListHelmChartReleases lists all Helm charts in the given namespace. Returns a slice of release.Release pointers and any error encountered.

func NewCattleHelmChartClient

func NewCattleHelmChartClient() (*versioned.Clientset, error)

NewCattleHelmChartClient creates a new clientset for interacting with Cattle Helm Charts. It returns an error if the Kubernetes configuration cannot be created.

func SetupHelmConfiguration

func SetupHelmConfiguration(namespace string) (*action.Configuration, error)

SetupHelmConfiguration sets up the Helm configuration with the given namespace. Returns an action.Configuration object and any error encountered.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides dynamic interactions with Kubernetes

func NewClient

func NewClient() (*Client, error)

NewClient creates a new instance of Client

func (*Client) ApplyResource

func (kc *Client) ApplyResource(fileContent []byte) error

ApplyResource applies a Kubernetes resource from a YAML/JSON content

func (*Client) DeleteResource

func (kc *Client) DeleteResource(resourceType, resourceName, namespace string, fileContent []byte) error

DeleteResource deletes a Kubernetes resource. If resourceType and resourceName are provided, it deletes that specific resource. If fileContent is provided, it extracts the resource details from the file and then deletes it.

func (*Client) GetResources

func (kc *Client) GetResources(resourceType, resourceName, namespace string) ([]unstructured.Unstructured, error)

GetResources retrieves a list of Kubernetes resources based on the resource type, name, and namespace. If namespace is an empty string, it lists resources across all namespaces.

func (*Client) ListAPIResources

func (kc *Client) ListAPIResources() ([]*metav1.APIResourceList, error)

ListAPIResources lists all available API resources

type ExtendedCattleHelmChart

type ExtendedCattleHelmChart struct {
	*helmv1.HelmChart
	InstallerJobLogs      string `json:"installer_job_logs,omitempty"`
	InstallerJobCompleted bool   `json:"installer_job_completed"`
}

ExtendedCattleHelmChart is a Helm chart with additional fields

func GetCattleHelmChart

func GetCattleHelmChart(namespace string, name string) (*ExtendedCattleHelmChart, error)

GetCattleHelmChart retrieves a specific Helm chart by name and namespace.

type ReleaseWithWorkloadStatus

type ReleaseWithWorkloadStatus struct {
	*release.Release
	Manifest  interface{}      `json:"manifest"`
	Workloads []WorkloadStatus `json:"workloads"`
}

ReleaseWithWorkloadStatus represents a Helm chart release with the status of its workloads.

func GetHelmChartRelease

func GetHelmChartRelease(namespace, releaseName string) (*ReleaseWithWorkloadStatus, error)

GetHelmChartRelease returns a Helm chart release with the given namespace and release name.

func GetHelmChartReleaseWithWorkloads

func GetHelmChartReleaseWithWorkloads(namespace, releaseName string) (*ReleaseWithWorkloadStatus, error)

GetHelmChartReleaseWithWorkloads returns a Helm chart release with the status of its workloads.

type WorkloadStatus

type WorkloadStatus struct {
	Status interface{} `json:"status"`
	Name   string      `json:"name"`
	Kind   string      `json:"kind"`
}

WorkloadStatus represents the status of a Kubernetes workload.

Jump to

Keyboard shortcuts

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