From 71953616aea03b0275dacc227ffe9d140016dd5b Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Mon, 3 Nov 2025 16:07:02 -0500 Subject: [PATCH] update to core@v1.10.5 and return err on var save Signed-off-by: Jay Pipes --- go.mod | 2 +- go.sum | 4 ++-- var.go | 24 ++++++++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 98049ee..cb937cb 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.24.3 require ( github.com/cenkalti/backoff v2.2.1+incompatible - github.com/gdt-dev/core v1.10.3 + github.com/gdt-dev/core v1.10.5 github.com/samber/lo v1.51.0 github.com/stretchr/testify v1.11.1 github.com/theory/jsonpath v0.10.1 diff --git a/go.sum b/go.sum index 795a654..c5be7e4 100644 --- a/go.sum +++ b/go.sum @@ -19,8 +19,8 @@ github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjT github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM= github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= -github.com/gdt-dev/core v1.10.3 h1:4cl8h8/SeL5oBzDFyg7WhZbRcLRBb6SUY57L5Swju2A= -github.com/gdt-dev/core v1.10.3/go.mod h1:Bw8J6kUW0b7MUL8qW5e7qSbxb4SI9EAWQ0a4cAoPVpo= +github.com/gdt-dev/core v1.10.5 h1:plVO6WegOEuJTopnmTRQTIwyvHY2iG4xXDax2OP4fO8= +github.com/gdt-dev/core v1.10.5/go.mod h1:Bw8J6kUW0b7MUL8qW5e7qSbxb4SI9EAWQ0a4cAoPVpo= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= diff --git a/var.go b/var.go index b7719bb..baebca0 100644 --- a/var.go +++ b/var.go @@ -9,7 +9,6 @@ import ( "fmt" "github.com/gdt-dev/core/api" - gdtjson "github.com/gdt-dev/core/assertion/json" "github.com/gdt-dev/core/debug" "github.com/theory/jsonpath" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -38,7 +37,7 @@ func saveVars( ) error { for varName, entry := range vars { path := entry.From - extracted, err := extractFrom(path, out) + extracted, err := extractFrom(varName, path, out) if err != nil { return err } @@ -48,7 +47,11 @@ func saveVars( return nil } -func extractFrom(path string, out any) (any, error) { +func extractFrom( + varName string, + path string, + out any, +) (any, error) { var normalized any switch out := out.(type) { case *unstructured.Unstructured: @@ -66,15 +69,16 @@ func extractFrom(path string, out any) (any, error) { default: return nil, fmt.Errorf("unhandled extract type %T", out) } - p, err := jsonpath.Parse(path) - if err != nil { - // Not terminal because during parse we validate the JSONPath - // expression is valid. - return nil, gdtjson.JSONPathNotFound(path, err) - } + // Ignore error because during parse we validate the JSONPath expression is + // valid. + p, _ := jsonpath.Parse(path) nodes := p.Select(normalized) if len(nodes) == 0 { - return nil, gdtjson.JSONPathNotFound(path, err) + // This IS terminal because it means that the returned results of the + // kube.get call did not match the expected JSONPath and that's a + // RuntimeError because we cannot continue execution if we don't match + // the JSONPath query. + return nil, api.JSONPathVarFromNotMatched(varName, path) } got := nodes[0] return got, nil