Skip to content

Stub out HCL dependencies#4522

Draft
jandubois wants to merge 2 commits intolima-vm:masterfrom
jandubois:yqlib-without-hcl
Draft

Stub out HCL dependencies#4522
jandubois wants to merge 2 commits intolima-vm:masterfrom
jandubois:yqlib-without-hcl

Conversation

@jandubois
Copy link
Member

The latest version of yqlib depends on the hashicorp/hcl module, which in turn depends on apparentlymart/go-textseg. That one has a custom license and is therefore not approved for use by CNCF projects.

yqlib already supports the yq_nohcl tag to build without HCL support. Unfortunately the go build system is not tag-aware and always includes all indirect dependencies in go.mod/go.sum.

This commit stubs out the HCL dependencies, so they will not be fetched, and unconditionally adds the yq_nohcl build tag.

Any downstream project will have to do the same, as the replace directives in go.mod only apply to this repo and are not inherited via the Go build system.

This PR addresses the concerns in #4460 (review).

@jandubois jandubois force-pushed the yqlib-without-hcl branch 3 times, most recently from 50cfa9a to 6952eb4 Compare January 12, 2026 21:49
Bumps [github.com/mikefarah/yq/v4](https://github.com/mikefarah/yq) from 4.49.2 to 4.50.1.
- [Release notes](https://github.com/mikefarah/yq/releases)
- [Changelog](https://github.com/mikefarah/yq/blob/master/release_notes.txt)
- [Commits](mikefarah/yq@v4.49.2...v4.50.1)

Signed-off-by: Jan Dubois <jan.dubois@suse.com>

---
updated-dependencies:
- dependency-name: github.com/mikefarah/yq/v4
  dependency-version: 4.50.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@jandubois jandubois force-pushed the yqlib-without-hcl branch 6 times, most recently from 42be709 to 2353736 Compare January 12, 2026 22:29
The latest version of yqlib depends on the hashicorp/hcl module, which in
turn depends on apparentlymart/go-textseg. That one has a custom license
and is therefore not approved for use by CNCF projects.

yqlib already supports the `yq_nohcl` tag to build without HCL support.
Unfortunately the go build system is not tag-aware and always includes
all indirect dependencies in go.mod/go.sum.

This commit stubs out the HCL dependencies, so they will not be fetched,
and unconditionally adds the `yq_nohcl` build tag.

Any downstream project will have to do the same, as the `replace`
directives in go.mod only apply to this repo and are not inherited
via the Go build system.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
@jandubois
Copy link
Member Author

The BATS test fails because of mikefarah/yq#2572.

I have not checked why the other integration tests failed.

@jandubois
Copy link
Member Author

Any downstream project will have to do the same, as the replace directives in go.mod only apply to this repo and are not inherited via the Go build system.

I have not tested this, but we probably should move the stubs from ./internal to ./pkg so downstream users of the Lima packages can just add the replace directory and don't have to create their own stubs.


// Avoid pulling in the real HCL module, which depends on github.com/apparentlymart/go-textseg/v15
// which uses a nonstandard license and therefore cannot be used by CNCF projects.
replace github.com/hashicorp/hcl/v2 => ./internal/hclstub
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, but not a fan of this complication.
Can we just ask CNCF to permit using HCL? That will help other CNCF projects too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we just ask CNCF to permit using HCL? That will help other CNCF projects too.

Maybe, but I'm not optimistic. The problem is not HCL but github.com/apparentlymart/go-textseg, which has 3 different licenses for different pieces, none of which have been approved.

Can you open a ticket with CNCF about that?

Thanks, but not a fan of this complication.

Me neither, but what is the alternative (assuming we don't get CNCF to approve the license)? Vendoring all of yqlib and manually removing the HCL dependency? That seems even worse that creating the stubs because we will no longer get dependabot notifications for updates, and there will be manual effort every time we bump yqlib.

This is really the best I can think of.

Copy link
Member

Choose a reason for hiding this comment

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

an alternative would be to just execute yq binary

Copy link
Member Author

Choose a reason for hiding this comment

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

You want to make an external installation of yq a requirement for each --yq option? And then bundle it in CIDATA for use by the guestagent? That is so much more complex than adding a few stub modules to work around a limitation of the Go dependency resolution.

Copy link
Member

Choose a reason for hiding this comment

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

Can you open a ticket with CNCF about that?

You want to make an external installation of yq a requirement for each --yq option? And then bundle it in CIDATA for use by the guestagent?

Not ideal. Let's see how CNCF handles the request.

Copy link
Member

Choose a reason for hiding this comment

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

One of the reasons I hesitate to accept replace() is that my gosocialcheck linter (not integrated to CI yet) does not support replace() yet:

There might be other tools that do not work well with replace() too.

Copy link
Member Author

Choose a reason for hiding this comment

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

go-licenses doesn't work with it either. The workaround was to run go mod vendor and then run GOFLAGS="-mod=vendor" go-licenses check ... (see the change in this PR).

Would that work for gosocialcheck too?

@jandubois
Copy link
Member Author

The BATS test fails because of mikefarah/yq#2572.

On closer inspection this does not look like a bug in yq. If anything the new behaviour is more consistent than the old, so I've closed that issue.

I've created #4539 to adjust our BATS test to the new behaviour.

I have not checked why the other integration tests failed.

I believe they are just flaky CI. There is no point in re-running because we are still waiting for a license exception for hcl/v2 from CNCF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants