builders

package
v0.0.0-...-a0b04c9 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: LGPL-2.1 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigMap

type ConfigMap struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
	Data        map[string]string
	Immutable   bool
	ConfigMap   *corev1.ConfigMap
}

ConfigMap struct for configmap kubernetes resource

func NewConfigMapBuilder

func NewConfigMapBuilder(name string) *ConfigMap

NewConfigMapBuilder return a ConfigMap Immutable is false for default

func (*ConfigMap) AddData

func (c *ConfigMap) AddData(key string, value string) *ConfigMap

AddData add data to data configmap

func (*ConfigMap) Build

func (c *ConfigMap) Build() *corev1.ConfigMap

Build build a configmap

func (*ConfigMap) SetAnnotations

func (c *ConfigMap) SetAnnotations(annotations map[string]string) *ConfigMap

SetAnnotations set labels in the configmap

func (*ConfigMap) SetData

func (c *ConfigMap) SetData(data map[string]string) *ConfigMap

SetData set the data of the configmap

func (*ConfigMap) SetImmutable

func (c *ConfigMap) SetImmutable() *ConfigMap

SetImmutable set the configmap immutable

func (*ConfigMap) SetLabels

func (c *ConfigMap) SetLabels(labels map[string]string) *ConfigMap

SetLabels set labels in the configmap

func (*ConfigMap) SetNamespace

func (c *ConfigMap) SetNamespace(namespace string) *ConfigMap

SetNamespace set the configmap namespace

func (*ConfigMap) ToYaml

func (c *ConfigMap) ToYaml() []byte

ToYaml convert deployment struct to kubernetes yaml

type Container

type Container struct {
	Name      string
	Image     string
	Tag       string
	Port      int32
	Container *corev1.Container
}

Container Struct for containers

func NewContainerBuilder

func NewContainerBuilder() Container

NewContainerBuilder return a container struct

func (*Container) Build

func (c *Container) Build() *corev1.Container

Build build container

func (*Container) SetImage

func (c *Container) SetImage(image string) *Container

SetImage Set container image

func (*Container) SetName

func (c *Container) SetName(name string) *Container

SetName Set container name

func (*Container) SetPort

func (c *Container) SetPort(port int32) *Container

SetPort Set container port

func (*Container) SetTag

func (c *Container) SetTag(tag string) *Container

SetTag Set container tag

type Namespace

type Namespace struct {
	Name        string
	Labels      map[string]string
	Annotations map[string]string
	Namespace   *corev1.Namespace
}

Namespace is the struct for namespace

func NewNamespaceBuilder

func NewNamespaceBuilder(name string) *Namespace

NewNamespaceBuilder return a namespace builder

func (*Namespace) Build

func (n *Namespace) Build() *corev1.Namespace

Build build a namespace

func (*Namespace) SetAnnotations

func (n *Namespace) SetAnnotations(annotations map[string]string) *Namespace

SetAnnotations sets annotations of a namespace

func (*Namespace) SetLabels

func (n *Namespace) SetLabels(labels map[string]string) *Namespace

SetLabels set labels of a namespace

func (*Namespace) ToYaml

func (n *Namespace) ToYaml() []byte

ToYaml conver namespace struct to kubernetes yaml

type Pod

type Pod struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
	Containers  []corev1.Container
	Pod         *corev1.Pod
	PodTemplate *corev1.PodTemplateSpec
}

Pod is the base for work with Pods

func NewPodBuilder

func NewPodBuilder(name string) *Pod

NewPodBuilder return a pod struct

func (*Pod) AddContainer

func (p *Pod) AddContainer(container corev1.Container) *Pod

AddContainer Add new container to deployment

func (*Pod) Build

func (p *Pod) Build() *corev1.Pod

Build Build de deployment interface

func (*Pod) BuildTemplate

func (p *Pod) BuildTemplate() *corev1.PodTemplateSpec

BuildTemplate build pod template

func (*Pod) SetAnnotations

func (p *Pod) SetAnnotations(annotations map[string]string) *Pod

SetAnnotations Set Annotations for deployment

func (*Pod) SetLabels

func (p *Pod) SetLabels(labels map[string]string) *Pod

SetLabels Set labels for deployment

func (*Pod) SetNamespace

func (p *Pod) SetNamespace(namespace string) *Pod

SetNamespace Set namespace for deployment

func (*Pod) ToYaml

func (p *Pod) ToYaml() []byte

ToYaml convert deployment struct to kubernetes yaml

type Ports

type Ports struct {
	Name        string
	Port        int32
	Protocol    corev1.Protocol
	TargetPort  intstr.IntOrString
	NodePort    int32
	ServicePort *corev1.ServicePort
}

Ports ports struct for service ports

func NewServicePort

func NewServicePort() *Ports

NewServicePort get a new service port

func (*Ports) Build

func (p *Ports) Build() *corev1.ServicePort

Build build the service port

func (*Ports) SetName

func (p *Ports) SetName(name string) *Ports

SetName set name of the service port

func (*Ports) SetNodePort

func (p *Ports) SetNodePort(nodePort int32) *Ports

SetNodePort set Node port for service port

func (*Ports) SetPort

func (p *Ports) SetPort(port int32) *Ports

SetPort set port of the service port

func (*Ports) SetProtocol

func (p *Ports) SetProtocol(protocol corev1.Protocol) *Ports

SetProtocol set protocol of the service port

func (*Ports) SetTargetPort

func (p *Ports) SetTargetPort(targetPort int) *Ports

SetTargetPort set target port for service port

type Secret

type Secret struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Annotations map[string]string
	Data        map[string][]byte
	StringData  map[string]string
	Immutable   bool
	Type        corev1.SecretType
	Secret      *corev1.Secret
}

Secret struct for secret

func NewSecretBuilder

func NewSecretBuilder(name string) *Secret

NewSecretBuilder get a sercret builder

func (*Secret) Build

func (s *Secret) Build() *corev1.Secret

Build a secret

func (*Secret) SetAnnotations

func (s *Secret) SetAnnotations(annotations map[string]string) *Secret

SetAnnotations set labels in the configmap

func (*Secret) SetData

func (s *Secret) SetData(data map[string][]byte) *Secret

SetData set the data in a secret

func (*Secret) SetImmutable

func (s *Secret) SetImmutable() *Secret

SetImmutable set to immutable the secret

func (*Secret) SetLabels

func (s *Secret) SetLabels(labels map[string]string) *Secret

SetLabels set labels in the configmap

func (*Secret) SetNamespace

func (s *Secret) SetNamespace(namespace string) *Secret

SetNamespace set the namespace of the secret

func (*Secret) SetStringData

func (s *Secret) SetStringData(data map[string]string) *Secret

SetStringData set data in the secret

func (*Secret) SetType

func (s *Secret) SetType(secretType corev1.SecretType) *Secret

SetType set the secret type

func (*Secret) ToYaml

func (s *Secret) ToYaml() []byte

ToYaml convert secret struct to kubernetes yaml

type Service

type Service struct {
	Name         string
	Namespace    string
	Type         corev1.ServiceType
	Selector     map[string]string
	ClusterIP    string
	Labels       map[string]string
	Annotations  map[string]string
	Ports        []corev1.ServicePort
	ExternalName string
	Service      *corev1.Service
}

Service struct for service kubernetes resource

func NewServiceBuilder

func NewServiceBuilder(name string) *Service

NewServiceBuilder return a service

func (*Service) AddPorts

func (s *Service) AddPorts(ports *corev1.ServicePort) *Service

AddPorts add ports to the service

func (*Service) Build

func (s *Service) Build() (*corev1.Service, error)

Build Build a service with the data

func (*Service) SetAnnotations

func (s *Service) SetAnnotations(annotations map[string]string) *Service

SetAnnotations Set annotations for the service

func (*Service) SetClusterIP

func (s *Service) SetClusterIP(clusterIP string) *Service

SetClusterIP Set the clusterIP of a service

func (*Service) SetExternalName

func (s *Service) SetExternalName(externalName string) *Service

SetExternalName set the external name (optional)

func (*Service) SetLabels

func (s *Service) SetLabels(labels map[string]string) *Service

SetLabels Set labels for the service

func (*Service) SetNamespace

func (s *Service) SetNamespace(namespace string) *Service

SetNamespace Set the namespace of the service

func (*Service) SetSelector

func (s *Service) SetSelector(selector map[string]string) *Service

SetSelector Set the selector of a service

func (*Service) SetType

func (s *Service) SetType(t corev1.ServiceType) *Service

SetType Set the type of a service The options could be "ClusterIP", "NodePort", "LoadBalancer" or "ExternalName" or use this contants https://pkg.go.dev/k8s.io/api/core/v1#ServiceType

func (*Service) ToYaml

func (s *Service) ToYaml() []byte

ToYaml Trasnform the struct in yaml

func (*Service) Validate

func (s *Service) Validate() error

Validate validate the values for build a service

type ServiceAccount

type ServiceAccount struct {
	Name           string
	Namespace      string
	Labels         map[string]string
	Annotations    map[string]string
	ServiceAccount *corev1.ServiceAccount
}

ServiceAccount struct for manage ServiceAccount

func NewServiceAccountBuilder

func NewServiceAccountBuilder(name string) *ServiceAccount

NewServiceAccountBuilder return ServiceAccountBuilder

func (*ServiceAccount) Build

func (sa *ServiceAccount) Build() *corev1.ServiceAccount

Build Build Namespace object

func (*ServiceAccount) SetAnnotations

func (sa *ServiceAccount) SetAnnotations(annotations map[string]string) *ServiceAccount

SetAnnotations set annotations for service account

func (*ServiceAccount) SetLabels

func (sa *ServiceAccount) SetLabels(labels map[string]string) *ServiceAccount

SetLabels set labels for service account

func (*ServiceAccount) SetNamespace

func (sa *ServiceAccount) SetNamespace(namespace string) *ServiceAccount

SetNamespace set namespace for service account

func (*ServiceAccount) ToYaml

func (sa *ServiceAccount) ToYaml() []byte

ToYaml Convert the object in yaml

Jump to

Keyboard shortcuts

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