Skip to content

Commit

Permalink
chore: revert removal of AtLeastOneOf check
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Sep 20, 2024
1 parent 51163e3 commit 69fe8ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions internal/provider/resource_access_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

jimmnames "github.com/canonical/jimm-go-sdk/v3/names"
"github.com/hashicorp/terraform-plugin-framework-validators/resourcevalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
Expand Down Expand Up @@ -83,6 +84,11 @@ type genericJAASAccessData struct {
func (r *genericJAASAccessResource) ConfigValidators(ctx context.Context) []resource.ConfigValidator {
return []resource.ConfigValidator{
NewRequiresJAASValidator(r.client),
resourcevalidator.AtLeastOneOf(
path.MatchRoot("users"),
path.MatchRoot("groups"),
path.MatchRoot("service_accounts"),
),
}
}

Expand Down
6 changes: 4 additions & 2 deletions internal/provider/resource_access_jaas_cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func TestAcc_ResourceJaasAccessCloudImportState(t *testing.T) {
ProtoV6ProviderFactories: frameworkProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccResourceJaasAccessCloudEmpty(cloudName, access),
Config: testAccResourceJaasAccessCloudEveryone(cloudName, access),
PlanOnly: true,
ImportStateVerify: false,
ImportStateCheck: func(is []*terraform.InstanceState) error {
if len(is) != 1 {
Expand Down Expand Up @@ -160,13 +161,14 @@ resource "juju_jaas_access_cloud" "test" {
})
}

func testAccResourceJaasAccessCloudEmpty(cloudName, access string) string {
func testAccResourceJaasAccessCloudEveryone(cloudName, access string) string {
return internaltesting.GetStringFromTemplateWithData(
"testAccResourceJaasAccessCloudEmpty",
`
resource "juju_jaas_access_cloud" "test" {
cloud_name = "{{.Cloud}}"
access = "{{.Access}}"
users = ["everyone@external"]
}
`, internaltesting.TemplateData{
"Cloud": cloudName,
Expand Down

0 comments on commit 69fe8ed

Please sign in to comment.