validators

package
v0.0.0-...-5c98bcf Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigMapEnvVars []EnvVar

The `deployment` validator needs access to these env vars so it can plug them into its template. This needs to happen because the current Deployment has the env vars embedded but the new Deployment will access them via a `ConfigMap`.

Functions

func GetClient

func GetClient() (*kubernetes.Clientset, error)

func GetDeploymentClient

func GetDeploymentClient(kind string) (*v1.Deployment, error)

func GetIngressClient

func GetIngressClient(kind string) (*networkingv1.Ingress, error)

func GetServiceClient

func GetServiceClient(kind string) (*corev1.Service, error)

func New

func New(filename string)

func WriteTemplate

func WriteTemplate(to, from string, T any) error

Types

type ConfigMapManifest

type ConfigMapManifest struct {
	APIVersion string   `json:"apiVersion"`
	Kind       string   `json:"kind"`
	Metadata   Metadata `json:"metadata"`
	Data       Data     `json:"data"`
}

func (ConfigMapManifest) Write

func (m ConfigMapManifest) Write()

type Container

type Container struct {
	Name            string    `json:"name,omitempty"`
	Image           string    `json:"image,omitempty"`
	ImagePullPolicy string    `json:"imagePullPolicy,omitempty"`
	Env             []EnvVar  `json:"env,omitempty"`
	EnvFrom         []EnvFrom `json:"envFrom,omitempty"`
	Ports           []Port    `json:"ports,omitempty"`
	Resources       Resources `json:"resources,omitempty"`
}

type Data

type Data map[string]string

type DeploymentManifest

type DeploymentManifest struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   `json:"metadata"`
	Spec       DeploymentSpec `json:"spec"`
}

func (DeploymentManifest) Write

func (m DeploymentManifest) Write()

type DeploymentSpec

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

type Document

type Document[T Manifest] struct {
	Manifest T `json:"manifest"`
}

func (*Document[T]) DecodeAndPrint

func (m *Document[T]) DecodeAndPrint(dec *json.Decoder) error

type EnvFrom

type EnvFrom struct {
	ConfigMapRef Data `json:"configMapRef,omitempty"`
}

type EnvVar

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

type HTTPIngressPath

type HTTPIngressPath struct {
	Path     string         `json:"path,omitempty"`
	PathType string         `json:"pathType,omitempty"`
	Backend  IngressBackend `json:"backend,omitempty"`
}

type HTTPIngressRuleValue

type HTTPIngressRuleValue struct {
	Paths []HTTPIngressPath `json:"paths,omitempty"`
}

type IngressBackend

type IngressBackend struct {
	Service IngressServiceBackend `json:"service,omitempty"`
}

type IngressManifest

type IngressManifest struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   `json:"metadata"`
	Spec       IngressSpec `json:"spec"`
}

func (IngressManifest) Write

func (m IngressManifest) Write()

type IngressRule

type IngressRule struct {
	IngressRuleValue `json:",inline,omitempty"`
}

type IngressRuleValue

type IngressRuleValue struct {
	HTTP HTTPIngressRuleValue `json:"http,omitempty"`
}

type IngressServiceBackend

type IngressServiceBackend struct {
	Name string             `json:"name,omitempty"`
	Port ServiceBackendPort `json:"port,omitempty"`
}

type IngressSpec

type IngressSpec struct {
	Rules []IngressRule `json:"rules,omitempty"`
}

type LabelSelector

type LabelSelector struct {
	MatchLabels Data `json:"matchLabels,omitempty"`
}

type Manifest

type Manifest interface {
	ConfigMapManifest | DeploymentManifest | IngressManifest | ServiceManifest
	Write()
}

type Metadata

type Metadata struct {
	Name        string            `json:"name,omitempty"`
	Namespace   string            `json:"namespace,omitempty"`
	Labels      Data              `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
}

type PodSpec

type PodSpec struct {
	Containers   []Container `json:"containers,omitempty"`
	NodeSelector Data
}

type Port

type Port struct {
	ContainerPort int `json:"container_port,omitempty"`
}

type Resource

type Resource struct {
	CPU    string `json:"cpu,omitempty"`
	Memory string `json:"memory,omitempty"`
}

type Resources

type Resources struct {
	Limits   Resource `json:"limits,omitempty"`
	Requests Resource `json:"requests,omitempty"`
}

type ServiceBackendPort

type ServiceBackendPort struct {
	Name   string `json:"name,omitempty"`
	Number int    `json:"number,omitempty"`
}

type ServiceManifest

type ServiceManifest struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Metadata   `json:"metadata"`
	Spec       ServiceSpec `json:"spec"`
}

func (ServiceManifest) Write

func (m ServiceManifest) Write()

type ServicePort

type ServicePort struct {
	Port       int
	TargetPort int
	Protocol   string
}

type ServiceSpec

type ServiceSpec struct {
	Ports    []ServicePort
	Selector Data
	Type     string
}

type Template

type Template struct {
	Metadata Metadata `json:"metadata,omitempty"`
	Spec     PodSpec  `json:"spec,omitempty"`
}

Jump to

Keyboard shortcuts

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