Documentation
¶
Index ¶
- Constants
- Variables
- func CanonicalOSType(osType string) string
- func CanonicalPkgManagerType(raw string) string
- func CheckEOSL(osType, osVersion string) (bool, string, error)
- func DeduplicateStringSlice(input []string) []string
- func EnsurePath(path string, perm fs.FileMode) (bool, error)
- func GetEOLAPIBaseURL() string
- func GetImageDescriptor(ctx context.Context, imageRef, runtime string) (*ocispec.Descriptor, error)
- func GetIndexManifestAnnotations(ctx context.Context, imageRef string) (map[string]string, error)
- func GetMediaType(imageRef, runtime string) (string, error)
- func GetMediaTypeWithContext(ctx context.Context, imageRef, runtime string) (string, error)
- func GetPlatformManifestAnnotations(ctx context.Context, imageRef string, targetPlatform *ocispec.Platform) (map[string]string, error)
- func GetProxy() llb.ProxyEnv
- func IsNonEmptyFile(dir, file string) bool
- func IsSUSEImage(osType string) bool
- func LocalImageIndex(ctx context.Context, imageRef string) (*ocispec.Index, *ocispec.Descriptor, bool, bool, error)
- func LocalImagePlatforms(ctx context.Context, imageRef string) ([]ocispec.Platform, bool, error)
- func LocalPlatformDescriptor(ctx context.Context, imageRef string, targetPlatform *ocispec.Platform) (*ocispec.Descriptor, bool, error)
- func LogPipe(pipe io.ReadCloser, level log.Level)
- func SetEOLAPIBaseURL(url string)
- type EOLAPIResponse
- type EOLProductInfo
Constants ¶
const ( OSTypeAlpine = "alpine" OSTypeDebian = "debian" OSTypeUbuntu = "ubuntu" OSTypeCBLMariner = "cbl-mariner" OSTypeAzureLinux = "azurelinux" OSTypeCentOS = "centos" OSTypeOracle = "oracle" OSTypeRedHat = "redhat" OSTypeRocky = "rocky" OSTypeAmazon = "amazon" OSTypeAlma = "alma" OSTypeAlmaLinux = "almalinux" OSTypeSLES = "sles" OSTypeOpenSUSELeap = "opensuse-leap" OSTypeOpenSUSETW = "opensuse-tumbleweed" OSTypeArchLinux = "archlinux" )
Canonical supported OS (distribution) identifiers used across Copacetic. Centralizing them avoids string literal drift and enables IDE refactors. These values correspond to normalized distro 'Type' values in manifests and inputs to GetPackageManager.
const ( PkgTypeLibrary = "library" PkgTypeOS = "os" PatchTypeMajor = "major" PatchTypeMinor = "minor" PatchTypePatch = "patch" // Package types for language managers. LangPackages = "lang-pkgs" PythonPackages = "python-pkg" NodePackages = "node-pkg" GoModules = "gomod" GoBinary = "gobinary" DotNetPackages = "dotnet-core" DefaultTempWorkingFolder = "/tmp" )
Variables ¶
var RPMDistros = []string{ OSTypeCBLMariner, OSTypeAzureLinux, OSTypeCentOS, OSTypeOracle, OSTypeRedHat, OSTypeRocky, OSTypeAmazon, OSTypeAlma, OSTypeAlmaLinux, OSTypeSLES, OSTypeOpenSUSELeap, OSTypeOpenSUSETW, }
RPMDistros is a helper slice listing rpm-family OS identifiers.
Functions ¶
func CanonicalOSType ¶ added in v0.13.0
func CanonicalPkgManagerType ¶ added in v0.12.0
CanonicalPkgManagerType maps various OS family/type identifiers that may appear in scanner outputs (e.g. Trivy) to the canonical package manager type strings used by Copacetic and expected in purl identifiers within generated VEX documents. If the provided value is already canonical or an unknown value, it is returned unchanged.
Examples:
alpine -> apk debian -> deb ubuntu -> deb centos -> rpm almalinux -> rpm rocky -> rpm redhat -> rpm amazon -> rpm oracle -> rpm cbl-mariner -> rpm sles -> rpm opensuse-leap -> rpm opensuse-tumbleweed -> rpm
func DeduplicateStringSlice ¶ added in v0.12.0
DeduplicateStringSlice removes duplicate strings from a slice while preserving order.
func GetEOLAPIBaseURL ¶ added in v0.12.0
func GetEOLAPIBaseURL() string
GetEOLAPIBaseURL returns the current EOL API base URL.
func GetImageDescriptor ¶ added in v0.11.0
GetImageDescriptor retrieves the image descriptor for a given image reference using the specified runtime. It first tries to inspect the image using the specified runtime client (local). If the image is not found locally or a local error occurs, it tries to get the image descriptor from the remote registry. runtime should be imageloader.Docker or imageloader.Podman.
func GetIndexManifestAnnotations ¶ added in v0.11.0
GetIndexManifestAnnotations retrieves annotations from an image index manifest. This is specifically for multi-platform images to get the index-level annotations. For single-platform manifests, it returns the annotations from the manifest body (NOT desc.Annotations, which is empty for top-level lookups since there is no parent index entry to inherit annotations from).
The local image store is checked first via the Docker daemon; if the image is present locally, its index-level annotations are returned from there and the remote registry is not contacted. Only when the image is not available locally does this function fall back to a remote registry lookup.
func GetMediaType ¶ added in v0.11.0
GetMediaType returns the manifest's media type for an image reference. It prefers a local inspection and falls back to a registry lookup only when the image is not present in the local image store. When the image is confirmed locally but no media type metadata is available, a Docker manifest v2 media type is returned to keep daemon-only refs strictly local-first.
func GetMediaTypeWithContext ¶ added in v0.15.0
GetMediaTypeWithContext behaves like GetMediaType but binds media type detection to ctx, so the local Docker inspection, Podman CLI execution, and remote registry lookup are canceled when the caller's context (e.g. the patch timeout) is done. A nil ctx is treated as context.Background() to avoid panicking exec.CommandContext.
func GetPlatformManifestAnnotations ¶ added in v0.11.0
func GetPlatformManifestAnnotations(ctx context.Context, imageRef string, targetPlatform *ocispec.Platform) (map[string]string, error)
GetPlatformManifestAnnotations retrieves manifest-level annotations for a specific platform from an image index manifest. For single-platform images (no index), it parses the manifest body to extract its annotations rather than returning nil — annotations on a single-platform manifest live in the manifest body, not in the descriptor returned by a top-level fetch.
The local image store is checked first via the Docker daemon; if the image is present locally, the matching platform's manifest-level annotations are returned from there and the remote registry is not contacted. Only when the image is not available locally does this function fall back to a remote registry lookup.
func IsNonEmptyFile ¶
func IsSUSEImage ¶ added in v0.13.0
func LocalImageIndex ¶ added in v0.15.0
func LocalImageIndex(ctx context.Context, imageRef string) (*ocispec.Index, *ocispec.Descriptor, bool, bool, error)
LocalImageIndex returns the locally available index metadata exposed by Docker's manifest-aware image inspection. The second return value is the top-level descriptor. Complete is false when Docker exposes an index but any of its descriptors are unavailable locally, and ok reports that the reference exists locally even when it resolves to a single image instead of an index.
func LocalImagePlatforms ¶ added in v0.15.0
LocalImagePlatforms returns the list of platforms present in the local Docker image store for the given image reference. The second return value indicates whether the image was found locally; callers should not fall back to a remote registry when ok is true. For single-platform local images, a one-element slice is returned. For multi-platform images (only available when the daemon uses a multi-platform image store), one entry per image manifest is returned.
func LocalPlatformDescriptor ¶ added in v0.15.0
func LocalPlatformDescriptor(ctx context.Context, imageRef string, targetPlatform *ocispec.Platform) (*ocispec.Descriptor, bool, error)
LocalPlatformDescriptor returns the OCI descriptor for a specific platform from a multi-platform image present in the local Docker image store. The second return value indicates whether the image was found locally; callers should not fall back to a remote registry when ok is true.
When ok is true but the returned descriptor is nil, the image is present locally but does not contain a matching platform (either because the daemon does not expose per-platform manifest entries — e.g. legacy snapshotter — or because the requested platform is not represented in the image).
func SetEOLAPIBaseURL ¶ added in v0.12.0
func SetEOLAPIBaseURL(url string)
SetEOLAPIBaseURL allows configuration of the EOL API base URL.
Types ¶
type EOLAPIResponse ¶ added in v0.11.0
type EOLAPIResponse struct {
SchemaVersion string `json:"schema_version"`
GeneratedAt string `json:"generated_at"`
Result EOLProductInfo `json:"result"`
}