file

package
v3.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Overview

Package file defines the operations on the binaries.

Index

Constants

View Source
const (
	ZONE                        = "cn"
	DefaultDownloadHost         = "https://github.com"
	DefaultDownloadHostGoogle   = "https://storage.googleapis.com"
	DefaultDownloadHostQingStor = "https://kubernetes-release.pek3b.qingstor.com"
)

Default

View Source
const (
	BinDir       = "/usr/local/bin"
	OptCniBinDir = "/opt/cni/bin"
	SystemdDir   = "/etc/systemd/system"
	MntDir       = "/mnt/kubekey"
)

Common dir

View Source
const (
	ContainerdName        = "containerd-%s-linux-%s.tar.gz"
	ContainerdID          = "containerd"
	ContainerdURLPathTmpl = "/containerd/containerd/releases/download/v%s/containerd-%s-linux-%s.tar.gz"
)

Containerd info

View Source
const (
	CrictlName          = "crictl-%s-linux-%s.tar.gz"
	CrictlID            = "crictl"
	CrictlURLPathTmpl   = "/kubernetes-sigs/cri-tools/releases/download/%s/crictl-%s-linux-%s.tar.gz"
	CrictlURLPathTmplCN = "/cri-tools/releases/download/%s/crictl-%s-linux-%s.tar.gz"
)

Crictl info

View Source
const (
	DockerName           = "docker-%s.tgz"
	DockerID             = "docker"
	DockerURL            = "https://download.docker.com"
	DockerURLPathTmpl    = "/linux/static/stable/%s/docker-%s.tgz"
	DockerURLCN          = "https://mirrors.aliyun.com"
	DockerURLPathTmplCN  = "/docker-ce/linux/static/stable/%s/docker-%s.tgz"
	DockerDefaultVersion = "20.10.8"
)

Docker info

View Source
const (
	CRIDockerdName           = "cri-dockerd-%s.%s.tgz"
	CRIDockerdID             = "cri-dockerd"
	CRIDockerdURL            = "https://github.com/Mirantis/cri-dockerd/releases/download"
	CRIDockerdURLPathTmpl    = "/v%s/cri-dockerd-%s.%s.tgz"
	DefaultCRIDockerdVersion = "0.2.6"
)

CRI-Dockerd Info

View Source
const (
	K3sName          = "k3s"
	K3sID            = "k3s"
	K3sURLPathTmpl   = "/k3s-io/k3s/releases/download/%s+k3s1/k3s%s"
	K3sURLPathTmplCN = "/k3s/releases/download/%s+k3s1/linux/%s/k3s"
)

K3s info

View Source
const (
	KubeadmName          = "kubeadm"
	KubeadmID            = "kubeadm"
	KubeadmURLPathTmpl   = "/kubernetes-release/release/%s/bin/linux/%s/kubeadm"
	KubeadmURLPathTmplCN = "/release/%s/bin/linux/%s/kubeadm"
)

Kubeadm info

View Source
const (
	KubecniName           = "cni-plugins-linux-%s-%s.tgz"
	KubecniID             = "kubecni"
	KubecniURLPathTmpl    = "/containernetworking/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz"
	KubecniURLCN          = "https://containernetworking.pek3b.qingstor.com"
	KubecniURLPathTmplCN  = "/plugins/releases/download/%s/cni-plugins-linux-%s-%s.tgz"
	KubecniDefaultVersion = "v0.9.1"
)

Kubecni info

View Source
const (
	KubectlName          = "kubectl"
	KubectlID            = "kubectl"
	KubectlURLPathTmpl   = "/kubernetes-release/release/%s/bin/linux/%s/kubectl"
	KubectlURLPathTmplCN = "/release/%s/bin/linux/%s/kubectl"
)

Kubectl info

View Source
const (
	KubeletName          = "kubelet"
	KubeletID            = "kubelet"
	KubeletURLPathTmpl   = "/kubernetes-release/release/%s/bin/linux/%s/kubelet"
	KubeletURLPathTmplCN = "/release/%s/bin/linux/%s/kubelet"
)

kubelet info

View Source
const (
	ISOName        = "%s.iso"
	ISOID          = "iso"
	ISOURLPathTmpl = "/kubesphere/kubekey/releases/download/v2.2.2/%s"
)

ISO info

View Source
const (
	RuncName           = "runc.%s"
	RuncID             = "runc"
	RuncURLPathTmpl    = "/opencontainers/runc/releases/download/%s/runc.%s"
	RuncDefaultVersion = "v1.1.1"
)

runc info

Variables

View Source
var (
	// FileBinary represents a binary file.
	FileBinary = Type("fileBinary")
	// FileText represents a text file.
	FileText = Type("fileText")
	// FileTemplate represents a template file.
	FileTemplate = Type("fileTemplate")
)

Functions

This section is empty.

Types

type Binary

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

Binary is a binary implementation of Binary interface.

func NewBinary

func NewBinary(params BinaryParams) *Binary

NewBinary returns a new Binary.

func (*Binary) AppendChecksum

func (b *Binary) AppendChecksum(c checksum.Interface)

AppendChecksum appends a checksum to the checksum list.

func (*Binary) Arch

func (b *Binary) Arch() string

Arch returns the arch of the binary.

func (*Binary) Chmod

func (b *Binary) Chmod(option string) error

Chmod changes the mode of the Binary file.

func (*Binary) CompareChecksum

func (b *Binary) CompareChecksum() error

CompareChecksum compares the checksum of the binary.

func (*Binary) Copy

func (b *Binary) Copy(override bool) error

Copy copies the Binary file from the local path to the remote path.

func (*Binary) Fetch

func (b *Binary) Fetch(override bool) error

Fetch copies the Binary file from the remote path to the local path.

func (*Binary) Get

func (b *Binary) Get(timeout time.Duration) error

Get downloads the binary from remote.

func (*Binary) ID

func (b *Binary) ID() string

ID returns the id of the binary.

func (*Binary) LocalExist

func (b *Binary) LocalExist() bool

LocalExist returns true if the Binary file is existed in the local path.

func (*Binary) LocalPath

func (b *Binary) LocalPath() string

LocalPath returns the local path of the Binary file.

func (*Binary) Name

func (b *Binary) Name() string

Name returns the name of the Binary file.

func (*Binary) RemoteExist

func (b *Binary) RemoteExist() bool

RemoteExist returns true if the Binary file is existed (and the SHA256 check passes) in the remote path.

func (*Binary) RemotePath

func (b *Binary) RemotePath() string

RemotePath returns the remote path of the Binary file.

func (*Binary) SHA256

func (b *Binary) SHA256() (string, error)

SHA256 calculates the SHA256 of the binary.

func (*Binary) SetHost

func (b *Binary) SetHost(host string)

SetHost sets the host to download the binaries.

func (*Binary) SetPath

func (b *Binary) SetPath(pathStr string)

SetPath sets the URL path of the binary.

func (*Binary) SetURL

func (b *Binary) SetURL(urlStr string)

SetURL sets the download url of the binary.

func (*Binary) SetZone

func (b *Binary) SetZone(zone string)

SetZone sets the zone of the binary.

func (*Binary) Type

func (b *Binary) Type() Type

Type returns the type of the Binary file.

func (*Binary) URL

func (b *Binary) URL() *url.URL

URL returns the download url of the binary.

func (*Binary) Version

func (b *Binary) Version() string

Version returns the version of the binary.

type BinaryParams

type BinaryParams struct {
	File         *File
	ID           string
	Version      string
	Arch         string
	URL          *url.URL
	ChecksumList []checksum.Interface
}

BinaryParams represents the parameters of a Binary.

type CRIDockerd

type CRIDockerd struct {
	*Binary
}

CRIDockerd is a Binary for cri-dockerd.

func NewCRIDockerd

func NewCRIDockerd(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*CRIDockerd, error)

NewCRIDockerd returns a new CRIDockerd.

func (*CRIDockerd) SetZone

func (d *CRIDockerd) SetZone(zone string)

SetZone override Binary's SetZone method.

type Containerd

type Containerd struct {
	*Binary
}

Containerd is a Binary for containerd.

func NewContainerd

func NewContainerd(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Containerd, error)

NewContainerd returns a new Containerd.

type Crictl

type Crictl struct {
	*Binary
}

Crictl is a Binary for crictl.

func NewCrictl

func NewCrictl(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Crictl, error)

NewCrictl returns a new Crictl.

func (*Crictl) SetZone

func (c *Crictl) SetZone(zone string)

SetZone override Binary's SetZone method.

type Data

type Data map[string]interface{}

Data is the data that will be passed to the template.

type Docker

type Docker struct {
	*Binary
}

Docker is a Binary for docker.

func NewDocker

func NewDocker(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Docker, error)

NewDocker returns a new Docker.

func (*Docker) SetZone

func (d *Docker) SetZone(zone string)

SetZone override Binary's SetZone method.

type File

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

File is an implementation of the File interface.

func NewFile

func NewFile(params Params) (*File, error)

NewFile returns a new File object given a FileParams.

func (*File) Chmod

func (s *File) Chmod(option string) error

Chmod changes the mode of the file.

func (*File) Copy

func (s *File) Copy(override bool) error

Copy copies the file from the local path to the remote path.

func (*File) Fetch

func (s *File) Fetch(override bool) error

Fetch copies the file from the remote path to the local path.

func (*File) LocalExist

func (s *File) LocalExist() bool

LocalExist returns true if the file exists in the local path.

func (*File) LocalPath

func (s *File) LocalPath() string

LocalPath returns the local path of the file.

func (*File) Name

func (s *File) Name() string

Name returns the name of the file.

func (*File) RemoteExist

func (s *File) RemoteExist() bool

RemoteExist returns true if the file exists in the remote path.

func (*File) RemotePath

func (s *File) RemotePath() string

RemotePath returns the remote path of the file.

func (*File) SetLocalPath

func (s *File) SetLocalPath(path string)

SetLocalPath sets the local path of the file.

func (*File) SetRemotePath

func (s *File) SetRemotePath(path string)

SetRemotePath sets the remote path of the file.

func (*File) Type

func (s *File) Type() Type

Type returns the type of the file.

type ISO

type ISO struct {
	*Binary
	HTTPChecksum *checksum.HTTPChecksum
}

ISO is a Binary for repository ISO file.

func NewISO

func NewISO(sshClient ssh.Interface, rootFs rootfs.Interface, os *osrelease.Data, arch string, isoName string) (*ISO, error)

NewISO returns a new repository ISO.

func (*ISO) SetZone

func (i *ISO) SetZone(zone string)

SetZone override Binary's SetZone method.

type K3s

type K3s struct {
	*Binary
}

K3s is a Binary for k3s.

func NewK3s

func NewK3s(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*K3s, error)

NewK3s returns a new K3s.

func (*K3s) SetZone

func (k *K3s) SetZone(zone string)

SetZone override Binary's SetZone method.

type Kubeadm

type Kubeadm struct {
	*Binary
}

Kubeadm is a Binary for kubeadm.

func NewKubeadm

func NewKubeadm(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Kubeadm, error)

NewKubeadm returns a new Kubeadm.

func (*Kubeadm) SetZone

func (k *Kubeadm) SetZone(zone string)

SetZone override Binary's SetZone method.

type Kubecni

type Kubecni struct {
	*Binary
}

Kubecni is a Binary for kubecni.

func NewKubecni

func NewKubecni(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Kubecni, error)

NewKubecni returns a new Kubecni.

func (*Kubecni) SetZone

func (k *Kubecni) SetZone(zone string)

SetZone override Binary's SetZone method.

type Kubectl

type Kubectl struct {
	*Binary
}

Kubectl is a Binary for kubectl.

func NewKubectl

func NewKubectl(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Kubectl, error)

NewKubectl returns a new Kubectl.

func (*Kubectl) SetZone

func (k *Kubectl) SetZone(zone string)

SetZone override Binary's SetZone method.

type Kubelet

type Kubelet struct {
	*Binary
}

Kubelet is a Binary for kubelet.

func NewKubelet

func NewKubelet(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Kubelet, error)

NewKubelet returns a new Kubelet.

func (*Kubelet) SetZone

func (k *Kubelet) SetZone(zone string)

SetZone override Binary's SetZone method.

type Params

type Params struct {
	SSHClient      ssh.Interface
	Name           string
	Type           Type
	LocalFullPath  string
	RemoteFullPath string
	RootFs         rootfs.Interface
}

Params represents the parameters of a file.

type Runc

type Runc struct {
	*Binary
}

Runc is a Binary for runc.

func NewRunc

func NewRunc(sshClient ssh.Interface, rootFs rootfs.Interface, version, arch string) (*Runc, error)

NewRunc returns a new Runc.

type Template

type Template struct {
	*File
	// contains filtered or unexported fields
}

Template is an implementation of the Template interface.

func NewTemplate

func NewTemplate(sshClient ssh.Interface, rootFs rootfs.Interface, template *template.Template, data Data, dst string) (*Template, error)

NewTemplate returns a new Template.

func (*Template) RenderToLocal

func (t *Template) RenderToLocal() error

RenderToLocal renders the template to the local filesystem.

type Type

type Type string

Type represents the type of file.

Directories

Path Synopsis
Package checksum implements methods for obtaining and verifying the checksum of binary files.
Package checksum implements methods for obtaining and verifying the checksum of binary files.

Jump to

Keyboard shortcuts

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