utils

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

func DecodeBase64

func DecodeBase64(encoded string) (string, error)

DecodeBase64 解密 Base64 编码的字符串

func DeepCopy

func DeepCopy[T any](src T) (T, error)

DeepCopy 函数接受任何类型的参数并返回其深复制的副本

func EncodeBase64

func EncodeBase64(str string) string

func Int32Ptr

func Int32Ptr(i int32) *int32

func Int64Ptr

func Int64Ptr(i int64) *int64

func IsTextFile

func IsTextFile(ob []byte) (bool, error)

func MustDecodeBase64

func MustDecodeBase64(encoded string) string

func RandNDigitInt

func RandNDigitInt(n int) int

RandNDigitInt generates a random number with n digits

func RandNLengthString

func RandNLengthString(n int) string

RandNLengthString generates a random string of specified length using the default charset

func SanitizeFileName

func SanitizeFileName(filename string) string

SanitizeFileName 去除文件名中的非法字符,并替换为下划线 '_'

func ToInt

func ToInt(s string) int

func ToInt64

func ToInt64(str string) int64

func ToInt64Slice

func ToInt64Slice(ids string) []int64

func ToIntDefault

func ToIntDefault(s string, i int) int

func ToIntSlice

func ToIntSlice(ids string) []int

ToIntSlice 将逗号分隔的数字字符串转换为 []int 切片

func ToJSON

func ToJSON(v interface{}) string

ToJSON 将任意结构体转换为格式化的 JSON 字符串

func ToUInt

func ToUInt(s string) uint

func TruncateString

func TruncateString(s string, length int) string

func UpdateImageName

func UpdateImageName(imageName string, imagePrefix string) string

UpdateImageName 检查镜像名称是否包含前缀,只能是harbor.power.sd.k9s.space 是否已harbor.power.sd.k9s.space开头,是,没问题。 否,检查是否有其他前缀,删除,替换为harbor.power.sd.k9s.space 没有,增加harbor.power.sd.k9s.space前缀 检查镜像名称是否已以指定前缀开头

Types

type LabelsManager

type LabelsManager struct {
	Labels map[string]string
}

LabelsManager 结构体,包含共享标签

func NewLabelsManager

func NewLabelsManager(labels map[string]string) *LabelsManager

NewLabelsManager 构造函数,初始化并返回一个 LabelsManager

func (*LabelsManager) AddCustomLabel

func (lm *LabelsManager) AddCustomLabel(meta *metav1.ObjectMeta, key, value string)

AddCustomLabel 动态添加用户指定的标签

func (*LabelsManager) AddLabels

func (lm *LabelsManager) AddLabels(meta *metav1.ObjectMeta)

AddLabels 给任意 Kubernetes 资源对象添加共享标签

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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