Fix the Scaleway provider in the metadata package

This commit will update the Scaleway provider to fetch the cloud-init/cloud-config data from the user_data/cloud-init endpoint it will also make sure the whole public ssh key is fetched and no longer strip out the `ssh-rsa` part of the keys

Signed-off-by: Simon Fridlund <simon@fridlund.email>
This commit is contained in:
Simon Fridlund 2019-10-13 20:58:05 +02:00
parent afff608c49
commit ea5f542450
No known key found for this signature in database
GPG Key ID: F68EEAFE7927D3FF

View File

@ -210,11 +210,11 @@ func scalewayGetUserdata() ([]byte, error) {
return nil, errors.New("not able to found a free port below 1024")
}
defer conn.Close()
fmt.Fprintf(conn, "GET /user_data HTTP/1.0\r\n\r\n")
fmt.Fprintf(conn, "GET /user_data/cloud-init HTTP/1.0\r\n\r\n")
reader := bufio.NewReader(conn)
resp, err := http.ReadResponse(reader, nil)
if err != nil {
if err != nil || resp.StatusCode == 404 {
return nil, err
}
defer resp.Body.Close()
@ -245,10 +245,7 @@ func (p *ProviderScaleway) handleSSH(metadata []byte) error {
}
line := string(bytes.Trim(sshKey, "'"))
parts := strings.SplitN(line, " ", 2)
if len(parts) == 2 {
rootKeys = rootKeys + parts[1] + "\n"
}
rootKeys = rootKeys + line + "\n"
}
if err := os.Mkdir(path.Join(ConfigPath, SSH), 0755); err != nil {