refactor: migrate away from Golang module github.com/vmware-labs/yaml-jsonpath#7527
Conversation
|
Hi @olblak , have you had a chance to review this? Is there anything you don’t agree with? |
|
@ErickdelaCruzCas thank your for the clear explanation, I think the replace approach is the only way to as you did Your pull request looks great as I mentioned in the previous comment but I am wondering about the motivation for this snippet: |
…m/ErickdelaCruzCas/updatecli into refactor--migrate-yaml-jasponpath
|
Thanks for calling this out. That snippet was only there as a quick sanity-check while I was testing whether the two NewPath(...) implementations behaved the same (old vs fork) for the same y.spec.Key. The idea was to compare their parsing/normalization output during the transition. Once I confirmed we don’t need to run both in parallel (because we’re switching the dependency via replace and aligning the YAML node types), that comparison became redundant — and I simply missed removing it before pushing. Sorry about that. I’ll update the PR to remove the snippet (and any related leftover code) so we keep the change focused on the actual fixes: the module-path replace and the YAML v3 import alignment. |
Thank you for the clarification, this makes sense at least that's how I understood it |
Head branch was pushed to by a user without write access
|
fixed the compilation fail and tested again |
Fix #4929 -> #4929
Context / Problem
While trying to use the maintained fork of
yaml-jsonpath, Go’s module resolution and type system exposed two separate issues:github.com/helm-unittest/yaml-jsonpath, but itsgo.modstill declares:module github.com/vmware-labs/yaml-jsonpathrequire github.com/helm-unittest/yaml-jsonpath, Go fails with:module declares its path as github.com/vmware-labs/yaml-jsonpath but was required as github.com/helm-unittest/yaml-jsonpathgo.yaml.in/yaml/v3.gopkg.in/yaml.v3.This breaks calls like
yamlpath.Find(...)because*yaml.Nodefrom one package is not assignable to*yaml.Nodefrom the other.Motivation
What changed (and why)
1) go.mod — use
replaceto redirect while keeping the declared module pathreplace github.com/vmware-labs/yaml-jsonpath => github.com/helm-unittest/yaml-jsonpath v0.4.0Why this is the correct fix
go.modis authoritative.github.com/vmware-labs/yaml-jsonpath, we must keep the original module path in our dependency graph, and usereplaceto fetch the fork’s source at build time.Result
github.com/vmware-labs/yaml-jsonpath/...(consistent with the declared module path).github.com/helm-unittest/[email protected].2) pkg/plugins/resources/yaml/*.go — align YAML v3 package to match fork types
Files updated:
pkg/plugins/resources/yaml/condition.gopkg/plugins/resources/yaml/source.gopkg/plugins/resources/yaml/target_yamlpath.goChange:
gopkg.in/yaml.v3→go.yaml.in/yaml/v3Why
yamlpath.Find(from the fork) expects nodes fromgo.yaml.in/yaml/v3.gopkg.in/yaml.v3produces identical-looking types, but Go treats them as unrelated.3) go.sum — dependency graph normalization
github.com/helm-unittest/yaml-jsonpath v0.4.0)github.com/vmware-labs/yaml-jsonpath v0.3.2) and other pruned transitive deps.Why
go mod tidyupdates the module graph and prunes unused entries sogo.summatches the effective dependency set.github.com/sergi/go-diff v1.4.0due to the fork’s transitive requirements.Alternatives considered
require github.com/helm-unittest/yaml-jsonpath)go.mod.modulelineRisk / Compatibility notes
replaceis explicit and documented to avoid “mystery dependency” surprises.How to test
go test ./...Footnote: This is my first contribution here. If anything in the style / structure / approach should be adjusted to match project conventions, happy to iterate — gentle reviews appreciated 🙂