-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstream client support for eno reconciler (#33)
Eno reconciler accepts an optional path to an upstream client through the "remote-kubeconfig" flag.
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package k8s | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
// GetRESTConfig is a convenience method to avoid manually opening a file. | ||
func GetRESTConfig(filename string) (*rest.Config, error) { | ||
b, err := os.ReadFile(filename) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get read Kubeconfig file: %w", err) | ||
} | ||
cfg, err := clientcmd.RESTConfigFromKubeConfig(b) | ||
if err != nil { | ||
return nil, fmt.Errorf("could not get get Kubeconfig from file: %w", err) | ||
} | ||
return cfg, nil | ||
} |