Skip to content

Commit

Permalink
chore: bump kcl version to 0.10.x and add dependency examples
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Sep 18, 2024
1 parent 474ac7b commit 3a4418a
Show file tree
Hide file tree
Showing 9 changed files with 261 additions and 101 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

env:
# Common versions
GO_VERSION: '1.22'
GO_VERSION: '1.23'
GOLANGCI_VERSION: 'v1.54.2'
DOCKER_BUILDX_VERSION: 'v0.11.2'

Expand All @@ -35,7 +35,7 @@ env:
XPKG: xpkg.upbound.io/${{ github.repository}}

# The package version to push. The default is 0.0.0-gitsha.
XPKG_VERSION: v0.9.4
XPKG_VERSION: v0.10.0

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [ main ]

env:
GO_VERSION: '1.22'
GO_VERSION: '1.23'

jobs:
test:
Expand Down
2 changes: 2 additions & 0 deletions examples/default/dependencies/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run:
crossplane beta render xr.yaml composition.yaml functions.yaml -r
85 changes: 85 additions & 0 deletions examples/default/dependencies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Example Manifests

You can run your function locally and test it using `crossplane beta render`
with these example manifests.

```shell
# Run the function locally
$ go run . --insecure --debug
```

```shell
# Then, in another terminal, call it with these example manifests
$ crossplane beta render xr.yaml composition.yaml functions.yaml -r
---
apiVersion: example.crossplane.io/v1beta1
kind: XR
metadata:
name: example
---
apiVersion: pkg.crossplane.io/v1beta1
kind: DeploymentRuntimeConfig
metadata:
annotations:
crossplane.io/composition-resource-name: provider-helm
generateName: example-
labels:
crossplane.io/composite: example
name: provider-helm
ownerReferences:
- apiVersion: example.crossplane.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: XR
name: example
uid: ""
spec:
serviceAccountTemplate:
metadata:
name: provider-helm
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
crossplane.io/composition-resource-name: provider-helm-cluster-admin
generateName: example-
labels:
crossplane.io/composite: example
name: provider-helm-cluster-admin
ownerReferences:
- apiVersion: example.crossplane.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: XR
name: example
uid: ""
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: provider-helm-cluster-admin
subjects:
- kind: ServiceAccount
name: provider-helm
namespace: crossplane-system
---
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
annotations:
crossplane.io/composition-resource-name: helm-provider
generateName: example-
labels:
crossplane.io/composite: example
name: helm-provider
ownerReferences:
- apiVersion: example.crossplane.io/v1beta1
blockOwnerDeletion: true
controller: true
kind: XR
name: example
uid: ""
spec:
credentials:
source: InjectedIdentity
```
61 changes: 61 additions & 0 deletions examples/default/dependencies/composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: function-template-go
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: XR
mode: Pipeline
pipeline:
- step: normal
functionRef:
name: kcl-function
input:
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLInput
metadata:
name: basic
spec:
dependencies: |
k8s = "1.31"
crossplane = "1.16.0"
source: |
import k8s.api.rbac.v1 as k8srbac
import crossplane.v1 as cpv1
import crossplane.v1beta1 as cpv1beta1
items = [
cpv1.Provider {
metadata.name = "provider-helm"
spec: {
package = "xpkg.upbound.io/crossplane-contrib/provider-helm:v0.19.0"
runtimeConfigRef.name = "provider-helm"
}
}
cpv1beta1.DeploymentRuntimeConfig {
metadata.name = "provider-helm"
spec: {
serviceAccountTemplate: {metadata.name = "provider-helm"}
}
}
k8srbac.ClusterRoleBinding {
metadata.name = "provider-helm-cluster-admin"
subjects: [{
kind = "ServiceAccount"
name = "provider-helm"
namespace = "crossplane-system"
}]
roleRef: {
kind = "ClusterRole"
name = "provider-helm-cluster-admin"
apiGroup = "rbac.authorization.k8s.io"
}
}
cpv1beta1.ProviderConfig {
metadata.name = "helm-provider"
spec = {
credentials.source = "InjectedIdentity"
}
}
]
9 changes: 9 additions & 0 deletions examples/default/dependencies/functions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: kcl-function
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-kcl:latest
6 changes: 6 additions & 0 deletions examples/default/dependencies/xr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: example.crossplane.io/v1beta1
kind: XR
metadata:
name: example
spec:
count: 1
56 changes: 27 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/crossplane-contrib/function-kcl

go 1.22.4

toolchain go1.22.6
go 1.23

require (
dario.cat/mergo v1.0.1
Expand All @@ -13,8 +11,8 @@ require (
github.com/pkg/errors v0.9.1
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v2 v2.4.0
k8s.io/apimachinery v0.31.0
kcl-lang.io/krm-kcl v0.9.3
k8s.io/apimachinery v0.31.1
kcl-lang.io/krm-kcl v0.10.0
sigs.k8s.io/controller-tools v0.16.2
sigs.k8s.io/yaml v1.4.0
)
Expand Down Expand Up @@ -47,7 +45,7 @@ require (
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containers/image/v5 v5.32.0 // indirect
github.com/containers/image/v5 v5.32.2 // indirect
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.2.0 // indirect
github.com/containers/storage v1.55.0 // indirect
Expand All @@ -62,7 +60,7 @@ require (
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dominikbraun/graph v0.23.0 // indirect
github.com/elliotchance/orderedmap/v2 v2.2.0 // indirect
github.com/elliotchance/orderedmap/v2 v2.4.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emicklei/proto v1.13.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
Expand All @@ -81,7 +79,7 @@ require (
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/analysis v0.23.0 // indirect
github.com/go-openapi/errors v0.22.0 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-openapi/inflect v0.21.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/loads v0.22.0 // indirect
Expand All @@ -106,7 +104,7 @@ require (
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.5 // indirect
github.com/hashicorp/go-getter v1.7.6 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
Expand Down Expand Up @@ -147,7 +145,7 @@ require (
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/powerman/rpc-codec v1.2.2 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_golang v1.20.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand Down Expand Up @@ -178,42 +176,42 @@ require (
go.opentelemetry.io/otel/trace v1.28.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.22.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/time v0.5.0 // indirect
golang.org/x/tools v0.24.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.6.0 // indirect
golang.org/x/tools v0.25.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
google.golang.org/grpc v1.66.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.31.0 // indirect
k8s.io/api v0.31.1 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/apiserver v0.31.0 // indirect
k8s.io/client-go v0.31.0 // indirect
k8s.io/client-go v0.31.1 // indirect
k8s.io/component-base v0.31.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-20240711033017-18e509b52bc8 // indirect
kcl-lang.io/cli v0.9.8 // indirect
kcl-lang.io/kcl-go v0.9.3 // indirect
kcl-lang.io/kcl-openapi v0.6.6 // indirect
kcl-lang.io/kpm v0.9.8 // indirect
kcl-lang.io/lib v0.9.3 // indirect
kcl-lang.io/cli v0.10.0 // indirect
kcl-lang.io/kcl-go v0.10.1 // indirect
kcl-lang.io/kcl-openapi v0.9.0 // indirect
kcl-lang.io/kpm v0.10.0 // indirect
kcl-lang.io/lib v0.10.0 // indirect
oras.land/oras-go v1.2.6 // indirect
oras.land/oras-go/v2 v2.5.0 // indirect
sigs.k8s.io/controller-runtime v0.18.4 // indirect
sigs.k8s.io/controller-runtime v0.19.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/kyaml v0.17.2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
Loading

0 comments on commit 3a4418a

Please sign in to comment.