Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake: move merge logic to an hcl package and add tests #2831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bake: move merge logic to an hcl package and add tests
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Feb 18, 2025

Verified

This commit was signed with the committer’s verified signature.
crazy-max CrazyMax
commit a86e6a9c2a955f32fbae4a31084be6f89b39eb11
3 changes: 2 additions & 1 deletion bake/bake.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import (

composecli "github.com/compose-spec/compose-go/v2/cli"
"github.com/docker/buildx/bake/hclparser"
hclalt "github.com/docker/buildx/bake/hclparser/hcl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this package is only to be used internally, and not directly used by others, it's worth considering moving it to an internal/ package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Buildx is just a client and I don't really like the internal pattern but I don't mind if we want to move that there.

"github.com/docker/buildx/build"
controllerapi "github.com/docker/buildx/controller/pb"
"github.com/docker/buildx/util/buildflags"
@@ -344,7 +345,7 @@ func ParseFiles(files []File, defaults map[string]string) (_ *Config, _ *hclpars

var pm hclparser.ParseMeta
if len(hclFiles) > 0 {
res, err := hclparser.Parse(hclparser.MergeFiles(hclFiles), hclparser.Opt{
res, err := hclparser.Parse(hclalt.MergeFiles(hclFiles), hclparser.Opt{
LookupVar: os.LookupEnv,
Vars: defaults,
ValidateLabel: validateTargetName,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions bake/hclparser/merged.go → bake/hclparser/hcl/merged.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

// Forked from https://github.com/hashicorp/hcl/blob/4679383728fe331fc8a6b46036a27b8f818d9bc0/merged.go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be kept?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we should as this now has the same hierarchy as upstream repo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe we could have a README in this package


package hclparser
package hcl

import (
"fmt"
Loading