Skip to content

Commit

Permalink
Temporarily work around issues with a valid hostname for pods
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed May 23, 2022
1 parent e1ace0d commit 1619c60
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/ionos/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package ionos

import (
"bytes"
"context"
"encoding/base64"
"encoding/hex"
Expand Down Expand Up @@ -85,6 +86,15 @@ func (p *MachineProvider) createMachine(ctx context.Context, req *driver.CreateM
return nil, status.Error(codes.Internal, "userData doesn't exist")
}

// @TODO: IONOS is currently unable to set-up hostnames. We need to hack around it for now.
if bytes.HasPrefix(userData, []byte("#cloud-config\n")) {
return nil, status.Error(codes.InvalidArgument, "userData #cloud-config which is not supported")
}

userDataBuffer := bytes.NewBuffer(userData)
userDataBuffer.WriteString(fmt.Sprintf("\n\necho '%s' > /etc/hostname", machine.Name))
userData = userDataBuffer.Bytes()

client := ionosapiwrapper.GetClientForUser(string(secret.Data["user"]), string(secret.Data["password"]))

image, _, err := client.ImagesApi.ImagesFindById(ctx, providerSpec.ImageID).Depth(1).Execute()
Expand Down

0 comments on commit 1619c60

Please sign in to comment.