mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 01:59:07 +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"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -57,6 +58,10 @@ func (p *ProviderGCP) Extract() ([]byte, error) {
|
|||||||
// container construct those users
|
// container construct those users
|
||||||
sshKeys, err := gcpGet(project + "attributes/sshKeys")
|
sshKeys, err := gcpGet(project + "attributes/sshKeys")
|
||||||
if err == nil {
|
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 := ""
|
rootKeys := ""
|
||||||
for _, line := range strings.Split(string(sshKeys), "\n") {
|
for _, line := range strings.Split(string(sshKeys), "\n") {
|
||||||
parts := strings.SplitN(line, ":", 2)
|
parts := strings.SplitN(line, ":", 2)
|
||||||
@ -71,6 +76,7 @@ func (p *ProviderGCP) Extract() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorSSH:
|
||||||
// Generic userdata
|
// Generic userdata
|
||||||
userData, err := gcpGet(instance + "attributes/userdata")
|
userData, err := gcpGet(instance + "attributes/userdata")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user