Commit Graph
335 Commits
Author SHA1 Message Date
CrazyMax 3836aeb949 bake: add semvercmp func to stdlib
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2026-01-06 09:34:10 +01:00
Roberto Villarreal 3301329d57 Ensure typed variables with no value still carry type
A value-less, untyped variable has always been converted to an empty
string.  The intention was that value-less, typed variables convert to a
 typed null, which was even specified in a code comment, but was never
actually implemented.

This resulted in a null value with a nil type.  A value with a nil type
cannot be coerced ("unified") with any other standard types.  When this
mismatch occurs, HCL attempts to return a diagnostic error, which in
turn panics as the nil type is literally a nil pointer.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-10-10 20:10:04 -06:00
Tonis Tiigi 1f39ad2001 vendor: update buildkit to v0.24.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-08-29 14:49:16 -07:00
CrazyMax a8f546eea5 build: fail early if trying to export index annotations with moby exporter
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-08-27 11:17:31 +02:00
Tõnis TiigiandGitHub c6d1e397a8 Merge pull request #3352 from crazy-max/compose-pull-nocache
bake: pull and no-cache support for compose
2025-08-11 11:55:06 +03:00
CrazyMax c365f015b1 compose: sanitize value of named contexts for target type
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-08-08 14:43:48 +02:00
Sebastiaan van Stijn 36b18a4c7a remove some intermediate vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-06 23:00:24 +02:00
CrazyMax 669fd1df2f bake: pull and no-cache support for compose
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-08-05 11:49:37 +02:00
CrazyMax e4b49a8cd9 bake: add homedir func
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-08-05 10:21:55 +02:00
CrazyMax 9d56b30c42 bake: fix dockerfile default if empty
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-31 10:02:44 +02:00
Guillaume Lours 19304c0c54 bump compose-go to v2.8.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-07-23 13:16:22 +02:00
CrazyMax 98f04b1290 bake: fix compose files validation
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-22 10:18:14 +02:00
Nicolas De Loof 08e74f8b62 do not assume intput is a compose file on .env parsing error
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-07-21 09:02:10 +02:00
Tõnis TiigiandGitHub f6d2c5ed7a Merge pull request #3292 from crazy-max/compose-filtered-spec
bake: ignore unrelated fields when parsing compose files
2025-07-13 23:36:05 -07:00
Tõnis TiigiandGitHub 661a1593f6 Merge pull request #3289 from crazy-max/bake-stdlib-description
bake: set missing stdlib functions description
2025-07-11 17:27:15 -07:00
Tõnis TiigiandGitHub 9a07004534 Merge pull request #3290 from thaJeztah/fix_lint
fix some linting issues
2025-07-10 08:30:29 -07:00
CrazyMax c124b14978 bake: ignore unrelated fields when parsing compose files
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-04 08:09:14 +02:00
Sebastiaan van Stijn 5da2ff5990 bake/hclparser/gohcl: fix typo
Looks like we forked this code, including the typo. As we already modify
the code to add the `//nolint`, we may as well fix the typo itself instead.
https://github.com/hashicorp/hcl/blob/dfa124f3c93ff1764fda03702a7a9aa8c9db48d8/gohcl/decode_test.go#L417-L423

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-03 13:27:37 +02:00
CrazyMax ddec7679f6 bake: set missing stdlib functions description
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-03 08:17:42 +02:00
CrazyMax 6997d61998 docs: generate docs for bake standard library functions
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-02 23:57:02 +02:00
Tõnis TiigiandGitHub 2b5a8c661f Merge pull request #3280 from crazy-max/bake-target-pattern
bake: add pattern matching for targets input
2025-07-01 09:31:32 -07:00
CrazyMax 7c22db3c34 bake: add pattern matching for targets input
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-01 10:53:02 +02:00
CrazyMax 68b49403a3 compose: evaluate vars from current env in dotenv file
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-07-01 09:43:17 +02:00
CrazyMax 40e3e5a27e compose: ignore dotenv that is a directory
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-30 17:11:54 +02:00
CrazyMax 989978a42b bake: multi ips support for extra hosts
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-16 11:55:17 +02:00
CrazyMax b514ed45fb bake: extra-hosts support
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-11 19:38:01 +02:00
CrazyMax 3f49ee5a90 bake: hcl merged tests
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-06-06 17:16:56 +02:00
Jonathan A. Sternberg 1d7cda1232 controller: remove remaining parts of the controller
Removes all references to the controller and moves the remaining
sections of code to other packages.

Processes has been moved to monitor where it is used and the data
structs have been removed so buildflags is used directly. The controller
build function has been moved to the commands package.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-06-05 11:57:03 -05:00
Roberto Villarreal b40b2caf1a Show types during variable list operation
If a type was explicitly provided, it will be displayed in the variable
listing.  Inferred type names are not displayed, as they likely would
not match the user's intent.

Previously only `string` and `bool` default values were displayed in the
 listing.  All default values, regardless of type, are now displayed.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-29 17:36:46 -06:00
CrazyMax 291c353575 bake: TestEmptyVariable
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-21 16:15:30 +02:00
Roberto Villarreal 3c0f5c5c21 Consider typed, value-less variables to have null value
A variable with a type but no default value or override resulted in an
empty string.  This matches the legacy behavior of untyped variables,
but does not make sense when using types (an empty string is itself a
type violation for everything except `string`).  All variables defined
with a type but with no value are now a typed `null`.

A variable explicitly typed `any` was previously treated as if the
typing was omitted; with no defined value or override, that resulted in
an empty string.  The `any` type is now distinguished from an omitted
type; these variables, with no default or override, are also `null`.

In other respects, the behavior of `any` is unchanged and largely
behaves as if the type was omitted.  It's not clear whether it should be
 supported, let alone how it should behave, so these tests were removed.
It's being treated as undefined behavior.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-20 13:09:13 -06:00
CrazyMax 1383aa30c1 lint: modernize fix
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-13 20:44:57 +02:00
CrazyMax b606e2f6bb update golangci-lint to v2.1.5
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-13 16:54:43 +02:00
Roberto Villarreal 56d39e619d Skip case-sensitive test on Windows
Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-09 18:36:11 -06:00
Roberto VillarrealandCopilot 65aea3028f Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-09 18:36:11 -06:00
Roberto Villarreal 956fc0c9eb Use unique environment variables to separate JSON from default parsing
The primary intent is to make JSON parsing explicitly opt-in rather than
 using heuristics to determine intent.

With some exceptions, given bake variable `VAR`, an environment variable
 `VAR_JSON` must be used to provide JSON content.  The value in
 `VAR_JSON` will be ignored when:
* a bake built-in of that same name exists
* a user-provided variable of that same name exists
* typing (attribute `type`) is not present

The first is unlikely to happen as built-ins will likely start with
`BUILDX_BAKE_`, an unlikely prefix for end users.  The second may be a
real scenario, where users have `VAR_JSON` dedicated to accepting a
string with JSON content and decoding via an HCL function.  This will
continue to work as-is, but can be simplified by removing the variable
from their bake file (`VAR_JSON`) and applying typing (to `VAR`).

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-09 18:36:11 -06:00
Roberto Villarreal 1f56984626 Implement CSV-based overrides for list-like variables
Though CSV is favored for 'simple' lists, a JSON value will be used if
it parses without error.  This assumes that it is extremely unlikely
that something that parses as JSON would be intended to be parsed as
CSV, e.g. `["a"` and `"b"]`, as opposed to `a` and `b`.  If
parsing/conversion fails, it is treated as if it was a CSV.

Since the CSV approach required processing of each element, code was
refactored to reuse the same logic used for individual non-typed
variables.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-09 18:36:11 -06:00
Roberto Villarreal 5b8a3b3728 Allow variables to be explicitly typed (and enforced)
This allows variables to have explicit types, similar to Terraform
variables.  It uses HCL's `typeexpr` extension for the specification.
For conversion of overrides to complex types (when explicit typing is
provided), HCL's native JSON-based unmarshalling is used.

Typing is independent of any default, but if a default is provided, it
will be validated.  Similarly, if an override is provided, it will be
converted to that type.

When typing is not provided, previous behavior is used, namely
passing through as a string when no default, converting to primitives if
 the default was primitive, and failing otherwise (complex types).

For complex types, the happy path is lists of primitives, but in theory
any complex/composite type can be used provided they are expressed
correctly in JSON.  In the interest of simplicity and correctness, there
 are no shortcuts for lists.  There *is* a shortcut for strings as users
  don't provide them for untyped variables and would be unintuitive.

Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
2025-05-09 18:36:11 -06:00
Nicolas De Loof c370f90b73 use filepath.IsAbs to support windows paths
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2025-04-22 11:37:53 +02:00
Tonis Tiigi 2e81e301ae bake: fix variadic_params inconsistency for user functions
There was inconsistency between variables used for function
definitions in HCL and JSON format. Updated JSON to match HCL,
fixed documentation and removed the unused code from userfunc
pkg (based on HCL upstream) to avoid confusion.

Theoretically we could add some temporary backwards compatibility
for the JSON format but I think it is unlikely that someone uses
JSON format for this and also defined variadic parameters.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-04-14 10:56:20 -07:00
CrazyMax 77139daa4b bake: check condition and error_message are set during validation
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-04-09 16:04:18 +02:00
CrazyMax a91db7ccc9 bake: keep escaped interpolation in print output
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-04-08 17:30:24 +02:00
Tonis Tiigi 49bd7e4edc bake: fix platforms field in compose yaml
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-04-07 14:14:40 -07:00
CrazyMax e114dd09a5 bake: support compose service as build context
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-03-27 17:58:16 +01:00
CrazyMax 212d598ab1 fix go.mod and lint issues
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-03-19 11:52:08 +01:00
Guillaume LoursandCrazyMax bf95aa3dfa bump compose-go to v2.4.9
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-03-18 10:03:19 +01:00
Tonis Tiigi d5d3d3d502 lint: apply x/tools/modernize fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-07 16:37:24 -08:00
CrazyMax 4c6eba5acd bake: support += operator to append with overrides
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-03-04 13:29:41 +01:00
CrazyMaxandGitHub 128acdb471 Merge pull request #3027 from LaurentGoderre/fix-attest-extra-args
Fix attest extra arguments
2025-03-03 16:28:02 +01:00
co63oc 7925a96726 Fix
Signed-off-by: co63oc <co63oc@users.noreply.github.com>
2025-03-02 21:20:50 +08:00