cephfs: use userid and keys for provisioning

This patch modifies the code to use userID and
userKey for provisioning of both static and dynamic
PVs.

In case user credentials are not found admin credentials
are used as a fallback and for backwards compatibility.

Signed-off-by: Niraj Yadav <niryadav@redhat.com>
This commit is contained in:
Niraj Yadav 2024-12-09 17:51:58 +05:30
parent 630c97a009
commit 13767d6f54

View File

@ -20,6 +20,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"github.com/ceph/ceph-csi/internal/util/log"
) )
const ( const (
@ -110,6 +112,12 @@ func NewUserCredentials(secrets map[string]string) (*Credentials, error) {
// NewAdminCredentials creates new admin credentials from secret. // NewAdminCredentials creates new admin credentials from secret.
func NewAdminCredentials(secrets map[string]string) (*Credentials, error) { func NewAdminCredentials(secrets map[string]string) (*Credentials, error) {
// Use userID and userKey if found else fallback to adminID and adminKey
if cred, err := newCredentialsFromSecret(credUserID, credUserKey, secrets); err == nil {
return cred, nil
}
log.WarningLogMsg("adminID and adminKey are deprecated, please use userID and userKey instead")
return newCredentialsFromSecret(credAdminID, credAdminKey, secrets) return newCredentialsFromSecret(credAdminID, credAdminKey, secrets)
} }