From 5e40f654d6de05a7bd8914080ce91caed4c4213f Mon Sep 17 00:00:00 2001 From: pjsier Date: Mon, 9 Oct 2023 16:07:10 -0400 Subject: [PATCH] Add service account values to read and import --- minio/resource_minio_service_account.go | 6 ++++++ minio/resource_minio_service_account_test.go | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/minio/resource_minio_service_account.go b/minio/resource_minio_service_account.go index b7ccb8ed..ea83339b 100644 --- a/minio/resource_minio_service_account.go +++ b/minio/resource_minio_service_account.go @@ -175,6 +175,12 @@ func minioReadServiceAccount(ctx context.Context, d *schema.ResourceData, meta i return NewResourceError("reading service account failed", d.Id(), err) } + _ = d.Set("disable_user", output.AccountStatus == "off") + + if err := d.Set("target_user", output.ParentUser); err != nil { + return NewResourceError("reading service account failed", d.Id(), err) + } + _ = d.Set("policy", output.Policy) return nil diff --git a/minio/resource_minio_service_account_test.go b/minio/resource_minio_service_account_test.go index 7a014f81..1751a9bc 100644 --- a/minio/resource_minio_service_account_test.go +++ b/minio/resource_minio_service_account_test.go @@ -30,8 +30,15 @@ func TestServiceAccount_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMinioServiceAccountExists(resourceName, &serviceAccount), testAccCheckMinioServiceAccountAttributes(resourceName, targetUser, status), + resource.TestCheckResourceAttr(resourceName, "target_user", targetUser), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"update_secret", "secret_key"}, + }, }, }) } @@ -130,6 +137,12 @@ func TestServiceAccount_Policy(t *testing.T) { testAccCheckMinioServiceAccountExists(resourceName2, &serviceAccount), ), }, + { + ResourceName: resourceName2, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"update_secret", "secret_key"}, + }, }, }) }