internal

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchLabels

func MatchLabels(resourceLabels, selector map[string]string) bool

MatchLabels returns true if the resource labels contain all selector labels.

func Now

func Now() string

Now returns a k8s-formatted timestamp string.

Types

type ConfigMap

type ConfigMap struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Data       map[string]string `json:"data,omitempty"`
	BinaryData map[string][]byte `json:"binaryData,omitempty"`
}

ConfigMap holds configuration data.

type ConfigMapList

type ConfigMapList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []ConfigMap `json:"items"`
}

ConfigMapList is a list of ConfigMaps.

type Container

type Container struct {
	Name    string          `json:"name"`
	Image   string          `json:"image"`
	Ports   []ContainerPort `json:"ports,omitempty"`
	Env     []EnvVar        `json:"env,omitempty"`
	Command []string        `json:"command,omitempty"`
	Args    []string        `json:"args,omitempty"`
}

type ContainerPort

type ContainerPort struct {
	Name          string `json:"name,omitempty"`
	ContainerPort int    `json:"containerPort"`
	Protocol      string `json:"protocol,omitempty"`
}

type Deployment

type Deployment struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Spec       DeploymentSpec   `json:"spec,omitempty"`
	Status     DeploymentStatus `json:"status,omitempty"`
}

Deployment represents a k8s deployment.

type DeploymentList

type DeploymentList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []Deployment `json:"items"`
}

DeploymentList is a list of Deployments.

type DeploymentSpec

type DeploymentSpec struct {
	Replicas int             `json:"replicas,omitempty"`
	Selector *LabelSelector  `json:"selector,omitempty"`
	Template PodTemplateSpec `json:"template,omitempty"`
}

type DeploymentStatus

type DeploymentStatus struct {
	Replicas          int `json:"replicas,omitempty"`
	ReadyReplicas     int `json:"readyReplicas,omitempty"`
	AvailableReplicas int `json:"availableReplicas,omitempty"`
	UpdatedReplicas   int `json:"updatedReplicas,omitempty"`
}

type EnvVar

type EnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value,omitempty"`
}

type LabelSelector

type LabelSelector struct {
	MatchLabels map[string]string `json:"matchLabels,omitempty"`
}

type ListMeta

type ListMeta struct {
	ResourceVersion string `json:"resourceVersion,omitempty"`
}

ListMeta describes metadata that synthetic resources must have.

type LoadBalancerIngress

type LoadBalancerIngress struct {
	IP       string `json:"ip,omitempty"`
	Hostname string `json:"hostname,omitempty"`
}

type LoadBalancerStatus

type LoadBalancerStatus struct {
	Ingress []LoadBalancerIngress `json:"ingress,omitempty"`
}

type Namespace

type Namespace struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Spec       NamespaceSpec   `json:"spec,omitempty"`
	Status     NamespaceStatus `json:"status,omitempty"`
}

Namespace represents a k8s namespace.

type NamespaceList

type NamespaceList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []Namespace `json:"items"`
}

NamespaceList is a list of Namespaces.

type NamespaceSpec

type NamespaceSpec struct {
	Finalizers []string `json:"finalizers,omitempty"`
}

type NamespaceStatus

type NamespaceStatus struct {
	Phase string `json:"phase,omitempty"`
}

type Node

type Node struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Spec       NodeSpec   `json:"spec,omitempty"`
	Status     NodeStatus `json:"status,omitempty"`
}

Node represents a k8s node.

type NodeAddress

type NodeAddress struct {
	Type    string `json:"type"`
	Address string `json:"address"`
}

type NodeCondition

type NodeCondition struct {
	Type   string `json:"type"`
	Status string `json:"status"`
}

type NodeList

type NodeList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []Node `json:"items"`
}

NodeList is a list of Nodes.

type NodeSpec

type NodeSpec struct {
	PodCIDR    string `json:"podCIDR,omitempty"`
	ProviderID string `json:"providerID,omitempty"`
}

type NodeStatus

type NodeStatus struct {
	Conditions []NodeCondition `json:"conditions,omitempty"`
	Addresses  []NodeAddress   `json:"addresses,omitempty"`
}

type ObjectMeta

type ObjectMeta struct {
	Name              string            `json:"name"`
	Namespace         string            `json:"namespace,omitempty"`
	UID               string            `json:"uid,omitempty"`
	ResourceVersion   string            `json:"resourceVersion,omitempty"`
	CreationTimestamp string            `json:"creationTimestamp,omitempty"`
	Labels            map[string]string `json:"labels,omitempty"`
	Annotations       map[string]string `json:"annotations,omitempty"`
}

ObjectMeta is metadata that all persisted resources must have.

type Pod

type Pod struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Spec       PodSpec   `json:"spec,omitempty"`
	Status     PodStatus `json:"status,omitempty"`
}

Pod represents a k8s pod.

type PodCondition

type PodCondition struct {
	Type   string `json:"type"`
	Status string `json:"status"`
}

type PodList

type PodList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []Pod `json:"items"`
}

PodList is a list of Pods.

type PodSpec

type PodSpec struct {
	Containers    []Container `json:"containers,omitempty"`
	NodeName      string      `json:"nodeName,omitempty"`
	RestartPolicy string      `json:"restartPolicy,omitempty"`
}

type PodStatus

type PodStatus struct {
	Phase      string         `json:"phase,omitempty"`
	PodIP      string         `json:"podIP,omitempty"`
	HostIP     string         `json:"hostIP,omitempty"`
	StartTime  *string        `json:"startTime,omitempty"`
	Conditions []PodCondition `json:"conditions,omitempty"`
}

type PodTemplateSpec

type PodTemplateSpec struct {
	ObjectMeta `json:"metadata,omitempty"`
	Spec       PodSpec `json:"spec,omitempty"`
}

type Router

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

Router maps Kubernetes API paths to the appropriate handlers.

func NewRouter

func NewRouter(store *Store) *Router

NewRouter creates a k8s API router backed by the given store.

func (*Router) Handle

func (rt *Router) Handle(method, path string, body []byte, queryParams map[string]string) (int, []byte)

Handle processes a k8s API request and returns (statusCode, responseBody).

type Secret

type Secret struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Data       map[string][]byte `json:"data,omitempty"`
	StringData map[string]string `json:"stringData,omitempty"`
	Type       string            `json:"type,omitempty"`
}

Secret holds secret data.

type SecretList

type SecretList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []Secret `json:"items"`
}

SecretList is a list of Secrets.

type Service

type Service struct {
	TypeMeta   `json:",inline"`
	ObjectMeta `json:"metadata"`
	Spec       ServiceSpec   `json:"spec,omitempty"`
	Status     ServiceStatus `json:"status,omitempty"`
}

Service represents a k8s service.

type ServiceList

type ServiceList struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata"`
	Items    []Service `json:"items"`
}

ServiceList is a list of Services.

type ServicePort

type ServicePort struct {
	Name       string `json:"name,omitempty"`
	Port       int    `json:"port"`
	TargetPort int    `json:"targetPort,omitempty"`
	Protocol   string `json:"protocol,omitempty"`
}

type ServiceSpec

type ServiceSpec struct {
	Type      string            `json:"type,omitempty"`
	ClusterIP string            `json:"clusterIP,omitempty"`
	Selector  map[string]string `json:"selector,omitempty"`
	Ports     []ServicePort     `json:"ports,omitempty"`
}

type ServiceStatus

type ServiceStatus struct {
	LoadBalancer LoadBalancerStatus `json:"loadBalancer,omitempty"`
}

type Status

type Status struct {
	TypeMeta `json:",inline"`
	ListMeta `json:"metadata,omitempty"`
	Status   string `json:"status,omitempty"`
	Message  string `json:"message,omitempty"`
	Reason   string `json:"reason,omitempty"`
	Code     int    `json:"code,omitempty"`
}

Status is a return value for calls that don't return other objects.

type Store

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

Store holds all k8s resources in memory, organized by resource type, namespace, and name.

func NewStore

func NewStore() *Store

NewStore creates an empty k8s resource store with default namespace.

func (*Store) CreateConfigMap

func (s *Store) CreateConfigMap(cm *ConfigMap) error

func (*Store) CreateDeployment

func (s *Store) CreateDeployment(dep *Deployment) error

func (*Store) CreateNamespace

func (s *Store) CreateNamespace(ns *Namespace) error

func (*Store) CreatePod

func (s *Store) CreatePod(pod *Pod) error

func (*Store) CreateSecret

func (s *Store) CreateSecret(sec *Secret) error

func (*Store) CreateService

func (s *Store) CreateService(svc *Service) error

func (*Store) DeleteConfigMap

func (s *Store) DeleteConfigMap(namespace, name string) error

func (*Store) DeleteDeployment

func (s *Store) DeleteDeployment(namespace, name string) error

func (*Store) DeleteNamespace

func (s *Store) DeleteNamespace(name string) error

func (*Store) DeletePod

func (s *Store) DeletePod(namespace, name string) error

func (*Store) DeleteSecret

func (s *Store) DeleteSecret(namespace, name string) error

func (*Store) DeleteService

func (s *Store) DeleteService(namespace, name string) error

func (*Store) FilterPodsByLabels

func (s *Store) FilterPodsByLabels(namespace string, selector string) []Pod

FilterPodsByLabels parses a k8s label selector string and filters pods.

func (*Store) GetConfigMap

func (s *Store) GetConfigMap(namespace, name string) (*ConfigMap, bool)

func (*Store) GetDeployment

func (s *Store) GetDeployment(namespace, name string) (*Deployment, bool)

func (*Store) GetNamespace

func (s *Store) GetNamespace(name string) (*Namespace, bool)

func (*Store) GetNode

func (s *Store) GetNode(name string) (*Node, bool)

func (*Store) GetPod

func (s *Store) GetPod(namespace, name string) (*Pod, bool)

func (*Store) GetSecret

func (s *Store) GetSecret(namespace, name string) (*Secret, bool)

func (*Store) GetService

func (s *Store) GetService(namespace, name string) (*Service, bool)

func (*Store) ListAllPods

func (s *Store) ListAllPods() []Pod

func (*Store) ListConfigMaps

func (s *Store) ListConfigMaps(namespace string) []ConfigMap

func (*Store) ListDeployments

func (s *Store) ListDeployments(namespace string) []Deployment

func (*Store) ListNamespaces

func (s *Store) ListNamespaces() []Namespace

func (*Store) ListNodes

func (s *Store) ListNodes() []Node

func (*Store) ListPods

func (s *Store) ListPods(namespace string) []Pod

func (*Store) ListSecrets

func (s *Store) ListSecrets(namespace string) []Secret

func (*Store) ListServices

func (s *Store) ListServices(namespace string) []Service

func (*Store) Subscribe

func (s *Store) Subscribe() chan WatchEvent

Subscribe returns a channel that receives watch events.

func (*Store) Unsubscribe

func (s *Store) Unsubscribe(ch chan WatchEvent)

Unsubscribe removes a watcher channel.

type TypeMeta

type TypeMeta struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`
}

TypeMeta describes an individual object in an API response.

type WatchEvent

type WatchEvent struct {
	Type   string      `json:"type"` // ADDED, MODIFIED, DELETED
	Object interface{} `json:"object"`
}

WatchEvent is a single event in a watch stream.

Jump to

Keyboard shortcuts

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