Documentation
¶
Index ¶
- Constants
- Variables
- func IsFileLevelPatternFilterable(t ArtifactType) bool
- func IsKnownArtifactType(t ArtifactType) bool
- func IsPackageLevelPatternFilterable(t ArtifactType) bool
- func IsPatternFilterable(t ArtifactType) bool
- func KnownArtifactTypesString() string
- func ValidatePackageFilters(filters []PackageSelector, t ArtifactType) error
- type Artifact
- type ArtifactType
- type Config
- type CredentialsConfig
- type DateFilter
- type DateFilterMatch
- type DownloadStat
- type DryRunDirectoryEntry
- type DryRunFileEntry
- type DryRunPackageEntry
- type DryRunStats
- func (s *DryRunStats) AddFiles(entries ...DryRunFileEntry)
- func (s *DryRunStats) AddVersionFile(registry, pkg, version string, file DryRunVersionFileEntry)
- func (s *DryRunStats) EnsurePackage(registry, pkg string)
- func (s *DryRunStats) EnsureRegistry(registry string)
- func (s *DryRunStats) EnsureVersion(registry, pkg, version string)
- type DryRunVersionEntry
- type DryRunVersionFileEntry
- type ErrorHook
- type ExistingIndex
- type File
- type FileStat
- type HelmOCIConfig
- type Package
- type PackageFiles
- type PackageSelector
- type RegistryConfig
- type RegistryInfo
- type RegistryMapping
- type RegistryType
- type Repository
- type SearchedFile
- type SelectorGranularity
- type Status
- type TransferStats
- type TreeNode
- type Version
Constants ¶
const ( // SkipReasonAlreadyExists marks skips caused by the destination already // holding the coordinate (destination index hit, HEAD 200, or an // idempotent HTTP 409 on upload). Safe to ignore on re-run. SkipReasonAlreadyExists = "already_exists" // SkipReasonNoContent marks skips where the source coordinate resolved to // nothing migratable (e.g. an OCI repository with no tags). SkipReasonNoContent = "no_content" )
Skip reasons recorded in FileStat.Reason when Status == StatusSkip, so reconciliation tooling can tell WHY a coordinate was skipped instead of treating every skip alike.
const ( ChartLayerMediaType = "application/vnd.cncf.helm.chart.layer.v1.tar+gzip" ConfigMediaType = "application/vnd.cncf.helm.config.v1+json" )
Variables ¶
var ( ErrUnsupportedRegistryType = errors.New("unsupported ar type") ErrArtifactNotFound = errors.New("artifact not found") ErrRegistryNotFound = errors.New("ar not found") ErrInvalidCredentials = errors.New("invalid credentials") ErrArtifactAlreadyExists = errors.New("artifact already exists") )
Common errors
Functions ¶
func IsFileLevelPatternFilterable ¶ added in v1.3.44
func IsFileLevelPatternFilterable(t ArtifactType) bool
IsFileLevelPatternFilterable reports whether include/exclude patterns are applied to individual file URIs for this artifact type.
func IsKnownArtifactType ¶ added in v1.3.39
func IsKnownArtifactType(t ArtifactType) bool
IsKnownArtifactType reports whether t is a recognised ArtifactType value.
func IsPackageLevelPatternFilterable ¶ added in v1.3.44
func IsPackageLevelPatternFilterable(t ArtifactType) bool
IsPackageLevelPatternFilterable reports whether include/exclude patterns are applied to package names for this artifact type.
func IsPatternFilterable ¶ added in v1.3.44
func IsPatternFilterable(t ArtifactType) bool
IsPatternFilterable reports whether include/exclude patterns have ANY effect for this artifact type (at either file or package level).
func KnownArtifactTypesString ¶ added in v1.3.44
func KnownArtifactTypesString() string
KnownArtifactTypesString returns the valid types as a single comma-separated string for error messages and help text.
func ValidatePackageFilters ¶ added in v1.3.37
func ValidatePackageFilters(filters []PackageSelector, t ArtifactType) error
ValidatePackageFilters validates that the provided package filters are compatible with the artifact type's supported granularity.
Types ¶
type ArtifactType ¶
type ArtifactType string
var ( DOCKER ArtifactType = "DOCKER" HELM ArtifactType = "HELM" HELM_LEGACY ArtifactType = "HELM_LEGACY" HELM_HTTP ArtifactType = "HELM_HTTP" GENERIC ArtifactType = "GENERIC" PYTHON ArtifactType = "PYTHON" MAVEN ArtifactType = "MAVEN" NPM ArtifactType = "NPM" NUGET ArtifactType = "NUGET" RPM ArtifactType = "RPM" DEBIAN ArtifactType = "DEBIAN" GO ArtifactType = "GO" CONDA ArtifactType = "CONDA" COMPOSER ArtifactType = "COMPOSER" DART ArtifactType = "DART" RAW ArtifactType = "RAW" SWIFT ArtifactType = "SWIFT" PUPPET ArtifactType = "PUPPET" CRAN ArtifactType = "CRAN" RUBY ArtifactType = "RUBY" CONAN ArtifactType = "CONAN" TERRAFORM ArtifactType = "TERRAFORM" )
func KnownArtifactTypes ¶ added in v1.3.44
func KnownArtifactTypes() []ArtifactType
KnownArtifactTypes returns the ordered list of all valid ArtifactType values. Safe to mutate by the caller (a fresh copy is returned each time).
type Config ¶
type Config struct {
Version string `yaml:"version"`
Concurrency int `yaml:"concurrency"`
Overwrite bool `yaml:"overwrite"`
DryRun bool `yaml:"dryRun"`
Summary bool `yaml:"summary"`
// ResultFile is an optional path to a JSON-lines file that receives one
// per-coordinate result record (mirroring FileStat) at the end of a
// non-dry-run migration, so automation never has to parse human tables.
ResultFile string `yaml:"resultFile,omitempty"`
Source RegistryConfig `yaml:"source"`
Dest RegistryConfig `yaml:"destination"`
Mappings []RegistryMapping `yaml:"mappings"`
}
Config represents the top-level configuration structure
func LoadConfig ¶
LoadConfig loads the configuration from a file
type CredentialsConfig ¶
type CredentialsConfig struct {
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
}
CredentialsConfig defines the credential configuration
type DateFilter ¶ added in v1.3.27
type DateFilter struct {
Match DateFilterMatch `yaml:"match"`
CreatedAfter *time.Time `yaml:"createdAfter"`
DownloadedAfter *time.Time `yaml:"downloadedAfter"`
}
DateFilter defines the time-based filtering criteria for a registry mapping
type DateFilterMatch ¶ added in v1.3.27
type DateFilterMatch string
const ( DateFilterMatchAny DateFilterMatch = "ANY" DateFilterMatchAll DateFilterMatch = "ALL" )
type DownloadStat ¶ added in v1.3.26
type DownloadStat struct {
Downloaded string `json:"downloaded"`
}
DownloadStat represents a single download stat entry for a searched file
type DryRunDirectoryEntry ¶ added in v1.3.7
type DryRunDirectoryEntry struct {
Registry string `json:"registry"`
Packages map[string]*DryRunPackageEntry `json:"packages"`
}
DryRunDirectoryEntry represents the directory structure for dry-run output
type DryRunFileEntry ¶ added in v1.3.7
type DryRunFileEntry struct {
Registry string `json:"registry"`
Name string `json:"name"`
Uri string `json:"uri"`
Size int `json:"size"`
LastModified string `json:"lastModified,omitempty"`
}
DryRunFileEntry represents a single file entry for dry-run output (from GetFiles)
type DryRunPackageEntry ¶ added in v1.3.7
type DryRunPackageEntry struct {
Name string `json:"name"`
Versions map[string]*DryRunVersionEntry `json:"versions"`
}
DryRunPackageEntry represents a package in the directory structure
type DryRunStats ¶ added in v1.3.7
type DryRunStats struct {
Files []DryRunFileEntry // All files from GetFiles
Directories map[string]*DryRunDirectoryEntry // Directory structure built incrementally
// contains filtered or unexported fields
}
DryRunStats holds the dry-run statistics.
A single DryRunStats is shared across the registry/package/version/file jobs that the migration engine runs concurrently, so all access to the Files slice and the Directories map (and the nested maps/slices) must go through the methods below, which are guarded by mu.
func (*DryRunStats) AddFiles ¶ added in v1.3.30
func (s *DryRunStats) AddFiles(entries ...DryRunFileEntry)
AddFiles appends the given file entries to the shared Files slice.
func (*DryRunStats) AddVersionFile ¶ added in v1.3.30
func (s *DryRunStats) AddVersionFile(registry, pkg, version string, file DryRunVersionFileEntry)
AddVersionFile appends a file entry to the given registry/package/version, creating the intermediate entries if necessary.
func (*DryRunStats) EnsurePackage ¶ added in v1.3.30
func (s *DryRunStats) EnsurePackage(registry, pkg string)
EnsurePackage creates the registry and package entries if they do not already exist.
func (*DryRunStats) EnsureRegistry ¶ added in v1.3.30
func (s *DryRunStats) EnsureRegistry(registry string)
EnsureRegistry creates the directory entry for the given registry if it does not already exist.
func (*DryRunStats) EnsureVersion ¶ added in v1.3.30
func (s *DryRunStats) EnsureVersion(registry, pkg, version string)
EnsureVersion creates the registry, package and version entries if they do not already exist.
type DryRunVersionEntry ¶ added in v1.3.7
type DryRunVersionEntry struct {
Name string `json:"name"`
Files []DryRunVersionFileEntry `json:"files"`
}
DryRunVersionEntry represents a version in the directory structure
type DryRunVersionFileEntry ¶ added in v1.3.7
type DryRunVersionFileEntry struct {
Name string `json:"name"`
Registry string `json:"registry"`
Uri string `json:"uri"`
Size int `json:"size"`
LastModified string `json:"lastModified,omitempty"`
}
DryRunVersionFileEntry represents a file with full details in the directory structure
type ExistingIndex ¶ added in v1.3.31
type ExistingIndex struct {
// contains filtered or unexported fields
}
ExistingIndex is a read-only-after-build snapshot of what already exists at the destination registry: pkg -> version -> set of LOWERCASED destination (HAR) file paths, exactly as returned by ListFilesV3.
Lookups query by source-relative path (types.File.Uri); HasFile owns the reverse conversion from a stored HAR path back to source form (see harToSourcePath), so every package-type path rewrite lives in one place and the index build can store HAR paths verbatim.
Concurrency: AddFile takes mu during the concurrent build. After BuildExistingIndex returns (a g.Wait() happens-before edge), the struct is treated as immutable and all reads are lock-free.
func NewExistingIndex ¶ added in v1.3.31
func NewExistingIndex() *ExistingIndex
func (*ExistingIndex) AddFile ¶ added in v1.3.31
func (i *ExistingIndex) AddFile(pkg, version, harPath string)
AddFile records a destination (HAR) file path under (pkg, version); the path is lowercased for case-insensitive matching.
func (*ExistingIndex) HasFile ¶ added in v1.3.31
func (i *ExistingIndex) HasFile(pkg, version, filePath string, artifactType ArtifactType) bool
HasFile reports whether the source-relative filePath already exists at the destination. The index stores destination (HAR) paths, so HasFile converts stored paths back to source form (harToSourcePath) before comparing; the query is lowercased to match the lowercased stored paths.
func (*ExistingIndex) Stats ¶ added in v1.3.41
func (i *ExistingIndex) Stats() (packages, versions, files int)
Stats reports how much the index holds: distinct packages, versions across all packages, and files across all versions. A nil index reports zeros.
type FileStat ¶
type FileStat struct {
Name string `json:"name"`
Registry string `json:"registry"`
Uri string `json:"uri"`
Status Status `json:"status"`
Size int64 `json:"size"`
Error string `json:"error,omitempty"`
// Reason classifies StatusSkip rows (see SkipReason* constants). Empty for
// non-skip rows and for skips recorded before a reason was introduced.
Reason string `json:"reason,omitempty"`
}
type HelmOCIConfig ¶
type Package ¶
type Package struct {
Registry string
Path string
Name string
Size int
URL string
URI string // Full registry-relative path without leading slash, matches strings.TrimPrefix(f.Uri, "/")
Version string
Metadata map[string]string // Package-type specific metadata (e.g., Debian: distribution, component, etc.)
}
type PackageFiles ¶
type PackageFiles struct {
File *File
DownloadFile io.ReadCloser
Header *http.Header
}
type PackageSelector ¶ added in v1.3.37
type PackageSelector struct {
Package string `yaml:"package"`
Versions []string `yaml:"versions,omitempty"`
Files []string `yaml:"files,omitempty"`
}
PackageSelector defines an opt-in allow-list for packages, versions, and files. Empty Versions means all versions of that package. Empty Files means all files of a selected version. Package, Versions, and Files are all matched case-insensitively.
type RegistryConfig ¶
type RegistryConfig struct {
Endpoint string `yaml:"endpoint"`
Type RegistryType `yaml:"type"`
Credentials CredentialsConfig `yaml:"credentials,omitempty"`
Insecure bool `yaml:"insecure" default:"false"`
}
RegistryConfig defines the source ar configuration
type RegistryInfo ¶
type RegistryMapping ¶
type RegistryMapping struct {
ArtifactType ArtifactType `yaml:"artifactType"`
SourceRegistry string `yaml:"sourceRegistry"`
DestinationRegistry string `yaml:"destinationRegistry"`
// IncludePatterns/ExcludePatterns are glob patterns (* and **) applied at
// file level for file-level-filterable types (GENERIC, RAW, PYTHON, MAVEN,
// NUGET, NPM, DART, GO) and at package-name level for
// package-level-filterable types (DOCKER, HELM, HELM_LEGACY, HELM_HTTP,
// RPM, CONDA, COMPOSER, SWIFT, CONAN). Setting them for any other type
// (DEBIAN, TERRAFORM, PUPPET) is a config error — scope controls must
// never be silent no-ops. Only one of the two may be set per mapping.
IncludePatterns []string `yaml:"includePatterns"`
ExcludePatterns []string `yaml:"excludePatterns"`
//Optional
SourcePackageHostname string `yaml:"sourcePackageHostname"`
DateFilter *DateFilter `yaml:"dateFilter"`
// PackageFilters is an opt-in allow-list restricting the migration to specific
// packages, and optionally specific versions/files within them. When empty, all
// packages migrate (behavior-preserving). Supported granularity varies by artifact
// type — see ValidatePackageFilters.
PackageFilters []PackageSelector `yaml:"packageFilters,omitempty"`
}
RegistryMapping defines the mapping between source and destination registries Slashes are used to defined the scope. The format would be - "registry": Create registry at Account level - "org/registry": Create registry at Org level - "org/project/registry": Create registry at Project level
type RegistryType ¶
type RegistryType string
var ( HAR RegistryType = "HAR" JFROG RegistryType = "JFROG" MOCK_JFROG RegistryType = "MOCK_JFROG" NEXUS RegistryType = "NEXUS" HARBOR RegistryType = "HARBOR" )
type Repository ¶
type Repository struct {
// Name is the repository name
Name string
// Description is the repository description
Description string
// ArtifactCount is the count of artifacts in this repository
ArtifactCount int
// Provider is the registry provider (HAR, JFROG)
Provider RegistryType
}
Repository represents a collection of artifacts
type SearchedFile ¶ added in v1.3.26
type SearchedFile struct {
Repo string `json:"repo"`
Path string `json:"path"`
Name string `json:"name"`
Created string `json:"created"`
Modified string `json:"modified"`
Stats []DownloadStat `json:"stats"`
}
SearchedFile represents a file entry returned by SearchFiles
type SelectorGranularity ¶ added in v1.3.37
type SelectorGranularity int
SelectorGranularity represents the level of filtering supported by an artifact type. Values are ordered so < comparisons work (Package < Version < File).
const ( GranularityPackage SelectorGranularity = iota GranularityVersion GranularityFile )
func SupportedSelectorGranularity ¶ added in v1.3.37
func SupportedSelectorGranularity(t ArtifactType) SelectorGranularity
SupportedSelectorGranularity returns the maximum filtering granularity supported by the given artifact type.
type TransferStats ¶
type TransferStats struct {
FileStats []FileStat
// contains filtered or unexported fields
}
func (*TransferStats) Add ¶ added in v1.3.31
func (s *TransferStats) Add(stat FileStat)
Add appends a single FileStat under the lock. Safe for concurrent use across many file jobs since TransferStats is always shared via a pointer.
func (*TransferStats) Snapshot ¶ added in v1.3.31
func (s *TransferStats) Snapshot() []FileStat
Snapshot returns an independent copy of the current FileStats under the lock. Always returns a non-nil slice (len 0 for a fresh/nil TransferStats) so downstream marshalling/reporting never has to nil-check.