From bed2c396311e9592f4e97177ff76a19b7ba20a03 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 22 Aug 2018 10:24:26 +0200 Subject: [PATCH] Introduce new `CSIDriver` CRD API Object --- pkg/generated/openapi/BUILD | 1 + staging/src/BUILD | 1 + .../csi-api/pkg/apis/csi/v1alpha1/BUILD | 32 ++++++++ .../csi-api/pkg/apis/csi/v1alpha1/doc.go | 20 +++++ .../csi-api/pkg/apis/csi/v1alpha1/register.go | 50 ++++++++++++ .../csi-api/pkg/apis/csi/v1alpha1/types.go | 76 +++++++++++++++++++ 6 files changed, 180 insertions(+) create mode 100644 staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/BUILD create mode 100644 staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go create mode 100644 staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go create mode 100644 staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go diff --git a/pkg/generated/openapi/BUILD b/pkg/generated/openapi/BUILD index a0ec8037baa..81fe8ec9122 100644 --- a/pkg/generated/openapi/BUILD +++ b/pkg/generated/openapi/BUILD @@ -69,6 +69,7 @@ openapi_library( "k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1", "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1", "k8s.io/client-go/pkg/version", + "k8s.io/csi-api/pkg/apis/csi/v1alpha1", "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1", "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1", "k8s.io/metrics/pkg/apis/custom_metrics/v1beta1", diff --git a/staging/src/BUILD b/staging/src/BUILD index 85bc0a78580..45125449675 100644 --- a/staging/src/BUILD +++ b/staging/src/BUILD @@ -201,6 +201,7 @@ filegroup( "//staging/src/k8s.io/code-generator/hack:all-srcs", "//staging/src/k8s.io/code-generator/pkg/util:all-srcs", "//staging/src/k8s.io/code-generator/third_party/forked/golang/reflect:all-srcs", + "//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:all-srcs", "//staging/src/k8s.io/csi-api/pkg/client/listers/csi/v1alpha1:all-srcs", "//staging/src/k8s.io/kube-aggregator:all-srcs", "//staging/src/k8s.io/kube-proxy/config/v1alpha1:all-srcs", diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/BUILD b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/BUILD new file mode 100644 index 00000000000..8bc3380730a --- /dev/null +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/BUILD @@ -0,0 +1,32 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "register.go", + "types.go", + ], + importmap = "k8s.io/kubernetes/vendor/k8s.io/csi-api/pkg/apis/csi/v1alpha1", + importpath = "k8s.io/csi-api/pkg/apis/csi/v1alpha1", + visibility = ["//visibility:public"], + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go new file mode 100644 index 00000000000..b60c9314875 --- /dev/null +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package,register +// +groupName=csi.storage.k8s.io +// +k8s:openapi-gen=true +package v1alpha1 // import "k8s.io/csi-api/pkg/apis/csi/v1alpha1" diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go new file mode 100644 index 00000000000..e09f9ff1c4d --- /dev/null +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/register.go @@ -0,0 +1,50 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "csi.storage.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to the given scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &CSIDriver{}, + &CSIDriverList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go new file mode 100644 index 00000000000..c09f1bc105f --- /dev/null +++ b/staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1/types.go @@ -0,0 +1,76 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSIDriver captures information about a Container Storage Interface (CSI) +// volume driver deployed on the cluster. +// CSIDriver objects are non-namespaced. +type CSIDriver struct { + metav1.TypeMeta `json:",inline"` + + // Standard object metadata. + // metadata.Name indicates the name of the CSI driver that this object + // refers to; it MUST be the same name returned by the CSI GetPluginName() + // call for that driver. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Specification of the CSI Driver. + Spec CSIDriverSpec `json:"spec"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CSIDriverList is a collection of CSIDriver objects. +type CSIDriverList struct { + metav1.TypeMeta `json:",inline"` + + // Standard list metadata + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + + // Items is the list of CSIDriver + Items []CSIDriver `json:"items"` +} + +// CSIDriverSpec is the specification of a CSIDriver. +type CSIDriverSpec struct { + // Indicates this CSI volume driver requires an attach operation (because it + // implements the CSI ControllerPublishVolume() method), and that Kubernetes + // should call attach and wait for any attach operation to complete before + // proceeding to mounting. + // If value is not specified, default is false -- meaning attach will not be + // called. + // +optional + AttachRequired *bool `json:"attachRequired"` + + // Indicates this CSI volume driver requires additional pod information + // (like podName, podUID, etc.) during mount operations. + // If this is set to true, Kubelet will pass pod information as + // VolumeAttributes in the CSI NodePublishVolume() calls. + // If value is not specified, default is false -- meaning pod information + // will not be passed on mount. + // +optional + PodInfoRequiredOnMount *bool `json:"podInfoRequiredOnMount"` +}