From 5445976346ce71e442e526191ac6009e1f5ed5f9 Mon Sep 17 00:00:00 2001 From: Stephan Zuercher Date: Fri, 22 Apr 2016 14:26:17 -0700 Subject: [PATCH] kube-aws: fail if configPath (cluster.yaml) already exists If the cluster.yaml file exists and is longer than the new version being written, the resulting cluster.yaml will contain portions of the previous version. Open it with os.O_EXCL, causing an error if the file already exists. --- multi-node/aws/cmd/kube-aws/command_init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multi-node/aws/cmd/kube-aws/command_init.go b/multi-node/aws/cmd/kube-aws/command_init.go index 252c64ac28..4c92d8c5b6 100644 --- a/multi-node/aws/cmd/kube-aws/command_init.go +++ b/multi-node/aws/cmd/kube-aws/command_init.go @@ -61,7 +61,7 @@ func runCmdInit(cmd *cobra.Command, args []string) error { return fmt.Errorf("Error parsing default config template: %v", err) } - out, err := os.OpenFile(configPath, os.O_CREATE|os.O_WRONLY, 0600) + out, err := os.OpenFile(configPath, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600) if err != nil { return fmt.Errorf("Error opening %s : %v", configPath, err) }