utils

package
v0.101.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeNow = func() time.Time { return time.Now() }

TimeNow returns the current time

Functions

func CreateLogFile

func CreateLogFile(dir string, name string) (io.Writer, error)

CreateLogFile creates file to be used as logger

func DieOnError added in v0.76.0

func DieOnError(err error, msg string)

func GenerateID

func GenerateID() string

GenerateID build random uuid-v4

func GetEnvOrDefault added in v0.76.0

func GetEnvOrDefault(name string, def string) string

func GetEnvOrDie added in v0.77.0

func GetEnvOrDie(name string, errMsg string) string

Types

type BuildKubeClientOptions

type BuildKubeClientOptions struct {
	KubeconfigPath string
	Host           string
	B64CRT         string
	Token          string
}

BuildKubeClientOptions options to constract Kubernetes client

type Command

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

Command runs command in as subprocess

func (*Command) AddCommand

func (_c *Command) AddCommand(cmd string)

AddCommand adds command argument to the command

func (*Command) AddEnv

func (_c *Command) AddEnv(key string, value string)

AddEnv adds env variable to the command

func (*Command) Bin

func (_c *Command) Bin(path string)

Bin sets the binary to execute

func (*Command) Create

func (_c *Command) Create() *exec.Cmd

Create builds exec.Cmd

type FileCreator

type FileCreator struct{}

FileCreator expose ability to operate on fs

func (*FileCreator) Create

func (_f *FileCreator) Create(dir string, name string) (io.Writer, error)

Create creates file in directory with mode = os.ModePerm

type GRPC

type GRPC struct{}

GRPC expose abilities on grpc connection

func (GRPC) Dial

func (_g GRPC) Dial(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error)

Dial returns a connection grpc server

type Kubernetes

type Kubernetes struct{}

Kubernetes expose abilities on run on kube cluster

func (*Kubernetes) BuildClient

func (_k *Kubernetes) BuildClient(opt BuildKubeClientOptions) (*kubernetes.Clientset, error)

BuildClient returns a kubernetes client based on path to kubeconfig

func (*Kubernetes) BuildClientWithToken

func (_k *Kubernetes) BuildClientWithToken(host string, ca string, token string) (*kubernetes.Clientset, error)

BuildClientWithToken returns a kubernetes client based on path to kubeconfig

func (*Kubernetes) BuildPodDefinition

func (_k *Kubernetes) BuildPodDefinition(namespace string, name string, version string, id string, port string, volume string, volumeClaimName string, volumeMoutnPath string) (*v1.Pod, error)

BuildPodDefinition returns pod definition from arguments

func (Kubernetes) BuildServiceDefinition

func (_k Kubernetes) BuildServiceDefinition(namespace string, name string, id string, port string, serviceType string) (*v1.Service, error)

BuildServiceDefinition returns service definition from argument

func (Kubernetes) CreatePod

func (_k Kubernetes) CreatePod(client *kubernetes.Clientset, def *v1.Pod) (*v1.Pod, error)

CreatePod applies a pod definitions on given client

func (Kubernetes) CreateService

func (_k Kubernetes) CreateService(client *kubernetes.Clientset, def *v1.Service) (*v1.Service, error)

CreateService applies a pod definitions on given client

func (Kubernetes) KillPod

func (_k Kubernetes) KillPod(client *kubernetes.Clientset, namespace string, name string) error

KillPod deletes kubernetes service

func (Kubernetes) KillService

func (_k Kubernetes) KillService(client *kubernetes.Clientset, namespace string, name string) error

KillService deletes kubernetes service

func (Kubernetes) WaitForPod

func (_k Kubernetes) WaitForPod(client *kubernetes.Clientset, pod *v1.Pod, phase string) error

WaitForPod waits til pod reaches given phase

type Port

type Port struct{}

Port expose ability to generate random available port on local machine

func (Port) GetAvailable

func (_p Port) GetAvailable() (string, error)

GetAvailable returns available port on local machine

type Proto

type Proto struct{}

Proto expose abilities to create new service client

func (Proto) New

func (_p Proto) New(cc *grpc.ClientConn) v1.ServiceClient

New creates new service for given connection

Jump to

Keyboard shortcuts

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