mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
cli: add missing flag to miniConstellation (#1374)
* Add missing flag to miniConstellation * Add config merger to miniConstellation * Soft fail if config can not be merged * Remove config flattening * Release spinner stop lock when stopping finished --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems> Co-authored-by: Nils Hanke <nils.hanke@outlook.com>
This commit is contained in:
parent
ebf7dd8842
commit
446b77828b
3 changed files with 10 additions and 10 deletions
|
@ -44,7 +44,6 @@ import (
|
|||
"google.golang.org/grpc/connectivity"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
clientcodec "k8s.io/client-go/tools/clientcmd/api/latest"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
@ -292,9 +291,11 @@ func (i *initCmd) writeOutput(
|
|||
|
||||
if mergeConfig {
|
||||
if err := i.merger.mergeConfigs(constants.AdminConfFilename, fileHandler); err != nil {
|
||||
return fmt.Errorf("merging kubeconfig: %w", err)
|
||||
writeRow(tw, "Failed to automatically merge kubeconfig", err.Error())
|
||||
mergeConfig = false // Set to false so we don't print the wrong message below.
|
||||
} else {
|
||||
writeRow(tw, "Kubernetes configuration merged with default config", "")
|
||||
}
|
||||
writeRow(tw, "Kubernetes configuration merged with default config", "")
|
||||
}
|
||||
|
||||
idFile.OwnerID = ownerID
|
||||
|
@ -478,19 +479,16 @@ func (c *kubeconfigMerger) mergeConfigs(configPath string, fileHandler file.Hand
|
|||
|
||||
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
|
||||
loadingRules.Precedence = []string{
|
||||
configPath, // load our config first so it takes precedence
|
||||
clientcmd.RecommendedHomeFile, // then load the default config
|
||||
clientcmd.RecommendedHomeFile,
|
||||
configPath, // our config should overwrite the default config
|
||||
}
|
||||
c.log.Debugf("Kubeconfig file loading precedence: %v", loadingRules.Precedence)
|
||||
|
||||
// merge and flatten the kubeconfigs
|
||||
// merge the kubeconfigs
|
||||
cfg, err := loadingRules.Load()
|
||||
if err != nil {
|
||||
return fmt.Errorf("loading merged kubeconfig: %w", err)
|
||||
}
|
||||
if err := clientcmdapi.FlattenConfig(cfg); err != nil {
|
||||
return fmt.Errorf("flattening merged kubeconfig: %w", err)
|
||||
}
|
||||
|
||||
// Set the current context to the cluster we just created
|
||||
cfg.CurrentContext = constellConfig.CurrentContext
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue