Skip to content

Commit

Permalink
Add APIConversion support
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>
  • Loading branch information
ncdc committed Oct 14, 2022
1 parent 473c2b1 commit e564b4f
Show file tree
Hide file tree
Showing 33 changed files with 2,265 additions and 135 deletions.
122 changes: 122 additions & 0 deletions config/crds/apis.kcp.dev_apiconversions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.10.0
creationTimestamp: null
name: apiconversions.apis.kcp.dev
spec:
group: apis.kcp.dev
names:
categories:
- kcp
kind: APIConversion
listKind: APIConversionList
plural: apiconversions
singular: apiconversion
scope: Cluster
versions:
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: APIConversion contains rules to convert between different API
versions in an APIResourceSchema. The name must match the name of the APIResourceSchema
for the conversions to take effect.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec holds the desired state.
properties:
conversions:
description: conversions specify rules to convert between different
API versions in an APIResourceSchema.
items:
description: APIVersionConversion contains rules to convert between
two specific API versions in an APIResourceSchema. Additionally,
to avoid data loss when round-tripping from a version that contains
a new field to one that doesn't and back again, you can specify
a list of fields to preserve (these are stored in annotations).
properties:
from:
description: from is the source version.
minLength: 1
pattern: ^v[1-9][0-9]*([a-z]+[1-9][0-9]*)?$
type: string
preserve:
description: preserve contains a list of JSONPath expressions
to fields to preserve in the originating version of the object,
relative to its, such as '.spec.name.first'.
items:
type: string
type: array
rules:
description: rules contains field-specific conversion expressions.
items:
description: APIConversionRule specifies how to convert a
single field.
properties:
destination:
description: destination is a JSONPath expression to the
field in the target version of the object, relative
to its root, such as '.spec.name.first'.
type: string
field:
description: field is a JSONPath expression to the field
in the originating version of the object, relative to
its root, such as '.spec.name.first'.
type: string
transformation:
description: transformation is an optional CEL expression
used to execute user-specified rules to transform the
originating field -- identified by 'self' -- to the
destination field.
type: string
required:
- destination
- field
type: object
type: array
x-kubernetes-list-map-keys:
- destination
x-kubernetes-list-type: map
to:
description: to is the target version.
minLength: 1
pattern: ^v[1-9][0-9]*([a-z]+[1-9][0-9]*)?$
type: string
required:
- from
- rules
- to
type: object
type: array
x-kubernetes-list-map-keys:
- from
- to
x-kubernetes-list-type: map
required:
- conversions
type: object
required:
- metadata
- spec
type: object
served: true
storage: true
subresources: {}
1 change: 1 addition & 0 deletions config/system-crds/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func Bootstrap(ctx context.Context, crdClient apiextensionsclient.Interface, dis
{Group: apis.GroupName, Resource: "apiexports"},
{Group: apis.GroupName, Resource: "apibindings"},
{Group: apis.GroupName, Resource: "apiresourceschemas"},
{Group: apis.GroupName, Resource: "apiconversions"},
}

if err := wait.PollImmediateInfiniteWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) {
Expand Down
56 changes: 28 additions & 28 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/fatih/color v1.12.0
github.com/go-logr/logr v1.2.3
github.com/google/cel-go v0.10.1
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.0
github.com/kcp-dev/apimachinery v0.0.0-20220912132244-efe716c18e43
Expand All @@ -32,6 +33,7 @@ require (
go.etcd.io/etcd/server/v3 v3.5.0
go.uber.org/multierr v1.7.0
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
gopkg.in/square/go-jose.v2 v2.2.2
k8s.io/api v0.24.3
k8s.io/apiextensions-apiserver v0.24.3
Expand Down Expand Up @@ -92,7 +94,6 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/cel-go v0.10.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand Down Expand Up @@ -167,7 +168,6 @@ require (
golang.org/x/tools v0.1.12 // indirect
gonum.org/v1/gonum v0.6.2 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand All @@ -191,30 +191,30 @@ require (

replace (
github.com/kcp-dev/kcp/pkg/apis => ./pkg/apis
k8s.io/api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/apiextensions-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/apimachinery => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/cli-runtime => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/client-go => github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/cloud-provider => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cloud-provider v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/cluster-bootstrap => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cluster-bootstrap v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/code-generator => github.com/kcp-dev/kubernetes/staging/src/k8s.io/code-generator v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/component-base => github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/component-helpers => github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/controller-manager => github.com/kcp-dev/kubernetes/staging/src/k8s.io/controller-manager v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/cri-api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/csi-translation-lib => github.com/kcp-dev/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kube-aggregator => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kube-controller-manager => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kube-proxy => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-proxy v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kube-scheduler => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-scheduler v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kubectl => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kubelet => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/kubernetes => github.com/kcp-dev/kubernetes v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/legacy-cloud-providers => github.com/kcp-dev/kubernetes/staging/src/k8s.io/legacy-cloud-providers v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/metrics => github.com/kcp-dev/kubernetes/staging/src/k8s.io/metrics v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/mount-utils => github.com/kcp-dev/kubernetes/staging/src/k8s.io/mount-utils v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/pod-security-admission => github.com/kcp-dev/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/sample-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20221005071841-6cfb7d485cbf
k8s.io/api => github.com/ncdc/kubernetes/staging/src/k8s.io/api v0.0.0-20221014211755-cf066b1323e1
k8s.io/apiextensions-apiserver => github.com/ncdc/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20221014211755-cf066b1323e1
k8s.io/apimachinery => github.com/ncdc/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20221014211755-cf066b1323e1
k8s.io/apiserver => github.com/ncdc/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20221014211755-cf066b1323e1
k8s.io/cli-runtime => github.com/ncdc/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20221014211755-cf066b1323e1
k8s.io/client-go => github.com/ncdc/kubernetes/staging/src/k8s.io/client-go v0.0.0-20221014211755-cf066b1323e1
k8s.io/cloud-provider => github.com/ncdc/kubernetes/staging/src/k8s.io/cloud-provider v0.0.0-20221014211755-cf066b1323e1
k8s.io/cluster-bootstrap => github.com/ncdc/kubernetes/staging/src/k8s.io/cluster-bootstrap v0.0.0-20221014211755-cf066b1323e1
k8s.io/code-generator => github.com/ncdc/kubernetes/staging/src/k8s.io/code-generator v0.0.0-20221014211755-cf066b1323e1
k8s.io/component-base => github.com/ncdc/kubernetes/staging/src/k8s.io/component-base v0.0.0-20221014211755-cf066b1323e1
k8s.io/component-helpers => github.com/ncdc/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20221014211755-cf066b1323e1
k8s.io/controller-manager => github.com/ncdc/kubernetes/staging/src/k8s.io/controller-manager v0.0.0-20221014211755-cf066b1323e1
k8s.io/cri-api => github.com/ncdc/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20221014211755-cf066b1323e1
k8s.io/csi-translation-lib => github.com/ncdc/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20221014211755-cf066b1323e1
k8s.io/kube-aggregator => github.com/ncdc/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20221014211755-cf066b1323e1
k8s.io/kube-controller-manager => github.com/ncdc/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20221014211755-cf066b1323e1
k8s.io/kube-proxy => github.com/ncdc/kubernetes/staging/src/k8s.io/kube-proxy v0.0.0-20221014211755-cf066b1323e1
k8s.io/kube-scheduler => github.com/ncdc/kubernetes/staging/src/k8s.io/kube-scheduler v0.0.0-20221014211755-cf066b1323e1
k8s.io/kubectl => github.com/ncdc/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20221014211755-cf066b1323e1
k8s.io/kubelet => github.com/ncdc/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20221014211755-cf066b1323e1
k8s.io/kubernetes => github.com/ncdc/kubernetes v0.0.0-20221014211755-cf066b1323e1
k8s.io/legacy-cloud-providers => github.com/ncdc/kubernetes/staging/src/k8s.io/legacy-cloud-providers v0.0.0-20221014211755-cf066b1323e1
k8s.io/metrics => github.com/ncdc/kubernetes/staging/src/k8s.io/metrics v0.0.0-20221014211755-cf066b1323e1
k8s.io/mount-utils => github.com/ncdc/kubernetes/staging/src/k8s.io/mount-utils v0.0.0-20221014211755-cf066b1323e1
k8s.io/pod-security-admission => github.com/ncdc/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0-20221014211755-cf066b1323e1
k8s.io/sample-apiserver => github.com/ncdc/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20221014211755-cf066b1323e1
)
Loading

0 comments on commit e564b4f

Please sign in to comment.