mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Fix the Hetzner provider in the metadata package
There were some mistakes made in the initial code where writes didn't work, this commit fixes that. Signed-off-by: Simon Fridlund <simon@fridlund.email>
This commit is contained in:
parent
afff608c49
commit
4005082664
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -128,17 +127,15 @@ func (p *ProviderHetzner) handleSSH() error {
|
|||||||
return fmt.Errorf("Failed to create %s: %s", SSH, err)
|
return fmt.Errorf("Failed to create %s: %s", SSH, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileHandle, _ := os.OpenFile(path.Join(ConfigPath, SSH, "authorized_keys"), os.O_CREATE|os.O_APPEND, 0600)
|
fileHandle, _ := os.OpenFile(path.Join(ConfigPath, SSH, "authorized_keys"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
|
||||||
writer := bufio.NewWriter(fileHandle)
|
|
||||||
defer fileHandle.Close()
|
defer fileHandle.Close()
|
||||||
|
|
||||||
for _, sshKey := range sshKeys {
|
for _, sshKey := range sshKeys {
|
||||||
_, err = fmt.Fprintln(writer, sshKey)
|
_, err = fileHandle.WriteString(sshKey + "\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to write ssh keys: %s", err)
|
return fmt.Errorf("Failed to write ssh keys: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.Flush()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user