fix the provisioner schema and update tests

The provisioenr schema needed to have `Optional: true` for all the
attributes. Also add the `type` attr and update the tests to match.
This commit is contained in:
James Bardin 2018-05-29 15:00:16 -04:00 committed by Martin Atkins
parent e0e177374f
commit 6a896c8748
2 changed files with 46 additions and 27 deletions

View File

@ -229,89 +229,93 @@ var connectionBlockSupersetSchema = &configschema.Block{
// by the config loader and stored away in a separate field.
// Common attributes for both connection types
"type": {
Type: cty.String,
Optional: true,
},
"user": {
Type: cty.String,
Required: false,
Optional: true,
},
"password": {
Type: cty.String,
Required: false,
Optional: true,
},
"host": {
Type: cty.String,
Required: false,
Optional: true,
},
"port": {
Type: cty.Number,
Required: false,
Type: cty.String,
Optional: true,
},
"timeout": {
Type: cty.String,
Required: false,
Optional: true,
},
"script_path": {
Type: cty.String,
Required: false,
Optional: true,
},
// For type=ssh only (enforced in ssh communicator)
"private_key": {
Type: cty.String,
Required: false,
Optional: true,
},
"host_key": {
Type: cty.String,
Required: false,
Optional: true,
},
"agent": {
Type: cty.Bool,
Required: false,
Optional: true,
},
"agent_identity": {
Type: cty.String,
Required: false,
Optional: true,
},
"bastion_host": {
Type: cty.String,
Required: false,
Optional: true,
},
"bastion_host_key": {
Type: cty.String,
Required: false,
Optional: true,
},
"bastion_port": {
Type: cty.Number,
Required: false,
Optional: true,
},
"bastion_user": {
Type: cty.String,
Required: false,
Optional: true,
},
"bastion_password": {
Type: cty.String,
Required: false,
Optional: true,
},
"bastion_private_key": {
Type: cty.String,
Required: false,
Optional: true,
},
// For type=winrm only (enforced in winrm communicator)
"https": {
Type: cty.Bool,
Required: false,
Optional: true,
},
"insecure": {
Type: cty.Bool,
Required: false,
Optional: true,
},
"cacert": {
Type: cty.String,
Required: false,
Optional: true,
},
"use_ntlm": {
Type: cty.Bool,
Required: false,
Optional: true,
},
},
}

View File

@ -261,7 +261,7 @@ func TestEvalValidateProvisioner_valid(t *testing.T) {
Config: hcl.EmptyBody(),
},
ConnConfig: &configs.Connection{
Type: "ssh",
//Type: "ssh",
Config: hcl.EmptyBody(),
},
}
@ -285,7 +285,14 @@ func TestEvalValidateProvisioner_warning(t *testing.T) {
ctx := &MockEvalContext{}
ctx.installSimpleEval()
schema := &configschema.Block{}
schema := &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"type": {
Type: cty.String,
Optional: true,
},
},
}
node := &EvalValidateProvisioner{
ResourceAddr: addrs.ResourceInstance{
@ -302,8 +309,9 @@ func TestEvalValidateProvisioner_warning(t *testing.T) {
Config: hcl.EmptyBody(),
},
ConnConfig: &configs.Connection{
Type: "ssh",
Config: hcl.EmptyBody(),
Config: configs.SynthBody("", map[string]cty.Value{
"type": cty.StringVal("ssh"),
}),
},
}
@ -330,7 +338,14 @@ func TestEvalValidateProvisioner_connectionInvalid(t *testing.T) {
ctx := &MockEvalContext{}
ctx.installSimpleEval()
schema := &configschema.Block{}
schema := &configschema.Block{
Attributes: map[string]*configschema.Attribute{
"type": {
Type: cty.String,
Optional: true,
},
},
}
node := &EvalValidateProvisioner{
ResourceAddr: addrs.ResourceInstance{
@ -347,8 +362,8 @@ func TestEvalValidateProvisioner_connectionInvalid(t *testing.T) {
Config: hcl.EmptyBody(),
},
ConnConfig: &configs.Connection{
Type: "ssh",
Config: configs.SynthBody("", map[string]cty.Value{
"type": cty.StringVal("ssh"),
"bananananananana": cty.StringVal("foo"),
"bazaz": cty.StringVal("bar"),
}),