Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add openAPIV3Schema to CRDs #56

Merged
merged 6 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ require (
k8s.io/apiextensions-apiserver v0.17.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.17.0
k8s.io/code-generator v0.17.0
k8s.io/klog v1.0.0
k8s.io/kube-aggregator v0.17.0
k8s.io/utils v0.0.0-20191114200735-6ca3b61696b6 // indirect
sigs.k8s.io/controller-tools v0.2.8
)
58 changes: 58 additions & 0 deletions go.sum

Large diffs are not rendered by default.

31 changes: 8 additions & 23 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,33 @@ THIS_REPO="github.com/kubernetes-sigs/kube-storage-version-migrator"
API_PKG="${THIS_REPO}/pkg/apis/migration/v1alpha1"
# Absolute path to this repo
THIS_REPO_ABSOLUTE="$(cd "$(dirname "${BASH_SOURCE}")/.." && pwd -P)"
WORK_DIR=`mktemp -d`

function cleanup {
rm -rf "$WORK_DIR"
}
trap cleanup EXIT
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen \
schemapatch:manifests="${THIS_REPO_ABSOLUTE}/manifests" \
paths="${THIS_REPO_ABSOLUTE}/pkg/apis/migration/v1alpha1" \
output:dir="${THIS_REPO_ABSOLUTE}/manifests"

# Install code generators
mkdir -p ${WORK_DIR}/go/src/k8s.io
pushd ${WORK_DIR}/go/src/k8s.io
git clone git@github.com:kubernetes/code-generator.git
popd
pushd ${WORK_DIR}/go/src/k8s.io/code-generator
# The version needs to match the one in Gopkg.toml
git checkout kubernetes-1.15.0-alpha.0
GOPATH=${WORK_DIR}/go/ go install k8s.io/code-generator/cmd/lister-gen
GOPATH=${WORK_DIR}/go/ go install k8s.io/code-generator/cmd/informer-gen
GOPATH=${WORK_DIR}/go/ go install k8s.io/code-generator/cmd/client-gen
GOPATH=${WORK_DIR}/go/ go install k8s.io/code-generator/cmd/deepcopy-gen
popd

${WORK_DIR}/go/bin/client-gen \
go run ./vendor/k8s.io/code-generator/cmd/client-gen \
--output-package "${THIS_REPO}/pkg/clients" \
--clientset-name="clientset" \
--input-base="${THIS_REPO}" \
--input="pkg/apis/migration/v1alpha1" \
--go-header-file "${THIS_REPO_ABSOLUTE}/hack/boilerplate/boilerplate.generatego.txt"

${WORK_DIR}/go/bin/lister-gen \
go run ./vendor/k8s.io/code-generator/cmd/lister-gen \
--output-package "${THIS_REPO}/pkg/clients/lister" \
--input-dirs="${API_PKG}" \
--go-header-file "${THIS_REPO_ABSOLUTE}/hack/boilerplate/boilerplate.generatego.txt"

${WORK_DIR}/go/bin/informer-gen \
go run ./vendor/k8s.io/code-generator/cmd/informer-gen \
--output-package "${THIS_REPO}/pkg/clients/informer" \
--input-dirs="${API_PKG}" \
--go-header-file "${THIS_REPO_ABSOLUTE}/hack/boilerplate/boilerplate.generatego.txt" \
--single-directory\
--versioned-clientset-package "${THIS_REPO}/pkg/clients/clientset" \
--listers-package "${THIS_REPO}/pkg/clients/lister"

${WORK_DIR}/go/bin/deepcopy-gen \
go run ./vendor/k8s.io/code-generator/cmd/deepcopy-gen \
--input-dirs="${API_PKG}" \
--output-file-base="zz_generated.deepcopy" \
--go-header-file "${THIS_REPO_ABSOLUTE}/hack/boilerplate/boilerplate.generatego.txt"
39 changes: 0 additions & 39 deletions manifests/crd.yaml

This file was deleted.

95 changes: 95 additions & 0 deletions manifests/storage_migration_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: storageversionmigrations.migration.k8s.io
spec:
group: migration.k8s.io
names:
kind: StorageVersionMigration
listKind: StorageVersionMigrationList
plural: storageversionmigrations
singular: storageversionmigration
scope: Cluster
subresources:
status: {}
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
"validation":
"openAPIV3Schema":
description: StorageVersionMigration represents a migration of stored data to
the latest storage version.
type: object
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: Specification of the migration.
type: object
required:
- resource
properties:
continueToken:
description: The token used in the list options to get the next chunk
of objects to migrate. When the .status.conditions indicates the migration
is "Running", users can use this token to check the progress of the
migration.
type: string
resource:
description: The resource that is being migrated. The migrator sends
requests to the endpoint serving the resource. Immutable.
type: object
properties:
group:
description: The name of the group.
type: string
resource:
description: The name of the resource.
type: string
version:
description: The name of the version.
type: string
status:
description: Status of the migration.
type: object
properties:
conditions:
description: The latest available observations of the migration's current
state.
type: array
items:
description: Describes the state of a migration at a certain point.
type: object
required:
- status
- type
properties:
lastUpdateTime:
description: The last time this condition was updated.
type: string
format: date-time
message:
description: A human readable message indicating details about
the transition.
type: string
reason:
description: The reason for the condition's last transition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of the condition.
type: string
79 changes: 79 additions & 0 deletions manifests/storage_state_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: storagestates.migration.k8s.io
spec:
group: migration.k8s.io
names:
kind: StorageState
listKind: StorageStateList
plural: storagestates
singular: storagestate
scope: Cluster
subresources:
status: {}
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
"validation":
"openAPIV3Schema":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why these two lines are quoted?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some encoding issue of the yaml library. We saw that before with controller-gen. Maybe @DirectXMan12 has an idea.

description: The state of the storage of a specific resource.
type: object
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:
description: The name must be "<.spec.resource.resouce>.<.spec.resource.group>".
type: object
spec:
description: Specification of the storage state.
type: object
properties:
resource:
description: The resource this storageState is about.
type: object
properties:
group:
description: The name of the group.
type: string
resource:
description: The name of the resource.
type: string
status:
description: Status of the storage state.
type: object
properties:
currentStorageVersionHash:
description: The hash value of the current storage version, as shown
in the discovery document served by the API server. Storage Version
is the version to which objects are converted to before persisted.
type: string
lastHeartbeatTime:
description: LastHeartbeatTime is the last time the storage migration
triggering controller checks the storage version hash of this resource
in the discovery document and updates this field.
type: string
format: date-time
persistedStorageVersionHashes:
description: The hash values of storage versions that persisted instances
of spec.resource might still be encoded in. "Unknown" is a valid value
in the list, and is the default value. It is not safe to upgrade or
downgrade to an apiserver binary that does not support all versions
listed in this field, or if "Unknown" is listed. Once the storage
version migration for this resource has completed, the value of this
field is refined to only contain the currentStorageVersionHash. Once
the apiserver has changed the storage version, the new storage version
is appended to the list.
type: array
items:
type: string
4 changes: 2 additions & 2 deletions pkg/apis/migration/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions pkg/clients/clientset/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pkg/clients/clientset/fake/clientset_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.