2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-03-22 11:03:15 -04:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/spf13/afero"
|
|
|
|
)
|
|
|
|
|
|
|
|
const kubeconfigPath = "/etc/kubernetes/admin.conf"
|
|
|
|
|
|
|
|
// KubeconfigReader implements ConfigReader.
|
|
|
|
type KubeconfigReader struct {
|
|
|
|
fs afero.Afero
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadKubeconfig reads the Kubeconfig from disk.
|
|
|
|
func (r KubeconfigReader) ReadKubeconfig() ([]byte, error) {
|
|
|
|
kubeconfig, err := r.fs.ReadFile(kubeconfigPath)
|
|
|
|
if err != nil {
|
2022-12-06 12:48:01 -05:00
|
|
|
return nil, fmt.Errorf("reading kubernetes config: %w", err)
|
2022-03-22 11:03:15 -04:00
|
|
|
}
|
|
|
|
return kubeconfig, nil
|
|
|
|
}
|