Documentation
¶
Index ¶
- Constants
- Variables
- func AddSourceToImage(imagesSet map[string]map[string]bool, image string, sources ...string)
- func Base64(s string) string
- func CheckFileExistsPrompt(ctx context.Context, name string, autoYes bool) error
- func ConstructRegistry(image, registryOverride string) string
- func CopyPolicy(src *signature.Policy) (*signature.Policy, error)
- func CopySystemContext(src *types.SystemContext) *types.SystemContext
- func DecodeBase64(s string) (string, error)
- func DefaultUserAgent() string
- func DetectURL(ctx context.Context, s string, insecure bool) (string, *http.Response, error)
- func EnsureSemverValid(v string) (string, error)
- func GetImageName(image string) string
- func GetImageTag(image string) string
- func GetProjectName(image string) string
- func GetRegistryName(image string) string
- func HTTPClientDo(client *http.Client, req *http.Request) (*http.Response, error)
- func HTTPClientDoWithRetry(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
- func HangarCacheDir() string
- func MergeImageSourceSet(a, b map[string]map[string]bool)
- func MergeSets(a, b map[string]bool)
- func ReadPassword(ctx context.Context) ([]byte, error)
- func ReplaceProjectName(image, project string) string
- func Scanf(ctx context.Context, format string, a ...any) (int, error)
- func SemverCompare(a, b string) (int, error)
- func SemverMajorEqual(a, b string) bool
- func SemverMajorMinorEqual(a, b string) bool
- func SetupLogrus(hideTime bool)
- func Sha256Sum(s string) string
- func SystemContextWithSharedBlobDir(sysctx *types.SystemContext, dir string) *types.SystemContext
- func SystemContextWithTLSVerify(sysctx *types.SystemContext, tlsVerify bool) *types.SystemContext
- func ToJSON(a any) string
- func ToObj(data interface{}, into interface{}) error
- func TrivyCacheDir() string
Constants ¶
const ( HangarGitHubURL = "https://github.com/cnrancher/hangar" DockerHubRegistry = "docker.io" CacheCloneRepoDirectory = "charts-repo-cache" MaxWorkerNum = 20 MinWorkerNum = 1 DefaultProject = "library" DefaultTag = "latest" LocalHost = "localhost" )
Variables ¶
var ( ErrVersionIsEmpty = errors.New("version is empty string") ErrNoAvailableImage = errors.New("no available image for specified arch and os") ErrIsSigstoreSignature = errors.New("image is a sigstore signature") )
var ( Version = "v1.9.0-dev" GitCommit = "HEAD" )
Functions ¶
func AddSourceToImage ¶
AddSourceToImage adds image into map[image][source]bool
func CheckFileExistsPrompt ¶ added in v1.7.1
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 CopySystemContext ¶ added in v1.7.0
func CopySystemContext(src *types.SystemContext) *types.SystemContext
func DecodeBase64 ¶
func DefaultUserAgent ¶ added in v1.9.0
func DefaultUserAgent() string
func DetectURL ¶ added in v1.8.0
DetectURL detects whether the server is using HTTPS or HTTP (if in insecure mode) User need to call resp.Body.Close after usage.
func EnsureSemverValid ¶
func GetImageName ¶ added in v1.5.0
GetImageName gets the image name, example:
nginx:latest -> nginx reg.io/nginx:latest -> nginx library/nginx:latest -> nginx reg.io/library/nginx -> nginx
func GetImageTag ¶ added in v1.7.0
GetImageTag gets the image tag, example:
nginx:latest -> latest nginx:1.22 -> 1.22 reg.io/nginx:1.22 -> 1.22 library/nginx -> latest reg.io/library/nginx -> latest
func GetProjectName ¶
GetProjectName gets the project name of the image, example:
nginx -> "library" docker.io/nginx -> "library" 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 HTTPClientDo ¶ added in v1.7.2
func HTTPClientDoWithRetry ¶ added in v1.7.1
func HangarCacheDir ¶ added in v1.8.0
func HangarCacheDir() string
Get the hangar cache dir.
The default cache dir is `${HOME}/.cache/hangar/<random>`.
func MergeImageSourceSet ¶ added in v1.7.1
Merge map[image]map[source]true from b into a
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
The result will be 0 if a == b, -1 if a < b, or +1 if a > b.
func SemverMajorEqual ¶
func SemverMajorMinorEqual ¶
func SetupLogrus ¶ added in v1.8.6
func SetupLogrus(hideTime bool)
func SystemContextWithSharedBlobDir ¶ added in v1.7.0
func SystemContextWithSharedBlobDir(sysctx *types.SystemContext, dir string) *types.SystemContext
func SystemContextWithTLSVerify ¶ added in v1.7.0
func SystemContextWithTLSVerify(sysctx *types.SystemContext, tlsVerify bool) *types.SystemContext
func TrivyCacheDir ¶ added in v1.8.0
func TrivyCacheDir() string
Get the teivy cache dir for trivy databases.
Types ¶
This section is empty.