sslobodr | d046be8 | 2019-01-16 10:02:22 -0500 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package v1alpha1 |
| 18 | |
| 19 | import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 20 | |
| 21 | // +genclient |
| 22 | // +genclient:nonNamespaced |
| 23 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 24 | |
| 25 | // VolumeAttachment captures the intent to attach or detach the specified volume |
| 26 | // to/from the specified node. |
| 27 | // |
| 28 | // VolumeAttachment objects are non-namespaced. |
| 29 | type VolumeAttachment struct { |
| 30 | metav1.TypeMeta `json:",inline"` |
| 31 | |
| 32 | // Standard object metadata. |
| 33 | // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata |
| 34 | // +optional |
| 35 | metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 36 | |
| 37 | // Specification of the desired attach/detach volume behavior. |
| 38 | // Populated by the Kubernetes system. |
| 39 | Spec VolumeAttachmentSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` |
| 40 | |
| 41 | // Status of the VolumeAttachment request. |
| 42 | // Populated by the entity completing the attach or detach |
| 43 | // operation, i.e. the external-attacher. |
| 44 | // +optional |
| 45 | Status VolumeAttachmentStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` |
| 46 | } |
| 47 | |
| 48 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 49 | |
| 50 | // VolumeAttachmentList is a collection of VolumeAttachment objects. |
| 51 | type VolumeAttachmentList struct { |
| 52 | metav1.TypeMeta `json:",inline"` |
| 53 | // Standard list metadata |
| 54 | // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata |
| 55 | // +optional |
| 56 | metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` |
| 57 | |
| 58 | // Items is the list of VolumeAttachments |
| 59 | Items []VolumeAttachment `json:"items" protobuf:"bytes,2,rep,name=items"` |
| 60 | } |
| 61 | |
| 62 | // VolumeAttachmentSpec is the specification of a VolumeAttachment request. |
| 63 | type VolumeAttachmentSpec struct { |
| 64 | // Attacher indicates the name of the volume driver that MUST handle this |
| 65 | // request. This is the name returned by GetPluginName(). |
| 66 | Attacher string `json:"attacher" protobuf:"bytes,1,opt,name=attacher"` |
| 67 | |
| 68 | // Source represents the volume that should be attached. |
| 69 | Source VolumeAttachmentSource `json:"source" protobuf:"bytes,2,opt,name=source"` |
| 70 | |
| 71 | // The node that the volume should be attached to. |
| 72 | NodeName string `json:"nodeName" protobuf:"bytes,3,opt,name=nodeName"` |
| 73 | } |
| 74 | |
| 75 | // VolumeAttachmentSource represents a volume that should be attached. |
| 76 | // Right now only PersistenVolumes can be attached via external attacher, |
| 77 | // in future we may allow also inline volumes in pods. |
| 78 | // Exactly one member can be set. |
| 79 | type VolumeAttachmentSource struct { |
| 80 | // Name of the persistent volume to attach. |
| 81 | // +optional |
| 82 | PersistentVolumeName *string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"` |
| 83 | |
| 84 | // Placeholder for *VolumeSource to accommodate inline volumes in pods. |
| 85 | } |
| 86 | |
| 87 | // VolumeAttachmentStatus is the status of a VolumeAttachment request. |
| 88 | type VolumeAttachmentStatus struct { |
| 89 | // Indicates the volume is successfully attached. |
| 90 | // This field must only be set by the entity completing the attach |
| 91 | // operation, i.e. the external-attacher. |
| 92 | Attached bool `json:"attached" protobuf:"varint,1,opt,name=attached"` |
| 93 | |
| 94 | // Upon successful attach, this field is populated with any |
| 95 | // information returned by the attach operation that must be passed |
| 96 | // into subsequent WaitForAttach or Mount calls. |
| 97 | // This field must only be set by the entity completing the attach |
| 98 | // operation, i.e. the external-attacher. |
| 99 | // +optional |
| 100 | AttachmentMetadata map[string]string `json:"attachmentMetadata,omitempty" protobuf:"bytes,2,rep,name=attachmentMetadata"` |
| 101 | |
| 102 | // The last error encountered during attach operation, if any. |
| 103 | // This field must only be set by the entity completing the attach |
| 104 | // operation, i.e. the external-attacher. |
| 105 | // +optional |
| 106 | AttachError *VolumeError `json:"attachError,omitempty" protobuf:"bytes,3,opt,name=attachError,casttype=VolumeError"` |
| 107 | |
| 108 | // The last error encountered during detach operation, if any. |
| 109 | // This field must only be set by the entity completing the detach |
| 110 | // operation, i.e. the external-attacher. |
| 111 | // +optional |
| 112 | DetachError *VolumeError `json:"detachError,omitempty" protobuf:"bytes,4,opt,name=detachError,casttype=VolumeError"` |
| 113 | } |
| 114 | |
| 115 | // VolumeError captures an error encountered during a volume operation. |
| 116 | type VolumeError struct { |
| 117 | // Time the error was encountered. |
| 118 | // +optional |
| 119 | Time metav1.Time `json:"time,omitempty" protobuf:"bytes,1,opt,name=time"` |
| 120 | |
| 121 | // String detailing the error encountered during Attach or Detach operation. |
| 122 | // This string maybe logged, so it should not contain sensitive |
| 123 | // information. |
| 124 | // +optional |
| 125 | Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` |
| 126 | } |