Skip to content

Commit baa6d93

Browse files
committed
chore(vd): add comments, fix typos
Signed-off-by: Isteb4k <[email protected]> Signed-off-by: Isteb4k <[email protected]>
1 parent 035882b commit baa6d93

File tree

15 files changed

+21
-10
lines changed

15 files changed

+21
-10
lines changed

crds/clustervirtualimage.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ spec:
211211
status:
212212
description: Status of the condition, one of True, False, Unknown.
213213
type: string
214-
enum: [ "True", "False", "Unknown" ]
214+
enum: ["True", "False", "Unknown"]
215215
type:
216216
description: Type of condition.
217217
type: string

crds/virtualdisk.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ spec:
216216
status:
217217
description: Status of the condition, one of True, False, Unknown.
218218
type: string
219-
enum: [ "True", "False", "Unknown" ]
219+
enum: ["True", "False", "Unknown"]
220220
type:
221221
description: Type of condition.
222222
type: string

images/virtualization-artifact/pkg/controller/cvi/internal/datasource_ready.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"strings"
2423

2524
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2625
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -72,15 +71,15 @@ func (h DatasourceReadyHandler) Handle(ctx context.Context, cvi *virtv2.ClusterV
7271
case errors.Is(err, source.ErrSecretNotFound):
7372
condition.Status = metav1.ConditionFalse
7473
condition.Reason = cvicondition.DatasourceReadyReason_ContainerRegistrySecretNotFound
75-
condition.Message = strings.ToTitle(err.Error())
74+
condition.Message = service.CapitalizeFirstLetter(err.Error())
7675
case errors.As(err, &source.ImageNotReadyError{}):
7776
condition.Status = metav1.ConditionFalse
7877
condition.Reason = cvicondition.DatasourceReadyReason_ImageNotReady
79-
condition.Message = strings.ToTitle(err.Error())
78+
condition.Message = service.CapitalizeFirstLetter(err.Error())
8079
case errors.As(err, &source.ClusterImageNotReadyError{}):
8180
condition.Status = metav1.ConditionFalse
8281
condition.Reason = cvicondition.DatasourceReadyReason_ClusterImageNotReady
83-
condition.Message = strings.ToTitle(err.Error())
82+
condition.Message = service.CapitalizeFirstLetter(err.Error())
8483
}
8584

8685
return reconcile.Result{}, err

images/virtualization-artifact/pkg/controller/cvi/internal/source/http.go

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ func (ds HTTPDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualIma
7878

7979
cvi.Status.Phase = virtv2.ImageReady
8080

81+
// Unprotect import time supplements to delete them later.
8182
err = ds.importerService.Unprotect(ctx, pod)
8283
if err != nil {
8384
return false, err

images/virtualization-artifact/pkg/controller/cvi/internal/source/object_ref.go

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtu
8484

8585
cvi.Status.Phase = virtv2.ImageReady
8686

87+
// Unprotect import time supplements to delete them later.
8788
err = ds.importerService.Unprotect(ctx, pod)
8889
if err != nil {
8990
return false, err

images/virtualization-artifact/pkg/controller/cvi/internal/source/registry.go

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func (ds RegistryDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtua
8686

8787
cvi.Status.Phase = virtv2.ImageReady
8888

89+
// Unprotect import time supplements to delete them later.
8990
err = ds.importerService.Unprotect(ctx, pod)
9091
if err != nil {
9192
return false, err

images/virtualization-artifact/pkg/controller/cvi/internal/source/upload.go

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (ds UploadDataSource) Sync(ctx context.Context, cvi *virtv2.ClusterVirtualI
9393

9494
cvi.Status.Phase = virtv2.ImageReady
9595

96+
// Unprotect upload time supplements to delete them later.
9697
err = ds.uploaderService.Unprotect(ctx, pod, svc, ing)
9798
if err != nil {
9899
return false, err

images/virtualization-artifact/pkg/controller/vd/internal/deletion.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type DeletionHandler struct {
3030
sources *source.Sources
3131
}
3232

33-
func NewDeletionHandlerHandler(sources *source.Sources) *DeletionHandler {
33+
func NewDeletionHandler(sources *source.Sources) *DeletionHandler {
3434
return &DeletionHandler{
3535
sources: sources,
3636
}

images/virtualization-artifact/pkg/controller/vd/internal/source/blank.go

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func (ds BlankDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (boo
8989
condition.Message = ""
9090
}
9191

92+
// Protect Ready Disk and underlying PVC and PV.
9293
err = ds.diskService.Protect(ctx, vd, nil, pvc, pv)
9394
if err != nil {
9495
return false, err

images/virtualization-artifact/pkg/controller/vd/internal/source/http.go

+2
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ func (ds HTTPDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (bool
108108
condition.Message = ""
109109
}
110110

111+
// Protect Ready Disk and underlying PVC and PV.
111112
err = ds.diskService.Protect(ctx, vd, nil, pvc, pv)
112113
if err != nil {
113114
return false, err
114115
}
115116

117+
// Unprotect import time supplements to delete them later.
116118
err = ds.importerService.Unprotect(ctx, pod)
117119
if err != nil {
118120
return false, err

images/virtualization-artifact/pkg/controller/vd/internal/source/object_ref.go

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func (ds ObjectRefDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk)
9696
condition.Message = ""
9797
}
9898

99+
// Protect Ready Disk and underlying PVC and PV.
99100
err = ds.diskService.Protect(ctx, vd, nil, pvc, pv)
100101
if err != nil {
101102
return false, err

images/virtualization-artifact/pkg/controller/vd/internal/source/registry.go

+2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,13 @@ func (ds RegistryDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (
111111
condition.Message = ""
112112
}
113113

114+
// Protect Ready Disk and underlying PVC and PV.
114115
err = ds.diskService.Protect(ctx, vd, nil, pvc, pv)
115116
if err != nil {
116117
return false, err
117118
}
118119

120+
// Unprotect import time supplements to delete them later.
119121
err = ds.importerService.Unprotect(ctx, pod)
120122
if err != nil {
121123
return false, err

images/virtualization-artifact/pkg/controller/vd/internal/source/upload.go

+2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,13 @@ func (ds UploadDataSource) Sync(ctx context.Context, vd *virtv2.VirtualDisk) (bo
119119
condition.Message = ""
120120
}
121121

122+
// Protect Ready Disk and underlying PVC and PV.
122123
err = ds.diskService.Protect(ctx, vd, nil, pvc, pv)
123124
if err != nil {
124125
return false, err
125126
}
126127

128+
// Unprotect upload time supplements to delete them later.
127129
err = ds.uploaderService.Unprotect(ctx, pod, svc, ing)
128130
if err != nil {
129131
return false, err

images/virtualization-artifact/pkg/controller/vd/vd_controller.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewController(
7070
internal.NewDatasourceReadyHandler(blank, sources),
7171
internal.NewLifeCycleHandler(blank, sources, mgr.GetClient()),
7272
internal.NewResizingHandler(disk),
73-
internal.NewDeletionHandlerHandler(sources),
73+
internal.NewDeletionHandler(sources),
7474
internal.NewAttacheeHandler(mgr.GetClient()),
7575
)
7676

images/virtualization-artifact/pkg/controller/vd/vd_webhook.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ func (v *Validator) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Obj
105105
ready, _ := service.GetCondition(cvicondition.ReadyType, newVD.Status.Conditions)
106106
if newVD.Status.Phase == virtv2.DiskReady || newVD.Status.Phase == virtv2.DiskLost || ready.Status == metav1.ConditionTrue {
107107
if !reflect.DeepEqual(oldVD.Spec.DataSource, newVD.Spec.DataSource) {
108-
return nil, fmt.Errorf("VirtualDisk is in a Ready state: data source cannot be changed")
108+
return nil, fmt.Errorf("VirtualDisk has already been created: data source cannot be changed after disk is created")
109109
}
110110

111111
if !reflect.DeepEqual(oldVD.Spec.PersistentVolumeClaim.StorageClass, newVD.Spec.PersistentVolumeClaim.StorageClass) {
112-
return nil, fmt.Errorf("VirtualDisk is in a Ready state: storge class cannot be changed")
112+
return nil, fmt.Errorf("VirtualDisk has already been created: storage class cannot be changed after disk is created")
113113
}
114114
}
115115

0 commit comments

Comments
 (0)