utils

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
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"
)

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.

View Source
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"
	DotNetPackages = "dotnet-core"

	DefaultTempWorkingFolder = "/tmp"
)

Variables

RPMDistros is a helper slice listing rpm-family OS identifiers.

Functions

func CanonicalOSType added in v0.13.0

func CanonicalOSType(osType string) string

func CanonicalPkgManagerType added in v0.12.0

func CanonicalPkgManagerType(raw string) string

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 CheckEOSL added in v0.11.0

func CheckEOSL(osType, osVersion string) (bool, string, error)

func DeduplicateStringSlice added in v0.12.0

func DeduplicateStringSlice(input []string) []string

DeduplicateStringSlice removes duplicate strings from a slice while preserving order.

func EnsurePath

func EnsurePath(path string, perm fs.FileMode) (bool, error)

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

func GetImageDescriptor(ctx context.Context, imageRef, runtime string) (*ocispec.Descriptor, error)

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

func GetIndexManifestAnnotations(_ context.Context, imageRef string) (map[string]string, error)

GetIndexManifestAnnotations retrieves annotations from an image index manifest. This is specifically for multi-platform images to get the index-level annotations.

func GetMediaType added in v0.11.0

func GetMediaType(imageRef, runtime string) (string, error)

GetMediaType returns the manifest’s media type for an image reference It prefers a local inspection and falls back to a registry lookup.

func GetPlatformManifestAnnotations added in v0.11.0

func GetPlatformManifestAnnotations(_ 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.

func GetProxy added in v0.2.0

func GetProxy() llb.ProxyEnv

func GetSinglePlatformManifestAnnotations added in v0.12.0

func GetSinglePlatformManifestAnnotations(_ context.Context, imageRef string) (map[string]string, error)

GetSinglePlatformManifestAnnotations retrieves annotations from a single-platform manifest. This is used when we need to get annotations from a pushed single-platform image.

func IsNonEmptyFile

func IsNonEmptyFile(dir, file string) bool

func IsSUSEImage added in v0.13.0

func IsSUSEImage(osType string) bool

func LogPipe

func LogPipe(pipe io.ReadCloser, level log.Level)

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"`
}

type EOLProductInfo added in v0.11.0

type EOLProductInfo struct {
	IsEOL        bool   `json:"isEol"`
	EOLDate      string `json:"eolFrom"`
	IsMaintained bool   `json:"isMaintained"`
}

Jump to

Keyboard shortcuts

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