Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ichung08 committed Jul 18, 2024
1 parent 4aab4c1 commit 717f77b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions internal/provider/resources/resource_api_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"strings"
"testing"

"github.com/astronomer/terraform-provider-astro/internal/clients"
Expand Down Expand Up @@ -498,14 +499,28 @@ type apiTokenInput struct {
}

func apiToken(input apiTokenInput) string {
roles := lo.Map(input.Roles, func(role apiTokenRole, _ int) string {
return fmt.Sprintf(`
{
role = "%v"
entity_id = "%v"
entity_type = "%v"
}`, role.Role, role.EntityId, role.EntityType)
})

var rolesString string
if len(input.Roles) > 0 {
rolesString = fmt.Sprintf("roles = [%v]", strings.Join(roles, ", "))
}

return fmt.Sprintf(`
resource astro_api_token "%v" {
name = "%v"
description = "%s"
type = "%s"
roles = %v
%v
expiry_period_in_days = %v
}`, input.Name, input.Name, input.Description, input.Type, input.Roles, input.ExpiryPeriodInDays)
}`, input.Name, input.Name, input.Description, input.Type, rolesString, input.ExpiryPeriodInDays)
}

type checkApiTokensExistenceInput struct {
Expand Down

0 comments on commit 717f77b

Please sign in to comment.