mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
cleanup: address golangci 'funcorder' linter problems
The new 'funcorder' linter expects all public functions to be placed before private functions of a struct. Many private functions needed moving further down into their files. Some files had many issues reported. To reduce the churn in those files, they have been annotated with a `//nolint:funcorder` comment. Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
0907f39d95
commit
0a22e3a186
@ -116,53 +116,6 @@ func initSecretsMetadataKMS(args ProviderInitArgs) (EncryptionKMS, error) {
|
||||
return smKMS, nil
|
||||
}
|
||||
|
||||
// fetchEncryptionPassphrase fetches encryptionPassphrase from user provided secret.
|
||||
func (kms secretsMetadataKMS) fetchEncryptionPassphrase(
|
||||
config map[string]interface{},
|
||||
defaultNamespace string,
|
||||
) (string, error) {
|
||||
var (
|
||||
secretName string
|
||||
secretNamespace string
|
||||
)
|
||||
|
||||
err := setConfigString(&secretName, config, metadataSecretNameKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = setConfigString(&secretNamespace, config, metadataSecretNamespaceKey)
|
||||
if err != nil {
|
||||
if !errors.Is(err, errConfigOptionMissing) {
|
||||
return "", err
|
||||
}
|
||||
// if 'secretNamespace' option is not specified, defaults to namespace in
|
||||
// which PVC was created
|
||||
secretNamespace = defaultNamespace
|
||||
}
|
||||
|
||||
c, err := k8s.NewK8sClient()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("can not get Secret %s/%s, failed to "+
|
||||
"connect to Kubernetes: %w", secretNamespace, secretName, err)
|
||||
}
|
||||
|
||||
secret, err := c.CoreV1().Secrets(secretNamespace).Get(context.TODO(),
|
||||
secretName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get Secret %s/%s: %w",
|
||||
secretNamespace, secretName, err)
|
||||
}
|
||||
|
||||
passphraseValue, ok := secret.Data[encryptionPassphraseKey]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("missing %q in Secret %s/%s",
|
||||
encryptionPassphraseKey, secretNamespace, secretName)
|
||||
}
|
||||
|
||||
return string(passphraseValue), nil
|
||||
}
|
||||
|
||||
// Destroy frees all used resources.
|
||||
func (kms secretsMetadataKMS) Destroy() {
|
||||
// nothing to do
|
||||
@ -287,6 +240,53 @@ func (kms secretsMetadataKMS) GetSecret(ctx context.Context, volumeID string) (s
|
||||
return kms.FetchDEK(ctx, volumeID)
|
||||
}
|
||||
|
||||
// fetchEncryptionPassphrase fetches encryptionPassphrase from user provided secret.
|
||||
func (kms secretsMetadataKMS) fetchEncryptionPassphrase(
|
||||
config map[string]interface{},
|
||||
defaultNamespace string,
|
||||
) (string, error) {
|
||||
var (
|
||||
secretName string
|
||||
secretNamespace string
|
||||
)
|
||||
|
||||
err := setConfigString(&secretName, config, metadataSecretNameKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
err = setConfigString(&secretNamespace, config, metadataSecretNamespaceKey)
|
||||
if err != nil {
|
||||
if !errors.Is(err, errConfigOptionMissing) {
|
||||
return "", err
|
||||
}
|
||||
// if 'secretNamespace' option is not specified, defaults to namespace in
|
||||
// which PVC was created
|
||||
secretNamespace = defaultNamespace
|
||||
}
|
||||
|
||||
c, err := k8s.NewK8sClient()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("can not get Secret %s/%s, failed to "+
|
||||
"connect to Kubernetes: %w", secretNamespace, secretName, err)
|
||||
}
|
||||
|
||||
secret, err := c.CoreV1().Secrets(secretNamespace).Get(context.TODO(),
|
||||
secretName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get Secret %s/%s: %w",
|
||||
secretNamespace, secretName, err)
|
||||
}
|
||||
|
||||
passphraseValue, ok := secret.Data[encryptionPassphraseKey]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("missing %q in Secret %s/%s",
|
||||
encryptionPassphraseKey, secretNamespace, secretName)
|
||||
}
|
||||
|
||||
return string(passphraseValue), nil
|
||||
}
|
||||
|
||||
// generateCipher returns a AEAD cipher based on a passphrase and salt
|
||||
// (volumeID). The cipher can then be used to encrypt/decrypt the DEK.
|
||||
func generateCipher(passphrase, salt string) (cipher.AEAD, error) {
|
||||
|
Reference in New Issue
Block a user