Documentation
¶
Index ¶
- Constants
- Variables
- func AddSourceToImage(imagesSet map[string]map[string]bool, image string, sources ...string)
- func AppendFileLine(fileName string, line string) error
- func Base64(s string) string
- func ConstructRegistry(image, registryOverride string) string
- func DecodeBase64(s string) (string, error)
- func DefaultRunCommandFunc(p string, i io.Reader, o io.Writer, args ...string) error
- func DeleteIfExist(name string) error
- func EnsureDirExists(directory string) error
- func EnsureSemverValid(v string) (string, error)
- func GetAbsPath(dir string) (string, error)
- func GetImageName(image string) string
- func GetProjectName(image string) string
- func GetRegistryName(image string) string
- func IsDirEmpty(name string) (bool, error)
- func ReadUsernamePasswd() (username, passwd string, err error)
- func ReplaceProjectName(image, project string) string
- func SaveJson(data interface{}, fileName string) error
- func SaveSlice(fileName string, data []string) error
- func SemverCompare(a, b string) (int, error)
- func SemverMajorEqual(a, b string) bool
- func SemverMajorMinorEqual(a, b string) bool
- func Sha256Sum(s string) string
- func ToObj(data interface{}, into interface{}) error
- type RunCmdFuncType
Constants ¶
const ( HangarGitHubURL = "https://github.com/cnrancher/hangar" DockerLoginURL = "https://hub.docker.com/v2/users/login/" DockerHubRegistry = "docker.io" DockerConfigFile = ".docker/config.json" SavedImageListFile = "saved-images-list.json" CacheImageDirectory = "saved-image-cache" CacheCloneRepoDirectory = "charts-repo-cache" ETC_SSL_FILE = "/etc/ssl/certs/ca-certificates.crt" MAX_WORKER_NUM = 20 MIN_WORKER_NUM = 1 )
Variables ¶
var ( EnvDestUsername = os.Getenv("DEST_USERNAME") EnvDestPassword = os.Getenv("DEST_PASSWORD") EnvDestRegistry = os.Getenv("DEST_REGISTRY") EnvSourceUsername = os.Getenv("SOURCE_USERNAME") EnvSourcePassword = os.Getenv("SOURCE_PASSWORD") EnvSourceRegistry = os.Getenv("SOURCE_REGISTRY") )
environment variables of source and destination registry url, username and password
var ( ErrReadJsonFailed = errors.New("failed to read value from json") ErrSkopeoNotFound = errors.New("skopeo not found") ErrDockerNotFound = errors.New("docker not found") ErrLoginFailed = errors.New("login failed") ErrNoAvailableImage = errors.New("no image available for specified arch list") ErrInvalidParameter = errors.New("invalid parameter") ErrInvalidMediaType = errors.New("invalid media type") ErrInvalidSchemaVersion = errors.New("invalid schema version") ErrNilPointer = errors.New("nil pointer") ErrDockerBuildxNotFound = errors.New("docker buildx not found") ErrDirNotEmpty = errors.New("directory is not empty") ErrCredsStore = errors.New("docker config use credsStore to store password") ErrCredsStoreUnsupport = errors.New("unsupported credsStore, only 'deskstop' supported") ErrVersionIsEmpty = errors.New("version is empty string") )
var ( Version = "v1.5.0-rc" GitCommit = "" )
Functions ¶
func AddSourceToImage ¶
AddSourceToImage adds image into map[image][source]bool
func AppendFileLine ¶
func ConstructRegistry ¶
ConstructRegistry will re-construct the image url:
If `registryOverride` is empty string, example:
nginx --> docker.io/nginx (add docker.io prefix) reg.io/nginx --> reg.io/nginx (nothing changed) reg.io/user/nginx --> reg.io/user/nginx (nothing changed)
If `registryOverride` set, example:
nginx --> ${registryOverride}/nginx (add ${registryOverride} prefix) reg.io/nginx --> ${registryOverride}/nginx (set registry ${registryOverride}) reg.io/user/nginx --> ${registryOverride}/user/nginx (same as above)
func DecodeBase64 ¶
func DefaultRunCommandFunc ¶
DefaultRunCommandFunc executes the command and specifies the stdin and stdout in parameters
func DeleteIfExist ¶
func EnsureDirExists ¶
func EnsureSemverValid ¶
func GetAbsPath ¶
func GetImageName ¶ added in v1.5.0
GetRegistryName gets the image name, example:
nginx:latest -> nginx reg.io/nginx:latest -> nginx library/nginx:latest -> nginx reg.io/library/nginx -> nginx
func GetProjectName ¶
GetProjectName gets the project name of the image, example:
nginx -> "" docker.io/nginx -> "" library/nginx -> library docker.io/library/nginx -> library
func GetRegistryName ¶
GetRegistryName gets the registry name of the image, example:
nginx -> docker.io reg.io/nginx -> reg.io library/nginx -> docker.io reg.io/library/nginx -> reg.io
func IsDirEmpty ¶
func ReadUsernamePasswd ¶
func ReplaceProjectName ¶
ReplaceProjectName will replace the image project name:
If `project` is empty string, the project name will be removed:
nginx --> nginx (nothing changed) reg.io/nginx --> reg.io/nginx (nothing changed) user/nginx --> nginx (remove project name) reg.io/user/nginx --> reg.io/nginx (remove project name)
If `project` set, example:
nginx --> ${project}/nginx (add project name) user/nginx --> ${project}/nginx (replace project name) reg.io/nginx --> reg.io/${project}/nginx reg.io/user/nginx --> reg.io/${project}/nginx
func SemverCompare ¶
SemverCompare compares two semvers