Documentation ¶
Index ¶
- Constants
- Variables
- func AbsolutePath(value string) (string, error)
- func ArePodsAllReady(pods []corev1.Pod) bool
- func ArePodsAllScheduled(pods []corev1.Pod) bool
- func BaseName(filename string) string
- func Bool(v bool) *bool
- func BuildPodMap(pods []corev1.Pod, keyFunc func(pod *corev1.Pod) string) map[string]*corev1.Pod
- func ByteMap(m *map[string][]byte)
- func BytesToString(b []byte) string
- func ContainsOnlyFinalizer(obj client.Object, finalizer string) bool
- func ConvTimeInLocation(t time.Time, local string) (time.Time, error)
- func ConvertToStruct(input map[string]interface{}, dst interface{}) error
- func Cyan(msg string) string
- func DirExists(filename string) bool
- func DirName(filename string) string
- func ExitSignalHandler(onExit func())
- func FileExists(filename string) bool
- func FileModTime(filename string) int64
- func FilterPodsBy(pods []corev1.Pod, filter func(pod *corev1.Pod) bool) []corev1.Pod
- func FuncCaller() string
- func GB(m *resource.Quantity) float64
- func GenerateResource(cpu float64, mem float64) (re map[corev1.ResourceName]resource.Quantity)
- func GetContainerFromPod(pod *corev1.Pod, name string) *corev1.Container
- func GetContainerFromPodSpec(podSpec *corev1.PodSpec, name string) *corev1.Container
- func GetEnvVarFromSecret(sctName, name, key string, opt bool) corev1.EnvVar
- func GetVarsFromTemplate(tmpl string) []string
- func GlobalTempDir() string
- func Green(msg string) string
- func IPAddress() (ipAddr string, err error)
- func InIntSlice(slice []int, value int) bool
- func InStringSlice(slice []string, value string) bool
- func Int32(v int32) *int32
- func Int64(v int64) *int64
- func InterfaceMapHash32(msg map[string]interface{}) (string, error)
- func IsAllPodsReady(pods []corev1.Pod) bool
- func IsPodDeleted(po *corev1.Pod) bool
- func IsPodDeletedOrFailed(po *corev1.Pod) bool
- func IsPodFailed(po *corev1.Pod) bool
- func IsPodReady(pod *corev1.Pod) bool
- func IsPodRunning(pod *corev1.Pod) bool
- func IsPodScheduled(po *corev1.Pod) bool
- func IsRetryFailure(err error) bool
- func IsStringSliceEqual(slice1, slice2 []string) bool
- func LOC() *time.Location
- func LOCWithName(name string) *time.Location
- func MD5Hash(input string) string
- func Max(a, b uint64) uint64
- func Min(a, b uint64) uint64
- func ParseCPUWithUnit(cpu float64, unit string) (re resource.Quantity, err error)
- func ParseMemoryWithUnit(mem float64, unit string) (re resource.Quantity, err error)
- func PrintFatalError(err error)
- func PrintMsg(msg string, strs ...string)
- func Red(msg string) string
- func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error
- func SafeTemplateFill(tmpl string, data map[string]interface{}) (string, error)
- func SetColor(msg string, conf, bg, text int) string
- func SizeToBytes(s string) (float64, error)
- func SlurpAsBytes(filename string) ([]byte, error)
- func String(v string) *string
- func StringMap(m *map[string]string)
- func StringToBytes(s string) []byte
- func Struct2Map(obj interface{}) (map[string]interface{}, error)
- func TimeParseInLocal(timeStr string) (*time.Time, error)
- func TimeParseInLocation(timeStr string, local string) (*time.Time, error)
- func ToUpperStringSlice(slice []string) []string
- func TrimmedLines(s string) string
- func UnsafeMergeMap[K comparable, V any](tgt map[K]V, src map[K]V) map[K]V
- func UnsafeMergeStringMap(tgt map[string]string, src map[string]string) map[string]string
- func Unzip(zipFile, dest string) error
- func White(msg string) string
- func WriteRegularFile(fileName, text, directory string) (string, error)
- func WriteString(line string, filename string) error
- func WriteStrings(lines []string, filename string, termination string) error
- func Yellow(msg string) string
- func Zip(files []*os.File, dest string) error
- type ConditionFunc
- type Encryptor
- func (e *Encryptor) Decrypt(ciphertext string) (string, error)
- func (e *Encryptor) DecryptSymmetric(ciphertext string) (string, error)
- func (e *Encryptor) Encrypt(plaintext string) (string, error)
- func (e *Encryptor) EncryptSymmetric(plaintext string) (string, error)
- func (e *Encryptor) ReplaceCharacters(plaintext string) string
- func (e *Encryptor) RestoreCharacters(ciphertext string) string
- type JSON6902
- func (patch *JSON6902) Add(path ...string) func(value interface{}) *JSON6902
- func (patch JSON6902) Bytes() ([]byte, error)
- func (patch JSON6902) Data(client.Object) ([]byte, error)
- func (patch JSON6902) IsEmpty() bool
- func (patch *JSON6902) Remove(path ...string) *JSON6902
- func (patch *JSON6902) Replace(path ...string) func(value interface{}) *JSON6902
- func (patch JSON6902) Type() types.PatchType
- type Merge7386
- func (patch *Merge7386) Add(path ...string) func(value interface{}) *Merge7386
- func (patch Merge7386) Bytes() ([]byte, error)
- func (patch Merge7386) Data(client.Object) ([]byte, error)
- func (patch Merge7386) IsEmpty() bool
- func (patch *Merge7386) PatchAnnos(actual, old map[string]string)
- func (patch *Merge7386) PatchByteMap(path []string, actual, old map[string][]byte)
- func (patch *Merge7386) PatchLabels(actual, old map[string]string)
- func (patch *Merge7386) PatchStringMap(path []string, actual, old map[string]string)
- func (patch *Merge7386) Remove(path ...string) *Merge7386
- func (patch Merge7386) Type() types.PatchType
- type OptionFunc
- type RetryError
Constants ¶
const ( B float64 = 1 KiB = 1024 * B MiB = 1024 * KiB GiB = 1024 * MiB )
const ( TextBlack = iota + 30 TextRed TextGreen TextYellow TextBlue TextMagenta TextCyan TextWhite )
const FormatTime = "2006-01-02 15:04:05"
Variables ¶
var DefaultEncryptor = Encryptor{ // contains filtered or unexported fields }
Functions ¶
func AbsolutePath ¶
Returns the absolute path of a file
func ArePodsAllReady ¶ added in v0.0.5
func ArePodsAllScheduled ¶ added in v0.0.5
func BuildPodMap ¶ added in v0.0.5
func BytesToString ¶
BytesToString casts slice to string without copy
func ContainsOnlyFinalizer ¶ added in v0.0.5
func ConvertToStruct ¶ added in v0.0.6
func ExitSignalHandler ¶
func ExitSignalHandler(onExit func())
func FilterPodsBy ¶ added in v0.0.5
func FuncCaller ¶ added in v0.0.4
func FuncCaller() string
func GenerateResource ¶ added in v0.0.5
func GetContainerFromPod ¶ added in v0.0.5
func GetContainerFromPodSpec ¶ added in v0.0.5
func GetEnvVarFromSecret ¶ added in v0.0.5
func GetVarsFromTemplate ¶ added in v0.0.7
GetVarsFromTemplate Gets a list of all variables mentioned in a template
func GlobalTempDir ¶
func GlobalTempDir() string
func InIntSlice ¶
func InStringSlice ¶
func InterfaceMapHash32 ¶ added in v0.0.6
func IsAllPodsReady ¶ added in v0.0.5
func IsPodDeleted ¶ added in v0.0.5
func IsPodDeletedOrFailed ¶ added in v0.0.5
func IsPodFailed ¶ added in v0.0.5
func IsPodReady ¶ added in v0.0.5
func IsPodRunning ¶ added in v0.0.5
func IsPodScheduled ¶ added in v0.0.5
func IsRetryFailure ¶
func IsStringSliceEqual ¶
func LOCWithName ¶
func ParseCPUWithUnit ¶ added in v0.0.5
func ParseMemoryWithUnit ¶ added in v0.0.5
func PrintFatalError ¶ added in v0.0.4
func PrintFatalError(err error)
func Retry ¶
func Retry(interval time.Duration, maxRetries int, f ConditionFunc) error
Retry retries f every interval until after maxRetries. The interval won't be affected by how long f takes. For example, if interval is 3s, f takes 1s, another f will be called 2s later. However, if f takes longer than interval, it will be delayed.
func SafeTemplateFill ¶ added in v0.0.7
SafeTemplateFill passed template string is formatted using its operands and returns the resulting string. It checks that the data was safely initialized
func SizeToBytes ¶ added in v0.0.6
SizeToBytes parses a string formatted by ByteSize as bytes.
func SlurpAsBytes ¶
reads a file and returns its contents as a byte slice
func StringToBytes ¶
StringToBytes casts string to slice without copy
func Struct2Map ¶ added in v0.0.6
func TimeParseInLocation ¶
func ToUpperStringSlice ¶
func TrimmedLines ¶ added in v0.0.7
TrimmedLines Given a multi-line string, this function removes leading spaces from every line. It also removes the first line, if it is empty
func UnsafeMergeMap ¶ added in v0.0.6
func UnsafeMergeMap[K comparable, V any](tgt map[K]V, src map[K]V) map[K]V
func UnsafeMergeStringMap ¶ added in v0.0.6
func WriteRegularFile ¶
func WriteString ¶
append a string into an existing file
func WriteStrings ¶
Writes a string slice into a file The file is created
Types ¶
type ConditionFunc ¶
type Encryptor ¶ added in v0.0.3
type Encryptor struct {
// contains filtered or unexported fields
}
func NewEncryptor ¶ added in v0.0.3
func NewEncryptor(opts ...OptionFunc) *Encryptor
func (*Encryptor) DecryptSymmetric ¶ added in v0.0.3
对密文进行对称解密
func (*Encryptor) EncryptSymmetric ¶ added in v0.0.3
对明文进行对称加密
func (*Encryptor) ReplaceCharacters ¶ added in v0.0.3
对明文进行字符替换
func (*Encryptor) RestoreCharacters ¶ added in v0.0.3
对密文进行字符替换
type JSON6902 ¶ added in v0.0.5
type JSON6902 []interface{}
JSON6902 represents a JSON Patch according to RFC 6902; the same as k8s.io/apimachinery/pkg/types.JSONPatchType.
func NewJSONPatch ¶ added in v0.0.5
func NewJSONPatch() *JSON6902
NewJSONPatch creates a new JSON Patch according to RFC 6902; the same as k8s.io/apimachinery/pkg/types.JSONPatchType.
func (*JSON6902) Add ¶ added in v0.0.5
Add appends an "add" operation to patch.
> The "add" operation performs one of the following functions, > depending upon what the target location references: > > o If the target location specifies an array index, a new value is > inserted into the array at the specified index. > > o If the target location specifies an object member that does not > already exist, a new member is added to the object. > > o If the target location specifies an object member that does exist, > that member's value is replaced.
func (*JSON6902) Remove ¶ added in v0.0.5
Remove appends a "remove" operation to patch.
> The "remove" operation removes the value at the target location. > > The target location MUST exist for the operation to be successful.
type Merge7386 ¶ added in v0.0.5
type Merge7386 map[string]interface{}
Merge7386 represents a JSON Merge Patch according to RFC 7386; the same as k8s.io/apimachinery/pkg/types.MergePatchType.
func NewMergePatch ¶ added in v0.0.5
func NewMergePatch() *Merge7386
NewMergePatch creates a new JSON Merge Patch according to RFC 7386; the same as k8s.io/apimachinery/pkg/types.MergePatchType.
func (*Merge7386) Add ¶ added in v0.0.5
Add modifies patch to indicate that the member at path should be added or replaced with value.
> If the provided merge patch contains members that do not appear > within the target, those members are added. If the target does > contain the member, the value is replaced. Null values in the merge > patch are given special meaning to indicate the removal of existing > values in the target.
func (*Merge7386) PatchAnnos ¶ added in v0.0.5
func (*Merge7386) PatchByteMap ¶ added in v0.0.5
func (*Merge7386) PatchLabels ¶ added in v0.0.5
func (*Merge7386) PatchStringMap ¶ added in v0.0.5
type OptionFunc ¶ added in v0.0.3
type OptionFunc func(o *Encryptor)
Option is an application option.
func Algorithm ¶ added in v0.0.3
func Algorithm(algorithm string) OptionFunc
func Iv ¶ added in v0.0.3
func Iv(iv string) OptionFunc
func Key ¶ added in v0.0.3
func Key(key string) OptionFunc
func ReplaceTable ¶ added in v0.0.3
func ReplaceTable(replaceTable string) OptionFunc
func ReplaceWith ¶ added in v0.0.3
func ReplaceWith(replaceWith string) OptionFunc
type RetryError ¶
type RetryError struct {
// contains filtered or unexported fields
}
func (*RetryError) Error ¶
func (e *RetryError) Error() string