Skip to content

Commit

Permalink
Merge pull request #9 from hashicorp/fix-hcl-support
Browse files Browse the repository at this point in the history
Fix HCL support for ProfitBricks plugin
  • Loading branch information
Wilken Rivera authored Jun 14, 2021
2 parents c213882 + a2d4233 commit 2555234
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions builder/profitbricks/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type Config struct {

Region string `mapstructure:"location"`
Image string `mapstructure:"image"`
SSHKey string
SnapshotName string `mapstructure:"snapshot_name"`
DiskSize int `mapstructure:"disk_size"`
DiskType string `mapstructure:"disk_type"`
Expand All @@ -37,7 +36,7 @@ type Config struct {
func (c *Config) Prepare(raws ...interface{}) ([]string, error) {

var md mapstructure.Metadata
err := config.Decode(&c, &config.DecodeOpts{
err := config.Decode(c, &config.DecodeOpts{
Metadata: &md,
Interpolate: true,
InterpolateContext: &c.ctx,
Expand Down
2 changes: 0 additions & 2 deletions builder/profitbricks/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions builder/profitbricks/step_create_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu

profitbricks.SetAuth(c.PBUsername, c.PBPassword)
profitbricks.SetDepth("5")
if c.Comm.SSHPublicKey != nil {
c.SSHKey = string(c.Comm.SSHPublicKey)
} else {
if c.Comm.SSHPublicKey == nil {
ui.Error("No ssh private key set; ssh authentication won't be possible. Please specify your private key in the ssh_private_key_file configuration key.")
return multistep.ActionHalt
}
Expand Down Expand Up @@ -63,9 +61,7 @@ func (s *stepCreateServer) Run(ctx context.Context, state multistep.StateBag) mu
},
},
}
if c.SSHKey != "" {
server.Entities.Volumes.Items[0].Properties.SshKeys = []string{c.SSHKey}
}
server.Entities.Volumes.Items[0].Properties.SshKeys = []string{string(c.Comm.SSHPublicKey)}

if c.Comm.SSHPassword != "" {
server.Entities.Volumes.Items[0].Properties.ImagePassword = c.Comm.SSHPassword
Expand Down

0 comments on commit 2555234

Please sign in to comment.