platform/api/oci: only send userdata if not empty
Currently we always pass in the `user_data` field as metadata when
creating instances, even when the actual userdata is empty. This
changes it so we only send non-empty userdata.
@@ -35,8 +35,9 @@ func (a *API) CreateInstance(name, userdata, sshKey string) (*Machine, error) {
return nil, err
}
- metadata := map[string]string{
- "user_data": base64.StdEncoding.EncodeToString([]byte(userdata)),
+ metadata := map[string]string{}
+ if userdata != "" {
+ metadata["user_data"] = base64.StdEncoding.EncodeToString([]byte(userdata))
}
if sshKey != "" {
metadata["ssh_authorized_keys"] = sshKey
