Skip to content
Permalink
Browse files
feat(kube-run): add --kube-config-base64
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
  • Loading branch information
ilya-lesikov committed Mar 29, 2022
1 parent cddc6b6 commit a32cd4fd0c0c735b9c2a9b66548734da078ba6ce
Showing with 10 additions and 11 deletions.
  1. +10 −11 cmd/werf/kube_run/kube_run.go
@@ -155,8 +155,7 @@ func NewCmd() *cobra.Command {

common.SetupSynchronization(&commonCmdData, cmd)
common.SetupKubeConfig(&commonCmdData, cmd)
// TODO(ilya-lesikov): doesn't work, need to be passed to `werf kubectl` somehow
// common.SetupKubeConfigBase64(&commonCmdData, cmd)
common.SetupKubeConfigBase64(&commonCmdData, cmd)
common.SetupKubeContext(&commonCmdData, cmd)

common.SetupDryRun(&commonCmdData, cmd)
@@ -275,9 +274,7 @@ func runMain(ctx context.Context) error {
return fmt.Errorf("unable to load werf config: %s", err)
}

// TODO(ilya-lesikov): doesn't work, need to be passed to `werf kubectl` somehow
// common.SetupOndemandKubeInitializer(*commonCmdData.KubeContext, *commonCmdData.KubeConfig, *commonCmdData.KubeConfigBase64, *commonCmdData.KubeConfigPathMergeList)
common.SetupOndemandKubeInitializer(*commonCmdData.KubeContext, *commonCmdData.KubeConfig, "", *commonCmdData.KubeConfigPathMergeList)
common.SetupOndemandKubeInitializer(*commonCmdData.KubeContext, *commonCmdData.KubeConfig, *commonCmdData.KubeConfigBase64, *commonCmdData.KubeConfigPathMergeList)
if err := common.GetOndemandKubeInitializer().Init(ctx); err != nil {
return err
}
@@ -425,12 +422,14 @@ func run(ctx context.Context, pod, secret, namespace string, werfConfig *config.
args = append(args, "--context", *commonCmdData.KubeContext)
}

if *commonCmdData.KubeConfig != "" {
args = append(args, "--kubeconfig", *commonCmdData.KubeConfig)
}

if kubeConf := common.GetFirstExistingKubeConfigEnvVar(); kubeConf != "" {
if err := os.Setenv("KUBECONFIG", kubeConf); err != nil {
if *commonCmdData.KubeConfigBase64 != "" {
args = append(args, "--kube-config-base64", *commonCmdData.KubeConfigBase64)
} else if *commonCmdData.KubeConfig != "" {
if err := os.Setenv("KUBECONFIG", *commonCmdData.KubeConfig); err != nil {
return fmt.Errorf("unable to set $KUBECONFIG env var: %w", err)
}
} else if len(*commonCmdData.KubeConfigPathMergeList) > 0 {
if err := os.Setenv("KUBECONFIG", common.GetFirstExistingKubeConfigEnvVar()); err != nil {
return fmt.Errorf("unable to set $KUBECONFIG env var: %w", err)
}
}

0 comments on commit a32cd4f

Please sign in to comment.