util

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessCodeLabel        = "hobbyfarm.io/accesscode"
	OneTimeAccessCodeLabel = "hobbyfarm.io/otac"
	ScheduledEventLabel    = "hobbyfarm.io/scheduledevent"
	SessionLabel           = "hobbyfarm.io/session"
	UserLabel              = "hobbyfarm.io/user"
	RBACManagedLabel       = "rbac.hobbyfarm.io/managed"
	EnvironmentLabel       = "hobbyfarm.io/environment"
	VirtualMachineTemplate = "hobbyfarm.io/virtualmachinetemplate"
)

Variables

This section is empty.

Functions

func CountMachinesPerTemplateAndEnvironment

func CountMachinesPerTemplateAndEnvironment(vmLister hfListers.VirtualMachineLister, template string, enviroment string) (int, error)

func CountMachinesPerTemplateAndEnvironmentAndScheduledEvent

func CountMachinesPerTemplateAndEnvironmentAndScheduledEvent(vmLister hfListers.VirtualMachineLister, template string, enviroment string, se string) (int, error)

func EnsureVMNotReady

func EnsureVMNotReady(hfClientset hfClientset.Interface, vmLister hfListers.VirtualMachineLister, vmName string, ctx context.Context) error

func GenKeyPair

func GenKeyPair() (string, string, error)

func GenerateResourceName

func GenerateResourceName(prefix string, input string, hashlength int) string

func GetHTTPErrorCode

func GetHTTPErrorCode(httpStatus int) string

func GetLock

func GetLock(lockName string, cfg *rest.Config) (resourcelock.Interface, error)

func GetProtoMarshaller

func GetProtoMarshaller() protojson.MarshalOptions

func GetReleaseNamespace

func GetReleaseNamespace() string

func GetVMConfig

func GetVMConfig(env *hfv1.Environment, vmt *hfv1.VirtualMachineTemplate) map[string]string

func Max

func Max(x, y int) int

func RandStringRunes

func RandStringRunes(n int) string

func ResourceVersionAtLeast

func ResourceVersionAtLeast(curr, min string) bool

borrowed from longhorn

func ReturnHTTPContent

func ReturnHTTPContent(w http.ResponseWriter, r *http.Request, httpStatus int, messageType string, content []byte)

func ReturnHTTPMessage

func ReturnHTTPMessage(w http.ResponseWriter, r *http.Request, httpStatus int, messageType string, message string)

func ReturnHTTPRaw

func ReturnHTTPRaw(w http.ResponseWriter, r *http.Request, content string)

func StringInSlice

func StringInSlice(a string, list []string) bool

func StringPtr

func StringPtr(s string) *string

func UniqueStringSlice

func UniqueStringSlice(stringSlice []string) []string

func VerifySession

func VerifySession(sLister hfListers.SessionLister, s *hfv1.Session) error

func VerifyVM

func VerifyVM(vmLister hfListers.VirtualMachineLister, vm *hfv1.VirtualMachine) error

func VerifyVMClaim

func VerifyVMClaim(vmClaimLister hfListers.VirtualMachineClaimLister, vmc *hfv1.VirtualMachineClaim) error

func VerifyVMDeleted

func VerifyVMDeleted(vmLister hfListers.VirtualMachineLister, vm *hfv1.VirtualMachine) error

func VerifyVMSet

func VerifyVMSet(vmSetLister hfListers.VirtualMachineSetLister, vms *hfv1.VirtualMachineSet) error

func VirtualMachinesUsedDuringPeriod

func VirtualMachinesUsedDuringPeriod(hfClientset hfClientset.Interface, environment string, startString string, endString string, ctx context.Context) (map[time.Time]map[string]int, map[string]int, error)

Calculates available virtualMachineTemplates for a given period (startString, endString) and environment Returns a map with timestamps and corresponding availability of virtualmachines. Also returns the maximum available count of virtualmachinetemplates over the whole duration.

Types

type ByTime

type ByTime []time.Time

These functions are used to sort arrays of time.Time

func (ByTime) Len

func (t ByTime) Len() int

func (ByTime) Less

func (t ByTime) Less(i, j int) bool

func (ByTime) Swap

func (t ByTime) Swap(i, j int)

type HTTPContent

type HTTPContent struct {
	Type    string `json:"type"`
	Status  string `json:"status"`
	Content []byte `json:"content"`
}

type HTTPMessage

type HTTPMessage struct {
	Type    string `json:"type"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

type Maximus

type Maximus struct {
	AvailableCount map[string]int `json:"available_count"`
}

pending rename...

func MaxAvailableDuringPeriod

func MaxAvailableDuringPeriod(hfClientset hfClientset.Interface, environment string, startString string, endString string, ctx context.Context) (Maximus, error)

type Range

type Range struct {
	Start     time.Time
	End       time.Time
	VMMapping map[string]int
}

Range with reserved virtual machine amounts for given time range

Jump to

Keyboard shortcuts

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