openshift / openshift/oadp-operator

Clean up credentials related code

Open
#1,336 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lifecycle/frozen
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.go be deleted/moved to pkg/credentials/credentials.go?

in controllers/bsl.go

in controllers/registry.go

// 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

in controllers/vsl.go

in pkg/credentials/credentials.go

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.