mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 08:15:48 -04:00
Create Kubernetes clients from bytes instead of filepath (#2663)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
4d6a7fa759
commit
a9cc9d8bbc
9 changed files with 94 additions and 33 deletions
|
@ -48,14 +48,10 @@ func NewUninitialized() *Kubectl {
|
|||
}
|
||||
|
||||
// NewFromConfig returns a Kubectl client using the given kubeconfig.
|
||||
func NewFromConfig(kubeconfigPath string) (*Kubectl, error) {
|
||||
clientConfig, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("creating k8s client from kubeconfig: %w", err)
|
||||
}
|
||||
k := &Kubectl{}
|
||||
if err := k.initialize(clientConfig); err != nil {
|
||||
return nil, fmt.Errorf("initializing kubectl: %w", err)
|
||||
func NewFromConfig(kubeconfig []byte) (*Kubectl, error) {
|
||||
k := NewUninitialized()
|
||||
if err := k.Initialize(kubeconfig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return k, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue