cleanup: move k8s functions to the util/k8s package

By placing the NewK8sClient() function in its own package, the KMS API
can be split from the "internal/util" package. Some of the KMS providers
use the NewK8sClient() function, and this causes circular dependencies
between "internal/utils" -> "internal/kms" -> "internal/utils", which
are not alowed in Go.

Updates: #852
Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2021-08-26 13:15:47 +02:00
committed by mergify[bot]
parent 2cc96dc539
commit 778b5e86de
8 changed files with 22 additions and 11 deletions

View File

@ -22,6 +22,7 @@ import (
"fmt"
"strings"
"github.com/ceph/ceph-csi/internal/util/k8s"
"github.com/ceph/ceph-csi/internal/util/log"
"github.com/container-storage-interface/spec/lib/go/csi"
@ -34,7 +35,7 @@ const (
)
func k8sGetNodeLabels(nodeName string) (map[string]string, error) {
client := NewK8sClient()
client := k8s.NewK8sClient()
node, err := client.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
if err != nil {
return nil, fmt.Errorf("failed to get node %q information: %w", nodeName, err)