Skip to content

Commit

Permalink
fix(core): Do not limit cluster size to 1 in provider's ssh config (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
otopetrik and bpg authored Jun 7, 2023
1 parent 0aa33f0 commit 926382c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions proxmoxtf/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func TestProviderSchema(t *testing.T) {
mkProviderOTP,
mkProviderPassword,
mkProviderUsername,
mkProviderSSH,
})

test.AssertValueTypes(t, veSchema, map[string]schema.ValueType{
Expand All @@ -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)
}
1 change: 0 additions & 1 deletion proxmoxtf/provider/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 10 additions & 0 deletions proxmoxtf/test/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 926382c

Please sign in to comment.