utils

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSaToRoleBindingWithRetries

func AddSaToRoleBindingWithRetries(logger *zap.Logger, k8sClient *kubernetes.Clientset, roleBinding, roleBindingNs, sa, saNamespace, role, roleKind string) (err error)

AddSaToRoleBindingWithRetries adds a service account to a rolebinding object. IT retries on already exists and conflict errors.

func DefaultErrorFormat

func DefaultErrorFormat(es []error) string

func DeleteRoleBinding

func DeleteRoleBinding(k8sClient *kubernetes.Clientset, roleBinding, roleBindingNs string) error

DeleteRoleBinding deletes a rolebinding object. if k8s throws an error that the rolebinding is not there, it just returns silently.

func DownloadUrl

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

func FileSize

func FileSize(filePath string) (int64, error)

func FindAllGlobs

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

FindAllGlobs returns a list of globs of input list.

func GetChecksum

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

func GetFileChecksum

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 GetTempDir

func GetTempDir() (string, error)

GetTempDir creates and return a temporary directory

func IsNetworkError

func IsNetworkError(err error) bool

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

func IsReadyPod

func IsReadyPod(pod *apiv1.Pod) bool

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

func IsURL

func IsURL(str string) bool

func MakeSAMapKey

func MakeSAMapKey(saName, saNamespace string) string

func MakeSAObj

func MakeSAObj(sa, ns string) *apiv1.ServiceAccount

MakeSAObj returns a ServiceAccount object with the given SA name and namespace

func MakeZipArchive

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

func MultiErrorWithFormat

func MultiErrorWithFormat() *multierror.Error

func RemoveSAFromRoleBindingWithRetries

func RemoveSAFromRoleBindingWithRetries(logger *zap.Logger, k8sClient *kubernetes.Clientset, roleBinding, roleBindingNs string, saToRemove map[string]bool) (err error)

RemoveSAFromRoleBindingWithRetries removes an SA from the rolebinding passed as parameter. If this is the only SA in the rolebinding, then it deletes the rolebinding object.

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 SetupRoleBinding

func SetupRoleBinding(logger *zap.Logger, k8sClient *kubernetes.Clientset, roleBinding, roleBindingNs, role, roleKind, sa, saNamespace string) error

SetupRoleBinding adds a role to a service account if the rolebinding object is already present in the namespace. if not, it creates a rolebinding object granting the role to the SA in the namespace.

func SetupSA

func SetupSA(k8sClient *kubernetes.Clientset, sa, ns string) (*apiv1.ServiceAccount, error)

SetupSA checks if a service account is present in the namespace, if not creates it.

func UrlForFunction

func UrlForFunction(name, namespace string) string

Types

type PatchSpec

type PatchSpec struct {
	Op    string       `json:"op"`
	Path  string       `json:"path"`
	Value rbac.Subject `json:"value"`
}

PatchSpec is a standard struct needed for JSON merge.

Jump to

Keyboard shortcuts

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