Skip to content

Commit

Permalink
Merge pull request #676 from am6737/master
Browse files Browse the repository at this point in the history
feat(region): support custom user data in Google Cloud VM rebuild
  • Loading branch information
ioito authored Dec 27, 2023
2 parents 6625665 + 10c2175 commit e2e631e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/multicloud/google/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (self *SInstance) Refresh() error {
return nil
}

//PROVISIONING, STAGING, RUNNING, STOPPING, STOPPED, SUSPENDING, SUSPENDED, and TERMINATED.
// PROVISIONING, STAGING, RUNNING, STOPPING, STOPPED, SUSPENDING, SUSPENDED, and TERMINATED.
func (instance *SInstance) GetStatus() string {
switch instance.Status {
case "PROVISIONING":
Expand Down Expand Up @@ -416,6 +416,7 @@ func (instance *SInstance) RebuildRoot(ctx context.Context, opts *cloudprovider.
deployOpts := &cloudprovider.SInstanceDeployOptions{
Username: opts.Account,
Password: opts.Password,
UserData: opts.UserData,
PublicKey: opts.PublicKey,
}
return diskId, instance.DeployVM(ctx, deployOpts)
Expand All @@ -425,6 +426,12 @@ func (instance *SInstance) DeployVM(ctx context.Context, opts *cloudprovider.SIn
conf := cloudinit.SCloudConfig{
SshPwauth: cloudinit.SSH_PASSWORD_AUTH_ON,
}
if len(opts.UserData) > 0 {
config, err := cloudinit.ParseUserData(opts.UserData)
if err == nil {
conf.Merge(config)
}
}
user := cloudinit.NewUser(opts.Username)
if len(opts.Password) > 0 {
user.Password(opts.Password)
Expand Down

0 comments on commit e2e631e

Please sign in to comment.