This makes the code slightly more idiomatic, but the errors produced will
change slightly to prevent having to path NamedContext as argument.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This package is part of the classic builder, and was currently only used
for the IsURL utility, which is a very rudimentary check for a string having
a "https://" or "http://" scheme.
This patch copies the code as non-exported functions where they're used to
remove the dependency.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
hasDigest would always be true when reaching this code, because the function
would return with an error when failing to resolve the digest;
if !hasDigest {
return nil, errors.Errorf("oci-layout reference %q could not be resolved", v.Path)
}
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
hasTag was always true as it was set to "true" when missing, in which case
the default (`:latest`) tag was applied;
localPath, tag, hasTag := strings.Cut(localPath, ":")
if !hasTag {
tag = "latest"
hasTag = true
}
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Currently it is possible for boot() to be called
multiple times, resulting multiple slow requests to
establish connection (eg. multiple container inspects
for container driver).
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Contexts using target: schema are replaced by input: pointing
to previous build result before build request is sent. Currently
this replacement did not work if multiple contexts pointed to
the same target name.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This eases build driver migrations, as it allows aligning the default behavior.
See also https://docs.docker.com/build/drivers/
Signed-off-by: Niklas Gehlen <niklas@namespacelabs.com>
This refactors the driver handle to initialize the tracer delegate
inside of the driver handle instead of the individual plugins.
This provides more uniformity to how the tracer delegate is created by
allowing the driver handle to pass additional client options to the
drivers when they create the client. It also avoids creating the tracer
delegate client multiple times because the driver handle will only
initialize the client once. This prevents some drivers, like the remote
driver, from accidentally registering multiple clients as tracer
delegates.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Because of the way buildkit cache works if you have request
with external cache, if some vertices from the request have
already been evaluated and are available in the shared graph
BuildKit will not load cache keys from external source for such
vertices. This may mean that children of such vertices will
not load cache because there isn't a cache path through the parent.
To work around it, wait before child definition is loaded before
evaluating the parent.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This adds a build duration metric for the build command with attributes
related to the buildx driver, the error type (if any), and which options
were used to perform the build from a subset of the options.
This also refactors some of the utility methods used by the git tool to
determine filepaths into its own separate package so they can be reused
in another place.
Also adds a test to ensure the resource is initialized correctly and
doesn't error. The otel handler logging message is suppressed on buildx
invocations so we never see the error if there's a problem with the
schema url. It's so easy to mess up the schema url when upgrading OTEL
that we need a proper test to make sure we haven't broken the
functionality.
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
This allows the buildx CLI to act a proxy to the configured instance.
It allows external code to use buildx itself as a driver for connecting
to buildkitd instances.
Instance and node selection should follow the same semantics as as
`buildx build`, including taking into account the `BUILDX_BUILDER` env
var and the `--builder` global flag.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Set local dirs metadata if relative to VCS directory so
dockerfile path is tracked accurately in case vcs information
is not fulfilled.
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
*client.SolveOpt in driver code is only used by build code.
For a clear separation of concerns, move it to an internal
struct type only accessible by BuildWithResultHandler func.
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This regression was introduced in 616fb3e55cbc85647026f6e409af17e1011a85c4,
with the node resolution refactor.
The core issue here is just that we would unconditionally set the
solve opt's platform to the default current platform, which was
incorrect. We can prevent this easily by having a special case for the
default case, like we had before, and then not setting the platforms
field on this (which keeping the resolution behavior which was
introduced).
Signed-off-by: Justin Chadwell <me@jedevc.com>
This was more error prone, as opposed to the approach used prior to
616fb3e55cbc85647026f6e409af17e1011a85c4.
Signed-off-by: Justin Chadwell <me@jedevc.com>
Fixesdocker/cli#4648
Make it easier to specify IPv6 addresses in the '--add-host' option by
permitting 'host=ip' in addition to 'host:ip', and allowing square
brackets around the address.
For example:
--add-host=hostname:127.0.0.1
--add-host=hostname:::1
--add-host=hostname=::1
--add-host=hostname=[::1]
Signed-off-by: Rob Murray <rob.murray@docker.com>
This patch reworks and updates the node resolution logic for selecting a
node from a builder.
The new implementation reworks the logic to make use of containerd's
platforms.Matcher interface instead of manually associated strings, and
additionally provides a few behavioural changes over the original
implementation, namely platforms can be matched with non-strict
semantics. e.g. i386 builds can be scheduled on an amd64 node, arm/v6
builds can be scheduled on an arm/v7 node.
We also add a new collection of tests for tracking regressions and
making the intended behaviour clearer.
Signed-off-by: Justin Chadwell <me@jedevc.com>