0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 02:52:58 +00:00

fix(core): Do not limit cluster size to 1 in provider's ssh config (#369)

fix(code): Do not limit cluster size to 1

Allow using repeated 'node' blocks in ssh configuration.

Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
Oto Petřík 2023-06-08 01:06:10 +02:00 committed by GitHub
parent 0aa33f0929
commit 926382c155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -58,6 +58,7 @@ func TestProviderSchema(t *testing.T) {
mkProviderOTP,
mkProviderPassword,
mkProviderUsername,
mkProviderSSH,
})
test.AssertValueTypes(t, veSchema, map[string]schema.ValueType{
@ -66,5 +67,11 @@ func TestProviderSchema(t *testing.T) {
mkProviderOTP: schema.TypeString,
mkProviderPassword: schema.TypeString,
mkProviderUsername: schema.TypeString,
mkProviderSSH: schema.TypeList,
})
providerSSHSchema := test.AssertNestedSchemaExistence(t, s, mkProviderSSH)
// do not limit number of nodes in the cluster
test.AssertListMaxItems(t, providerSSHSchema, mkProviderSSHNode, 0)
}

View File

@ -197,7 +197,6 @@ func nestedProviderSchema() map[string]*schema.Schema {
Type: schema.TypeList,
Optional: true,
MinItems: 0,
MaxItems: 1,
Description: "Overrides for SSH connection configuration to a Proxmox node",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{

View File

@ -39,6 +39,16 @@ func AssertNestedSchemaExistence(t *testing.T, s *schema.Resource, key string) *
return sh
}
// AssertListMaxItems checks that the given schema attribute has given expected MaxItems value.
func AssertListMaxItems(t *testing.T, s *schema.Resource, key string, expectedMaxItems int) {
t.Helper()
require.NotNil(t, s.Schema[key], "Error in Schema: Missing definition for \"%s\"", key)
assert.Equal(t, s.Schema[key].MaxItems, expectedMaxItems,
"Error in Schema: Argument \"%s\" has \"MaxItems: %#v\", but value %#v is expected!",
key, s.Schema[key].MaxItems, expectedMaxItems)
}
// AssertOptionalArguments checks that the given schema has the given optional arguments.
func AssertOptionalArguments(t *testing.T, s *schema.Resource, keys []string) {
t.Helper()