Skip to content

Commit 48602bc

Browse files
committed
Update to function-sdk-go 0.5.0
Signed-off-by: Bob Haddleton <[email protected]>
1 parent 4b72837 commit 48602bc

File tree

13 files changed

+227
-237
lines changed

13 files changed

+227
-237
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414

1515
env:
1616
# Common versions
17-
GO_VERSION: '1.23.12'
18-
GOLANGCI_VERSION: 'v1.62.0'
17+
GO_VERSION: '1.24.9'
18+
GOLANGCI_VERSION: 'v2.4.0'
1919
DOCKER_BUILDX_VERSION: 'v0.23.0'
2020

2121
# These environment variables are important to the Crossplane CLI install.sh
@@ -53,7 +53,7 @@ jobs:
5353
run: go mod tidy && git diff --exit-code go.mod go.sum
5454

5555
- name: Lint
56-
uses: golangci/golangci-lint-action@v6
56+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
5757
with:
5858
version: ${{ env.GOLANGCI_VERSION }}
5959

claimconditions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package main
22

33
import (
4-
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
4+
xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1"
55
"github.com/crossplane/function-sdk-go/errors"
66
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
77
"github.com/crossplane/function-sdk-go/response"
@@ -43,8 +43,8 @@ func UpdateClaimConditions(rsp *fnv1.RunFunctionResponse, conditions ...Targeted
4343
// transformCondition converts a TargetedCondition to be compatible with the Protobuf SDK
4444
func transformCondition(tc TargetedCondition) *fnv1.Condition {
4545
c := &fnv1.Condition{
46-
Type: string(tc.Condition.Type),
47-
Reason: string(tc.Condition.Reason),
46+
Type: string(tc.Type),
47+
Reason: string(tc.Reason),
4848
Target: transformTarget(tc.Target),
4949
}
5050

claimconditions_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"reflect"
55
"testing"
66

7-
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
8-
"github.com/crossplane/crossplane-runtime/pkg/test"
7+
xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1"
8+
"github.com/crossplane/crossplane-runtime/v2/pkg/test"
99
"github.com/crossplane/function-sdk-go/errors"
1010
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
1111
"github.com/google/go-cmp/cmp"

context_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"testing"
55

6-
"github.com/crossplane/crossplane-runtime/pkg/logging"
6+
"github.com/crossplane/crossplane-runtime/v2/pkg/logging"
77
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
88
"github.com/crossplane/function-sdk-go/resource"
99
"github.com/google/go-cmp/cmp"

extraresources.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"maps"
66

7-
"github.com/crossplane/crossplane-runtime/pkg/errors"
7+
"github.com/crossplane/crossplane-runtime/v2/pkg/errors"
88
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
99
"github.com/crossplane/function-sdk-go/request"
1010
"github.com/crossplane/function-sdk-go/response"
@@ -55,14 +55,14 @@ func (e *ExtraResourcesRequirement) ToResourceSelector() *fnv1.ResourceSelector
5555
}
5656

5757
func mergeExtraResourcesToContext(req *fnv1.RunFunctionRequest, rsp *fnv1.RunFunctionResponse) error {
58-
b, err := json.Marshal(req.ExtraResources)
58+
b, err := json.Marshal(req.RequiredResources)
5959
if err != nil {
60-
return errors.Errorf("cannot marshal %T: %w", req.ExtraResources, err)
60+
return errors.Errorf("cannot marshal %T: %w", req.RequiredResources, err)
6161
}
6262

6363
s := &structpb.Struct{}
6464
if err := protojson.Unmarshal(b, s); err != nil {
65-
return errors.Errorf("cannot unmarshal %T into %T: %w", req.ExtraResources, s, err)
65+
return errors.Errorf("cannot unmarshal %T into %T: %w", req.RequiredResources, s, err)
6666
}
6767

6868
extraResourcesFromContext, exists := request.GetContextKey(req, extraResourcesContextKey)

fn.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"k8s.io/apimachinery/pkg/util/json"
1919
"k8s.io/apimachinery/pkg/util/yaml"
2020

21-
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
22-
"github.com/crossplane/crossplane-runtime/pkg/meta"
21+
"github.com/crossplane/crossplane-runtime/v2/pkg/fieldpath"
22+
"github.com/crossplane/crossplane-runtime/v2/pkg/meta"
2323

2424
"github.com/crossplane/function-sdk-go/errors"
2525
"github.com/crossplane/function-sdk-go/logging"
@@ -134,12 +134,12 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
134134
if yamlErr == (YamlErrorContext{}) {
135135
newErr = err
136136
} else {
137-
context := strings.TrimSpace(yamlErr.Context)
138-
if len(context) > 80 {
139-
context = context[:80] + "..."
137+
ctx := strings.TrimSpace(yamlErr.Context)
138+
if len(ctx) > 80 {
139+
ctx = ctx[:80] + "..."
140140
}
141141

142-
newErr = fmt.Errorf("error converting YAML to JSON: yaml: line %d (document %d, line %d) near: '%s': %s", yamlErr.AbsLine, docIndex+1, yamlErr.RelLine, context, yamlErr.Message)
142+
newErr = fmt.Errorf("error converting YAML to JSON: yaml: line %d (document %d, line %d) near: '%s': %s", yamlErr.AbsLine, docIndex+1, yamlErr.RelLine, ctx, yamlErr.Message)
143143
}
144144

145145
response.Fatal(rsp, errors.Wrap(newErr, "cannot decode manifest"))
@@ -187,7 +187,7 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
187187
}
188188

189189
// Initialize the requirements.
190-
requirements := &fnv1.Requirements{ExtraResources: make(map[string]*fnv1.ResourceSelector)}
190+
requirements := &fnv1.Requirements{Resources: make(map[string]*fnv1.ResourceSelector)}
191191

192192
// Convert the rendered manifests to a list of desired composed resources.
193193
for _, obj := range objs {
@@ -274,11 +274,11 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
274274
return rsp, nil
275275
}
276276
for k, v := range ers {
277-
if _, found := requirements.ExtraResources[k]; found {
277+
if _, found := requirements.Resources[k]; found {
278278
response.Fatal(rsp, errors.Errorf("duplicate extra resource key %q", k))
279279
return rsp, nil
280280
}
281-
requirements.ExtraResources[k] = v.ToResourceSelector()
281+
requirements.Resources[k] = v.ToResourceSelector()
282282
}
283283
default:
284284
response.Fatal(rsp, errors.Errorf("invalid kind %q for apiVersion %q - must be one of CompositeConnectionDetails, Context or ExtraResources", obj.GetKind(), metaApiVersion))
@@ -327,11 +327,11 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
327327
return rsp, nil
328328
}
329329

330-
if len(requirements.ExtraResources) > 0 {
330+
if len(requirements.Resources) > 0 {
331331
rsp.Requirements = requirements
332332
}
333333

334-
if len(req.ExtraResources) > 0 {
334+
if len(req.RequiredResources) > 0 {
335335
err = mergeExtraResourcesToContext(req, rsp)
336336
if err != nil {
337337
return rsp, nil

fn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"google.golang.org/protobuf/types/known/durationpb"
1313
"k8s.io/utils/ptr"
1414

15-
"github.com/crossplane/crossplane-runtime/pkg/logging"
15+
"github.com/crossplane/crossplane-runtime/v2/pkg/logging"
1616

1717
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
1818
"github.com/crossplane/function-sdk-go/resource"

function_maps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
sprig "github.com/Masterminds/sprig/v3"
1111
"github.com/crossplane-contrib/function-go-templating/input/v1beta1"
12-
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
13-
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
12+
xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1"
13+
"github.com/crossplane/crossplane-runtime/v2/pkg/fieldpath"
1414
"github.com/crossplane/function-sdk-go/errors"
1515
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
1616
"google.golang.org/protobuf/encoding/protojson"

function_maps_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/google/go-cmp/cmp/cmpopts"
1010
"google.golang.org/protobuf/testing/protocmp"
1111

12-
v1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
12+
v1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1"
1313
fnv1 "github.com/crossplane/function-sdk-go/proto/v1"
1414
)
1515

go.mod

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,95 @@
11
module github.com/crossplane-contrib/function-go-templating
22

3-
go 1.23.12
3+
go 1.24.9
44

55
require (
66
dario.cat/mergo v1.0.2
77
github.com/Masterminds/sprig/v3 v3.3.0
88
github.com/alecthomas/kong v1.12.1
9-
github.com/crossplane/crossplane-runtime v1.20.0
10-
github.com/crossplane/function-sdk-go v0.4.0
9+
github.com/crossplane/crossplane-runtime/v2 v2.0.0
10+
github.com/crossplane/function-sdk-go v0.5.0
1111
github.com/google/go-cmp v0.7.0
1212
google.golang.org/protobuf v1.36.10
1313
gopkg.in/yaml.v3 v3.0.1
14-
k8s.io/api v0.31.0
15-
k8s.io/apimachinery v0.31.0
14+
k8s.io/api v0.33.0
15+
k8s.io/apimachinery v0.33.0
1616
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
17-
sigs.k8s.io/controller-tools v0.16.0
17+
sigs.k8s.io/controller-tools v0.18.0
1818
)
1919

2020
require (
2121
github.com/Masterminds/goutils v1.1.1 // indirect
2222
github.com/Masterminds/semver/v3 v3.3.1 // indirect
23+
github.com/beorn7/perks v1.0.1 // indirect
24+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2325
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
24-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
26+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
2527
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
26-
github.com/fatih/color v1.17.0 // indirect
27-
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
28+
github.com/fatih/color v1.18.0 // indirect
29+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
2830
github.com/go-json-experiment/json v0.0.0-20240815175050-ebd3a8989ca1 // indirect
29-
github.com/go-logr/logr v1.4.2 // indirect
31+
github.com/go-logr/logr v1.4.3 // indirect
3032
github.com/go-logr/zapr v1.3.0 // indirect
31-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
32-
github.com/go-openapi/jsonreference v0.20.2 // indirect
33-
github.com/go-openapi/swag v0.22.4 // indirect
34-
github.com/gobuffalo/flect v1.0.2 // indirect
33+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
34+
github.com/go-openapi/jsonreference v0.21.0 // indirect
35+
github.com/go-openapi/swag v0.23.0 // indirect
36+
github.com/gobuffalo/flect v1.0.3 // indirect
3537
github.com/gogo/protobuf v1.3.2 // indirect
36-
github.com/golang/protobuf v1.5.4 // indirect
37-
github.com/google/gnostic-models v0.6.8 // indirect
38-
github.com/google/gofuzz v1.2.0 // indirect
38+
github.com/google/gnostic-models v0.7.0 // indirect
3939
github.com/google/uuid v1.6.0 // indirect
40+
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 // indirect
41+
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
4042
github.com/huandu/xstrings v1.5.0 // indirect
4143
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4244
github.com/josharian/intern v1.0.0 // indirect
4345
github.com/json-iterator/go v1.1.12 // indirect
4446
github.com/mailru/easyjson v0.7.7 // indirect
45-
github.com/mattn/go-colorable v0.1.13 // indirect
47+
github.com/mattn/go-colorable v0.1.14 // indirect
4648
github.com/mattn/go-isatty v0.0.20 // indirect
4749
github.com/mitchellh/copystructure v1.2.0 // indirect
4850
github.com/mitchellh/reflectwalk v1.0.2 // indirect
4951
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
50-
github.com/modern-go/reflect2 v1.0.2 // indirect
52+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
5153
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
5254
github.com/pkg/errors v0.9.1 // indirect
53-
github.com/rogpeppe/go-internal v1.13.1 // indirect
55+
github.com/prometheus/client_golang v1.22.0 // indirect
56+
github.com/prometheus/client_model v0.6.1 // indirect
57+
github.com/prometheus/common v0.62.0 // indirect
58+
github.com/prometheus/procfs v0.15.1 // indirect
5459
github.com/shopspring/decimal v1.4.0 // indirect
55-
github.com/spf13/afero v1.11.0 // indirect
60+
github.com/spf13/afero v1.12.0 // indirect
5661
github.com/spf13/cast v1.7.0 // indirect
57-
github.com/spf13/cobra v1.8.1 // indirect
58-
github.com/spf13/pflag v1.0.5 // indirect
62+
github.com/spf13/cobra v1.10.1 // indirect
63+
github.com/spf13/pflag v1.0.10 // indirect
5964
github.com/x448/float16 v0.8.4 // indirect
6065
go.uber.org/multierr v1.11.0 // indirect
6166
go.uber.org/zap v1.27.0 // indirect
62-
golang.org/x/crypto v0.36.0 // indirect
63-
golang.org/x/mod v0.21.0 // indirect
64-
golang.org/x/net v0.38.0 // indirect
65-
golang.org/x/oauth2 v0.27.0 // indirect
66-
golang.org/x/sync v0.12.0 // indirect
67-
golang.org/x/sys v0.31.0 // indirect
68-
golang.org/x/term v0.30.0 // indirect
69-
golang.org/x/text v0.23.0 // indirect
70-
golang.org/x/time v0.5.0 // indirect
71-
golang.org/x/tools v0.25.0 // indirect
72-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
73-
google.golang.org/grpc v1.67.0 // indirect
67+
go.yaml.in/yaml/v2 v2.4.2 // indirect
68+
go.yaml.in/yaml/v3 v3.0.4 // indirect
69+
golang.org/x/crypto v0.43.0 // indirect
70+
golang.org/x/mod v0.29.0 // indirect
71+
golang.org/x/net v0.46.0 // indirect
72+
golang.org/x/oauth2 v0.30.0 // indirect
73+
golang.org/x/sync v0.17.0 // indirect
74+
golang.org/x/sys v0.37.0 // indirect
75+
golang.org/x/term v0.36.0 // indirect
76+
golang.org/x/text v0.30.0 // indirect
77+
golang.org/x/time v0.11.0 // indirect
78+
golang.org/x/tools v0.38.0 // indirect
79+
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated // indirect
80+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251007200510-49b9836ed3ff // indirect
81+
google.golang.org/grpc v1.75.1 // indirect
7482
gopkg.in/inf.v0 v0.9.1 // indirect
7583
gopkg.in/yaml.v2 v2.4.0 // indirect
76-
k8s.io/apiextensions-apiserver v0.31.0 // indirect
77-
k8s.io/client-go v0.31.0 // indirect
84+
k8s.io/apiextensions-apiserver v0.33.0 // indirect
85+
k8s.io/client-go v0.33.0 // indirect
86+
k8s.io/code-generator v0.33.0 // indirect
87+
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f // indirect
7888
k8s.io/klog/v2 v2.130.1 // indirect
79-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
89+
k8s.io/kube-openapi v0.0.0-20250701173324-9bd5c66d9911 // indirect
8090
sigs.k8s.io/controller-runtime v0.19.0 // indirect
81-
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
82-
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
91+
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
92+
sigs.k8s.io/randfill v1.0.0 // indirect
93+
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
8394
sigs.k8s.io/yaml v1.4.0 // indirect
8495
)

0 commit comments

Comments
 (0)