diff --git a/go.mod b/go.mod index 7a5bb76..116b9e8 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ toolchain go1.22.4 require ( github.com/blang/semver/v4 v4.0.0 - github.com/docker/cli v26.1.4+incompatible + github.com/docker/cli v27.1.1+incompatible github.com/docker/distribution v2.8.2+incompatible - github.com/docker/docker v26.1.4+incompatible + github.com/docker/docker v27.1.1+incompatible github.com/docker/go-connections v0.4.0 github.com/google/go-cmp v0.6.0 github.com/mitchellh/go-homedir v1.1.0 diff --git a/go.sum b/go.sum index 02ff6f2..c507084 100644 --- a/go.sum +++ b/go.sum @@ -116,13 +116,13 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v26.1.4+incompatible h1:I8PHdc0MtxEADqYJZvhBrW9bo8gawKwwenxRM7/rLu8= -github.com/docker/cli v26.1.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.1.1+incompatible h1:goaZxOqs4QKxznZjjBWKONQci/MywhtRv2oNn0GkeZE= +github.com/docker/cli v27.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v26.1.4+incompatible h1:vuTpXDuoga+Z38m1OZHzl7NKisKWaWlhjQk7IDPSLsU= -github.com/docker/docker v26.1.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.1.1+incompatible h1:hO/M4MtV36kzKldqnA37IWhebRA+LnqqcqDja6kVaKY= +github.com/docker/docker v27.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.3 h1:zI2p9+1NQYdnG6sMU26EX4aVGlqbInSQxQXLvzJ4RPQ= github.com/docker/docker-credential-helpers v0.6.3/go.mod h1:WRaJzqw3CTB9bk10avuGsjVBZsD05qeibJ1/TYlvc0Y= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= diff --git a/pkg/cluster/docker.go b/pkg/cluster/docker.go index 43f201d..2d16d87 100644 --- a/pkg/cluster/docker.go +++ b/pkg/cluster/docker.go @@ -3,12 +3,30 @@ package cluster import ( "context" "os" - - "github.com/docker/docker/pkg/stringid" + "regexp" "github.com/tilt-dev/ctlptl/internal/dctr" ) +const ( + shortLen = 12 +) + +var ( + validShortID = regexp.MustCompile("^[a-f0-9]{12}$") +) + +// IsShortID determines if id has the correct format and length for a short ID. +// It checks the IDs length and if it consists of valid characters for IDs (a-f0-9). +// +// Deprecated: this function is no longer used, and will be removed in the next release. +func isShortID(id string) bool { + if len(id) != shortLen { + return false + } + return validShortID.MatchString(id) +} + type detectInContainer interface { insideContainer(ctx context.Context) string } @@ -37,7 +55,7 @@ func insideContainer(ctx context.Context, client dctr.Client) string { return "" } - if !stringid.IsShortID(containerID) { + if !isShortID(containerID) { return "" }