From 030aaea7b26bc95abd450f074c7152ba80acb47d Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 18:17:14 -0600 Subject: [PATCH 01/13] update to sdk v0.3.0 Signed-off-by: Steven Borrelli --- context.go | 4 +- context_test.go | 8 +- extraresources.go | 16 +- fn.go | 10 +- fn_test.go | 430 ++++++++++++++++++++++++---------------------- go.mod | 69 ++++---- go.sum | 272 ++++++++++++++--------------- 7 files changed, 400 insertions(+), 409 deletions(-) diff --git a/context.go b/context.go index ee90fdc..d664d84 100644 --- a/context.go +++ b/context.go @@ -3,11 +3,11 @@ package main import ( "dario.cat/mergo" "github.com/crossplane/function-sdk-go/errors" - fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" ) // MergeContext merges existing Context with new values provided -func (f *Function) MergeContext(req *fnv1beta1.RunFunctionRequest, val map[string]interface{}) (map[string]interface{}, error) { +func (f *Function) MergeContext(req *fnv1.RunFunctionRequest, val map[string]interface{}) (map[string]interface{}, error) { mergedContext := req.GetContext().AsMap() if len(val) == 0 { return mergedContext, nil diff --git a/context_test.go b/context_test.go index e058380..70a2cba 100644 --- a/context_test.go +++ b/context_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/crossplane/crossplane-runtime/pkg/logging" - fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/resource" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" @@ -14,7 +14,7 @@ import ( func TestMergeContext(t *testing.T) { type args struct { val map[string]interface{} - req *fnv1beta1.RunFunctionRequest + req *fnv1.RunFunctionRequest } type want struct { us map[string]any @@ -29,7 +29,7 @@ func TestMergeContext(t *testing.T) { "NoContextAtKey": { reason: "When there is no existing context data at the key to merge, return the value", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Context: nil, }, val: map[string]interface{}{"hello": "world"}, @@ -42,7 +42,7 @@ func TestMergeContext(t *testing.T) { "SuccessfulMerge": { reason: "Confirm that keys are merged with source overwriting destination", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Context: resource.MustStructJSON(`{"apiextensions.crossplane.io/environment":{"complex":{"a":"b","c":{"d":"e","f":"1","overWrite": "fromContext"}}}}`), }, val: map[string]interface{}{ diff --git a/extraresources.go b/extraresources.go index 071a5fc..14eb6ce 100644 --- a/extraresources.go +++ b/extraresources.go @@ -1,7 +1,7 @@ package main import ( - fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" ) // ExtraResourcesRequirements defines the requirements for extra resources. @@ -9,7 +9,7 @@ type ExtraResourcesRequirements map[string]ExtraResourcesRequirement // ExtraResourcesRequirement defines a single requirement for extra resources. // Needed to have camelCase keys instead of the snake_case keys as defined -// through json tags by fnv1beta1.ResourceSelector. +// through json tags by fnv1.ResourceSelector. type ExtraResourcesRequirement struct { // APIVersion of the resource. APIVersion string `json:"apiVersion"` @@ -23,20 +23,20 @@ type ExtraResourcesRequirement struct { MatchName string `json:"matchName,omitempty"` } -// ToResourceSelector converts the ExtraResourcesRequirement to a fnv1beta1.ResourceSelector. -func (e *ExtraResourcesRequirement) ToResourceSelector() *fnv1beta1.ResourceSelector { - out := &fnv1beta1.ResourceSelector{ +// ToResourceSelector converts the ExtraResourcesRequirement to a fnv1.ResourceSelector. +func (e *ExtraResourcesRequirement) ToResourceSelector() *fnv1.ResourceSelector { + out := &fnv1.ResourceSelector{ ApiVersion: e.APIVersion, Kind: e.Kind, } if e.MatchName == "" { - out.Match = &fnv1beta1.ResourceSelector_MatchLabels{ - MatchLabels: &fnv1beta1.MatchLabels{Labels: e.MatchLabels}, + out.Match = &fnv1.ResourceSelector_MatchLabels{ + MatchLabels: &fnv1.MatchLabels{Labels: e.MatchLabels}, } return out } - out.Match = &fnv1beta1.ResourceSelector_MatchName{ + out.Match = &fnv1.ResourceSelector_MatchName{ MatchName: e.MatchName, } return out diff --git a/fn.go b/fn.go index 6c2ccce..7d05468 100644 --- a/fn.go +++ b/fn.go @@ -20,7 +20,7 @@ import ( "github.com/crossplane/function-sdk-go/errors" "github.com/crossplane/function-sdk-go/logging" - fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/request" "github.com/crossplane/function-sdk-go/resource" "github.com/crossplane/function-sdk-go/response" @@ -38,7 +38,7 @@ func (*osFS) Open(name string) (fs.File, error) { // Function uses Go templates to compose resources. type Function struct { - fnv1beta1.UnimplementedFunctionRunnerServiceServer + fnv1.UnimplementedFunctionRunnerServiceServer log logging.Logger fsys fs.FS @@ -52,7 +52,7 @@ const ( ) // RunFunction runs the Function. -func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequest) (*fnv1beta1.RunFunctionResponse, error) { +func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) (*fnv1.RunFunctionResponse, error) { f.log.Info("Running Function", "tag", req.GetMeta().GetTag()) rsp := response.To(req, response.DefaultTTL) @@ -145,7 +145,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequ } // Initialize the requirements. - requirements := &fnv1beta1.Requirements{ExtraResources: make(map[string]*fnv1beta1.ResourceSelector)} + requirements := &fnv1.Requirements{ExtraResources: make(map[string]*fnv1.ResourceSelector)} // Convert the rendered manifests to a list of desired composed resources. for _, obj := range objs { @@ -283,7 +283,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1beta1.RunFunctionRequ return rsp, nil } -func convertToMap(req *fnv1beta1.RunFunctionRequest) (map[string]any, error) { +func convertToMap(req *fnv1.RunFunctionRequest) (map[string]any, error) { jReq, err := protojson.Marshal(req) if err != nil { return nil, errors.Wrap(err, "cannot marshal request from proto to json") diff --git a/fn_test.go b/fn_test.go index 96a16e5..1c56ddb 100644 --- a/fn_test.go +++ b/fn_test.go @@ -13,7 +13,7 @@ import ( "github.com/crossplane/crossplane-runtime/pkg/logging" - fnv1beta1 "github.com/crossplane/function-sdk-go/proto/v1beta1" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/resource" "github.com/crossplane/function-sdk-go/response" @@ -56,10 +56,10 @@ var ( func TestRunFunction(t *testing.T) { type args struct { ctx context.Context - req *fnv1beta1.RunFunctionRequest + req *fnv1.RunFunctionRequest } type want struct { - rsp *fnv1beta1.RunFunctionResponse + rsp *fnv1.RunFunctionResponse err error } @@ -71,7 +71,7 @@ func TestRunFunction(t *testing.T) { "WrongInputSourceType": { reason: "The Function should return a fatal result if the cd source type is wrong", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: "wrong", @@ -79,12 +79,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: invalid source: wrong", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -93,15 +94,16 @@ func TestRunFunction(t *testing.T) { "NoInput": { reason: "The Function should return a fatal result if no cd was specified", args: args{ - req: &fnv1beta1.RunFunctionRequest{}, + req: &fnv1.RunFunctionRequest{}, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: source is required", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -110,7 +112,7 @@ func TestRunFunction(t *testing.T) { "WrongInlineInput": { reason: "The Function should return a fatal result if there is no inline template provided", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, @@ -118,12 +120,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: inline.template should be provided", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -131,7 +134,7 @@ func TestRunFunction(t *testing.T) { }, "WrongFileSystemInput": { args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.FileSystemSource, @@ -139,12 +142,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: fileSystem.dirPath should be provided", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -153,7 +157,7 @@ func TestRunFunction(t *testing.T) { "NoResourceNameAnnotation": { reason: "The Function should return a fatal result if the cd does not have a composition-resource-name annotation", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, @@ -162,12 +166,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "\"CD\" template is missing required \"" + annotationKeyCompositionResourceName + "\" annotation", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -176,7 +181,7 @@ func TestRunFunction(t *testing.T) { "CannotDecodeManifest": { reason: "The Function should return a fatal result if the manifest cannot be decoded", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, @@ -185,12 +190,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: fmt.Sprintf("cannot decode manifest: Object 'Kind' is missing in '%s'", cdMissingKind), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -199,36 +205,37 @@ func TestRunFunction(t *testing.T) { "CannotParseTemplate": { reason: "The Function should return a fatal result if the template cannot be parsed", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: cdWrongTmpl}, }, ), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: cannot parse the provided templates: template: manifests:1: bad character U+002D '-'", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, @@ -238,23 +245,23 @@ func TestRunFunction(t *testing.T) { "ResponseIsReturnedWithNoChange": { reason: "The Function should return the desired composite resource and cd composed resource without any changes.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ - Meta: &fnv1beta1.RequestMeta{Tag: "nochange"}, + req: &fnv1.RunFunctionRequest{ + Meta: &fnv1.RequestMeta{Tag: "nochange"}, Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: cd}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(cd), }, @@ -263,13 +270,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Tag: "nochange", Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Tag: "nochange", Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(`{"apiVersion":"example.org/v1","kind":"CD","metadata":{"annotations":{},"name":"cool-cd"}}`), }, @@ -281,33 +288,33 @@ func TestRunFunction(t *testing.T) { "ResponseIsReturnedWithTemplating": { reason: "The Function should return the desired composite resource and the templated composed resources.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ - Meta: &fnv1beta1.RequestMeta{Tag: "templates"}, + req: &fnv1.RunFunctionRequest{ + Meta: &fnv1.RequestMeta{Tag: "templates"}, Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: cdTmpl}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Tag: "templates", Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Tag: "templates", Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(`{"apiVersion": "example.org/v1","kind":"CD","metadata":{"annotations":{},"name":"cool-cd","labels":{"belongsTo":"cool-xr"}}}`), }, @@ -319,30 +326,30 @@ func TestRunFunction(t *testing.T) { "UpdateDesiredCompositeStatus": { reason: "The Function should update the desired composite resource status.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ - Meta: &fnv1beta1.RequestMeta{Tag: "status"}, + req: &fnv1.RunFunctionRequest{ + Meta: &fnv1.RequestMeta{Tag: "status"}, Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: xrWithStatus}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Tag: "status", Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Tag: "status", Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xrWithStatus), }, }, @@ -352,30 +359,30 @@ func TestRunFunction(t *testing.T) { "UpdateDesiredCompositeNestedStatus": { reason: "The Function should update the desired composite resource nested status.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ - Meta: &fnv1beta1.RequestMeta{Tag: "status"}, + req: &fnv1.RunFunctionRequest{ + Meta: &fnv1.RequestMeta{Tag: "status"}, Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: xrWithNestedStatusBaz}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xrWithNestedStatusFoo), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xrWithNestedStatusFoo), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Tag: "status", Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Tag: "status", Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(`{"apiVersion":"example.org/v1","kind":"XR","metadata":{"name":"cool-xr"},"spec":{"count":2},"status":{"state":{"foo":"bar","baz":"qux"}}}`), }, }, @@ -385,33 +392,33 @@ func TestRunFunction(t *testing.T) { "ResponseIsReturnedWithTemplatedXR": { reason: "The Function should return the desired composite resource and the composed templated XR resource.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ - Meta: &fnv1beta1.RequestMeta{Tag: "status"}, + req: &fnv1.RunFunctionRequest{ + Meta: &fnv1.RequestMeta{Tag: "status"}, Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: xrRecursiveTmpl}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Tag: "status", Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Tag: "status", Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "recursive-xr": { Resource: resource.MustStructJSON(`{"apiVersion": "example.org/v1","kind":"XR","metadata":{"annotations":{},"name":"recursive-xr","labels":{"belongsTo":"cool-xr"}},"spec":{"count":2}}`), }, @@ -423,33 +430,33 @@ func TestRunFunction(t *testing.T) { "ResponseIsReturnedWithTemplatingFS": { reason: "The Function should return the desired composite resource and the templated composed resources with FileSystem cd.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ - Meta: &fnv1beta1.RequestMeta{Tag: "templates"}, + req: &fnv1.RunFunctionRequest{ + Meta: &fnv1.RequestMeta{Tag: "templates"}, Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.FileSystemSource, FileSystem: &v1beta1.TemplateSourceFileSystem{DirPath: path}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Tag: "templates", Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Tag: "templates", Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(`{"apiVersion": "example.org/v1","kind":"CD","metadata":{"annotations":{},"name":"cool-cd","labels":{"belongsTo":"cool-xr"}}}`), }, @@ -461,7 +468,7 @@ func TestRunFunction(t *testing.T) { "CannotReadTemplatesFromFS": { reason: "The Function should return a fatal result if the templates cannot be read from the filesystem.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.FileSystemSource, @@ -471,12 +478,13 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: cannot read tmpl from the folder {testdata/wrong}: open testdata/wrong: file does not exist", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -485,35 +493,36 @@ func TestRunFunction(t *testing.T) { "ReadyStatusAnnotationNotValid": { reason: "The Function should return a fatal result if the ready annotation is not valid.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: cdWithReadyWrong}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid function input: invalid \"" + annotationKeyReady + "\" annotation value \"wrongValue\": must be True, False, or Unspecified", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, @@ -523,37 +532,37 @@ func TestRunFunction(t *testing.T) { "ReadyStatusAnnotation": { reason: "The Function should return desired composed resource with True ready state.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: cdWithReadyTrue}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(cd), }, }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(`{"apiVersion":"example.org/v1","kind":"CD","metadata":{"annotations":{},"name":"cool-cd"}}`), Ready: 1, @@ -566,35 +575,36 @@ func TestRunFunction(t *testing.T) { "InvalidMetaKind": { reason: "The Function should return a fatal result if the meta kind is invalid.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: metaResourceInvalid}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "invalid kind \"InvalidMeta\" for apiVersion \"" + metaApiVersion + "\" - must be one of CompositeConnectionDetails, Context or ExtraResources", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, @@ -604,29 +614,29 @@ func TestRunFunction(t *testing.T) { "CompositeConnectionDetails": { reason: "The Function should return the desired composite with CompositeConnectionDetails.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: metaResourceConDet}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), ConnectionDetails: map[string][]byte{"key": []byte("value")}, }, @@ -637,36 +647,37 @@ func TestRunFunction(t *testing.T) { "ContextInvalidData": { reason: "The Function should return an error if he context data is invalid.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: metaResourceContextInvalid}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Results: []*fnv1beta1.Result{ + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "cannot get Contexts from input: cannot unmarshal value from JSON: json: cannot unmarshal number into Go value of type map[string]interface {}", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, }, @@ -675,29 +686,29 @@ func TestRunFunction(t *testing.T) { "Context": { reason: "The Function should return the desired composite with updated context.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: metaResourceContext}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, @@ -714,22 +725,22 @@ func TestRunFunction(t *testing.T) { "ExtraResources": { reason: "The Function should return the desired composite with extra resources.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: extraResources}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(cd), }, @@ -738,23 +749,23 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{}, - Requirements: &fnv1beta1.Requirements{ - ExtraResources: map[string]*fnv1beta1.ResourceSelector{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{}, + Requirements: &fnv1.Requirements{ + ExtraResources: map[string]*fnv1.ResourceSelector{ "cool-extra-resource": { ApiVersion: "example.org/v1", Kind: "CoolExtraResource", - Match: &fnv1beta1.ResourceSelector_MatchName{ + Match: &fnv1.ResourceSelector_MatchName{ MatchName: "cool-extra-resource", }, }, "another-cool-extra-resource": { ApiVersion: "example.org/v1", Kind: "CoolExtraResource", - Match: &fnv1beta1.ResourceSelector_MatchLabels{ - MatchLabels: &fnv1beta1.MatchLabels{ + Match: &fnv1.ResourceSelector_MatchLabels{ + MatchLabels: &fnv1.MatchLabels{ Labels: map[string]string{"key": "value"}, }, }, @@ -762,26 +773,26 @@ func TestRunFunction(t *testing.T) { "yet-another-cool-extra-resource": { ApiVersion: "example.org/v1", Kind: "CoolExtraResource", - Match: &fnv1beta1.ResourceSelector_MatchName{ + Match: &fnv1.ResourceSelector_MatchName{ MatchName: "foo", }, }, "all-cool-resources": { ApiVersion: "example.org/v1", Kind: "CoolExtraResource", - Match: &fnv1beta1.ResourceSelector_MatchLabels{ - MatchLabels: &fnv1beta1.MatchLabels{ + Match: &fnv1.ResourceSelector_MatchLabels{ + MatchLabels: &fnv1.MatchLabels{ Labels: map[string]string{}, }, }, }, }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(cd), }, @@ -793,22 +804,22 @@ func TestRunFunction(t *testing.T) { "DuplicateExtraResourceKey": { reason: "The Function should return a fatal result if the extra resource key is duplicated.", args: args{ - req: &fnv1beta1.RunFunctionRequest{ + req: &fnv1.RunFunctionRequest{ Input: resource.MustStructObject( &v1beta1.GoTemplate{ Source: v1beta1.InlineSource, Inline: &v1beta1.TemplateSourceInline{Template: extraResourcesDuplicatedKey}, }), - Observed: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(cd), }, @@ -817,19 +828,20 @@ func TestRunFunction(t *testing.T) { }, }, want: want{ - rsp: &fnv1beta1.RunFunctionResponse{ - Meta: &fnv1beta1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, - Results: []*fnv1beta1.Result{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ { - Severity: fnv1beta1.Severity_SEVERITY_FATAL, + Severity: fnv1.Severity_SEVERITY_FATAL, Message: "duplicate extra resource key \"cool-extra-resource\"", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, - Desired: &fnv1beta1.State{ - Composite: &fnv1beta1.Resource{ + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ Resource: resource.MustStructJSON(xr), }, - Resources: map[string]*fnv1beta1.Resource{ + Resources: map[string]*fnv1.Resource{ "cool-cd": { Resource: resource.MustStructJSON(cd), }, diff --git a/go.mod b/go.mod index 1281aed..e65951c 100644 --- a/go.mod +++ b/go.mod @@ -1,38 +1,38 @@ module github.com/crossplane-contrib/function-go-templating -go 1.21 +go 1.23 -toolchain go1.22.6 +toolchain go1.23.2 require ( dario.cat/mergo v1.0.1 github.com/Masterminds/sprig/v3 v3.3.0 github.com/alecthomas/kong v0.9.0 - github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a2f5 - github.com/crossplane/function-sdk-go v0.2.0 + github.com/crossplane/crossplane-runtime v1.17.0 + github.com/crossplane/function-sdk-go v0.3.0 github.com/google/go-cmp v0.6.0 - google.golang.org/protobuf v1.34.2 + google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689 gopkg.in/yaml.v3 v3.0.1 - k8s.io/apimachinery v0.29.0 - sigs.k8s.io/controller-tools v0.13.0 + k8s.io/apimachinery v0.30.0 + sigs.k8s.io/controller-tools v0.14.0 ) require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/fatih/color v1.15.0 // indirect - github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d // indirect - github.com/go-logr/logr v1.4.1 // indirect + github.com/evanphx/json-patch/v5 v5.9.0 // indirect + github.com/fatih/color v1.17.0 // indirect + github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1 // indirect + github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/swag v0.22.4 // indirect github.com/gobuffalo/flect v1.0.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect @@ -42,7 +42,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -52,32 +52,31 @@ require ( github.com/shopspring/decimal v1.4.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.7.0 // indirect - github.com/spf13/cobra v1.8.0 // indirect + github.com/spf13/cobra v1.8.1 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.25.0 // indirect - golang.org/x/oauth2 v0.15.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/mod v0.21.0 // indirect + golang.org/x/net v0.29.0 // indirect + golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.23.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac // indirect - google.golang.org/grpc v1.60.1 // indirect + golang.org/x/tools v0.25.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/grpc v1.66.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/api v0.29.0 // indirect - k8s.io/apiextensions-apiserver v0.28.4 // indirect - k8s.io/client-go v0.29.0 // indirect - k8s.io/klog/v2 v2.110.1 // indirect - k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect - k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect - sigs.k8s.io/controller-runtime v0.16.3 // indirect + k8s.io/api v0.30.0 // indirect + k8s.io/apiextensions-apiserver v0.30.0 // indirect + k8s.io/client-go v0.30.0 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect + k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 // indirect + sigs.k8s.io/controller-runtime v0.18.2 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect diff --git a/go.sum b/go.sum index ce677b7..69e3aa3 100644 --- a/go.sum +++ b/go.sum @@ -18,99 +18,98 @@ github.com/antchfx/htmlquery v1.2.4 h1:qLteofCMe/KGovBI6SQgmou2QNyedFUW+pE+BpeZ4 github.com/antchfx/htmlquery v1.2.4/go.mod h1:2xO6iu3EVWs7R2JYqBbp8YzG50gj/ofqs5/0VZoDZLc= github.com/antchfx/xpath v1.2.0 h1:mbwv7co+x0RwgeGAOHdrKy89GvHaGvxxBtPK0uF9Zr8= github.com/antchfx/xpath v1.2.0/go.mod h1:i54GszH55fYfBmoZXapTHN8T8tkcHfRgLyVwwqzXNcs= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a2f5 h1:B2EyxQYejCX1zp+7tUmuT6fTDUGB0k9LJUWvJ72NT1w= -github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a2f5/go.mod h1:pgt7PaTvvOQz3jILyxbCaeleU9MrAqKaNoPJavhGBgM= -github.com/crossplane/function-sdk-go v0.2.0 h1:4r+dXeGgwOC2XehJlHsHlkdkUsGW8PzkiyPPd2cshQs= -github.com/crossplane/function-sdk-go v0.2.0/go.mod h1:AvaWMHeKvzzE0vODLBrU5njOzW6sm61Ou4js9OdBUXM= -github.com/crossplane/upjet v1.1.0-rc.0.0.20231227120826-4cb45f9104ac h1:T1MTxsPAE/Cs0/EAGjeC29H9O/rO81yol2/5qGsf888= -github.com/crossplane/upjet v1.1.0-rc.0.0.20231227120826-4cb45f9104ac/go.mod h1:t9etxIdYaxgyvFPBToikm5zBHi8RIpX8N4mTH77lQFM= +github.com/crossplane/crossplane-runtime v1.17.0 h1:y+GvxPT1M9s8BKt2AeZJdd2d6pg2xZeCO6LiR+VxEF8= +github.com/crossplane/crossplane-runtime v1.17.0/go.mod h1:vtglCrnnbq2HurAk9yLHa4qS0bbnCxaKL7C21cQcB/0= +github.com/crossplane/function-sdk-go v0.3.0 h1:ezutyOxtRXhIMSB93mzyp8pc4G7N9e9SRs5KqW5x6sU= +github.com/crossplane/function-sdk-go v0.3.0/go.mod h1:bvJQih3IbrNOSiQWzdkVhOpR+BHL125jTBqFyEYJxIE= +github.com/crossplane/upjet v1.4.1-0.20240911184956-3afbb7796d46 h1:2IH1YPTBrNmBj0Z1OCjEBTrQCuRaLutZbWLaswFeCFQ= +github.com/crossplane/upjet v1.4.1-0.20240911184956-3afbb7796d46/go.mod h1:wkdZf/Cvhr6PI30VdHIOjg4dX39Z5uijqnLWFk5PbGM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= -github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= -github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= +github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= +github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= +github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= -github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= -github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= +github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d h1:zqfo2jECgX5eYQseB/X+uV4Y5ocGOG/vG/LTztUCyPA= -github.com/go-json-experiment/json v0.0.0-20231013223334-54c864be5b8d/go.mod h1:6daplAwHHGbUGib4990V3Il26O0OC4aRyvewaaAihaA= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1 h1:xcuWappghOVI8iNWoF2OKahVejd1LSVi/v4JED44Amo= +github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1/go.mod h1:BWmvoE1Xia34f3l/ibJweyhrT+aROb/FQ6d+37F0e2s= +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= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20240117000934-35fc243c5815 h1:WzfWbQz/Ze8v6l++GGbGNFZnUShVpP/0xffCPLL+ax8= -github.com/google/pprof v0.0.0-20240117000934-35fc243c5815/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134 h1:c5FlPPgxOn7kJz3VoPLkQYQXGBS3EklQ4Zfi57uOuqQ= +github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= -github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637 h1:Ud/6/AdmJ1R7ibdS0Wo5MWPj0T1R0fkpaD087bBaW8I= +github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hcl/v2 v2.17.0 h1:z1XvSUyXd1HP10U4lrLg5e0JMVz6CPaJvAgxM0KNZVY= -github.com/hashicorp/hcl/v2 v2.17.0/go.mod h1:gJyW2PTShkJqQBKpAmPO3yxMxIuoXkOF2TpqXzrQyx4= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= +github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/terraform-json v0.17.0 h1:EiA1Wp07nknYQAiv+jIt4dX4Cq5crgP+TsTE45MjMmM= -github.com/hashicorp/terraform-json v0.17.0/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= -github.com/hashicorp/terraform-plugin-go v0.16.0 h1:DSOQ0rz5FUiVO4NUzMs8ln9gsPgHMTsfns7Nk+6gPuE= -github.com/hashicorp/terraform-plugin-go v0.16.0/go.mod h1:4sn8bFuDbt+2+Yztt35IbOrvZc0zyEi87gJzsTgCES8= +github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= +github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= +github.com/hashicorp/terraform-plugin-framework v1.10.0 h1:xXhICE2Fns1RYZxEQebwkB2+kXouLC932Li9qelozrc= +github.com/hashicorp/terraform-plugin-framework v1.10.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= +github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= +github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1 h1:G9WAfb8LHeCxu7Ae8nc1agZlQOSCUWsb610iAogBhCs= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1/go.mod h1:xcOSYlRVdPLmDUoqPhO9fiO/YCN/l6MGYeTzGt5jgkQ= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= @@ -121,7 +120,6 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= @@ -140,10 +138,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= @@ -165,25 +161,24 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= -github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= +github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= -github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= -github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= -github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= -github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE= +github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= @@ -191,8 +186,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= -github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= -github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= +github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -202,88 +197,75 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tmccombs/hcl2json v0.3.3 h1:+DLNYqpWE0CsOQiEZu+OZm5ZBImake3wtITYxQ8uLFQ= github.com/tmccombs/hcl2json v0.3.3/go.mod h1:Y2chtz2x9bAeRTvSibVRVgbLJhLJXKlUeIvjeVdnm4w= -github.com/upbound/provider-aws v0.47.1 h1:Z+eAy9Ut4suVrx79pkzhsYTC6uvxNW2jkwAQCUVbq3g= -github.com/upbound/provider-aws v0.47.1/go.mod h1:kYxEeLtZv1CJKbc+O1IribFA47Oqkuso3hSo5vdwptU= +github.com/upbound/provider-aws v1.13.1 h1:PpJQXGF8oIQeLsvWIxx5W9RzIoSjJcp46myghjZ2mHQ= +github.com/upbound/provider-aws v1.13.1/go.mod h1:wPs6bHy0ayQczxNTe9w54LML5tFIDdvZpjbMvRNwMSU= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zclconf/go-cty v1.13.2 h1:4GvrUxe/QUDYuJKAav4EYqdM47/kZa672LwmXFmEKT0= -github.com/zclconf/go-cty v1.13.2/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= -golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= +golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= -golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= -golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= +golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= +golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -292,14 +274,12 @@ gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac h1:nUQEQmH/csSvFECKYRv6HWEyypysidKl2I6Qpsglq/0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689 h1:hNwajDgT0MlsxZzlUajZVmUYFpts8/CYe4BSNx503ZE= +google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -313,26 +293,26 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A= -k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA= -k8s.io/apiextensions-apiserver v0.28.4 h1:AZpKY/7wQ8n+ZYDtNHbAJBb+N4AXXJvyZx6ww6yAJvU= -k8s.io/apiextensions-apiserver v0.28.4/go.mod h1:pgQIZ1U8eJSMQcENew/0ShUTlePcSGFq6dxSxf2mwPM= -k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o= -k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis= -k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8= -k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38= -k8s.io/component-base v0.28.4 h1:c/iQLWPdUgI90O+T9TeECg8o7N3YJTiuz2sKxILYcYo= -k8s.io/component-base v0.28.4/go.mod h1:m9hR0uvqXDybiGL2nf/3Lf0MerAfQXzkfWhUY58JUbU= -k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= -k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= -k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= -k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= -k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= -k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= -sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= -sigs.k8s.io/controller-tools v0.13.0 h1:NfrvuZ4bxyolhDBt/rCZhDnx3M2hzlhgo5n3Iv2RykI= -sigs.k8s.io/controller-tools v0.13.0/go.mod h1:5vw3En2NazbejQGCeWKRrE7q4P+CW8/klfVqP8QZkgA= +k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= +k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= +k8s.io/apiextensions-apiserver v0.30.0 h1:jcZFKMqnICJfRxTgnC4E+Hpcq8UEhT8B2lhBcQ+6uAs= +k8s.io/apiextensions-apiserver v0.30.0/go.mod h1:N9ogQFGcrbWqAY9p2mUAL5mGxsLqwgtUce127VtRX5Y= +k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= +k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= +k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= +k8s.io/component-base v0.30.0 h1:cj6bp38g0ainlfYtaOQuRELh5KSYjhKxM+io7AUIk4o= +k8s.io/component-base v0.30.0/go.mod h1:V9x/0ePFNaKeKYA3bOvIbrNoluTSG+fSJKjLdjOoeXQ= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= +k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 h1:b2FmK8YH+QEwq/Sy2uAEhmqL5nPfGYbJOcaqjeYYZoA= +k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/controller-runtime v0.18.2 h1:RqVW6Kpeaji67CY5nPEfRz6ZfFMk0lWQlNrLqlNpx+Q= +sigs.k8s.io/controller-runtime v0.18.2/go.mod h1:tuAt1+wbVsXIT8lPtk5RURxqAnq7xkpv2Mhttslg7Hw= +sigs.k8s.io/controller-tools v0.14.0 h1:rnNoCC5wSXlrNoBKKzL70LNJKIQKEzT6lloG6/LF73A= +sigs.k8s.io/controller-tools v0.14.0/go.mod h1:TV7uOtNNnnR72SpzhStvPkoS/U5ir0nMudrkrC4M9Sc= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= From a5b856bfabf41184cfa2c45606757fe5bbe5b47d Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 18:21:21 -0600 Subject: [PATCH 02/13] update go Signed-off-by: Steven Borrelli --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bce67e..90679c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ on: env: # Common versions - GO_VERSION: '1.21.3' + GO_VERSION: '1.23.2' GOLANGCI_VERSION: 'v1.54.2' DOCKER_BUILDX_VERSION: 'v0.11.2' From cd3de0d8fbf88e77c484a1dcfffbf566ccc76317 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 18:29:45 -0600 Subject: [PATCH 03/13] update linter Signed-off-by: Steven Borrelli --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90679c0..ed1d7c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,8 @@ on: env: # Common versions - GO_VERSION: '1.23.2' - GOLANGCI_VERSION: 'v1.54.2' + GO_VERSION: '1.23.3' + GOLANGCI_VERSION: 'v1.62.2' DOCKER_BUILDX_VERSION: 'v0.11.2' # These environment variables are important to the Crossplane CLI install.sh From f14f52090eaf6081f034ad99739273f2fc8e96c6 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 18:32:01 -0600 Subject: [PATCH 04/13] fix version Signed-off-by: Steven Borrelli --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed1d7c8..ba90a52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ on: env: # Common versions GO_VERSION: '1.23.3' - GOLANGCI_VERSION: 'v1.62.2' + GOLANGCI_VERSION: 'v1.62.0' DOCKER_BUILDX_VERSION: 'v0.11.2' # These environment variables are important to the Crossplane CLI install.sh From b38124398d936109b541df5afd31709e2700ce78 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 17:58:58 -0600 Subject: [PATCH 05/13] wip Signed-off-by: Steven Borrelli --- claimconditions.go | 43 +++++++++++ example/conditions/README.md | 84 ++++++++++++++++++++++ example/conditions/composition.yaml | 49 +++++++++++++ example/conditions/environmentConfigs.yaml | 10 +++ example/conditions/functions.yaml | 25 +++++++ example/conditions/xr.yaml | 5 ++ example/conditions/xrd.yaml | 25 +++++++ fn.go | 12 ++++ go.mod | 4 +- go.sum | 21 +++--- 10 files changed, 265 insertions(+), 13 deletions(-) create mode 100644 claimconditions.go create mode 100644 example/conditions/README.md create mode 100644 example/conditions/composition.yaml create mode 100644 example/conditions/environmentConfigs.yaml create mode 100644 example/conditions/functions.yaml create mode 100644 example/conditions/xr.yaml create mode 100644 example/conditions/xrd.yaml diff --git a/claimconditions.go b/claimconditions.go new file mode 100644 index 0000000..b5b5789 --- /dev/null +++ b/claimconditions.go @@ -0,0 +1,43 @@ +package main + +import ( + xpruntimev1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/function-sdk-go/errors" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" + "github.com/crossplane/function-sdk-go/response" + "github.com/davecgh/go-spew/spew" + corev1 "k8s.io/api/core/v1" +) + +// A CompositionTarget is the target of a composition event or condition. +type CompositionTarget string + +// Composition event and condition targets. +const ( + CompositionTargetComposite CompositionTarget = "Composite" + CompositionTargetCompositeAndClaim CompositionTarget = "CompositeAndClaim" +) + +func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...xpruntimev1.Condition) (*fnv1.RunFunctionResponse, error) { + for _, c := range conditions { + if xpruntimev1.IsSystemConditionType(c.Type) { + response.Fatal(rsp, errors.Errorf("cannot set ClaimCondition type: %s is a reserved Crossplane Condition", c.Type)) + return rsp, nil + } + var co *response.ConditionOption + switch c.Status { + case corev1.ConditionTrue: + co = response.ConditionTrue(rsp, string(c.Type), string(c.Reason)).WithMessage(c.Message) + case corev1.ConditionFalse: + co = response.ConditionFalse(rsp, string(c.Type), string(c.Reason)) + case corev1.ConditionUnknown: + co = response.ConditionFalse(rsp, string(c.Type), string(c.Reason)) + } + if c.Message != "" { + co.WithMessage(c.Message) + } + + spew.Dump(co) + } + return rsp, nil +} diff --git a/example/conditions/README.md b/example/conditions/README.md new file mode 100644 index 0000000..21587cd --- /dev/null +++ b/example/conditions/README.md @@ -0,0 +1,84 @@ +# Writing to the Function Context + +function-go-templating can write to the Function Context + +## Testing This Function Locally + +You can run your function locally and test it using [`crossplane render`](https://docs.crossplane.io/latest/cli/command-reference/#render) +with these example manifests. + +```shell +crossplane render \ + --extra-resources environmentConfigs.yaml \ + --include-context \ + xr.yaml composition.yaml functions.yaml +``` + +Will produce an output like: + +```shell +--- +apiVersion: example.crossplane.io/v1 +kind: XR +metadata: + name: example-xr +status: + conditions: + - lastTransitionTime: "2024-01-01T00:00:00Z" + reason: Available + status: "True" + type: Ready + fromEnv: e +--- +apiVersion: render.crossplane.io/v1beta1 +fields: + apiextensions.crossplane.io/environment: + apiVersion: internal.crossplane.io/v1alpha1 + array: + - "1" + - "2" + complex: + a: b + c: + d: e + f: "1" + kind: Environment + nestedEnvUpdate: + hello: world + update: environment + newkey: + hello: world + other-context-key: + complex: + a: b + c: + d: e + f: "1" +kind: Context +``` + +## Debugging This Function + +First we need to run the command in debug mode. In a terminal Window Run: + +```shell +# Run the function locally +$ go run . --insecure --debug +``` + +Next, set the go-templating function `render.crossplane.io/runtime: Development` annotation so that +`crossplane render` communicates with the local process instead of downloading an image: + +```yaml +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: crossplane-contrib-function-go-templating + annotations: + render.crossplane.io/runtime: Development +spec: + package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.6.0 +``` + +While the function is running in one terminal, open another terminal window and run `crossplane render`. +The function should output debug-level logs in the terminal. diff --git a/example/conditions/composition.yaml b/example/conditions/composition.yaml new file mode 100644 index 0000000..7f59d3f --- /dev/null +++ b/example/conditions/composition.yaml @@ -0,0 +1,49 @@ +apiVersion: apiextensions.crossplane.io/v1 +kind: Composition +metadata: + name: go-template-context.example.crossplane.io +spec: + compositeTypeRef: + apiVersion: example.crossplane.io/v1 + kind: XR + mode: Pipeline + pipeline: + - step: go-templating-update-conditions + functionRef: + name: crossplane-contrib-function-go-templating + input: + apiVersion: gotemplating.fn.crossplane.io/v1beta1 + kind: GoTemplate + source: Inline + inline: + template: | + --- + apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1 + kind: ClaimConditions + conditions: + # Type of the condition, e.g. DatabaseReady. + # 'Healthy', 'Ready' and 'Synced' are reserved for use by Crossplane and this function will raise an error if used + # - type: + # Status of the condition. + # status: + # Machine-readable PascalCase reason. + # reason: + # Optional Target. Publish Condition only to the Composite, or the Composite and the Claim. + # Defaults to CompositeAndClaim + # target: + - type: TestCondition + status: "False" + reason: InstallFail + message: "failed to install" + - type: ConditionTrue + status: "True" + reason: this condition is true + message: we are true + target: Composite + - type: DatabaseReady + status: "True" + reason: Ready + message: Database is ready + - step: automatically-detect-ready-composed-resources + functionRef: + name: crossplane-contrib-function-auto-ready diff --git a/example/conditions/environmentConfigs.yaml b/example/conditions/environmentConfigs.yaml new file mode 100644 index 0000000..46dc62b --- /dev/null +++ b/example/conditions/environmentConfigs.yaml @@ -0,0 +1,10 @@ +apiVersion: apiextensions.crossplane.io/v1alpha1 +kind: EnvironmentConfig +metadata: + name: example-config +data: + complex: + a: b + c: + d: e + f: "1" \ No newline at end of file diff --git a/example/conditions/functions.yaml b/example/conditions/functions.yaml new file mode 100644 index 0000000..82ebe3b --- /dev/null +++ b/example/conditions/functions.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: crossplane-contrib-function-environment-configs +spec: + # This is ignored when using the Development runtime. + package: xpkg.upbound.io/crossplane-contrib/function-environment-configs:v0.0.7 +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: crossplane-contrib-function-go-templating + annotations: + # This tells crossplane beta render to connect to the function locally. + render.crossplane.io/runtime: Development +spec: + package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.7.0 +--- +apiVersion: pkg.crossplane.io/v1beta1 +kind: Function +metadata: + name: crossplane-contrib-function-auto-ready +spec: + package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.3.0 diff --git a/example/conditions/xr.yaml b/example/conditions/xr.yaml new file mode 100644 index 0000000..35a7feb --- /dev/null +++ b/example/conditions/xr.yaml @@ -0,0 +1,5 @@ +apiVersion: example.crossplane.io/v1 +kind: XR +metadata: + name: example-xr +spec: {} \ No newline at end of file diff --git a/example/conditions/xrd.yaml b/example/conditions/xrd.yaml new file mode 100644 index 0000000..8955af2 --- /dev/null +++ b/example/conditions/xrd.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: apiextensions.crossplane.io/v1 +kind: CompositeResourceDefinition +metadata: + name: xrs.example.crossplane.io +spec: + group: example.crossplane.io + names: + kind: XR + plural: xrs + connectionSecretKeys: + - test + versions: + - name: v1 + served: true + referenceable: true + schema: + openAPIV3Schema: + type: object + properties: + status: + type: object + properties: + fromEnv: + type: string \ No newline at end of file diff --git a/fn.go b/fn.go index 7d05468..9e81075 100644 --- a/fn.go +++ b/fn.go @@ -15,6 +15,7 @@ import ( "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/yaml" + xpruntimev1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/fieldpath" "github.com/crossplane/crossplane-runtime/pkg/meta" @@ -192,6 +193,17 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) d, _ := base64.StdEncoding.DecodeString(v) //nolint:errcheck // k8s returns secret values encoded desiredComposite.ConnectionDetails[k] = d } + case "ClaimConditions": + var conditions []xpruntimev1.Condition + if err = cd.Resource.GetValueInto("conditions", &conditions); err != nil { + response.Fatal(rsp, errors.Wrap(err, "cannot get Conditions from input")) + return rsp, nil + } + rsp, err := UpdateClaimConditions(rsp, conditions...) + if err != nil { + response.Fatal(rsp, errors.Wrap(err, "cannot set ClaimCondition")) + return rsp, nil + } case "Context": contextData := make(map[string]interface{}) if err = cd.Resource.GetValueInto("data", &contextData); err != nil { diff --git a/go.mod b/go.mod index e65951c..1359f43 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,11 @@ require ( github.com/alecthomas/kong v0.9.0 github.com/crossplane/crossplane-runtime v1.17.0 github.com/crossplane/function-sdk-go v0.3.0 + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/google/go-cmp v0.6.0 google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689 gopkg.in/yaml.v3 v3.0.1 + k8s.io/api v0.30.0 k8s.io/apimachinery v0.30.0 sigs.k8s.io/controller-tools v0.14.0 ) @@ -20,7 +22,6 @@ require ( require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fatih/color v1.17.0 // indirect @@ -70,7 +71,6 @@ require ( google.golang.org/grpc v1.66.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/api v0.30.0 // indirect k8s.io/apiextensions-apiserver v0.30.0 // indirect k8s.io/client-go v0.30.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect diff --git a/go.sum b/go.sum index 69e3aa3..9720234 100644 --- a/go.sum +++ b/go.sum @@ -2,16 +2,16 @@ dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= -github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU= -github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= -github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= +github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= +github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= +github.com/alecthomas/kong v1.4.0 h1:UL7tzGMnnY0YRMMvJyITIRX1EpO6RbBRZDNcCevy3HA= +github.com/alecthomas/kong v1.4.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/antchfx/htmlquery v1.2.4 h1:qLteofCMe/KGovBI6SQgmou2QNyedFUW+pE+BpeZ494= @@ -126,11 +126,8 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -167,7 +164,6 @@ github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= @@ -209,6 +205,8 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= @@ -283,11 +281,12 @@ google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689/go.mod h1:qYOHt gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From aef7a5d2425b2b303bc2e300795a192540417688 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 21:07:02 -0600 Subject: [PATCH 06/13] initial working example Signed-off-by: Steven Borrelli --- claimconditions.go | 73 ++++++++++++++++++++++++++++++++++------------ fn.go | 4 +-- go.mod | 8 +++-- go.sum | 21 ++++++------- 4 files changed, 73 insertions(+), 33 deletions(-) diff --git a/claimconditions.go b/claimconditions.go index b5b5789..5df2140 100644 --- a/claimconditions.go +++ b/claimconditions.go @@ -1,43 +1,80 @@ package main import ( - xpruntimev1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/function-sdk-go/errors" fnv1 "github.com/crossplane/function-sdk-go/proto/v1" "github.com/crossplane/function-sdk-go/response" - "github.com/davecgh/go-spew/spew" corev1 "k8s.io/api/core/v1" ) // A CompositionTarget is the target of a composition event or condition. type CompositionTarget string +// A TargetedCondition represents a condition produced by the composition +// process. It can target either the XR only, or both the XR and the claim. +type TargetedCondition struct { + xpv1.Condition `json:",inline"` + Target CompositionTarget `json:"target"` +} + // Composition event and condition targets. const ( CompositionTargetComposite CompositionTarget = "Composite" CompositionTargetCompositeAndClaim CompositionTarget = "CompositeAndClaim" ) -func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...xpruntimev1.Condition) (*fnv1.RunFunctionResponse, error) { +// UpdateClaimConditions updates Conditions in the Claim and Composite +func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...TargetedCondition) (*fnv1.RunFunctionResponse, error) { for _, c := range conditions { - if xpruntimev1.IsSystemConditionType(c.Type) { + if xpv1.IsSystemConditionType(v1.ConditionType(c.Type)) { response.Fatal(rsp, errors.Errorf("cannot set ClaimCondition type: %s is a reserved Crossplane Condition", c.Type)) return rsp, nil } - var co *response.ConditionOption - switch c.Status { - case corev1.ConditionTrue: - co = response.ConditionTrue(rsp, string(c.Type), string(c.Reason)).WithMessage(c.Message) - case corev1.ConditionFalse: - co = response.ConditionFalse(rsp, string(c.Type), string(c.Reason)) - case corev1.ConditionUnknown: - co = response.ConditionFalse(rsp, string(c.Type), string(c.Reason)) - } - if c.Message != "" { - co.WithMessage(c.Message) - } - - spew.Dump(co) + co := transformCondition(c) + UpdateResponseWithCondition(rsp, co) } return rsp, nil } + +// transformCondition converts a TargetedCondition to be compatible with the Protobuf SDK +func transformCondition(tc TargetedCondition) *fnv1.Condition { + c := &fnv1.Condition{ + Type: string(tc.Condition.Type), + Reason: string(tc.Condition.Reason), + Target: transformTarget(tc.Target), + } + + switch tc.Condition.Status { + case corev1.ConditionTrue: + c.Status = fnv1.Status_STATUS_CONDITION_TRUE + case corev1.ConditionFalse: + c.Status = fnv1.Status_STATUS_CONDITION_FALSE + case corev1.ConditionUnknown: + fallthrough + default: + c.Status = fnv1.Status_STATUS_CONDITION_UNKNOWN + } + + if tc.Message != "" { + c.Message = &tc.Message + } + return c +} + +// transformTarget converts the input into a target Go SDK Enum +// Default to TARGET_COMPOSITE_AND_CLAIM +func transformTarget(ct CompositionTarget) *fnv1.Target { + if ct == CompositionTargetComposite { + return fnv1.Target_TARGET_COMPOSITE.Enum() + } + return fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() +} + +func UpdateResponseWithCondition(rsp *fnv1.RunFunctionResponse, c *fnv1.Condition) { + if rsp.GetConditions() == nil { + rsp.Conditions = make([]*fnv1.Condition, 0, 1) + } + rsp.Conditions = append(rsp.GetConditions(), c) +} diff --git a/fn.go b/fn.go index 9e81075..835f1fd 100644 --- a/fn.go +++ b/fn.go @@ -15,7 +15,6 @@ import ( "k8s.io/apimachinery/pkg/util/json" "k8s.io/apimachinery/pkg/util/yaml" - xpruntimev1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/crossplane-runtime/pkg/fieldpath" "github.com/crossplane/crossplane-runtime/pkg/meta" @@ -194,7 +193,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) desiredComposite.ConnectionDetails[k] = d } case "ClaimConditions": - var conditions []xpruntimev1.Condition + var conditions []TargetedCondition if err = cd.Resource.GetValueInto("conditions", &conditions); err != nil { response.Fatal(rsp, errors.Wrap(err, "cannot get Conditions from input")) return rsp, nil @@ -204,6 +203,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) response.Fatal(rsp, errors.Wrap(err, "cannot set ClaimCondition")) return rsp, nil } + f.log.Debug("updating ClaimConditions", "conditions", rsp.Conditions) case "Context": contextData := make(map[string]interface{}) if err = cd.Resource.GetValueInto("data", &contextData); err != nil { diff --git a/go.mod b/go.mod index 1359f43..884676b 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/crossplane-contrib/function-go-templating go 1.23 -toolchain go1.23.2 +toolchain go1.23.3 require ( dario.cat/mergo v1.0.1 @@ -21,7 +21,8 @@ require ( require ( github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.3.0 // indirect + github.com/Masterminds/semver/v3 v3.3.1 // indirect + github.com/alecthomas/assert/v2 v2.11.0 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fatih/color v1.17.0 // indirect @@ -50,6 +51,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.7.0 // indirect @@ -62,7 +64,7 @@ require ( golang.org/x/net v0.29.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.27.0 // indirect golang.org/x/term v0.24.0 // indirect golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index 9720234..0a58f2b 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7l github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/kong v1.4.0 h1:UL7tzGMnnY0YRMMvJyITIRX1EpO6RbBRZDNcCevy3HA= -github.com/alecthomas/kong v1.4.0/go.mod h1:p2vqieVMeTAnaC83txKtXe8FLke2X07aruPWXyMPQrU= +github.com/alecthomas/kong v0.9.0 h1:G5diXxc85KvoV2f0ZRVuMsi45IrBgx9zDNGNj165aPA= +github.com/alecthomas/kong v0.9.0/go.mod h1:Y47y5gKfHp1hDc7CH7OeXgLIpp+Q2m1Ni0L5s3bI8Os= github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/antchfx/htmlquery v1.2.4 h1:qLteofCMe/KGovBI6SQgmou2QNyedFUW+pE+BpeZ494= @@ -126,8 +126,11 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= @@ -164,6 +167,7 @@ github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk= github.com/onsi/gomega v1.32.0/go.mod h1:a4x4gW6Pz2yK1MAmvluYme5lvYTn61afQ2ETw/8n4Lg= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= @@ -173,8 +177,8 @@ github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSz github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= @@ -205,8 +209,6 @@ github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IU github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= -github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= -github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= @@ -248,8 +250,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -281,12 +283,11 @@ google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689/go.mod h1:qYOHt gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= -gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From b440da52ba34ff542b768843d781d5799ed96d2c Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 21:12:28 -0600 Subject: [PATCH 07/13] update example Signed-off-by: Steven Borrelli --- claimconditions.go | 3 +- example/conditions/README.md | 51 ++-------------------- example/conditions/composition.yaml | 1 + example/conditions/environmentConfigs.yaml | 10 ----- 4 files changed, 5 insertions(+), 60 deletions(-) delete mode 100644 example/conditions/environmentConfigs.yaml diff --git a/claimconditions.go b/claimconditions.go index 5df2140..c4581b6 100644 --- a/claimconditions.go +++ b/claimconditions.go @@ -1,7 +1,6 @@ package main import ( - v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" "github.com/crossplane/function-sdk-go/errors" fnv1 "github.com/crossplane/function-sdk-go/proto/v1" @@ -28,7 +27,7 @@ const ( // UpdateClaimConditions updates Conditions in the Claim and Composite func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...TargetedCondition) (*fnv1.RunFunctionResponse, error) { for _, c := range conditions { - if xpv1.IsSystemConditionType(v1.ConditionType(c.Type)) { + if xpv1.IsSystemConditionType(xpv1.ConditionType(c.Type)) { response.Fatal(rsp, errors.Errorf("cannot set ClaimCondition type: %s is a reserved Crossplane Condition", c.Type)) return rsp, nil } diff --git a/example/conditions/README.md b/example/conditions/README.md index 21587cd..60de2cc 100644 --- a/example/conditions/README.md +++ b/example/conditions/README.md @@ -1,6 +1,6 @@ -# Writing to the Function Context +# Writing to the Composite or Claim Status -function-go-templating can write to the Function Context +function-go-templating can write to the Composite or Claim Status. See [Communication Between Composition Functions and the Claim](https://github.com/crossplane/crossplane/blob/main/design/one-pager-fn-claim-conditions.md) for more information. ## Testing This Function Locally @@ -9,54 +9,9 @@ with these example manifests. ```shell crossplane render \ - --extra-resources environmentConfigs.yaml \ - --include-context \ xr.yaml composition.yaml functions.yaml ``` -Will produce an output like: - -```shell ---- -apiVersion: example.crossplane.io/v1 -kind: XR -metadata: - name: example-xr -status: - conditions: - - lastTransitionTime: "2024-01-01T00:00:00Z" - reason: Available - status: "True" - type: Ready - fromEnv: e ---- -apiVersion: render.crossplane.io/v1beta1 -fields: - apiextensions.crossplane.io/environment: - apiVersion: internal.crossplane.io/v1alpha1 - array: - - "1" - - "2" - complex: - a: b - c: - d: e - f: "1" - kind: Environment - nestedEnvUpdate: - hello: world - update: environment - newkey: - hello: world - other-context-key: - complex: - a: b - c: - d: e - f: "1" -kind: Context -``` - ## Debugging This Function First we need to run the command in debug mode. In a terminal Window Run: @@ -77,7 +32,7 @@ metadata: annotations: render.crossplane.io/runtime: Development spec: - package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.6.0 + package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.9.0 ``` While the function is running in one terminal, open another terminal window and run `crossplane render`. diff --git a/example/conditions/composition.yaml b/example/conditions/composition.yaml index 7f59d3f..04c0af1 100644 --- a/example/conditions/composition.yaml +++ b/example/conditions/composition.yaml @@ -35,6 +35,7 @@ spec: status: "False" reason: InstallFail message: "failed to install" + target: ClaimAndComposite - type: ConditionTrue status: "True" reason: this condition is true diff --git a/example/conditions/environmentConfigs.yaml b/example/conditions/environmentConfigs.yaml deleted file mode 100644 index 46dc62b..0000000 --- a/example/conditions/environmentConfigs.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: apiextensions.crossplane.io/v1alpha1 -kind: EnvironmentConfig -metadata: - name: example-config -data: - complex: - a: b - c: - d: e - f: "1" \ No newline at end of file From 0c46a6982670fb2b1506530eb649b8abbc35be5a Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 21:17:22 -0600 Subject: [PATCH 08/13] go.mod tidy Signed-off-by: Steven Borrelli --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 884676b..91035a7 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/alecthomas/kong v0.9.0 github.com/crossplane/crossplane-runtime v1.17.0 github.com/crossplane/function-sdk-go v0.3.0 - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/google/go-cmp v0.6.0 google.golang.org/protobuf v1.34.3-0.20240816073751-94ecbc261689 gopkg.in/yaml.v3 v3.0.1 @@ -23,6 +22,7 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.1 // indirect github.com/alecthomas/assert/v2 v2.11.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch/v5 v5.9.0 // indirect github.com/fatih/color v1.17.0 // indirect From 62a60f1d339af52fd8f2fa46353287a8daa89e62 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 22:37:59 -0600 Subject: [PATCH 09/13] update fn_test.go with ClaimConditions Signed-off-by: Steven Borrelli --- fn_test.go | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/fn_test.go b/fn_test.go index 1c56ddb..a0331f4 100644 --- a/fn_test.go +++ b/fn_test.go @@ -10,6 +10,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "google.golang.org/protobuf/testing/protocmp" "google.golang.org/protobuf/types/known/durationpb" + "k8s.io/utils/ptr" "github.com/crossplane/crossplane-runtime/pkg/logging" @@ -40,6 +41,9 @@ var ( xrWithNestedStatusBaz = `{"apiVersion":"example.org/v1","kind":"XR","metadata":{"name":"cool-xr"},"spec":{"count":2},"status":{"state":{"baz":"qux"}}}` xrRecursiveTmpl = `{"apiVersion":"example.org/v1","kind":"XR","metadata":{"annotations":{"gotemplating.fn.crossplane.io/composition-resource-name":"recursive-xr"},"name":"recursive-xr","labels":{"belongsTo":{{.observed.composite.resource.metadata.name|quote}}}},"spec":{"count":2}}` + claimConditions = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ClaimConditions","conditions":[{"type":"TestCondition","status":"False","reason":"InstallFail","message":"failed to install","target":"ClaimAndComposite"},{"type":"ConditionTrue","status":"True","reason":"this condition is true","message":"we are true","target":"Composite"},{"type":"DatabaseReady","status":"True","reason":"Ready","message":"Database is ready"}]}` + claimConditionsReservedKey = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ClaimConditions","conditions":[{"type":"Ready","tatus":"False","reason":"InstallFail","message":"I am using a reserved Condition","target":"ClaimAndComposite"}]}` + extraResources = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ExtraResources","requirements":{"cool-extra-resource":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchName":"cool-extra-resource"}}} {"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ExtraResources","requirements":{"another-cool-extra-resource":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchLabels":{"key": "value"}},"yet-another-cool-extra-resource":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchName":"foo"}}} {"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ExtraResources","requirements":{"all-cool-resources":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchLabels":{}}}}` @@ -611,6 +615,100 @@ func TestRunFunction(t *testing.T) { }, }, }, + "ClaimConditionsError": { + reason: "The Function should return a fatal result if a reserved Condition is set.", + args: args{ + req: &fnv1.RunFunctionRequest{ + Input: resource.MustStructObject( + &v1beta1.GoTemplate{ + Source: v1beta1.InlineSource, + Inline: &v1beta1.TemplateSourceInline{Template: claimConditionsReservedKey}, + }), + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ + Resource: resource.MustStructJSON(xr), + }, + }, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ + Resource: resource.MustStructJSON(xr), + }, + }, + }, + }, + want: want{ + rsp: &fnv1.RunFunctionResponse{ + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Results: []*fnv1.Result{ + { + Severity: fnv1.Severity_SEVERITY_FATAL, + Message: "cannot set ClaimCondition type: Ready is a reserved Crossplane Condition", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + }, + }, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ + Resource: resource.MustStructJSON(xr), + }, + }, + }, + }, + }, + "ClaimConditions": { + reason: "The Function should correctly set ClaimConditions.", + args: args{ + req: &fnv1.RunFunctionRequest{ + Input: resource.MustStructObject( + &v1beta1.GoTemplate{ + Source: v1beta1.InlineSource, + Inline: &v1beta1.TemplateSourceInline{Template: claimConditions}, + }), + Observed: &fnv1.State{ + Composite: &fnv1.Resource{ + Resource: resource.MustStructJSON(xr), + }, + }, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ + Resource: resource.MustStructJSON(xr), + }, + }, + }, + }, + want: want{ + rsp: &fnv1.RunFunctionResponse{ + Conditions: []*fnv1.Condition{ + { + Type: "TestCondition", + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Reason: "InstallFail", + Message: ptr.To("failed to install"), + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + }, + { + Type: "ConditionTrue", + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Reason: "this condition is true", + Message: ptr.To("we are true"), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + }, + { + Type: "DatabaseReady", + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Reason: "Ready", + Message: ptr.To("Database is ready"), + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + }, + }, + Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, + Desired: &fnv1.State{ + Composite: &fnv1.Resource{ + Resource: resource.MustStructJSON(xr), + }, + }, + }, + }, + }, "CompositeConnectionDetails": { reason: "The Function should return the desired composite with CompositeConnectionDetails.", args: args{ From 4c256db706dbb6521d27a7ab81d5ededa83bc727 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Fri, 22 Nov 2024 22:43:00 -0600 Subject: [PATCH 10/13] go mod tidy Signed-off-by: Steven Borrelli --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 91035a7..358aee8 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.30.0 k8s.io/apimachinery v0.30.0 + k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 sigs.k8s.io/controller-tools v0.14.0 ) @@ -77,7 +78,6 @@ require ( k8s.io/client-go v0.30.0 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect - k8s.io/utils v0.0.0-20240902221715-702e33fdd3c3 // indirect sigs.k8s.io/controller-runtime v0.18.2 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect From f9edb3ff601ca4d1b3be18b84cb36a647454886c Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Sun, 24 Nov 2024 17:58:51 -0600 Subject: [PATCH 11/13] add testing Signed-off-by: Steven Borrelli --- claimconditions.go | 17 +- claimconditions_test.go | 333 ++++++++++++++++++++++++++++ example/conditions/composition.yaml | 2 +- fn.go | 3 +- fn_test.go | 2 +- 5 files changed, 349 insertions(+), 8 deletions(-) create mode 100644 claimconditions_test.go diff --git a/claimconditions.go b/claimconditions.go index c4581b6..6e8537b 100644 --- a/claimconditions.go +++ b/claimconditions.go @@ -25,16 +25,19 @@ const ( ) // UpdateClaimConditions updates Conditions in the Claim and Composite -func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...TargetedCondition) (*fnv1.RunFunctionResponse, error) { +func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...TargetedCondition) error { + if rsp == nil { + return nil + } for _, c := range conditions { if xpv1.IsSystemConditionType(xpv1.ConditionType(c.Type)) { response.Fatal(rsp, errors.Errorf("cannot set ClaimCondition type: %s is a reserved Crossplane Condition", c.Type)) - return rsp, nil + return errors.New("error updating response") } co := transformCondition(c) UpdateResponseWithCondition(rsp, co) } - return rsp, nil + return nil } // transformCondition converts a TargetedCondition to be compatible with the Protobuf SDK @@ -71,9 +74,15 @@ func transformTarget(ct CompositionTarget) *fnv1.Target { return fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() } +// UpdateResponseWithCondition updates the RunFunctionResponse with a Condition func UpdateResponseWithCondition(rsp *fnv1.RunFunctionResponse, c *fnv1.Condition) { + if rsp == nil { + return + } if rsp.GetConditions() == nil { rsp.Conditions = make([]*fnv1.Condition, 0, 1) } - rsp.Conditions = append(rsp.GetConditions(), c) + if c != nil { + rsp.Conditions = append(rsp.GetConditions(), c) + } } diff --git a/claimconditions_test.go b/claimconditions_test.go new file mode 100644 index 0000000..f933f6e --- /dev/null +++ b/claimconditions_test.go @@ -0,0 +1,333 @@ +package main + +import ( + "reflect" + "testing" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/test" + "github.com/crossplane/function-sdk-go/errors" + fnv1 "github.com/crossplane/function-sdk-go/proto/v1" + "github.com/google/go-cmp/cmp" + "github.com/google/go-cmp/cmp/cmpopts" + v1 "k8s.io/api/core/v1" + "k8s.io/utils/ptr" +) + +func Test_UpdateClaimConditions(t *testing.T) { + type args struct { + rsp *fnv1.RunFunctionResponse + c []TargetedCondition + } + type want struct { + rsp *fnv1.RunFunctionResponse + err error + } + cases := map[string]struct { + reason string + args args + want want + }{ + "EmptyResponseNoConditions": { + reason: "When No Response or Conditions are provided, return a nil response", + args: args{}, + want: want{}, + }, + "ErrorOnReadyReservedType": { + reason: "Return an error if a Reserved Condition Type is being used", + args: args{ + rsp: &fnv1.RunFunctionResponse{}, + c: []TargetedCondition{ + { + Condition: xpv1.Condition{ + Message: "Ready Message", + Status: v1.ConditionTrue, + Type: "Ready", + }, + Target: CompositionTargetComposite, + }, + }, + }, + want: want{ + rsp: &fnv1.RunFunctionResponse{ + Results: []*fnv1.Result{ + { + Severity: fnv1.Severity_SEVERITY_FATAL, + Message: "cannot set ClaimCondition type: Ready is a reserved Crossplane Condition", + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + }, + }, + }, + err: errors.New("error updating response"), + }, + }, + "SuccessfullyAddConditions": { + reason: "Add Conditions Successfully", + args: args{ + rsp: &fnv1.RunFunctionResponse{}, + c: []TargetedCondition{ + { + Condition: xpv1.Condition{ + Message: "Creating Resource", + Status: v1.ConditionFalse, + Type: "NetworkReady", + }, + Target: CompositionTargetCompositeAndClaim, + }, + { + Condition: xpv1.Condition{ + Message: "Ready Message", + Status: v1.ConditionTrue, + Type: "DatabaseReady", + }, + Target: CompositionTargetComposite, + }, + { + Condition: xpv1.Condition{ + Message: "No Target should add CompositeAndClaim", + Status: v1.ConditionTrue, + Type: "NoTarget", + }, + }, + }, + }, + want: want{ + rsp: &fnv1.RunFunctionResponse{ + Conditions: []*fnv1.Condition{ + { + Message: ptr.To("Creating Resource"), + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "NetworkReady", + }, + { + Message: ptr.To("Ready Message"), + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + Type: "DatabaseReady", + }, + { + Message: ptr.To("No Target should add CompositeAndClaim"), + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "NoTarget", + }, + }, + }, + }, + }, + } + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := UpdateClaimConditions(tc.args.rsp, tc.args.c...) + if diff := cmp.Diff(tc.args.rsp, tc.want.rsp, cmpopts.IgnoreUnexported(fnv1.RunFunctionResponse{}, fnv1.Result{}, fnv1.Condition{})); diff != "" { + t.Errorf("%s\nUpdateClaimConditions(...): -want rsp, +got rsp:\n%s", tc.reason, diff) + } + if diff := cmp.Diff(tc.want.err, err, test.EquateErrors()); diff != "" { + t.Errorf("%s\nUpdateClaimConditions(...): -want err, +got err:\n%s", tc.reason, diff) + } + + }) + } +} + +func Test_transformCondition(t *testing.T) { + type args struct { + tc TargetedCondition + } + cases := map[string]struct { + reason string + args args + want *fnv1.Condition + }{ + "Basic": { + reason: "Basic Target", + args: args{ + tc: TargetedCondition{ + Condition: xpv1.Condition{ + Message: "Basic Message", + Status: v1.ConditionTrue, + Type: "TestType", + }, + Target: CompositionTargetComposite, + }, + }, + want: &fnv1.Condition{ + Message: ptr.To("Basic Message"), + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + Type: "TestType", + }, + }, + "Defaults": { + reason: "Default Settings", + args: args{ + tc: TargetedCondition{ + Condition: xpv1.Condition{}, + }, + }, + want: &fnv1.Condition{ + Status: fnv1.Status_STATUS_CONDITION_UNKNOWN, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + }, + }, + "StatusFalseNoTarget": { + reason: "When Status is false and no target set", + args: args{ + tc: TargetedCondition{ + Condition: xpv1.Condition{ + Message: "Basic Message", + Status: v1.ConditionFalse, + Type: "TestType", + }, + }, + }, + want: &fnv1.Condition{ + Message: ptr.To("Basic Message"), + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "TestType", + }, + }, + } + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + if got := transformCondition(tc.args.tc); !reflect.DeepEqual(got, tc.want) { + t.Errorf("transformCondition() = %v, want %v", got, tc.want) + } + }) + } +} + +func Test_transformTarget(t *testing.T) { + type args struct { + ct CompositionTarget + } + cases := map[string]struct { + reason string + args args + want *fnv1.Target + }{ + "DefaultToCompositeAndClaim": { + reason: "unknown target will default to CompositeAndClaim", + args: args{ + ct: "COMPOSE", + }, + want: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + }, + "Composite": { + reason: "Composite target correctly set", + args: args{ + ct: "Composite", + }, + want: fnv1.Target_TARGET_COMPOSITE.Enum(), + }, + "CompositeAndClaim": { + reason: "CompositeAndClaim target correctly set", + args: args{ + ct: "CompositeAndClaim", + }, + want: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + }, + } + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + if got := transformTarget(tc.args.ct); !reflect.DeepEqual(got, tc.want) { + t.Errorf("transformTarget() = %v, want %v", got, tc.want) + } + }) + } +} + +func Test_UpdateResponseWithCondition(t *testing.T) { + type args struct { + rsp *fnv1.RunFunctionResponse + c *fnv1.Condition + } + cases := map[string]struct { + reason string + args args + want *fnv1.RunFunctionResponse + }{ + "EmptyResponseNoConditions": { + reason: "When No Response or Conditions are provided, return a nil response", + args: args{}, + }, + "ResponseWithNoConditions": { + reason: "A response with no conditions should initialize an array before adding the condition", + args: args{ + rsp: &fnv1.RunFunctionResponse{}, + }, + want: &fnv1.RunFunctionResponse{ + Conditions: []*fnv1.Condition{}, + }, + }, + "ResponseAddCondition": { + reason: "A response with no conditions should initialize an array before adding the condition", + args: args{ + rsp: &fnv1.RunFunctionResponse{}, + c: &fnv1.Condition{ + Message: ptr.To("Basic Message"), + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "TestType", + }, + }, + want: &fnv1.RunFunctionResponse{ + Conditions: []*fnv1.Condition{ + { + Message: ptr.To("Basic Message"), + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "TestType", + }, + }, + }, + }, + "ResponseAppCondition": { + reason: "A response with existing conditions should append the condition", + args: args{ + rsp: &fnv1.RunFunctionResponse{ + Conditions: []*fnv1.Condition{ + { + Message: ptr.To("Existing Message"), + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + Type: "ExistingTestType", + }, + }, + }, + c: &fnv1.Condition{ + Message: ptr.To("Basic Message"), + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "TestType", + }, + }, + want: &fnv1.RunFunctionResponse{ + Conditions: []*fnv1.Condition{ + { + Message: ptr.To("Existing Message"), + Status: fnv1.Status_STATUS_CONDITION_TRUE, + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), + Type: "ExistingTestType", + }, + { + Message: ptr.To("Basic Message"), + Status: fnv1.Status_STATUS_CONDITION_FALSE, + Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Type: "TestType", + }, + }, + }, + }, + } + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + UpdateResponseWithCondition(tc.args.rsp, tc.args.c) + if diff := cmp.Diff(tc.args.rsp, tc.want, cmpopts.IgnoreUnexported(fnv1.RunFunctionResponse{}, fnv1.Condition{})); diff != "" { + t.Errorf("%s\nUpdateResponseWithCondition(...): -want rsp, +got rsp:\n%s", tc.reason, diff) + } + }) + } +} diff --git a/example/conditions/composition.yaml b/example/conditions/composition.yaml index 04c0af1..26f9da3 100644 --- a/example/conditions/composition.yaml +++ b/example/conditions/composition.yaml @@ -35,7 +35,7 @@ spec: status: "False" reason: InstallFail message: "failed to install" - target: ClaimAndComposite + target: CompositeAndClaim - type: ConditionTrue status: "True" reason: this condition is true diff --git a/fn.go b/fn.go index 835f1fd..fd1376d 100644 --- a/fn.go +++ b/fn.go @@ -198,9 +198,8 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) response.Fatal(rsp, errors.Wrap(err, "cannot get Conditions from input")) return rsp, nil } - rsp, err := UpdateClaimConditions(rsp, conditions...) + err := UpdateClaimConditions(rsp, conditions...) if err != nil { - response.Fatal(rsp, errors.Wrap(err, "cannot set ClaimCondition")) return rsp, nil } f.log.Debug("updating ClaimConditions", "conditions", rsp.Conditions) diff --git a/fn_test.go b/fn_test.go index a0331f4..11f69c4 100644 --- a/fn_test.go +++ b/fn_test.go @@ -42,7 +42,7 @@ var ( xrRecursiveTmpl = `{"apiVersion":"example.org/v1","kind":"XR","metadata":{"annotations":{"gotemplating.fn.crossplane.io/composition-resource-name":"recursive-xr"},"name":"recursive-xr","labels":{"belongsTo":{{.observed.composite.resource.metadata.name|quote}}}},"spec":{"count":2}}` claimConditions = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ClaimConditions","conditions":[{"type":"TestCondition","status":"False","reason":"InstallFail","message":"failed to install","target":"ClaimAndComposite"},{"type":"ConditionTrue","status":"True","reason":"this condition is true","message":"we are true","target":"Composite"},{"type":"DatabaseReady","status":"True","reason":"Ready","message":"Database is ready"}]}` - claimConditionsReservedKey = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ClaimConditions","conditions":[{"type":"Ready","tatus":"False","reason":"InstallFail","message":"I am using a reserved Condition","target":"ClaimAndComposite"}]}` + claimConditionsReservedKey = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ClaimConditions","conditions":[{"type":"Ready","status":"False","reason":"InstallFail","message":"I am using a reserved Condition","target":"ClaimAndComposite"}]}` extraResources = `{"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ExtraResources","requirements":{"cool-extra-resource":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchName":"cool-extra-resource"}}} {"apiVersion":"meta.gotemplating.fn.crossplane.io/v1alpha1","kind":"ExtraResources","requirements":{"another-cool-extra-resource":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchLabels":{"key": "value"}},"yet-another-cool-extra-resource":{"apiVersion":"example.org/v1","kind":"CoolExtraResource","matchName":"foo"}}} From 54705fe87b5b8c6059a314cf068bf28a79c37ca1 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Mon, 25 Nov 2024 09:53:23 -0600 Subject: [PATCH 12/13] default to Composite claimcondition Signed-off-by: Steven Borrelli --- claimconditions.go | 8 ++++---- claimconditions_test.go | 12 ++++++------ example/conditions/composition.yaml | 11 +++++++---- fn_test.go | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/claimconditions.go b/claimconditions.go index 6e8537b..3788e28 100644 --- a/claimconditions.go +++ b/claimconditions.go @@ -66,12 +66,12 @@ func transformCondition(tc TargetedCondition) *fnv1.Condition { } // transformTarget converts the input into a target Go SDK Enum -// Default to TARGET_COMPOSITE_AND_CLAIM +// Default to TARGET_COMPOSITE func transformTarget(ct CompositionTarget) *fnv1.Target { - if ct == CompositionTargetComposite { - return fnv1.Target_TARGET_COMPOSITE.Enum() + if ct == CompositionTargetCompositeAndClaim { + return fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum().Enum() } - return fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum() + return fnv1.Target_TARGET_COMPOSITE.Enum() } // UpdateResponseWithCondition updates the RunFunctionResponse with a Condition diff --git a/claimconditions_test.go b/claimconditions_test.go index f933f6e..d948d90 100644 --- a/claimconditions_test.go +++ b/claimconditions_test.go @@ -109,7 +109,7 @@ func Test_UpdateClaimConditions(t *testing.T) { { Message: ptr.To("No Target should add CompositeAndClaim"), Status: fnv1.Status_STATUS_CONDITION_TRUE, - Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), Type: "NoTarget", }, }, @@ -168,7 +168,7 @@ func Test_transformCondition(t *testing.T) { }, want: &fnv1.Condition{ Status: fnv1.Status_STATUS_CONDITION_UNKNOWN, - Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, "StatusFalseNoTarget": { @@ -185,7 +185,7 @@ func Test_transformCondition(t *testing.T) { want: &fnv1.Condition{ Message: ptr.To("Basic Message"), Status: fnv1.Status_STATUS_CONDITION_FALSE, - Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), Type: "TestType", }, }, @@ -208,12 +208,12 @@ func Test_transformTarget(t *testing.T) { args args want *fnv1.Target }{ - "DefaultToCompositeAndClaim": { - reason: "unknown target will default to CompositeAndClaim", + "DefaultToComposite": { + reason: "unknown target will default to Composite", args: args{ ct: "COMPOSE", }, - want: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + want: fnv1.Target_TARGET_COMPOSITE.Enum(), }, "Composite": { reason: "Composite target correctly set", diff --git a/example/conditions/composition.yaml b/example/conditions/composition.yaml index 26f9da3..7c23e6c 100644 --- a/example/conditions/composition.yaml +++ b/example/conditions/composition.yaml @@ -21,16 +21,19 @@ spec: apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1 kind: ClaimConditions conditions: + # Guide to ClaimConditions fields: # Type of the condition, e.g. DatabaseReady. # 'Healthy', 'Ready' and 'Synced' are reserved for use by Crossplane and this function will raise an error if used # - type: - # Status of the condition. + # Status of the condition. String of "True"/"False"/"Unknown" # status: - # Machine-readable PascalCase reason. + # Machine-readable PascalCase reason, for example "DatabaseReady" # reason: - # Optional Target. Publish Condition only to the Composite, or the Composite and the Claim. - # Defaults to CompositeAndClaim + # Optional Target. Publish Condition only to the Composite, or the Composite and the Claim (CompositeAndClaim). + # Defaults to Composite # target: + # Optional message: + # message: - type: TestCondition status: "False" reason: InstallFail diff --git a/fn_test.go b/fn_test.go index 11f69c4..227d208 100644 --- a/fn_test.go +++ b/fn_test.go @@ -683,7 +683,7 @@ func TestRunFunction(t *testing.T) { Status: fnv1.Status_STATUS_CONDITION_FALSE, Reason: "InstallFail", Message: ptr.To("failed to install"), - Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, { Type: "ConditionTrue", @@ -697,7 +697,7 @@ func TestRunFunction(t *testing.T) { Status: fnv1.Status_STATUS_CONDITION_TRUE, Reason: "Ready", Message: ptr.To("Database is ready"), - Target: fnv1.Target_TARGET_COMPOSITE_AND_CLAIM.Enum(), + Target: fnv1.Target_TARGET_COMPOSITE.Enum(), }, }, Meta: &fnv1.ResponseMeta{Ttl: durationpb.New(response.DefaultTTL)}, From 56034b634cdc491a4637191afa4c1155ef69c310 Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Mon, 25 Nov 2024 10:48:44 -0600 Subject: [PATCH 13/13] update docs Signed-off-by: Steven Borrelli --- README.md | 41 +++++++++++++++++++++++++++++ example/conditions/composition.yaml | 5 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 410a05e..595a4c4 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,47 @@ spec: For more information, see the example in [recursive](example/recursive). +## Setting Conditions on the Claim and Composite + +Starting with Crossplane 1.17, Composition authors can set custom Conditions on the +Composite and the Claim. + +Add a `ClaimConditions` to your template to set Conditions: + +```yaml +apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1 +kind: ClaimConditions +conditions: +# Guide to ClaimConditions fields: +# Type of the condition, e.g. DatabaseReady. +# 'Healthy', 'Ready' and 'Synced' are reserved for use by Crossplane and this function will raise an error if used +# - type: +# Status of the condition. String of "True"/"False"/"Unknown" +# status: +# Machine-readable PascalCase reason, for example "ErrorProvisioning" +# reason: +# Optional Target. Publish Condition only to the Composite, or the Composite and the Claim (CompositeAndClaim). +# Defaults to Composite +# target: +# Optional message: +# message: +- type: TestCondition + status: "False" + reason: InstallFail + message: "failed to install" + target: CompositeAndClaim +- type: ConditionTrue + status: "True" + reason: TrueCondition + message: we are true + target: Composite +- type: DatabaseReady + status: "True" + reason: Ready + message: Database is ready + target: CompositeAndClaim +``` + ## Additional functions | Name | Description | diff --git a/example/conditions/composition.yaml b/example/conditions/composition.yaml index 7c23e6c..d034db6 100644 --- a/example/conditions/composition.yaml +++ b/example/conditions/composition.yaml @@ -27,7 +27,7 @@ spec: # - type: # Status of the condition. String of "True"/"False"/"Unknown" # status: - # Machine-readable PascalCase reason, for example "DatabaseReady" + # Machine-readable PascalCase reason, for example "ErrorProvisioning" # reason: # Optional Target. Publish Condition only to the Composite, or the Composite and the Claim (CompositeAndClaim). # Defaults to Composite @@ -41,13 +41,14 @@ spec: target: CompositeAndClaim - type: ConditionTrue status: "True" - reason: this condition is true + reason: TrueCondition message: we are true target: Composite - type: DatabaseReady status: "True" reason: Ready message: Database is ready + target: CompositeAndClaim - step: automatically-detect-ready-composed-resources functionRef: name: crossplane-contrib-function-auto-ready