k8s

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package k8s provides Kubernetes client helpers for Deployah resources.

It wraps label selectors, pod queries, and component discovery for projects deployed through Deployah.

Index

Constants

View Source
const (
	ProjectLabel     = "deployah.dev/project"
	ComponentLabel   = "deployah.dev/component"
	EnvironmentLabel = "deployah.dev/environment"
)

Label constants for Deployah resources

Variables

This section is empty.

Functions

func BuildComponentSelector

func BuildComponentSelector(project, component string) (string, error)

BuildComponentSelector builds a selector for a specific project and component

func BuildLabelSelector

func BuildLabelSelector(project, environment string) (labels.Selector, error)

BuildLabelSelector returns a labels.Selector for project and/or environment filters.

func BuildProjectSelector

func BuildProjectSelector(project string) (string, error)

BuildProjectSelector builds a selector for a specific project

func BuildSelector

func BuildSelector(project, component, environment string) (string, error)

BuildSelector builds a label selector from project, component, and environment.

Types

type Client

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

Client wraps Kubernetes operations for Deployah resources

func NewClient

func NewClient(k8sClient runtime.KubernetesClient, namespace string) *Client

NewClient creates a new Kubernetes client for Deployah operations

func NewClientFromRuntime

func NewClientFromRuntime(ctx context.Context, rt *runtime.Runtime) (*Client, error)

NewClientFromRuntime creates a new client from a runtime instance

func (*Client) GetAvailableComponents

func (c *Client) GetAvailableComponents(ctx context.Context, projectName string) ([]string, error)

GetAvailableComponents lists component names from running pods for a project.

func (*Client) GetAvailableEnvironments

func (c *Client) GetAvailableEnvironments(ctx context.Context, projectName, componentName string) ([]string, error)

GetAvailableEnvironments lists environment names from running pods for a project and component.

func (*Client) GetComponentInfo

func (c *Client) GetComponentInfo(ctx context.Context, projectName, componentName string) (*ComponentInfo, error)

GetComponentInfo gets detailed information about a specific component

func (*Client) GetKubernetesClient

func (c *Client) GetKubernetesClient() runtime.KubernetesClient

GetKubernetesClient returns the underlying Kubernetes client

func (*Client) GetNamespace

func (c *Client) GetNamespace() string

GetNamespace returns the namespace this client operates in

func (*Client) GetPodInfo

func (c *Client) GetPodInfo(ctx context.Context, podName string) (*PodInfo, error)

GetPodInfo retrieves detailed information about a specific pod

func (*Client) GetPodStatus

func (c *Client) GetPodStatus(ctx context.Context, releaseName string) (int, int, string, error)

GetPodStatus retrieves pod status information for a release

func (*Client) GetProjectComponents

func (c *Client) GetProjectComponents(ctx context.Context, projectName string) ([]ComponentInfo, error)

GetProjectComponents gets all components for a project with their information

func (*Client) GetRunningPods

func (c *Client) GetRunningPods(ctx context.Context, project, component, environment string) ([]PodInfo, error)

GetRunningPods lists running pods for a project, component, and environment.

func (*Client) ValidateComponentExists

func (c *Client) ValidateComponentExists(ctx context.Context, projectName, componentName string) error

ValidateComponentExists reports whether a component has running pods.

func (*Client) ValidatePodExists

func (c *Client) ValidatePodExists(ctx context.Context, podName string) error

ValidatePodExists checks if a pod with the given name exists

type ComponentInfo

type ComponentInfo struct {
	Name      string
	Project   string
	PodCount  int
	ReadyPods int
}

ComponentInfo contains information about a component

type PodInfo

type PodInfo struct {
	Name       string
	Namespace  string
	Containers []string
	Status     string
}

PodInfo contains information about a pod

type ProjectInfo

type ProjectInfo struct {
	Name        string
	Environment string
	Components  []string
	PodCount    int
	ReadyPods   int
}

ProjectInfo contains information about a project

type SelectorBuilder

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

SelectorBuilder helps build Kubernetes label selectors for Deployah resources

func NewSelectorBuilder

func NewSelectorBuilder() *SelectorBuilder

NewSelectorBuilder creates a new selector builder

func (*SelectorBuilder) Build

func (sb *SelectorBuilder) Build() string

Build returns the final label selector string

func (*SelectorBuilder) WithComponent

func (sb *SelectorBuilder) WithComponent(component string) (*SelectorBuilder, error)

WithComponent adds a component label requirement to the selector

func (*SelectorBuilder) WithEnvironment

func (sb *SelectorBuilder) WithEnvironment(environment string) (*SelectorBuilder, error)

WithEnvironment adds an environment label requirement to the selector

func (*SelectorBuilder) WithProject

func (sb *SelectorBuilder) WithProject(project string) (*SelectorBuilder, error)

WithProject adds a project label requirement to the selector

Jump to

Keyboard shortcuts

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