generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 40
/
common.go
45 lines (39 loc) · 1.18 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package cloudprovider
import (
"context"
"log"
"github.com/harness/terraform-provider-harness/internal"
"github.com/harness/terraform-provider-harness/internal/service/cd/usagescope"
"github.com/harness/terraform-provider-harness/internal/utils"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func commonCloudProviderSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"id": {
Description: "The id of the cloud provider.",
Type: schema.TypeString,
Computed: true,
},
"name": {
Description: "The name of the cloud provider.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"usage_scope": usagescope.Schema(),
}
}
func resourceCloudProviderDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
log.Printf("[DEBUG] Deleting cloud provider %s", d.Get("name"))
c := meta.(*internal.Session).CDClient
if c == nil {
return diag.Errorf(utils.CDClientAPIKeyError)
}
id := d.Get("id").(string)
err := c.CloudProviderClient.DeleteCloudProvider(id)
if err != nil {
return diag.FromErr(err)
}
return nil
}