From 528ba33b26f9291abc7c118073c017b71b9d4ab4 Mon Sep 17 00:00:00 2001 From: Pat Sier Date: Tue, 24 Oct 2023 08:24:40 -0400 Subject: [PATCH] Add service account values to read and import (#525) (cherry picked from commit cf0c88d0d7adbb4aab0e5ca9b133c06c072d562d) --- 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 4d1017a3..76546118 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 0d6d6488..6eadd8d5 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"}, + }, }, }) }