Skip to content

Commit

Permalink
eksconfig: improve default log file paths
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
  • Loading branch information
gyuho committed Feb 12, 2020
1 parent 1137f16 commit 5d5b9aa
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions eksconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ func (cfg *Config) ValidateAndSetDefaults() error {
return err
}
dirCreated = true
f, err := ioutil.TempFile(rootDir, cfg.Name+"-config-yaml")
f, err := ioutil.TempFile(rootDir, cfg.Name+"-config.yaml")
if err != nil {
return err
}
Expand Down Expand Up @@ -833,24 +833,15 @@ func (cfg *Config) ValidateAndSetDefaults() error {
cfg.SSHCommandsOutputPath = cfg.SSHCommandsOutputPath + ".sh"
}
if cfg.KubeConfigPath == "" {
f, err := ioutil.TempFile(filepath.Dir(cfg.ConfigPath), cfg.Name+"-kubeconfig")
if err != nil {
return err
}
var p string
p, err = filepath.Abs(f.Name())
if err != nil {
panic(err)
}
cfg.KubeConfigPath = p
f.Close()
os.RemoveAll(cfg.KubeConfigPath)
cfg.KubeConfigPath = strings.ReplaceAll(cfg.ConfigPath, ".yaml", "") + ".kubeconfig.yaml"
}
if filepath.Ext(cfg.KubeConfigPath) != ".yaml" {
cfg.KubeConfigPath = cfg.KubeConfigPath + ".yaml"
}
cfg.Sync()

if cfg.AddOnManagedNodeGroups.LogDir == "" {
cfg.AddOnManagedNodeGroups.LogDir = filepath.Dir(cfg.ConfigPath)
}
cfg.Sync()

if !strings.Contains(cfg.KubectlDownloadURL, runtime.GOOS) {
return fmt.Errorf("kubectl-download-url %q build OS mismatch, expected %q", cfg.KubectlDownloadURL, runtime.GOOS)
Expand Down

0 comments on commit 5d5b9aa

Please sign in to comment.