pkg/urlutil: deprecate, and move to builder/remotecontext/urlutil#43477
pkg/urlutil: deprecate, and move to builder/remotecontext/urlutil#43477thaJeztah merged 3 commits intomoby:masterfrom
Conversation
828167b to
da8bf54
Compare
da8bf54 to
47b4161
Compare
|
@tonistiigi @crazy-max ptal |
| // | ||
| // | Build Syntax Suffix | Git reference used | Build Context Used | | ||
| // |--------------------------------|----------------------|--------------------| | ||
| // | my-repo.git | refs/heads/master | / | |
There was a problem hiding this comment.
let me change this to main instead of master (and describe "default branch")
There was a problem hiding this comment.
oh, actually, looks like we still have that hardcoded, so we'll have to look at that in a follow-up.
|
Ah dang; can't create an alias; |
47b4161 to
183ab02
Compare
183ab02 to
9675870
Compare
pkg/urlutil/deprecated.go
Outdated
| // Deprecated: use github.com/docker/docker/builder/remotecontext/urlutil.IsURL | ||
| // to detect build-context type, or use strings.HasPrefix() to check if the | ||
| // string has a https:// or http:// prefix. | ||
| IsURL = urlutil.IsURL |
There was a problem hiding this comment.
Is there a particular reason you went with the variable approach here rather than providing these as functions? I can't think (off the top of my head) of any particular reason why it would break a consumer as-is, but (public) variables are writable globals, so it's conceivable that another package could modify these and inject unintended behavior into a consumer.
There was a problem hiding this comment.
Bit of a habit (not sure if "good" or "bad") it's slightly easier to create a list of aliases when deprecating a package (which could be slightly clearer "hey, don't use this; here's where to look"), and in some cases may remove imports that are used in the signature of the aliased function 😅
There was a problem hiding this comment.
and in some cases may remove imports that are used in the signature of the aliased function 😅
🤯 I can see why this can matter, though here both IsURL and IsGitURL are both func (string) bool, so there's nothing outside builtin types used.
There was a problem hiding this comment.
Yup, you're right. In this case it doesn't bring much; let me change it
54888cf to
271e36e
Compare
271e36e to
0d7dce7
Compare
This function is no longer used (either internally, or externally), so can be removed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
pkg/urlutil (despite its poorly chosen name) is not really intended as a generic utility to handle URLs, and should only be used by the builder to handle (remote) build contexts. - IsURL() only does a very rudimentary check for http(s):// prefixes, without any other validation, but due to its name may give incorrect expectations. - IsGitURL() is written specifically with docker build remote git contexts in mind, and has handling for backward-compatibility, where strings that are not URLs, but start with "github.com/" are accepted. Because of the above, this patch: - moves the package inside builder/remotecontext, close to where it's intended to be used (ideally this would be part of build/remotecontext itself, but this package imports many other dependencies, which would introduce those as extra dependencies in the CLI). - deprecates pkg/urlutil, but adds aliases as there are some external consumers. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Simplify some of the logic, and add documentation about the package, as well as warnings that this package should not be used as a general- purpose utility. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
0d7dce7 to
4492509
Compare
tonistiigi
left a comment
There was a problem hiding this comment.
I wouldn't bother with pkg/urlutil and just remove it.
|
Yeah, definitely not planning to keep it for long, but found it used in various external projects, so wanted to give a tiny amount of room for those to move away from it. |
|
Interesting error on CI (DCO check test) git openssh-client && cd /workspace && hack/validate/dco
[2022-04-12T21:37:15.034Z] Unable to find image 'alpine:latest' locally
[2022-04-12T21:37:15.293Z] latest: Pulling from library/alpine
[2022-04-12T21:37:15.293Z] df9b9388f04a: Pulling fs layer
[2022-04-12T21:37:15.860Z] df9b9388f04a: Pull complete
[2022-04-12T21:37:15.860Z] Digest: sha256:4edbd2beb5f78b1014028f4fbb99f3237d9561100b6881aabbf5acce2c4f9454
[2022-04-12T21:37:15.860Z] Status: Downloaded newer image for alpine:latest
[2022-04-12T21:37:23.999Z] fatal: unsafe repository ('/workspace' is owned by someone else)
[2022-04-12T21:37:23.999Z] To add an exception for this directory, call:
[2022-04-12T21:37:23.999Z]
[2022-04-12T21:37:23.999Z] git config --global --add safe.directory /workspace
script returned exit code 128 |
|
I see it's using an |
samuelkarp
left a comment
There was a problem hiding this comment.
LGTM aside from whatever weirdness is going on with CI.
|
Looks to be related to a vulnerability that was fixed in git; https://github.blog/2022-04-12-git-security-vulnerability-announced/ |
|
Triggered CI with the DCO check skipped (to check if the rest of the pipeline also needs adjustments) I'll have a look at fixing the DCO stage to adjust for the git security fix (looks to be because the source is checked out on the worker by Jenkins, but then accessed inside a container, in which case the user doesn't match the user on the host, triggering the security warning) |
|
opened #43485 to fix the DCO check |
follow-up to #43476 (only last three commits are new)
pkg/urlutil: remove unused IsTransportURL()
This function is no longer used (either internally, or externally), so can be removed.
pkg/urlutil: deprecate, and move to builder/remotecontext/urlutil
pkg/urlutil (despite its poorly chosen name) is not really intended as a generic utility to handle URLs, and should only be used by the builder to handle (remote) build contexts.
Because of the above, this patch:
builder/remotecontext/urlutil: simplify and improve documentation
Simplify some of the logic, and add documentation about the package, as well as warnings that this package should not be used as a general-purpose utility.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)