fix: close the file before attempting to write it
Also remove the unnecessary sleep call
This commit is contained in:
1 parent
f377c23403
commit
7101d1bf7b
1 file changed
+4
-6
@@ -31,6 +31,10 @@ func CommandInitialize() error {
|
|||||||
}
|
}
|
||||||
defer os.Remove(f.Name())
|
defer os.Remove(f.Name())
|
||||||
|
|
||||||
|
if err := f.Close(); err != nil {
|
||||||
|
return fmt.Errorf("Unable to close k3s installer file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
err = common.WriteSliceToFile(common.WriteSliceToFileInput{
|
err = common.WriteSliceToFile(common.WriteSliceToFileInput{
|
||||||
Filename: f.Name(),
|
Filename: f.Name(),
|
||||||
Lines: strings.Split(resp.String(), "\n"),
|
Lines: strings.Split(resp.String(), "\n"),
|
||||||
@@ -40,10 +44,6 @@ func CommandInitialize() error {
|
|||||||
return fmt.Errorf("Unable to write k3s installer to file: %w", err)
|
return fmt.Errorf("Unable to write k3s installer to file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := f.Close(); err != nil {
|
|
||||||
return fmt.Errorf("Unable to close k3s installer file: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fi, err := os.Stat(f.Name())
|
fi, err := os.Stat(f.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to get k3s installer file size: %w", err)
|
return fmt.Errorf("Unable to get k3s installer file size: %w", err)
|
||||||
@@ -53,8 +53,6 @@ func CommandInitialize() error {
|
|||||||
return fmt.Errorf("Invalid k3s installer filesize")
|
return fmt.Errorf("Invalid k3s installer filesize")
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(1 * time.Second)
|
|
||||||
|
|
||||||
// todo: allow this to be passed as an option or environment variable
|
// todo: allow this to be passed as an option or environment variable
|
||||||
token := "password"
|
token := "password"
|
||||||
if err := CommandSet("--global", "token", token); err != nil {
|
if err := CommandSet("--global", "token", token); err != nil {
|
||||||
|
|||||||
Reference in new issue
Block a user