Skip to content

Commit

Permalink
Merge pull request #93 from sttts/sttts-codegen-1.16
Browse files Browse the repository at this point in the history
hack/update-codegen.sh: add -mod=vendor to work with recent Golang
  • Loading branch information
k8s-ci-robot committed Apr 21, 2021
2 parents be91cbb + a8e94f9 commit acdee30
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_output
22 changes: 17 additions & 5 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,44 @@ API_PKG="${THIS_REPO}/pkg/apis/migration/v1alpha1"
# Absolute path to this repo
THIS_REPO_ABSOLUTE="$(cd "$(dirname "${BASH_SOURCE}")/.." && pwd -P)"

go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen \
mkdir -p _output
go run -mod=vendor ./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"

go run ./vendor/k8s.io/code-generator/cmd/client-gen \
# download and run yaml-patch to add the metadata.name schema. Kubebuilder's controller-tools lacks
# experessivity for that.
curl -s -f -L https://github.com/krishicks/yaml-patch/releases/download/v0.0.10/yaml_patch_$(go env GOHOSTOS) -o _output/yaml-patch
chmod +x _output/yaml-patch
for m in "${THIS_REPO_ABSOLUTE}/manifests/"*.yaml; do
if [ -f "${m}-patch" ]; then
_output/yaml-patch -o "${m}-patch" < "${m}" > "_output/$(basename "${m}")"
mv _output/$(basename "${m}") "${THIS_REPO_ABSOLUTE}/manifests"
fi
done

go run -mod=vendor ./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"

go run ./vendor/k8s.io/code-generator/cmd/lister-gen \
go run -mod=vendor ./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"

go run ./vendor/k8s.io/code-generator/cmd/informer-gen \
go run -mod=vendor ./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"

go run ./vendor/k8s.io/code-generator/cmd/deepcopy-gen \
go run -mod=vendor ./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"
14 changes: 7 additions & 7 deletions manifests/storage_migration_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spec:
status: {}
schema:
openAPIV3Schema:
description: StorageVersionMigration represents a migration of stored data to
the latest storage version.
description: StorageVersionMigration represents a migration of stored data
to the latest storage version.
type: object
properties:
apiVersion:
Expand All @@ -45,9 +45,9 @@ spec:
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.
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
Expand All @@ -68,8 +68,8 @@ spec:
type: object
properties:
conditions:
description: The latest available observations of the migration's current
state.
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.
Expand Down
44 changes: 22 additions & 22 deletions manifests/storage_state_crd.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: storagestates.migration.k8s.io
annotations:
"api-approved.kubernetes.io": "https://github.com/kubernetes/enhancements/pull/747"
api-approved.kubernetes.io: https://github.com/kubernetes/enhancements/pull/747
name: storagestates.migration.k8s.io
spec:
group: migration.k8s.io
names:
kind: StorageState
listKind: StorageStateList
plural: storagestates
singular: storagestate
scope: Cluster
preserveUnknownFields: false
scope: Cluster
versions:
- name: v1alpha1
served: true
storage: true
subresources:
status: {}
schema:
openAPIV3Schema:
description: The state of the storage of a specific resource.
type: object
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -35,28 +30,27 @@ spec:
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
properties:
name:
description: The name must be "<.spec.resource.resouce>.<.spec.resource.group>".
description: name must be "<.spec.resource.resouce>.<.spec.resource.group>".
type: string
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
type: object
type: object
status:
description: Status of the storage state.
type: object
properties:
currentStorageVersionHash:
description: The hash value of the current storage version, as shown
Expand All @@ -67,18 +61,24 @@ spec:
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
type: string
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
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
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.
items:
type: string
type: array
type: object
type: object
served: true
storage: true
subresources:
status: {}
6 changes: 6 additions & 0 deletions manifests/storage_state_crd.yaml-patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- op: add
path: /spec/versions/name=v1alpha1/schema/openAPIV3Schema/properties/metadata/properties
value:
name:
description: name must be "<.spec.resource.resouce>.<.spec.resource.group>".
type: string
1 change: 0 additions & 1 deletion pkg/apis/migration/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ type StorageVersionMigrationList struct {
// The state of the storage of a specific resource.
type StorageState struct {
metav1.TypeMeta `json:",inline"`
// The name must be "<.spec.resource.resouce>.<.spec.resource.group>".
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the storage state.
Expand Down
2 changes: 1 addition & 1 deletion pkg/clients/clientset/fake/register.go

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

3 changes: 3 additions & 0 deletions pkg/clients/lister/migration/v1alpha1/storagestate.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.

0 comments on commit acdee30

Please sign in to comment.