Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance/system config eks/#2842/#165 #167

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added warning message. Signed-off-by: Sekiranda Hamza sekirandahamza@…
…gmail.com

Signed-off-by: Sekiranda Hamza <sekirandahamza@gmail.com>
  • Loading branch information
Zanda256 committed Apr 3, 2022
commit 6ef9cc93ab7674b38b33d1604eb8cae021120875
13 changes: 13 additions & 0 deletions utils/kubernetes/kubeconfig.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kubernetes

import (
"io/ioutil"
"log"
"os"
"path/filepath"
@@ -79,8 +80,20 @@ func WriteEKSConfig(clusterName, region, configPath string) error {
Contexts: contexts,
CurrentContext: cname,
}

prevConfigbytes, err := ioutil.ReadFile(configPath)
if err != nil {
return err
}
tmpArch := "tmp/kube/config"
err = os.WriteFile(tmpArch, prevConfigbytes, 0644)
if err != nil {
return err
}
log.Printf("Warning: Overwriting previous config, archived config at %s", tmpArch)
if err := clientcmd.WriteToFile(clientConfig, configPath); err != nil {
return err
}
// O_CREATE O_TRUNC
return nil
}