Skip to content

Commit c512771

Browse files
committed
Address code review comments
- Make registry field required - Replace custom bool comparison with library - Minor tweeks Signed-off-by: Ales Raszka <[email protected]>
1 parent f9297b6 commit c512771

File tree

9 files changed

+17
-20
lines changed

9 files changed

+17
-20
lines changed

apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ type BackupCronJobConfig struct {
8484
Schedule string `json:"schedule,omitempty"`
8585
// A registry where backup images are stored. Images are stored
8686
// in {registry}/backup-${DEVWORKSPACE_NAMESPACE}-${DEVWORKSPACE_NAME}
87-
// +kubebuilder:validation:Optional
87+
// +kubebuilder:validation:Required
8888
Registry string `json:"registry,omitempty"`
8989

9090
// RegistryAuthSecret is the name of a Kubernetes secret of

controllers/backupcronjob/backupcronjob_controller.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ import (
4646
"sigs.k8s.io/controller-runtime/pkg/predicate"
4747
)
4848

49-
const (
50-
defaultBackupImage = "registry.access.redhat.com/ubi8/ubi-minimal:latest"
51-
)
52-
5349
// BackupCronJobReconciler reconciles `BackupCronJob` configuration for the purpose of backing up workspace PVCs.
5450
type BackupCronJobReconciler struct {
5551
client.Client
@@ -76,24 +72,13 @@ func shouldReconcileOnUpdate(e event.UpdateEvent, log logr.Logger) bool {
7672
oldBackup := oldConfig.Config.Workspace.BackupCronJob
7773
newBackup := newConfig.Config.Workspace.BackupCronJob
7874

79-
differentBool := func(a, b *bool) bool {
80-
switch {
81-
case a == nil && b == nil:
82-
return false
83-
case a == nil || b == nil:
84-
return true
85-
default:
86-
return *a != *b
87-
}
88-
}
89-
9075
if oldBackup == nil && newBackup == nil {
9176
return false
9277
}
9378
if (oldBackup == nil && newBackup != nil) || (oldBackup != nil && newBackup == nil) {
9479
return true
9580
}
96-
if differentBool(oldBackup.Enable, newBackup.Enable) {
81+
if !ptr.Equal(oldBackup.Enable, newBackup.Enable) {
9782
return true
9883
}
9984

@@ -517,7 +502,7 @@ func (r *BackupCronJobReconciler) copySecret(workspace *dw.DevWorkspace, ctx con
517502
log := logger.WithName("copySecret")
518503
existingNamespaceSecret := &corev1.Secret{}
519504
err = r.NonCachingClient.Get(ctx, client.ObjectKey{
520-
Name: constants.DevWorkspaceBackuptAuthSecretName,
505+
Name: constants.DevWorkspaceBackupAuthSecretName,
521506
Namespace: workspace.Namespace}, existingNamespaceSecret)
522507
if client.IgnoreNotFound(err) != nil {
523508
log.Error(err, "Failed to check for existing registry auth secret in workspace namespace", "namespace", workspace.Namespace)
@@ -533,7 +518,7 @@ func (r *BackupCronJobReconciler) copySecret(workspace *dw.DevWorkspace, ctx con
533518
}
534519
namespaceSecret = &corev1.Secret{
535520
ObjectMeta: metav1.ObjectMeta{
536-
Name: constants.DevWorkspaceBackuptAuthSecretName,
521+
Name: constants.DevWorkspaceBackupAuthSecretName,
537522
Namespace: workspace.Namespace,
538523
Labels: map[string]string{
539524
constants.DevWorkspaceIDLabel: workspace.Status.DevWorkspaceId,

deploy/bundle/manifests/controller.devfile.io_devworkspaceoperatorconfigs.yaml

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

deploy/deployment/kubernetes/combined.yaml

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

deploy/deployment/kubernetes/objects/devworkspaceoperatorconfigs.controller.devfile.io.CustomResourceDefinition.yaml

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

deploy/deployment/openshift/combined.yaml

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

deploy/deployment/openshift/objects/devworkspaceoperatorconfigs.controller.devfile.io.CustomResourceDefinition.yaml

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

deploy/templates/crd/bases/controller.devfile.io_devworkspaceoperatorconfigs.yaml

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

pkg/constants/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@ const (
179179
// DevWorkspaceBackupJobLabel is the label key to identify backup jobs created for DevWorkspaces
180180
DevWorkspaceBackupJobLabel = "controller.devfile.io/backup-job"
181181

182-
DevWorkspaceBackuptAuthSecretName = "devworkspace-backup-registry-auth"
182+
DevWorkspaceBackupAuthSecretName = "devworkspace-backup-registry-auth"
183183
)

0 commit comments

Comments
 (0)