openshift / openshift/oadp-operator
Clean up credentials related code
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 92
- Forks
- 93
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 43
Description
Credentials are used by BackupStorageLocation (BSL) and VolumeSnapshotLocation (VSL)
- confirm that no other part of OADP uses credentials code
- should
controllers/registry.gobe deleted/moved topkg/credentials/credentials.go?
in controllers/bsl.go
-
https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L72-L74 is duplication of https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L415
-
https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L81-L83 is duplication of https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L386
-
these functions all have duplication
https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L268
https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L299
https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L330move it to this function https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L361 (but remove secret validation from it, it already done by other part of the code)
-
should this only be called if
!(dpa.Spec.Configuration.Velero.HasFeatureFlag("no-secret"))? https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L123-L127 -
remove validation from this function, it was done previously https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/bsl.go#L194
in controllers/registry.go
- are not these duplication from
api/v1alpha1/oadp_types.go? https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/registry.go#L55 - this function should not patch secret every time https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/registry.go#L216 move patching code to validation part
- delete this code https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/registry.go#L264-L270 and
docs/developer/testing/ MULTI_CLOUD_TESTING_UPDATES.mdfile - 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 https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/validator.go#L74 credentials should have been already validated previously
in controllers/vsl.go
- duplication from
controllers/registry.gohttps://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/vsl.go#L18 - duplication from function pluginExistsInVeleroCR in
controllers/bsl.gohttps://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/controllers/vsl.go#L256
in pkg/credentials/credentials.go
- delete https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/pkg/credentials/credentials.go#L77
- delete https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/pkg/credentials/credentials.go#L358 duplication from registry.go
- remove duplication in https://github.com/openshift/oadp-operator/blob/91e1aacf47ea2b44bafdb9d6d3c14ffee6907baf/pkg/credentials/credentials.go#L389
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing credential handling across controllers/bsl.go, controllers/registry.go, controllers/validator.go, controllers/vsl.go, pkg/credentials/credentials.go, and api/v1alpha1/oadp_types.go. Review the linked locations and existing validation paths first; done means the listed duplication, unnecessary patching, obsolete code, and credential-checking gaps have been resolved consistently across BSL and VSL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devops, security
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100