mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
metadata: Make sure the ssh directory exists before writing to it
Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
ce52c28cf6
commit
a21c566777
@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
@ -57,6 +58,10 @@ func (p *ProviderGCP) Extract() ([]byte, error) {
|
||||
// container construct those users
|
||||
sshKeys, err := gcpGet(project + "attributes/sshKeys")
|
||||
if err == nil {
|
||||
if err := os.Mkdir(path.Join(ConfigPath, SSH), 0755); err != nil {
|
||||
log.Printf("Failed to create %s: %s", SSH, err)
|
||||
goto ErrorSSH
|
||||
}
|
||||
rootKeys := ""
|
||||
for _, line := range strings.Split(string(sshKeys), "\n") {
|
||||
parts := strings.SplitN(line, ":", 2)
|
||||
@ -71,6 +76,7 @@ func (p *ProviderGCP) Extract() ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
ErrorSSH:
|
||||
// Generic userdata
|
||||
userData, err := gcpGet(instance + "attributes/userdata")
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user