Clean up credentials related code
Opened this issue · 3 comments
Credentials are used by BackupStorageLocation (BSL) and VolumeSnapshotLocation (VSL)
- confirm that no other part of OADP uses credentials code
- should
controllers/registry.go
be deleted/moved topkg/credentials/credentials.go
?
in controllers/bsl.go
-
oadp-operator/controllers/bsl.go
Lines 72 to 74 in 91e1aac
oadp-operator/controllers/bsl.go
Line 415 in 91e1aac
-
oadp-operator/controllers/bsl.go
Lines 81 to 83 in 91e1aac
oadp-operator/controllers/bsl.go
Line 386 in 91e1aac
-
these functions all have duplication
oadp-operator/controllers/bsl.go
Line 268 in 91e1aac
oadp-operator/controllers/bsl.go
Line 299 in 91e1aac
oadp-operator/controllers/bsl.go
Line 330 in 91e1aac
move it to this function
oadp-operator/controllers/bsl.go
Line 361 in 91e1aac
-
should this only be called if
!(dpa.Spec.Configuration.Velero.HasFeatureFlag("no-secret"))
?oadp-operator/controllers/bsl.go
Lines 123 to 127 in 91e1aac
-
remove validation from this function, it was done previously
oadp-operator/controllers/bsl.go
Line 194 in 91e1aac
in controllers/registry.go
- are not these duplication from
api/v1alpha1/oadp_types.go
?oadp-operator/controllers/registry.go
Line 55 in 91e1aac
- this function should not patch secret every time
oadp-operator/controllers/registry.go
Line 216 in 91e1aac
- delete this code
oadp-operator/controllers/registry.go
Lines 264 to 270 in 91e1aac
docs/developer/testing/ MULTI_CLOUD_TESTING_UPDATES.md
file - verify credential function should check all cases
// add doc comments!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
func (r *DPAReconciler) verifyCredential(credential *corev1.SecretKeySelector, provider oadpv1alpha1.DefaultPlugin, location string) error {
var credentialName string
var credentialKey string
if credential != nil {
// Check if user specified empty credential name
if credential.Name == "" {
return fmt.Errorf("credential name specified in %s cannot be empty", location)
} else {
credentialName = credential.Name
}
// Check if user specified empty credential key
if credential.Key == "" {
return fmt.Errorf("credential key specified in %s cannot be empty", location)
} else {
credentialKey = credential.Key
}
} else {
if provider != "" {
// Assume default values
credentialName = credentials.PluginSpecificFields[provider].SecretName
credentialKey = credentials.PluginSpecificFields[provider].PluginSecretKey
} else {
// cloud storage case
return fmt.Errorf("must provide a valid credential secret")
}
}
secret, err := r.getProviderSecret(credentialName)
if err != nil {
return err
}
// need???
// if secret.Name == "" {
// return false, errors.New("secret not found")
// }
data, foundKey := secret.Data[credentialKey]
if !foundKey || len(data) == 0 {
return fmt.Errorf("Secret name %s is missing data for key %s", credentialName, credentialKey)
}
return nil
}
in controllers/validator.go
- delete this function
oadp-operator/controllers/validator.go
Line 74 in 91e1aac
in controllers/vsl.go
- duplication from
controllers/registry.go
oadp-operator/controllers/vsl.go
Line 18 in 91e1aac
- duplication from function pluginExistsInVeleroCR in
controllers/bsl.go
oadp-operator/controllers/vsl.go
Line 256 in 91e1aac
in pkg/credentials/credentials.go
- delete
- delete
oadp-operator/pkg/credentials/credentials.go
Line 358 in 91e1aac
- remove duplication in
oadp-operator/pkg/credentials/credentials.go
Line 389 in 91e1aac
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
/lifecycle frozen