builder/openstack: validate ssh key name/file
This is a port for OpenStack of PR #4665
This commit is contained in:
parent
ad5a41082e
commit
6cd3cb18da
|
@ -56,6 +56,15 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
errs := c.Comm.Prepare(ctx)
|
errs := c.Comm.Prepare(ctx)
|
||||||
|
|
||||||
|
if c.SSHKeyPairName != "" {
|
||||||
|
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKey == "" {
|
||||||
|
errs = append(errs, errors.New("A private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))
|
||||||
|
} else if c.Comm.SSHPrivateKey == "" && !c.Comm.SSHAgentAuth {
|
||||||
|
errs = append(errs, errors.New("A private_key_file must be provided or ssh_agent_auth enabled when ssh_keypair_name is specified."))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if c.SourceImage == "" && c.SourceImageName == "" {
|
if c.SourceImage == "" && c.SourceImageName == "" {
|
||||||
errs = append(errs, errors.New("Either a source_image or a source_image_name must be specified"))
|
errs = append(errs, errors.New("Either a source_image or a source_image_name must be specified"))
|
||||||
} else if len(c.SourceImage) > 0 && len(c.SourceImageName) > 0 {
|
} else if len(c.SourceImage) > 0 && len(c.SourceImageName) > 0 {
|
||||||
|
|
Loading…
Reference in New Issue