utils

package
v0.0.0-...-7481e07 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	K8sV17         = "1.17.0"
	FlagDebugMode  *bool
	Logger         *log.Logger
	MaxWaitingTime = 200 //seconds

	AccessKeyID     string
	AccessKeySecret string
	APIHost         string
)

Functions

func CreateDir

func CreateDir(target string, mode int) error

CreateDir create the target directory with error handling

func DoRequest

func DoRequest(req *CloudRequest) (resp *http.Response, err error)

func DownloadFile

func DownloadFile(url, filepath, name string)

func FileExisted

func FileExisted(filename string) bool

FileExisted checks if a file or directory exists

func HttpGet

func HttpGet(url string) ([]byte, error)

func ImagePullAndTag

func ImagePullAndTag(imageSlice []string) ([]string, error)

func InstallPkgs

func InstallPkgs(pkgs []string, group bool) ([]string, error)

func MarshalJsonToIOReader

func MarshalJsonToIOReader(v interface{}) (io.Reader, error)

func RunCommand

func RunCommand(cmd string) (string, error)

RunCommand runs a given shell command

func SendRequest

func SendRequest(method, url string, data_bytes []byte, headers []string) ([]byte, error)

Types

type BaseResponse

type BaseResponse struct {
	Code    string `json:"code"`
	Message string `json:"msg"`
}

type CloudRequest

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

func NewCCKRequest

func NewCCKRequest(action, method string, params map[string]string, body io.Reader) (*CloudRequest, error)

func NewRequest

func NewRequest(action, method string, params map[string]string, productType string, body io.Reader) (*CloudRequest, error)

type InitData

type InitData struct {
	K8sVersion   string
	ClusterID    string
	RootPassword string
	Ak           string
	Sk           string
	UserID       string
	CustomerID   string
	Gateway      string
	PrivateIP    string
}

type K8sV17Config

type K8sV17Config struct {
	K8sInstall    k8s
	SystemConfig  config
	YumConfig     yum
	PythonInstall python
	DockerInstall docker
	DockerImages  images
	NetworkConfig network
}

type TargetDef

type TargetDef struct {
	Version             string `json: "version"`
	Download_url        string `json: "download_url"`
	Checksum_md5_url    string `json: "checksum_md5_url"`
	Checksum_sha256_url string `json: "checksum_sha256_url"`
}

noinspection ALL

type TunnelGetResponse

type TunnelGetResponse struct {
	BaseResponse
	Data struct {
		NodeID        string `json:"node_id"`
		TunnelAddress string `json:"tunnel_address"`
		TunnelPort    string `json:"tunnel_port"`
		IdRsaPub      string `json:"id_rsa_pub"`
		Token         string `json:"token"`
		Version       string `json:"version"`
		ServerPort    string `json:"server_port"`
		ImageUrl      string `json:"image_url"`
	} `json:"data"`
}

type TunnelInitResponse

type TunnelInitResponse struct {
	BaseResponse
	Data struct {
		ClusterID string `json:"cluster_id"`
		TaskId    string `json:"task_id"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

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