fix: close the file before attempting to write it
Also remove the unnecessary sleep call
This commit is contained in:
@@ -31,6 +31,10 @@ func CommandInitialize() error {
|
||||
}
|
||||
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{
|
||||
Filename: f.Name(),
|
||||
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)
|
||||
}
|
||||
|
||||
if err := f.Close(); err != nil {
|
||||
return fmt.Errorf("Unable to close k3s installer file: %w", err)
|
||||
}
|
||||
|
||||
fi, err := os.Stat(f.Name())
|
||||
if err != nil {
|
||||
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")
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
// todo: allow this to be passed as an option or environment variable
|
||||
token := "password"
|
||||
if err := CommandSet("--global", "token", token); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user