Skip to content

Commit

Permalink
Fix lint warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
draghuram authored and JerusJ committed Jan 24, 2020
1 parent c4accf4 commit 365ff71
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 126 deletions.
1 change: 1 addition & 0 deletions kubedr/api/v1alpha1/backuplocation_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
// log is for logging in this package.
var backuplocationlog = logf.Log.WithName("backuplocation-resource")

// Configures the web hook with the manager.
func (r *BackupLocation) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
1 change: 1 addition & 0 deletions kubedr/api/v1alpha1/metadatabackuppolicy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
// log is for logging in this package.
var log = logf.Log.WithName("metadatabackuppolicy-resource")

// Configures the web hook with the manager.
func (r *MetadataBackupPolicy) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(r).
Expand Down
2 changes: 1 addition & 1 deletion kubedr/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: kubedr
newTag: "0.53"
newTag: "0.54"
34 changes: 18 additions & 16 deletions kubedr/controllers/backuplocation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func ignoreNotFound(err error) error {
return err
}

// In case of some errors such as "not found" and "already exist",
// In case of some errors such as "not found" and "already exists",
// there is no point in requeuing the reconcile.
// See https://github.com/kubernetes-sigs/controller-runtime/issues/377
func ignoreErrors(err error) error {
Expand Down Expand Up @@ -89,6 +89,7 @@ func (r *BackupLocationReconciler) setStatus(backupLoc *kubedrv1alpha1.BackupLoc
}
}

// The main reconcile entry point called by the framework.
func (r *BackupLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
ctx := context.Background()
log := r.Log.WithValues("backuplocation", req.NamespacedName)
Expand All @@ -100,7 +101,7 @@ func (r *BackupLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
// requeue (we'll need to wait for a new notification).
log.Info("BackupLocation (" + req.NamespacedName.Name + ") is not found")
return ctrl.Result{}, nil
}
}

log.Error(err, "unable to fetch BackupLocation")
return ctrl.Result{}, err
Expand Down Expand Up @@ -138,9 +139,9 @@ func (r *BackupLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, err
// Check annotations to see if repo is already initialized.
// Ideally, we should check the repo itself to confirm that it is
// initialized, instead of depending on annotation.
init_annotation := "initialized.annotations.kubedr.catalogicsoftware.com"
initAnnotation := "initialized.annotations.kubedr.catalogicsoftware.com"

initialized, exists := backupLoc.ObjectMeta.Annotations[init_annotation]
initialized, exists := backupLoc.ObjectMeta.Annotations[initAnnotation]
if exists && (initialized == "true") {
// No need to initialize the repo.
log.Info("Repo is already initialized")
Expand Down Expand Up @@ -203,17 +204,17 @@ func buildResticRepoInitPod(cr *kubedrv1alpha1.BackupLocation, log logr.Logger)
"kubedr.backuploc": cr.Name,
}

access_key := corev1.SecretKeySelector{}
access_key.Name = cr.Spec.Credentials
access_key.Key = "access_key"
accessKey := corev1.SecretKeySelector{}
accessKey.Name = cr.Spec.Credentials
accessKey.Key = "access_key"

secret_key := corev1.SecretKeySelector{}
secret_key.Name = cr.Spec.Credentials
secret_key.Key = "secret_key"
secretKey := corev1.SecretKeySelector{}
secretKey.Name = cr.Spec.Credentials
secretKey.Key = "secret_key"

restic_password := corev1.SecretKeySelector{}
restic_password.Name = cr.Spec.Credentials
restic_password.Key = "restic_repo_password"
resticPassword := corev1.SecretKeySelector{}
resticPassword.Name = cr.Spec.Credentials
resticPassword.Key = "restic_repo_password"

return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -233,19 +234,19 @@ func buildResticRepoInitPod(cr *kubedrv1alpha1.BackupLocation, log logr.Logger)
{
Name: "AWS_ACCESS_KEY",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &access_key,
SecretKeyRef: &accessKey,
},
},
{
Name: "AWS_SECRET_KEY",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &secret_key,
SecretKeyRef: &secretKey,
},
},
{
Name: "RESTIC_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &restic_password,
SecretKeyRef: &resticPassword,
},
},
{
Expand All @@ -264,6 +265,7 @@ func buildResticRepoInitPod(cr *kubedrv1alpha1.BackupLocation, log logr.Logger)
}, nil
}

// Hooks up this controller with the manager.
func (r *BackupLocationReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&kubedrv1alpha1.BackupLocation{}).
Expand Down
Loading

0 comments on commit 365ff71

Please sign in to comment.