1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2025-06-14 18:53:35 +00:00

build: move e2e dependencies into e2e/go.mod

Several packages are only used while running the e2e suite. These
packages are less important to update, as the they can not influence the
final executable that is part of the Ceph-CSI container-image.

By moving these dependencies out of the main Ceph-CSI go.mod, it is
easier to identify if a reported CVE affects Ceph-CSI, or only the
testing (like most of the Kubernetes CVEs).

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-03-04 08:57:28 +01:00
committed by mergify[bot]
parent 15da101b1b
commit bec6090996
8047 changed files with 1407827 additions and 3453 deletions
Makefile
e2e
go.modgo.sum
vendor
cel.dev
github.com
JeffAshton
Microsoft
NYTimes
antlr4-go
asaskevich
beorn7
blang
cenkalti
ceph
ceph-csi
cespare
containerd
coreos
cyphar
davecgh
distribution
docker
emicklei
euank
go-kmsg-parser
felixge
fsnotify
fxamacker
go-logr
go-openapi
go-task
godbus
gogo
golang
google
btree
cadvisor
cel-go
LICENSE
cel
checker
common
ext
interpreter
parser
gnostic-models
go-cmp
gofuzz
pprof
uuid
gorilla
grpc-ecosystem
inconshreveable
josharian
json-iterator
karrick
klauspost
kubernetes-csi
kylelemons
godebug
mailru
mistifyio
moby
modern-go
munnerz
mxk
onsi
ginkgo
v2
.gitignoreCHANGELOG.mdCONTRIBUTING.mdLICENSEMakefileREADME.mdRELEASING.md
config
core_dsl.godecorator_dsl.godeprecated_dsl.go
formatter
ginkgo
ginkgo_cli_dependencies.goginkgo_t_dsl.go
internal
reporters
reporting_dsl.gotable_dsl.go
types
gomega
.gitignoreCHANGELOG.mdCONTRIBUTING.mdLICENSEREADME.mdRELEASING.md
format
gcustom
gomega_dsl.go
internal
matchers.go
matchers
types
opencontainers
pkg
prometheus
client_golang
client_model
common
procfs
sirupsen
spf13
stoewer
x448
go.etcd.io
go.opentelemetry.io
auto
contrib
otel
.codespellignore.codespellrc.gitattributes.gitignore.golangci.yml.lycheeignore.markdownlint.yamlCHANGELOG.mdCODEOWNERSCONTRIBUTING.mdLICENSEMakefileREADME.mdRELEASING.mdVERSIONING.md
attribute
baggage
codes
doc.goerror_handler.go
exporters
get_main_pkgs.shhandler.go
internal
internal_logging.gometric.go
metric
propagation.go
propagation
renovate.jsonrequirements.txt
sdk
semconv
trace.go
trace
verify_readmes.shverify_released_changelog.shversion.goversions.yaml
proto
go.uber.org
golang.org
x
crypto
exp
net
oauth2
sync
sys
LICENSEPATENTS
cpu
plan9
unix
.gitignoreREADME.mdaffinity_linux.goaliases.goasm_aix_ppc64.sasm_bsd_386.sasm_bsd_amd64.sasm_bsd_arm.sasm_bsd_arm64.sasm_bsd_ppc64.sasm_bsd_riscv64.sasm_linux_386.sasm_linux_amd64.sasm_linux_arm.sasm_linux_arm64.sasm_linux_loong64.sasm_linux_mips64x.sasm_linux_mipsx.sasm_linux_ppc64x.sasm_linux_riscv64.sasm_linux_s390x.sasm_openbsd_mips64.sasm_solaris_amd64.sasm_zos_s390x.sauxv.goauxv_unsupported.gobluetooth_linux.gobpxsvc_zos.gobpxsvc_zos.scap_freebsd.goconstants.godev_aix_ppc.godev_aix_ppc64.godev_darwin.godev_dragonfly.godev_freebsd.godev_linux.godev_netbsd.godev_openbsd.godev_zos.godirent.goendian_big.goendian_little.goenv_unix.gofcntl.gofcntl_darwin.gofcntl_linux_32bit.gofdset.gogccgo.gogccgo_c.cgccgo_linux_amd64.goifreq_linux.goioctl_linux.goioctl_signed.goioctl_unsigned.goioctl_zos.gomkall.shmkerrors.shmmap_nomremap.gomremap.gopagesize_unix.gopledge_openbsd.goptrace_darwin.goptrace_ios.gorace.gorace0.goreaddirent_getdents.goreaddirent_getdirentries.gosockcmsg_dragonfly.gosockcmsg_linux.gosockcmsg_unix.gosockcmsg_unix_other.gosockcmsg_zos.gosymaddr_zos_s390x.ssyscall.gosyscall_aix.gosyscall_aix_ppc.gosyscall_aix_ppc64.gosyscall_bsd.gosyscall_darwin.gosyscall_darwin_amd64.gosyscall_darwin_arm64.gosyscall_darwin_libSystem.gosyscall_dragonfly.gosyscall_dragonfly_amd64.gosyscall_freebsd.gosyscall_freebsd_386.gosyscall_freebsd_amd64.gosyscall_freebsd_arm.gosyscall_freebsd_arm64.gosyscall_freebsd_riscv64.gosyscall_hurd.gosyscall_hurd_386.gosyscall_illumos.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_alarm.gosyscall_linux_amd64.gosyscall_linux_amd64_gc.gosyscall_linux_arm.gosyscall_linux_arm64.gosyscall_linux_gc.gosyscall_linux_gc_386.gosyscall_linux_gc_arm.gosyscall_linux_gccgo_386.gosyscall_linux_gccgo_arm.gosyscall_linux_loong64.gosyscall_linux_mips64x.gosyscall_linux_mipsx.gosyscall_linux_ppc.gosyscall_linux_ppc64x.gosyscall_linux_riscv64.gosyscall_linux_s390x.gosyscall_linux_sparc64.gosyscall_netbsd.gosyscall_netbsd_386.gosyscall_netbsd_amd64.gosyscall_netbsd_arm.gosyscall_netbsd_arm64.gosyscall_openbsd.gosyscall_openbsd_386.gosyscall_openbsd_amd64.gosyscall_openbsd_arm.gosyscall_openbsd_arm64.gosyscall_openbsd_libc.gosyscall_openbsd_mips64.gosyscall_openbsd_ppc64.gosyscall_openbsd_riscv64.gosyscall_solaris.gosyscall_solaris_amd64.gosyscall_unix.gosyscall_unix_gc.gosyscall_unix_gc_ppc64x.gosyscall_zos_s390x.gosysvshm_linux.gosysvshm_unix.gosysvshm_unix_other.gotimestruct.gounveil_openbsd.govgetrandom_linux.govgetrandom_unsupported.goxattr_bsd.gozerrors_aix_ppc.gozerrors_aix_ppc64.gozerrors_darwin_amd64.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_freebsd_arm64.gozerrors_freebsd_riscv64.gozerrors_linux.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_loong64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_riscv64.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_netbsd_arm64.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_openbsd_arm.gozerrors_openbsd_arm64.gozerrors_openbsd_mips64.gozerrors_openbsd_ppc64.gozerrors_openbsd_riscv64.gozerrors_solaris_amd64.gozerrors_zos_s390x.gozptrace_armnn_linux.gozptrace_linux_arm64.gozptrace_mipsnn_linux.gozptrace_mipsnnle_linux.gozptrace_x86_linux.gozsymaddr_zos_s390x.szsyscall_aix_ppc.gozsyscall_aix_ppc64.gozsyscall_aix_ppc64_gc.gozsyscall_aix_ppc64_gccgo.gozsyscall_darwin_amd64.gozsyscall_darwin_amd64.szsyscall_darwin_arm64.gozsyscall_darwin_arm64.szsyscall_dragonfly_amd64.gozsyscall_freebsd_386.gozsyscall_freebsd_amd64.gozsyscall_freebsd_arm.gozsyscall_freebsd_arm64.gozsyscall_freebsd_riscv64.gozsyscall_illumos_amd64.gozsyscall_linux.gozsyscall_linux_386.gozsyscall_linux_amd64.gozsyscall_linux_arm.gozsyscall_linux_arm64.gozsyscall_linux_loong64.gozsyscall_linux_mips.gozsyscall_linux_mips64.gozsyscall_linux_mips64le.gozsyscall_linux_mipsle.gozsyscall_linux_ppc.gozsyscall_linux_ppc64.gozsyscall_linux_ppc64le.gozsyscall_linux_riscv64.gozsyscall_linux_s390x.gozsyscall_linux_sparc64.gozsyscall_netbsd_386.gozsyscall_netbsd_amd64.gozsyscall_netbsd_arm.gozsyscall_netbsd_arm64.gozsyscall_openbsd_386.gozsyscall_openbsd_386.szsyscall_openbsd_amd64.gozsyscall_openbsd_amd64.szsyscall_openbsd_arm.gozsyscall_openbsd_arm.szsyscall_openbsd_arm64.gozsyscall_openbsd_arm64.szsyscall_openbsd_mips64.gozsyscall_openbsd_mips64.szsyscall_openbsd_ppc64.gozsyscall_openbsd_ppc64.szsyscall_openbsd_riscv64.gozsyscall_openbsd_riscv64.szsyscall_solaris_amd64.gozsyscall_zos_s390x.gozsysctl_openbsd_386.gozsysctl_openbsd_amd64.gozsysctl_openbsd_arm.gozsysctl_openbsd_arm64.gozsysctl_openbsd_mips64.gozsysctl_openbsd_ppc64.gozsysctl_openbsd_riscv64.gozsysnum_darwin_amd64.gozsysnum_darwin_arm64.gozsysnum_dragonfly_amd64.gozsysnum_freebsd_386.gozsysnum_freebsd_amd64.gozsysnum_freebsd_arm.gozsysnum_freebsd_arm64.gozsysnum_freebsd_riscv64.gozsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_loong64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_riscv64.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_netbsd_386.gozsysnum_netbsd_amd64.gozsysnum_netbsd_arm.gozsysnum_netbsd_arm64.gozsysnum_openbsd_386.gozsysnum_openbsd_amd64.gozsysnum_openbsd_arm.gozsysnum_openbsd_arm64.gozsysnum_openbsd_mips64.gozsysnum_openbsd_ppc64.gozsysnum_openbsd_riscv64.gozsysnum_zos_s390x.goztypes_aix_ppc.goztypes_aix_ppc64.goztypes_darwin_amd64.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_freebsd_386.goztypes_freebsd_amd64.goztypes_freebsd_arm.goztypes_freebsd_arm64.goztypes_freebsd_riscv64.goztypes_linux.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_loong64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_riscv64.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_netbsd_386.goztypes_netbsd_amd64.goztypes_netbsd_arm.goztypes_netbsd_arm64.goztypes_openbsd_386.goztypes_openbsd_amd64.goztypes_openbsd_arm.goztypes_openbsd_arm64.goztypes_openbsd_mips64.goztypes_openbsd_ppc64.goztypes_openbsd_riscv64.goztypes_solaris_amd64.goztypes_zos_s390x.go
windows
term
text
time
tools
google.golang.org
genproto
grpc
AUTHORSCODE-OF-CONDUCT.mdCONTRIBUTING.mdGOVERNANCE.mdLICENSEMAINTAINERS.mdMakefileNOTICE.txtREADME.mdSECURITY.md
attributes
backoff.go
backoff
balancer
balancer_wrapper.go
binarylog
grpc_binarylog_v1
call.go
channelz
clientconn.gocodec.go
codes
connectivity
credentials
dialoptions.godoc.go
encoding
experimental
grpclog
health
interceptor.go
internal
keepalive
mem
metadata
peer
picker_wrapper.gopreloader.go
resolver
resolver_wrapper.gorpc_util.goserver.goservice_config.go
serviceconfig
stats
status
stream.gostream_interfaces.go
tap
trace.gotrace_notrace.gotrace_withtrace.goversion.go
protobuf
LICENSEPATENTS
encoding
internal
descfmt
descopts
detrand
editiondefaults
editionssupport
encoding
errors
filedesc
filetype
flags
genid
impl
order
pragma
protolazy
set
strs
version
proto
protoadapt
reflect
runtime
types
descriptorpb
dynamicpb
gofeaturespb
known
anypb
durationpb
emptypb
fieldmaskpb
structpb
timestamppb
wrapperspb
gopkg.in
k8s.io
api
LICENSE
admission
admissionregistration
apidiscovery
apiserverinternal
apps
authentication
authorization
autoscaling
batch
certificates
coordination
core
discovery
events
extensions
flowcontrol
imagepolicy
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
apiextensions-apiserver
apimachinery
LICENSE
pkg
api
apis
conversion
fields
labels
runtime
selection
types
util
version
watch
third_party
apiserver
LICENSE
pkg
admission
attributes.goaudit.gochain.goconfig.go
configuration
conversion.godecorator.goerrors.gohandler.go
initializer
interfaces.go
metrics
plugin
plugins.goreinvocation.goutil.go
apis
audit
authentication
authorization
cel
endpoints
features
quota
registry
server
storage
storageversion
util
warning
plugin
pkg
audit
authenticator
authorizer
client-go
LICENSE
applyconfigurations
OWNERS
admissionregistration
apiserverinternal
apps
autoscaling
v1
v2
v2beta1
v2beta2
batch
certificates
coordination
core
v1
affinity.goapparmorprofile.goattachedvolume.goawselasticblockstorevolumesource.goazurediskvolumesource.goazurefilepersistentvolumesource.goazurefilevolumesource.gocapabilities.gocephfspersistentvolumesource.gocephfsvolumesource.gocinderpersistentvolumesource.gocindervolumesource.goclientipconfig.goclustertrustbundleprojection.gocomponentcondition.gocomponentstatus.goconfigmap.goconfigmapenvsource.goconfigmapkeyselector.goconfigmapnodeconfigsource.goconfigmapprojection.goconfigmapvolumesource.gocontainer.gocontainerimage.gocontainerport.gocontainerresizepolicy.gocontainerstate.gocontainerstaterunning.gocontainerstateterminated.gocontainerstatewaiting.gocontainerstatus.gocontaineruser.gocsipersistentvolumesource.gocsivolumesource.godaemonendpoint.godownwardapiprojection.godownwardapivolumefile.godownwardapivolumesource.goemptydirvolumesource.goendpointaddress.goendpointport.goendpoints.goendpointsubset.goenvfromsource.goenvvar.goenvvarsource.goephemeralcontainer.goephemeralcontainercommon.goephemeralvolumesource.goevent.goeventseries.goeventsource.goexecaction.gofcvolumesource.goflexpersistentvolumesource.goflexvolumesource.goflockervolumesource.gogcepersistentdiskvolumesource.gogitrepovolumesource.goglusterfspersistentvolumesource.goglusterfsvolumesource.gogrpcaction.gohostalias.gohostip.gohostpathvolumesource.gohttpgetaction.gohttpheader.goimagevolumesource.goiscsipersistentvolumesource.goiscsivolumesource.gokeytopath.golifecycle.golifecyclehandler.golimitrange.golimitrangeitem.golimitrangespec.golinuxcontaineruser.goloadbalanceringress.goloadbalancerstatus.golocalobjectreference.golocalvolumesource.gomodifyvolumestatus.gonamespace.gonamespacecondition.gonamespacespec.gonamespacestatus.gonfsvolumesource.gonode.gonodeaddress.gonodeaffinity.gonodecondition.gonodeconfigsource.gonodeconfigstatus.gonodedaemonendpoints.gonodefeatures.gonoderuntimehandler.gonoderuntimehandlerfeatures.gonodeselector.gonodeselectorrequirement.gonodeselectorterm.gonodespec.gonodestatus.gonodesysteminfo.goobjectfieldselector.goobjectreference.gopersistentvolume.gopersistentvolumeclaim.gopersistentvolumeclaimcondition.gopersistentvolumeclaimspec.gopersistentvolumeclaimstatus.gopersistentvolumeclaimtemplate.gopersistentvolumeclaimvolumesource.gopersistentvolumesource.gopersistentvolumespec.gopersistentvolumestatus.gophotonpersistentdiskvolumesource.gopod.gopodaffinity.gopodaffinityterm.gopodantiaffinity.gopodcondition.gopoddnsconfig.gopoddnsconfigoption.gopodip.gopodos.gopodreadinessgate.gopodresourceclaim.gopodresourceclaimstatus.gopodschedulinggate.gopodsecuritycontext.gopodspec.gopodstatus.gopodtemplate.gopodtemplatespec.goportstatus.goportworxvolumesource.gopreferredschedulingterm.goprobe.goprobehandler.goprojectedvolumesource.goquobytevolumesource.gorbdpersistentvolumesource.gorbdvolumesource.goreplicationcontroller.goreplicationcontrollercondition.goreplicationcontrollerspec.goreplicationcontrollerstatus.goresourceclaim.goresourcefieldselector.goresourcehealth.goresourcequota.goresourcequotaspec.goresourcequotastatus.goresourcerequirements.goresourcestatus.goscaleiopersistentvolumesource.goscaleiovolumesource.goscopedresourceselectorrequirement.goscopeselector.goseccompprofile.gosecret.gosecretenvsource.gosecretkeyselector.gosecretprojection.gosecretreference.gosecretvolumesource.gosecuritycontext.goselinuxoptions.goservice.goserviceaccount.goserviceaccounttokenprojection.goserviceport.goservicespec.goservicestatus.gosessionaffinityconfig.gosleepaction.gostorageospersistentvolumesource.gostorageosvolumesource.gosysctl.gotaint.gotcpsocketaction.gotoleration.gotopologyselectorlabelrequirement.gotopologyselectorterm.gotopologyspreadconstraint.gotypedlocalobjectreference.gotypedobjectreference.govolume.govolumedevice.govolumemount.govolumemountstatus.govolumenodeaffinity.govolumeprojection.govolumeresourcerequirements.govolumesource.govspherevirtualdiskvolumesource.goweightedpodaffinityterm.gowindowssecuritycontextoptions.go
discovery
doc.go
events
extensions
flowcontrol
v1
v1beta1
v1beta2
v1beta3
imagepolicy
internal
meta
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
utils.go
discovery
dynamic
features
gentype
informers
admissionregistration
apiserverinternal
apps
autoscaling
batch
certificates
coordination
core
discovery
doc.go
events
extensions
factory.go
flowcontrol
generic.go
internalinterfaces
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
kubernetes
clientset.godoc.go
fake
import.go
scheme
typed
admissionregistration
apiserverinternal
apps
authentication
authorization
autoscaling
batch
certificates
coordination
core
discovery
events
extensions
flowcontrol
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
listers
admissionregistration
apiserverinternal
apps
autoscaling
batch
certificates
coordination
core
discovery
doc.go
events
extensions
flowcontrol
generic_helpers.go
networking
node
policy
rbac
resource
scheduling
storage
storagemigration
openapi
pkg
plugin
pkg
client
rest
restmapper
scale
testing
tools
transport
util
cloud-provider
component-base
LICENSE
cli
config
featuregate
logs
metrics
tracing
version
zpages
component-helpers
LICENSE
node
resource
scheduling
storage
controller-manager
cri-api
cri-client
csi-translation-lib
dynamic-resource-allocation
klog
kms
kube-openapi
kube-scheduler
kubectl
LICENSE
pkg
scale
util
podutils
kubelet
kubernetes
LICENSE
pkg
api
apis
capabilities
client
conditions
cluster
controller
features
fieldpath
kubelet
apis
cadvisor
checkpointmanager
cm
.mockery.yamlOWNERS
admission
cgroup_manager_linux.gocgroup_manager_unsupported.gocgroup_v1_manager_linux.gocgroup_v2_manager_linux.gocontainer_manager.gocontainer_manager_linux.gocontainer_manager_stub.gocontainer_manager_unsupported.gocontainer_manager_windows.go
containermap
cpumanager
devicemanager
doc.go
dra
fake_container_manager.gofake_internal_container_lifecycle.gofake_pod_container_manager.gohelpers.gohelpers_linux.gohelpers_unsupported.gointernal_container_lifecycle.gointernal_container_lifecycle_linux.gointernal_container_lifecycle_unsupported.gointernal_container_lifecycle_windows.go
memorymanager
node_container_manager_linux.gopod_container_manager_linux.gopod_container_manager_stub.goqos_container_manager_linux.go
resourceupdates
topologymanager
types.go
util
config
container
events
eviction
kuberuntime
lifecycle
metrics
pluginmanager
server
metrics
stats
status
types
util
winstats
probe
scheduler
OWNERS
apis
backend
eventhandlers.goextender.go
framework
metrics
profile
schedule_one.goscheduler.go
util
security
securitycontext
util
volume
test
e2e
framework
perftype
storage
testing-manifests
README.md
dra
embed.go
flexvolume
gpu
guestbook
kubectl
podrbd-storage-class.yaml
sample-device-plugin
statefulset
storage-csi
utils
third_party
mount-utils
pod-security-admission
utils
modules.txt
sigs.k8s.io
go.modgo.sum
scripts
vendor
gomodules.xyz
jsonpatch
modules.txt

@ -0,0 +1,432 @@
// Package reference provides a general type to represent any way of referencing images within the registry.
// Its main purpose is to abstract tags and digests (content-addressable hash).
//
// Grammar
//
// reference := name [ ":" tag ] [ "@" digest ]
// name := [domain '/'] remote-name
// domain := host [':' port-number]
// host := domain-name | IPv4address | \[ IPv6address \] ; rfc3986 appendix-A
// domain-name := domain-component ['.' domain-component]*
// domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/
// port-number := /[0-9]+/
// path-component := alpha-numeric [separator alpha-numeric]*
// path (or "remote-name") := path-component ['/' path-component]*
// alpha-numeric := /[a-z0-9]+/
// separator := /[_.]|__|[-]*/
//
// tag := /[\w][\w.-]{0,127}/
//
// digest := digest-algorithm ":" digest-hex
// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ]*
// digest-algorithm-separator := /[+.-_]/
// digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/
// digest-hex := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value
//
// identifier := /[a-f0-9]{64}/
package reference
import (
"errors"
"fmt"
"strings"
"github.com/opencontainers/go-digest"
)
const (
// RepositoryNameTotalLengthMax is the maximum total number of characters in a repository name.
RepositoryNameTotalLengthMax = 255
// NameTotalLengthMax is the maximum total number of characters in a repository name.
//
// Deprecated: use [RepositoryNameTotalLengthMax] instead.
NameTotalLengthMax = RepositoryNameTotalLengthMax
)
var (
// ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference.
ErrReferenceInvalidFormat = errors.New("invalid reference format")
// ErrTagInvalidFormat represents an error while trying to parse a string as a tag.
ErrTagInvalidFormat = errors.New("invalid tag format")
// ErrDigestInvalidFormat represents an error while trying to parse a string as a tag.
ErrDigestInvalidFormat = errors.New("invalid digest format")
// ErrNameContainsUppercase is returned for invalid repository names that contain uppercase characters.
ErrNameContainsUppercase = errors.New("repository name must be lowercase")
// ErrNameEmpty is returned for empty, invalid repository names.
ErrNameEmpty = errors.New("repository name must have at least one component")
// ErrNameTooLong is returned when a repository name is longer than RepositoryNameTotalLengthMax.
ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", RepositoryNameTotalLengthMax)
// ErrNameNotCanonical is returned when a name is not canonical.
ErrNameNotCanonical = errors.New("repository name must be canonical")
)
// Reference is an opaque object reference identifier that may include
// modifiers such as a hostname, name, tag, and digest.
type Reference interface {
// String returns the full reference
String() string
}
// Field provides a wrapper type for resolving correct reference types when
// working with encoding.
type Field struct {
reference Reference
}
// AsField wraps a reference in a Field for encoding.
func AsField(reference Reference) Field {
return Field{reference}
}
// Reference unwraps the reference type from the field to
// return the Reference object. This object should be
// of the appropriate type to further check for different
// reference types.
func (f Field) Reference() Reference {
return f.reference
}
// MarshalText serializes the field to byte text which
// is the string of the reference.
func (f Field) MarshalText() (p []byte, err error) {
return []byte(f.reference.String()), nil
}
// UnmarshalText parses text bytes by invoking the
// reference parser to ensure the appropriately
// typed reference object is wrapped by field.
func (f *Field) UnmarshalText(p []byte) error {
r, err := Parse(string(p))
if err != nil {
return err
}
f.reference = r
return nil
}
// Named is an object with a full name
type Named interface {
Reference
Name() string
}
// Tagged is an object which has a tag
type Tagged interface {
Reference
Tag() string
}
// NamedTagged is an object including a name and tag.
type NamedTagged interface {
Named
Tag() string
}
// Digested is an object which has a digest
// in which it can be referenced by
type Digested interface {
Reference
Digest() digest.Digest
}
// Canonical reference is an object with a fully unique
// name including a name with domain and digest
type Canonical interface {
Named
Digest() digest.Digest
}
// namedRepository is a reference to a repository with a name.
// A namedRepository has both domain and path components.
type namedRepository interface {
Named
Domain() string
Path() string
}
// Domain returns the domain part of the [Named] reference.
func Domain(named Named) string {
if r, ok := named.(namedRepository); ok {
return r.Domain()
}
domain, _ := splitDomain(named.Name())
return domain
}
// Path returns the name without the domain part of the [Named] reference.
func Path(named Named) (name string) {
if r, ok := named.(namedRepository); ok {
return r.Path()
}
_, path := splitDomain(named.Name())
return path
}
// splitDomain splits a named reference into a hostname and path string.
// If no valid hostname is found, the hostname is empty and the full value
// is returned as name
func splitDomain(name string) (string, string) {
match := anchoredNameRegexp.FindStringSubmatch(name)
if len(match) != 3 {
return "", name
}
return match[1], match[2]
}
// Parse parses s and returns a syntactically valid Reference.
// If an error was encountered it is returned, along with a nil Reference.
func Parse(s string) (Reference, error) {
matches := ReferenceRegexp.FindStringSubmatch(s)
if matches == nil {
if s == "" {
return nil, ErrNameEmpty
}
if ReferenceRegexp.FindStringSubmatch(strings.ToLower(s)) != nil {
return nil, ErrNameContainsUppercase
}
return nil, ErrReferenceInvalidFormat
}
var repo repository
nameMatch := anchoredNameRegexp.FindStringSubmatch(matches[1])
if len(nameMatch) == 3 {
repo.domain = nameMatch[1]
repo.path = nameMatch[2]
} else {
repo.domain = ""
repo.path = matches[1]
}
if len(repo.path) > RepositoryNameTotalLengthMax {
return nil, ErrNameTooLong
}
ref := reference{
namedRepository: repo,
tag: matches[2],
}
if matches[3] != "" {
var err error
ref.digest, err = digest.Parse(matches[3])
if err != nil {
return nil, err
}
}
r := getBestReferenceType(ref)
if r == nil {
return nil, ErrNameEmpty
}
return r, nil
}
// ParseNamed parses s and returns a syntactically valid reference implementing
// the Named interface. The reference must have a name and be in the canonical
// form, otherwise an error is returned.
// If an error was encountered it is returned, along with a nil Reference.
func ParseNamed(s string) (Named, error) {
named, err := ParseNormalizedNamed(s)
if err != nil {
return nil, err
}
if named.String() != s {
return nil, ErrNameNotCanonical
}
return named, nil
}
// WithName returns a named object representing the given string. If the input
// is invalid ErrReferenceInvalidFormat will be returned.
func WithName(name string) (Named, error) {
match := anchoredNameRegexp.FindStringSubmatch(name)
if match == nil || len(match) != 3 {
return nil, ErrReferenceInvalidFormat
}
if len(match[2]) > RepositoryNameTotalLengthMax {
return nil, ErrNameTooLong
}
return repository{
domain: match[1],
path: match[2],
}, nil
}
// WithTag combines the name from "name" and the tag from "tag" to form a
// reference incorporating both the name and the tag.
func WithTag(name Named, tag string) (NamedTagged, error) {
if !anchoredTagRegexp.MatchString(tag) {
return nil, ErrTagInvalidFormat
}
var repo repository
if r, ok := name.(namedRepository); ok {
repo.domain = r.Domain()
repo.path = r.Path()
} else {
repo.path = name.Name()
}
if canonical, ok := name.(Canonical); ok {
return reference{
namedRepository: repo,
tag: tag,
digest: canonical.Digest(),
}, nil
}
return taggedReference{
namedRepository: repo,
tag: tag,
}, nil
}
// WithDigest combines the name from "name" and the digest from "digest" to form
// a reference incorporating both the name and the digest.
func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
if !anchoredDigestRegexp.MatchString(digest.String()) {
return nil, ErrDigestInvalidFormat
}
var repo repository
if r, ok := name.(namedRepository); ok {
repo.domain = r.Domain()
repo.path = r.Path()
} else {
repo.path = name.Name()
}
if tagged, ok := name.(Tagged); ok {
return reference{
namedRepository: repo,
tag: tagged.Tag(),
digest: digest,
}, nil
}
return canonicalReference{
namedRepository: repo,
digest: digest,
}, nil
}
// TrimNamed removes any tag or digest from the named reference.
func TrimNamed(ref Named) Named {
repo := repository{}
if r, ok := ref.(namedRepository); ok {
repo.domain, repo.path = r.Domain(), r.Path()
} else {
repo.domain, repo.path = splitDomain(ref.Name())
}
return repo
}
func getBestReferenceType(ref reference) Reference {
if ref.Name() == "" {
// Allow digest only references
if ref.digest != "" {
return digestReference(ref.digest)
}
return nil
}
if ref.tag == "" {
if ref.digest != "" {
return canonicalReference{
namedRepository: ref.namedRepository,
digest: ref.digest,
}
}
return ref.namedRepository
}
if ref.digest == "" {
return taggedReference{
namedRepository: ref.namedRepository,
tag: ref.tag,
}
}
return ref
}
type reference struct {
namedRepository
tag string
digest digest.Digest
}
func (r reference) String() string {
return r.Name() + ":" + r.tag + "@" + r.digest.String()
}
func (r reference) Tag() string {
return r.tag
}
func (r reference) Digest() digest.Digest {
return r.digest
}
type repository struct {
domain string
path string
}
func (r repository) String() string {
return r.Name()
}
func (r repository) Name() string {
if r.domain == "" {
return r.path
}
return r.domain + "/" + r.path
}
func (r repository) Domain() string {
return r.domain
}
func (r repository) Path() string {
return r.path
}
type digestReference digest.Digest
func (d digestReference) String() string {
return digest.Digest(d).String()
}
func (d digestReference) Digest() digest.Digest {
return digest.Digest(d)
}
type taggedReference struct {
namedRepository
tag string
}
func (t taggedReference) String() string {
return t.Name() + ":" + t.tag
}
func (t taggedReference) Tag() string {
return t.tag
}
type canonicalReference struct {
namedRepository
digest digest.Digest
}
func (c canonicalReference) String() string {
return c.Name() + "@" + c.digest.String()
}
func (c canonicalReference) Digest() digest.Digest {
return c.digest
}