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:
parent
e0e177374f
commit
6a896c8748
|
@ -229,89 +229,93 @@ var connectionBlockSupersetSchema = &configschema.Block{
|
||||||
// by the config loader and stored away in a separate field.
|
// by the config loader and stored away in a separate field.
|
||||||
|
|
||||||
// Common attributes for both connection types
|
// Common attributes for both connection types
|
||||||
|
"type": {
|
||||||
|
Type: cty.String,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
"user": {
|
"user": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"password": {
|
"password": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"host": {
|
"host": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"port": {
|
"port": {
|
||||||
Type: cty.Number,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"timeout": {
|
"timeout": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"script_path": {
|
"script_path": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// For type=ssh only (enforced in ssh communicator)
|
// For type=ssh only (enforced in ssh communicator)
|
||||||
"private_key": {
|
"private_key": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"host_key": {
|
"host_key": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"agent": {
|
"agent": {
|
||||||
Type: cty.Bool,
|
Type: cty.Bool,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"agent_identity": {
|
"agent_identity": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"bastion_host": {
|
"bastion_host": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"bastion_host_key": {
|
"bastion_host_key": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"bastion_port": {
|
"bastion_port": {
|
||||||
Type: cty.Number,
|
Type: cty.Number,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"bastion_user": {
|
"bastion_user": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"bastion_password": {
|
"bastion_password": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"bastion_private_key": {
|
"bastion_private_key": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// For type=winrm only (enforced in winrm communicator)
|
// For type=winrm only (enforced in winrm communicator)
|
||||||
"https": {
|
"https": {
|
||||||
Type: cty.Bool,
|
Type: cty.Bool,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"insecure": {
|
"insecure": {
|
||||||
Type: cty.Bool,
|
Type: cty.Bool,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"cacert": {
|
"cacert": {
|
||||||
Type: cty.String,
|
Type: cty.String,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
"use_ntlm": {
|
"use_ntlm": {
|
||||||
Type: cty.Bool,
|
Type: cty.Bool,
|
||||||
Required: false,
|
Optional: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,7 +261,7 @@ func TestEvalValidateProvisioner_valid(t *testing.T) {
|
||||||
Config: hcl.EmptyBody(),
|
Config: hcl.EmptyBody(),
|
||||||
},
|
},
|
||||||
ConnConfig: &configs.Connection{
|
ConnConfig: &configs.Connection{
|
||||||
Type: "ssh",
|
//Type: "ssh",
|
||||||
Config: hcl.EmptyBody(),
|
Config: hcl.EmptyBody(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,14 @@ func TestEvalValidateProvisioner_warning(t *testing.T) {
|
||||||
ctx := &MockEvalContext{}
|
ctx := &MockEvalContext{}
|
||||||
ctx.installSimpleEval()
|
ctx.installSimpleEval()
|
||||||
|
|
||||||
schema := &configschema.Block{}
|
schema := &configschema.Block{
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"type": {
|
||||||
|
Type: cty.String,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
node := &EvalValidateProvisioner{
|
node := &EvalValidateProvisioner{
|
||||||
ResourceAddr: addrs.ResourceInstance{
|
ResourceAddr: addrs.ResourceInstance{
|
||||||
|
@ -302,8 +309,9 @@ func TestEvalValidateProvisioner_warning(t *testing.T) {
|
||||||
Config: hcl.EmptyBody(),
|
Config: hcl.EmptyBody(),
|
||||||
},
|
},
|
||||||
ConnConfig: &configs.Connection{
|
ConnConfig: &configs.Connection{
|
||||||
Type: "ssh",
|
Config: configs.SynthBody("", map[string]cty.Value{
|
||||||
Config: hcl.EmptyBody(),
|
"type": cty.StringVal("ssh"),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +338,14 @@ func TestEvalValidateProvisioner_connectionInvalid(t *testing.T) {
|
||||||
ctx := &MockEvalContext{}
|
ctx := &MockEvalContext{}
|
||||||
ctx.installSimpleEval()
|
ctx.installSimpleEval()
|
||||||
|
|
||||||
schema := &configschema.Block{}
|
schema := &configschema.Block{
|
||||||
|
Attributes: map[string]*configschema.Attribute{
|
||||||
|
"type": {
|
||||||
|
Type: cty.String,
|
||||||
|
Optional: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
node := &EvalValidateProvisioner{
|
node := &EvalValidateProvisioner{
|
||||||
ResourceAddr: addrs.ResourceInstance{
|
ResourceAddr: addrs.ResourceInstance{
|
||||||
|
@ -347,8 +362,8 @@ func TestEvalValidateProvisioner_connectionInvalid(t *testing.T) {
|
||||||
Config: hcl.EmptyBody(),
|
Config: hcl.EmptyBody(),
|
||||||
},
|
},
|
||||||
ConnConfig: &configs.Connection{
|
ConnConfig: &configs.Connection{
|
||||||
Type: "ssh",
|
|
||||||
Config: configs.SynthBody("", map[string]cty.Value{
|
Config: configs.SynthBody("", map[string]cty.Value{
|
||||||
|
"type": cty.StringVal("ssh"),
|
||||||
"bananananananana": cty.StringVal("foo"),
|
"bananananananana": cty.StringVal("foo"),
|
||||||
"bazaz": cty.StringVal("bar"),
|
"bazaz": cty.StringVal("bar"),
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue