util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareFiles

func CompareFiles(fileone string, filetwo string) (bool, error)

CompareFiles will compare two files, byte by byte to see if they are equal

Args:

 fileone - first file to compare
 filetwo - second file to compare

Returns:
   bool and error

func CreateTempFile

func CreateTempFile(dirname string, filename string) (*os.File, error)

CreateTempFile will create temporary file

Args:

 dirname - dir name
 filename - file name

Returns:
   filename as string or error

func DetectConcurrencyPolicy added in v0.0.2

func DetectConcurrencyPolicy(currencyPolicy string) (batchv1.ConcurrencyPolicy, error)

DetectConcurrencyPolicy is a helper for users use only Allow, Forbid and Replace instead of require them to manage k8s.io/api/batch/v1/types.go

Args:

allow, forbid, replace

Returns:

batch.AllowConcurrent, batch.ForbidConcurrent, batch.ReplaceConcurrent

func DetectContainerPortProtocol

func DetectContainerPortProtocol(protocol string) (v1.Protocol, error)

DetectContainerPortProtocol is a helper for users to use TCP or UDP words instead of require them to manage k8s.io/api/core/v1. This will convert TCP or UDP to v1.ProtocolTCP or v1.ProtocolUDP

Args:

protocol - tcp or udp as string

Returns:

v1.ProtocolUDP, v1.ProtocolTCP or error

func DetectContainerRestartPolicy added in v0.0.2

func DetectContainerRestartPolicy(policy string) (v1.RestartPolicy, error)

DetectContainerRestartPolicy is a helper for users to more friendly words like: onfailure, never or always instead of require them to manage k8s.io/api/core/v1.

Args:

onfailure, always, never

Returns:

v1.RestartPolicyOnFailure
v1.RestartPolicyNever
v1.RestartPolicyAlways or error

func DetectImagePullPolicy added in v0.0.2

func DetectImagePullPolicy(pullpolicy string) (v1.PullPolicy, error)

DetectImagePullPolicy is a helper for users to use more friendly words like: always, ifnotpresent or never instead to require them to manage k8s.io/api/core/v1.

Args:

ifnotpresent, always or never

Returns:

v1.PullAlways
v1.PullNever
v1.PullIfNotPresent or error

func DetectLimitType added in v0.0.2

func DetectLimitType(limitType string) (v1.LimitType, error)

LimitType is a helper for users to specify the limit type as string: "Pod", "Container" or "PersistentVolumeClaim" in a namespace

Args:

string - pod, container or persistentvolumeclaim

Returns:

v1.LimitType (v1.LimitTypePod, v1.LimitTypeContainer, v1.LimitTypePersistentVolumeClaim,  or error)

func DetectVolumeAccessModes added in v0.0.2

func DetectVolumeAccessModes(access string) ([]v1.PersistentVolumeAccessMode, error)

DetectVolumeAccessModes is a helper for users use access mode as: rox, rwo, rwx, readonlymany, readwritemany, readwriteonce

Remember:

ROX - ReadOnlyMany - can be mounted in read-only mode to many hosts RWO - ReadWriteOnce - can be mounted in read/write mode to exactly 1 host RWX - ReadWriteMany - can be mounted in read/write mode to many hosts

Args:

string - rox, rwo, rwx, readonlymany,
	 readwritemany, readwriteonce

Returns:

v1.PersistentVolumeAccessMode (v1.ReadOnlyMany, v1.ReadWriteMany, v1.ReadWriteOnce) or error

func DetectVolumeMode added in v0.0.2

func DetectVolumeMode(mode string) (v1.PersistentVolumeMode, error)

DetectVolumeMode is a helper for users use mode as:

persistentvolumeblock or block persistentvolumefilesystem or filesystem

Args:

	string - persistentvolumeblock or block
              persistentvolumefilesystem or filesystem

Returns:

v1.PersistentVolumeMode or error

func DiffCommand

func DiffCommand(fileone string, filetwo string) ([]byte, error)

DiffCommand will diff two files

Args:

 fileone
 filtwo

Returns:
   bytes from the file or error

func DownloadFile

func DownloadFile(url string) (string, error)

DownloadFile will download a file specified as temporary file

Args:

 url - url to be download

Returns:
   path as string or error

func GenerateRandomString

func GenerateRandomString(numberOfChars int, modeString string) (string, error)

GenerateRandomString will generate a random string

Args:

	number of chars to be generated
	modeString lower or all

  Returns:
	random string

func GetResourceList added in v0.0.2

func GetResourceList(cpu string, memory string, ephemeralStorage string) v1.ResourceList

GetResourceList returns a ResourceList with the specified cpu and memory or disk resource values

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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