utils

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInitialInterval = 500 * time.Millisecond
	DefaultMultiplier      = 1.5
	DefaultMaxInterval     = 300 * time.Second
	DefaultMaxCount        = 30
)
View Source
const (
	ENV_FUNCTION_NAMESPACE   string = "FISSION_FUNCTION_NAMESPACE"
	ENV_BUILDER_NAMESPACE    string = "FISSION_BUILDER_NAMESPACE"
	ENV_DEFAULT_NAMESPACE    string = "FISSION_DEFAULT_NAMESPACE"
	ENV_ADDITIONAL_NAMESPACE string = "FISSION_RESOURCE_NAMESPACES"
)
View Source
const (
	FetcherSAName   string = "fission-fetcher"
	BuilderSAName   string = "fission-builder"
	ENV_CREATE_SA   string = "SERVICEACCOUNT_CHECK_ENABLED"
	ENV_SA_INTERVAL string = "SERVICEACCOUNT_CHECK_INTERVAL"
)

Variables

This section is empty.

Functions

func CreateMissingPermissionForSA added in v1.18.0

func CreateMissingPermissionForSA(ctx context.Context, kubernetesClient kubernetes.Interface, logger *zap.Logger)

func DefaultErrorFormat added in v1.7.0

func DefaultErrorFormat(es []error) string

func DownloadUrl added in v1.7.0

func DownloadUrl(ctx context.Context, httpClient *http.Client, url string, localPath string) error

func FileSize added in v1.7.0

func FileSize(filePath string) (int64, error)

func FindAllGlobs

func FindAllGlobs(paths ...string) ([]string, error)

FindAllGlobs returns a list of globs of input list.

func FindFreePort added in v1.20.0

func FindFreePort() (int, error)

func GetChecksum added in v1.7.0

func GetChecksum(src io.Reader) (*fv1.Checksum, error)

func GetFileChecksum added in v1.7.0

func GetFileChecksum(fileName string) (*fv1.Checksum, error)

func GetFunctionIstioServiceName

func GetFunctionIstioServiceName(fnName, fnNamespace string) string

GetFunctionIstioServiceName return service name of function for istio feature

func GetImagePullPolicy

func GetImagePullPolicy(policy string) apiv1.PullPolicy

GetImagePullPolicy returns the image pull policy base on the input value.

func GetInformerEventChecker added in v1.18.0

func GetInformerEventChecker(ctx context.Context, client kubernetes.Interface, reason string) map[string]cache.SharedInformer

func GetInformerFactoryByExecutor added in v1.14.1

func GetInformerFactoryByExecutor(client kubernetes.Interface, labels labels.Selector, defaultResync time.Duration) map[string]k8sInformers.SharedInformerFactory

func GetInformerFactoryByReadyPod added in v1.15.0

func GetInformerFactoryByReadyPod(client kubernetes.Interface, namespace string, labelSelector *metav1.LabelSelector) (k8sInformers.SharedInformerFactory, error)

func GetInformerLabelByExecutor added in v1.18.0

func GetInformerLabelByExecutor(executorType fv1.ExecutorType) (labels.Selector, error)

func GetInformersForNamespaces added in v1.18.0

func GetInformersForNamespaces(client versioned.Interface, defaultSync time.Duration, kind string) map[string]cache.SharedIndexInformer

func GetIntValueFromEnv added in v1.20.1

func GetIntValueFromEnv(envVar string) (int, error)

func GetK8sInformersForNamespaces added in v1.18.0

func GetK8sInformersForNamespaces(client kubernetes.Interface, defaultSync time.Duration, kind string) map[string]cache.SharedIndexInformer

func GetNamespaces added in v1.18.0

func GetNamespaces() map[string]string

func GetStringValueFromEnv added in v1.18.0

func GetStringValueFromEnv(envVar string) (string, error)

func GetTempDir

func GetTempDir() (string, error)

GetTempDir creates and return a temporary directory

func GetUIntValueFromEnv added in v1.18.0

func GetUIntValueFromEnv(envVar string) (uint, error)

func IsNetworkError

func IsNetworkError(err error) bool

IsNetworkError returns true if an error is a network error, and false otherwise.

func IsPodTerminated added in v1.15.1

func IsPodTerminated(pod *v1.Pod) bool

func IsReadyPod

func IsReadyPod(pod *v1.Pod) bool

IsReadyPod checks both all containers in a pod are ready and whether the .metadata.DeletionTimestamp is nil.

func IsURL added in v1.7.0

func IsURL(str string) bool

func IsZip added in v1.16.0

func IsZip(filename string) (bool, error)

func MakeZipArchive added in v1.7.0

func MakeZipArchive(targetName string, globs ...string) (string, error)

func MultiErrorWithFormat added in v1.7.0

func MultiErrorWithFormat() *multierror.Error

func NewBackOff added in v1.10.0

func NewBackOff(initialInterval time.Duration, maxInterval time.Duration, multiplier float64, maxCount float64) (*backoff, error)

NewBackOff returns a new backoff struct with initialized values

func NewDefaultBackOff added in v1.10.0

func NewDefaultBackOff() *backoff

NewDefaultBackOff returns new backoff struct with default values

func PodContainerReadyStatus added in v1.15.0

func PodContainerReadyStatus(pod *v1.Pod) (readyContainers, noOfContainers int)

PodContainerReadyStatus returns the number of ready containers and total containers present in pod

func RemoveZeroBytes

func RemoveZeroBytes(src []byte) []byte

RemoveZeroBytes remove empty byte(\x00) from input byte slice and return a new byte slice This function is trying to fix the problem that empty byte will fail os.Openfile For more information, please visit: 1. https://github.com/golang/go/issues/24195 2. https://play.golang.org/p/5F9ykC2tlbc

func SupportedMetricsAPIVersionAvailable added in v1.14.1

func SupportedMetricsAPIVersionAvailable(discoveredAPIGroups *metav1.APIGroupList) bool

func UrlForFunction

func UrlForFunction(name, namespace string) string

func WithBuilderNs added in v1.18.0

func WithBuilderNs() option

func WithDefaultNs added in v1.18.0

func WithDefaultNs() option

func WithFunctionNs added in v1.18.0

func WithFunctionNs() option

Types

type NamespaceResolver added in v1.18.0

type NamespaceResolver struct {
	FunctionNamespace string
	BuilderNamespace  string
	DefaultNamespace  string
	FissionResourceNS map[string]string
	Logger            *zap.Logger
}

func DefaultNSResolver added in v1.18.0

func DefaultNSResolver() *NamespaceResolver

GetFissionNamespaces => return all fission core component namespaces

func (*NamespaceResolver) FissionNSWithOptions added in v1.18.0

func (nsr *NamespaceResolver) FissionNSWithOptions(option ...option) map[string]string

func (*NamespaceResolver) GetBuilderNS added in v1.18.0

func (nsr *NamespaceResolver) GetBuilderNS(namespace string) string

func (*NamespaceResolver) GetFunctionNS added in v1.18.0

func (nsr *NamespaceResolver) GetFunctionNS(namespace string) string

func (*NamespaceResolver) ResolveNamespace added in v1.18.0

func (nsr *NamespaceResolver) ResolveNamespace(namespace string) string

type PermissionCheck added in v1.18.0

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

type ServiceAccount added in v1.18.0

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

type ServiceAccountPermissions added in v1.18.0

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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