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
@@ -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 {
