Skip to content

Commit d0157b6

Browse files
committed
Fix API review comments for CnsNodeVMBatachAttachment API
1 parent f85c5ff commit d0157b6

File tree

10 files changed

+171
-159
lines changed

10 files changed

+171
-159
lines changed

pkg/apis/cnsoperator/cnsnodevmbatchattachment/v1alpha1/cnsnodebatchvmattachment_types.go

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,35 @@ import (
2121
)
2222

2323
// DiskMode describes the desired mode to use when attaching the volume.
24+
// +kubebuilder:validation:Enum=independent_persistent;persistent
2425
type DiskMode string
2526

2627
const (
27-
// By setting DiskMode to independent_persistent, a virtual machine's disk is not captured in snapshots and
28+
// IndependentPersistent is the diskMode in which, a virtual machine's disk is not captured in snapshots and
2829
// changes are permanently written to the disk, regardless of snapshot operations.
2930
IndependentPersistent DiskMode = "independent_persistent"
30-
// Changes are immediately and permanently written to the virtual disk.
31+
// Persistent diskMode changes are immediately and permanently written to the virtual disk.
3132
Persistent DiskMode = "persistent"
3233
)
3334

34-
// The sharing mode of the virtual disk.
35+
// SharingMode is the sharing mode of the virtual disk.
36+
// +kubebuilder:validation:Enum=sharingMultiWriter;sharingNone
3537
type SharingMode string
3638

3739
const (
38-
// The virtual disk is shared between multiple virtual machines.
40+
// SharingMultiWriter: The virtual disk is shared between multiple virtual machines.
3941
SharingMultiWriter SharingMode = "sharingMultiWriter"
40-
// The virtual disk is not shared.
42+
// SharingNone: The virtual disk is not shared.
4143
SharingNone SharingMode = "sharingNone"
4244
)
4345

44-
// CnsNodeVmBatchAttachmentSpec defines the desired state of CnsNodeVmBatchAttachment
46+
// CnsNodeVMBatchAttachmentSpec defines the desired state of CnsNodeVMBatchAttachment
4547
// +k8s:openapi-gen=true
46-
type CnsNodeVmBatchAttachmentSpec struct {
48+
type CnsNodeVMBatchAttachmentSpec struct {
49+
// +required
4750
// NodeUUID indicates the UUID of the node where the volume needs to be attached to.
4851
// Here NodeUUID is the instance UUID of the node.
49-
NodeUUID string `json:"nodeuuid"`
52+
NodeUUID string `json:"nodeUUID"`
5053

5154
// +listType=map
5255
// +listMapKey=name
@@ -63,20 +66,25 @@ type VolumeSpec struct {
6366

6467
type PersistentVolumeClaimSpec struct {
6568
// ClaimName is the PVC name.
69+
// +required
6670
ClaimName string `json:"claimName"`
6771
// DiskMode is the desired mode to use when attaching the volume
72+
// +optional
6873
DiskMode DiskMode `json:"diskMode,omitempty"`
69-
// SharingMode indicates the shraring mode if the virtual disk while attaching.
74+
// SharingMode indicates the sharing mode if the virtual disk while attaching.
75+
// +optional
7076
SharingMode SharingMode `json:"sharingMode,omitempty"`
7177
// ControllerKey is the object key for the controller object for this device.
78+
// +optional
7279
ControllerKey string `json:"controllerKey,omitempty"`
7380
// UnitNumber of this device on its controller.
81+
// +optional
7482
UnitNumber string `json:"unitNumber,omitempty"`
7583
}
7684

77-
// CnsNodeVmBatchAttachmentStatus defines the observed state of CnsNodeVmBatchAttachment
85+
// CnsNodeVMBatchAttachmentStatus defines the observed state of CnsNodeVMBatchAttachment
7886
// +k8s:openapi-gen=true
79-
type CnsNodeVmBatchAttachmentStatus struct {
87+
type CnsNodeVMBatchAttachmentStatus struct {
8088
// Error is the overall error status for the instance.
8189
Error string `json:"error,omitempty"`
8290
// +listType=map
@@ -95,6 +103,7 @@ type VolumeStatus struct {
95103
type PersistentVolumeClaimStatus struct {
96104
// ClaimName is the PVC name.
97105
ClaimName string `json:"claimName"`
106+
// Attached indicates the attach status of a PVC.
98107
// If volume is not attached, Attached will be set to false.
99108
// If volume is attached, Attached will be set to true.
100109
// If volume is detached successfully, its entry will be removed from VolumeStatus.
@@ -103,30 +112,33 @@ type PersistentVolumeClaimStatus struct {
103112
Error string `json:"error,omitempty"`
104113
// CnsVolumeID is the volume ID for the PVC.
105114
CnsVolumeID string `json:"cnsVolumeId,omitempty"`
106-
// Diskuuid is the ID obtained when volume is attached to a VM.
107-
Diskuuid string `json:"diskuuid,omitempty"`
115+
// DiskUUID is the ID obtained when volume is attached to a VM.
116+
DiskUUID string `json:"DiskUUID,omitempty"`
108117
}
109118

110119
// +genclient
111120
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
112121

113122
// +k8s:openapi-gen=true
114123
// +kubebuilder:subresource:status
124+
// +kubebuilder:object:root=true
125+
// +kubebuilder:resource:shortName=batchattach
126+
// +kubebuilder:printcolumn:name="NodeUUID",type="string",JSONPath=".spec.nodeUUID"
115127

116-
// CnsNodeVmBatchAttachment is the Schema for the cnsnodevmbatchattachments API
117-
type CnsNodeVmBatchAttachment struct {
128+
// CnsNodeVMBatchAttachment is the Schema for the cnsnodevmbatchattachments API
129+
type CnsNodeVMBatchAttachment struct {
118130
metav1.TypeMeta `json:",inline"`
119131
metav1.ObjectMeta `json:"metadata,omitempty"`
120132

121-
Spec CnsNodeVmBatchAttachmentSpec `json:"spec,omitempty"`
122-
Status CnsNodeVmBatchAttachmentStatus `json:"status,omitempty"`
133+
Spec CnsNodeVMBatchAttachmentSpec `json:"spec,omitempty"`
134+
Status CnsNodeVMBatchAttachmentStatus `json:"status,omitempty"`
123135
}
124136

125137
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
126138

127-
// CnsNodeVmBatchAttachmentList contains a list of CnsNodeVmBatchAttachment
128-
type CnsNodeVmBatchAttachmentList struct {
139+
// CnsNodeVMBatchAttachmentList contains a list of CnsNodeVMBatchAttachment
140+
type CnsNodeVMBatchAttachmentList struct {
129141
metav1.TypeMeta `json:",inline"`
130142
metav1.ListMeta `json:"metadata,omitempty"`
131-
Items []CnsNodeVmBatchAttachment `json:"items"`
143+
Items []CnsNodeVMBatchAttachment `json:"items"`
132144
}

pkg/apis/cnsoperator/cnsnodevmbatchattachment/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/cnsoperator/config/cns.vmware.com_cnsnodevmbatchattachments.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ metadata:
88
spec:
99
group: cns.vmware.com
1010
names:
11-
kind: CnsNodeVmBatchAttachment
12-
listKind: CnsNodeVmBatchAttachmentList
11+
kind: CnsNodeVMBatchAttachment
12+
listKind: CnsNodeVMBatchAttachmentList
1313
plural: cnsnodevmbatchattachments
1414
singular: cnsnodevmbatchattachment
1515
scope: Namespaced
1616
versions:
1717
- name: v1alpha1
1818
schema:
1919
openAPIV3Schema:
20-
description: CnsNodeVmBatchAttachment is the Schema for the cnsnodevmbatchattachments
20+
description: CnsNodeVMBatchAttachment is the Schema for the cnsnodevmbatchattachments
2121
API
2222
properties:
2323
apiVersion:
@@ -38,8 +38,8 @@ spec:
3838
metadata:
3939
type: object
4040
spec:
41-
description: CnsNodeVmBatchAttachmentSpec defines the desired state of
42-
CnsNodeVmBatchAttachment
41+
description: CnsNodeVMBatchAttachmentSpec defines the desired state of
42+
CnsNodeVMBatchAttachment
4343
properties:
4444
nodeuuid:
4545
description: |-
@@ -69,7 +69,7 @@ spec:
6969
the volume
7070
type: string
7171
sharingMode:
72-
description: SharingMode indicates the shraring mode if
72+
description: SharingMode indicates the sharing mode if
7373
the virtual disk while attaching.
7474
type: string
7575
unitNumber:
@@ -91,8 +91,8 @@ spec:
9191
- volumes
9292
type: object
9393
status:
94-
description: CnsNodeVmBatchAttachmentStatus defines the observed state
95-
of CnsNodeVmBatchAttachment
94+
description: CnsNodeVMBatchAttachmentStatus defines the observed state
95+
of CnsNodeVMBatchAttachment
9696
properties:
9797
error:
9898
description: Error is the overall error status for the instance.

pkg/apis/cnsoperator/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var EmbedCnsNodeVmAttachmentCRFile embed.FS
88
const EmbedCnsNodeVmAttachmentCRFileName = "cns.vmware.com_cnsnodevmattachments.yaml"
99

1010
//go:embed cns.vmware.com_cnsnodevmbatchattachments.yaml
11-
var EmbedCnsNodeVmBatchAttachmentCRFile embed.FS
11+
var EmbedCnsNodeVMBatchAttachmentCRFile embed.FS
1212

1313
const EmbedCnsNodeVmABatchttachmentCRFileName = "cns.vmware.com_cnsnodevmbatchattachments.yaml"
1414

pkg/apis/cnsoperator/register.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ var (
5151
CnsNodeVMAttachmentSingular = "cnsnodevmattachment"
5252
// CnsNodeVMAttachmentPlural is plural of CnsNodeVmAttachment
5353
CnsNodeVMAttachmentPlural = "cnsnodevmattachments"
54-
// CnsNodeVmBatchAttachmentPlural is plural of CnsNodeVmBatchAttachment
55-
CnsNodeVmBatchAttachmentPlural = "cnsnodevmbatchattachments"
54+
// CnsNodeVMBatchAttachmentPlural is plural of CnsNodeVMBatchAttachment
55+
CnsNodeVMBatchAttachmentPlural = "cnsnodevmbatchattachments"
5656
// CnsVolumeMetadataSingular is Singular of CnsVolumeMetadata
5757
CnsVolumeMetadataSingular = "cnsvolumemetadata"
5858
// CnsVolumeMetadataPlural is plural of CnsVolumeMetadata
@@ -133,8 +133,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
133133

134134
scheme.AddKnownTypes(
135135
SchemeGroupVersion,
136-
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVmBatchAttachment{},
137-
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVmBatchAttachmentList{},
136+
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVMBatchAttachment{},
137+
&cnsnodevmbatchattachmentv1alpha1.CnsNodeVMBatchAttachmentList{},
138138
)
139139

140140
scheme.AddKnownTypes(

pkg/common/cns-lib/volume/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141
type BatchAttachRequest struct {
4242
// The volume ID for the given PVC.
4343
VolumeID string
44-
// SharingMode indicates the shraring mode if the virtual disk while attaching.
44+
// SharingMode indicates the sharing mode if the virtual disk while attaching.
4545
SharingMode string
4646
// DiskMode is the desired mode to use when attaching the volume
4747
DiskMode string

0 commit comments

Comments
 (0)