From e086886c643a0785a1315b48878b463733eeb3ad Mon Sep 17 00:00:00 2001 From: Chase Walden Date: Mon, 8 Jul 2024 18:11:06 -0600 Subject: [PATCH] remove old files --- pkg/sdkv2/data_sources/service_token.go | 94 ------------------- .../service_token_acceptance_test.go | 55 ----------- 2 files changed, 149 deletions(-) delete mode 100644 pkg/sdkv2/data_sources/service_token.go delete mode 100644 pkg/sdkv2/data_sources/service_token_acceptance_test.go diff --git a/pkg/sdkv2/data_sources/service_token.go b/pkg/sdkv2/data_sources/service_token.go deleted file mode 100644 index 64b30f3b..00000000 --- a/pkg/sdkv2/data_sources/service_token.go +++ /dev/null @@ -1,94 +0,0 @@ -package data_sources - -import ( - "context" - "strconv" - - "github.com/dbt-labs/terraform-provider-dbtcloud/pkg/dbt_cloud" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -var serviceTokenSchema = map[string]*schema.Schema{ - "service_token_id": &schema.Schema{ - Type: schema.TypeInt, - Required: true, - Description: "ID of the service token", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Service token name", - }, - "uid": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The UID of the service token (part of the token secret)", - }, - "service_token_permissions": &schema.Schema{ - Type: schema.TypeSet, - Computed: true, - Description: "Permissions set for the service token", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "permission_set": { - Type: schema.TypeString, - Computed: true, - Description: "Set of permissions to apply", - }, - "project_id": { - Type: schema.TypeInt, - Computed: true, - Description: "Project ID to apply this permission to for this service token", - }, - "all_projects": { - Type: schema.TypeBool, - Computed: true, - Description: "Whether or not to apply this permission to all projects for this service token", - }, - }, - }, - }} - -func DatasourceServiceToken() *schema.Resource { - return &schema.Resource{ - ReadContext: datasourceServiceTokenRead, - Schema: serviceTokenSchema, - } -} - -func datasourceServiceTokenRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { - c := m.(*dbt_cloud.Client) - - var diags diag.Diagnostics - - serviceTokenID := d.Get("service_token_id").(int) - - serviceToken, err := c.GetServiceToken(serviceTokenID) - if err != nil { - return diag.FromErr(err) - } - - if err := d.Set("name", serviceToken.Name); err != nil { - return diag.FromErr(err) - } - if err := d.Set("uid", serviceToken.UID); err != nil { - return diag.FromErr(err) - } - - permissions := make([]interface{}, len(serviceToken.Permissions)) - for i, permission := range serviceToken.Permissions { - p := make(map[string]interface{}) - p["permission_set"] = permission.Set - p["project_id"] = permission.ProjectID - p["all_projects"] = permission.AllProjects - permissions[i] = p - } - if err := d.Set("service_token_permissions", permissions); err != nil { - return diag.FromErr(err) - } - - d.SetId(strconv.Itoa(*serviceToken.ID)) - - return diags -} diff --git a/pkg/sdkv2/data_sources/service_token_acceptance_test.go b/pkg/sdkv2/data_sources/service_token_acceptance_test.go deleted file mode 100644 index e7570eb9..00000000 --- a/pkg/sdkv2/data_sources/service_token_acceptance_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package data_sources_test - -import ( - "fmt" - "testing" - - "github.com/dbt-labs/terraform-provider-dbtcloud/pkg/framework/acctest_helper" - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" -) - -func TestAccDbtCloudServiceTokenDataSource(t *testing.T) { - - serviceTokenName := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum) - - config := serviceToken(serviceTokenName) - - check := resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr( - "data.dbtcloud_service_token.test_service_token_read", - "name", - serviceTokenName, - ), - resource.TestCheckResourceAttrSet( - "data.dbtcloud_service_token.test_service_token_read", - "uid", - ), - resource.TestCheckResourceAttrSet( - "data.dbtcloud_service_token.test_service_token_read", - "service_token_id", - ), - ) - - resource.ParallelTest(t, resource.TestCase{ - ProtoV6ProviderFactories: acctest_helper.TestAccProtoV6ProviderFactories, - Steps: []resource.TestStep{ - { - Config: config, - Check: check, - }, - }, - }) -} - -func serviceToken(serviceTokenName string) string { - return fmt.Sprintf(` -resource "dbtcloud_service_token" "test_service_token" { - name = "%s" -} - -data "dbtcloud_service_token" "test_service_token_read" { - service_token_id = dbtcloud_service_token.test_service_token.id -} -`, serviceTokenName) -}