utils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: GPL-3.0 Imports: 31 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressZip

func CompressZip(files []*os.File, dest string) error

CompressZip Compress files to zip files File array, which can be files or folders under different dirs dest Compressed file storage address

func CreateDeployment added in v1.0.3

func CreateDeployment(client *kubernetes.Clientset, username, deploymentName string, container []corev1.Container) (*appsv1.Deployment, error)

CreateDeployment create deployment

func CreateHttpsIngress added in v1.0.3

func CreateHttpsIngress(client *kubernetes.Clientset, namespace, serviceName, gateway string, ports []corev1.ServicePort) (*networkingv1beta1.Ingress, error)

func CreateIngress added in v1.0.3

func CreateIngress(client *kubernetes.Clientset, namespace, serviceName, gateway string, ports []corev1.ServicePort) (*networkingv1beta1.Ingress, error)

func CreateNamespace added in v1.0.3

func CreateNamespace(client *kubernetes.Clientset, username string) error

func CreateService added in v1.0.3

func CreateService(client *kubernetes.Clientset, username, serviceName string, ports []corev1.ServicePort) error

func DeCompressZip

func DeCompressZip(zipFile, dest string) error

DeCompressZip Zip unzip

func DefaultConfigDir

func DefaultConfigDir() string

func FileToHexString added in v1.0.3

func FileToHexString(filePath string) (string, error)

FileToHexString 读取文件内容,转换为 hex 字符串

func FormatJobToString added in v1.0.3

func FormatJobToString(name string, id int) string

FormatJobToString 格式化为字符串 return: name(id)

func GetDefaultNamedAddress added in v1.0.3

func GetDefaultNamedAddress(tomlPath string) (string, error)

func GetFilenameWithSuffixAndFilenameOnly

func GetFilenameWithSuffixAndFilenameOnly(path string) (fileName string, fileNameWithSuffix string)

GetFilenameWithSuffixAndFilenameOnly 获取带后置的文件名和不带后缀的文件名

func GetFiles

func GetFiles(workdir string, fuzzyPath []string, pathList []string) []string

GetFiles 获取文件路径集合 workdir 基础路径 fuzzyPath 要赛选的路径 pathList 查找到的路径对象

func GetJobNameAndIDFromFormatString added in v1.0.3

func GetJobNameAndIDFromFormatString(str string) (string, int, error)

func GetKeyValuesFromString added in v1.0.3

func GetKeyValuesFromString(keyValueString string) (map[string]string, error)

func GetMyHostname added in v1.0.3

func GetMyHostname() (string, error)

func GetMyIP added in v1.0.3

func GetMyIP() (string, error)

func GetNodeKey added in v1.0.3

func GetNodeKey(name, address string) string

func GetPodLogs added in v1.0.3

func GetPodLogs(containerName, deploymentName, namespace string) (*restclient.Request, error)

func GetRedundantPath

func GetRedundantPath(shortPath string, longPath string) (string, error)

GetRedundantPath 获取多余的路径 longPath 相对于 shortPath 的 /a/b/ /a/b/c/d.txt return c/d.txt

func GetSameFileNameFiles

func GetSameFileNameFiles(workdir string, fileName string, pathList []string) []string

GetSameFileNameFiles 获取路径下的所有相同文件文件名的文件 workdir 基础路径 fileName 要赛选的路径 pathList 查找到的路径对象

func GetSuffixFiles

func GetSuffixFiles(workdir string, suffixName string, pathList []string) []string

GetSuffixFiles 获取路径下的所有相同后缀文件 workdir 基础路径 suffixName 要赛选的路径 pathList 查找到的路径对象

func GetUIDAndGID

func GetUIDAndGID() (string, string, error)

func InitK8sClient added in v1.0.3

func InitK8sClient() (*kubernetes.Clientset, error)

func KeyValuesToString added in v1.0.3

func KeyValuesToString(keyValues []KeyValue) string

func RandSeq

func RandSeq(n int) string

func ReplaceWithParam

func ReplaceWithParam(content string, paramMap map[string]string) string

ReplaceWithParam 参数替换

func SaveMoveTomlString added in v1.0.3

func SaveMoveTomlString(moveToml *MoveToml) (string, error)

func SlicePage

func SlicePage(page, pageSize, nums int) (int, int, int, int)

SlicePage paging return:page,pageSize,start,end

Types

type Cmd

type Cmd struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(ctx context.Context, command string, args ...string) *Cmd

NewCommand is like exec.CommandContext but ensures that subprocesses are killed when the context times out, not just the top level process.

func (*Cmd) Run

func (c *Cmd) Run() error

func (*Cmd) Start

func (c *Cmd) Start() error

type HttpUtil added in v1.0.3

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

func NewHttp added in v1.0.3

func NewHttp() *HttpUtil

func (*HttpUtil) NewRequest added in v1.0.3

func (h *HttpUtil) NewRequest() *resty.Request

type KeyValue added in v1.0.3

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func KeyValuesFromString added in v1.0.3

func KeyValuesFromString(keyValues string) ([]KeyValue, error)

type MoveToml added in v1.0.3

type MoveToml struct {
	Package      `toml:"package"`
	Addresses    map[string]string `toml:"addresses"`
	Dependencies map[string]any    `toml:"dependencies"`
}

MoveToml Move.toml

func ParseMoveToml added in v1.0.3

func ParseMoveToml(tomlPath string) (*MoveToml, error)

func ParseMoveTomlWithString added in v1.0.3

func ParseMoveTomlWithString(tomlString string) (*MoveToml, error)

func (*MoveToml) GetAddressField added in v1.0.3

func (m *MoveToml) GetAddressField() []KeyValue

type Package added in v1.0.3

type Package struct {
	Name    string `toml:"name"`
	Version string `toml:"version"`
}

type Stack

type Stack[T any] struct {
	// contains filtered or unexported fields
}

Stack 堆栈

func (*Stack[T]) IsEmpty

func (s *Stack[T]) IsEmpty() bool

IsEmpty 判断堆栈是否为空

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (T, error)

Pop 出栈

func (*Stack[T]) Push

func (s *Stack[T]) Push(value T)

Push 入栈

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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