Skip to content

Commit

Permalink
Remove newly added id attributes in resources (#102)
Browse files Browse the repository at this point in the history
As part of #92, new "id" attributes were added to the schema for some
of the resources. These are not actually needed since they are part of
the plugin sdk by default. These parameters were not required before
and "id" is something that is available on *ALL* TF based resources

Because we (Pulumi) dervice our schema from your schema (and the plugin SDK)
we are getting the following error:

```
sdk/python/bin/build/lib/pulumi_civo/dns_domain_name.py:218: error: Duplicate argument "id" in function definition
```

If the schema needed these, then the make build would fail but it still works

```
▶ make build
==> Checking that code complies with gofmt requirements...
go install
```

You can see from the internals of the plugin SDK (helper/schema/resource_data.go),
the following func:

```
// SetId sets the ID of the resource. If the value is blank, then the
// resource is destroyed.
func (d *ResourceData) SetId(v string) {
	d.once.Do(d.init)
	d.newState.ID = v

	// once we transition away from the legacy state types, "id" will no longer
	// be a special field, and will become a normal attribute.
	// set the attribute normally
	d.setWriter.unsafeWriteField("id", v)

	// Make sure the newState is also set, otherwise the old value
	// may get precedence.
	if d.newState.Attributes == nil {
		d.newState.Attributes = map[string]string{}
	}
	d.newState.Attributes["id"] = v
}
```

So when you use d.SetID, it actually creates the ID attribute for you
  • Loading branch information
stack72 committed Oct 27, 2021
1 parent 674bb13 commit 604a784
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 58 deletions.
5 changes: 0 additions & 5 deletions civo/resource_dns_domain_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ func resourceDNSDomainName() *schema.Resource {
ValidateFunc: utils.ValidateName,
},
// Computed resource
"id": {
Description: "The ID of this resource.",
Type: schema.TypeString,
Computed: true,
},
"account_id": {
Type: schema.TypeString,
Computed: true,
Expand Down
5 changes: 0 additions & 5 deletions civo/resource_dns_domain_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ func resourceDNSDomainRecord() *schema.Resource {
Description: "How long caching DNS servers should cache this record for, in seconds (the minimum is 600 and the default if unspecified is 600)",
},
// Computed resource
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource.",
},
"account_id": {
Type: schema.TypeString,
Computed: true,
Expand Down
6 changes: 0 additions & 6 deletions civo/resource_firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ func resourceFirewall() *schema.Resource {
Computed: true,
Description: "The firewall network, if is not defined we use the default network",
},
// Computed resource
"id": {
Description: "The ID of this resource.",
Type: schema.TypeString,
Computed: true,
},
},
Create: resourceFirewallCreate,
Read: resourceFirewallRead,
Expand Down
6 changes: 0 additions & 6 deletions civo/resource_firewall_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ func resourceFirewallRule() *schema.Resource {
Description: "The region for this rule",
ValidateFunc: validation.StringIsNotEmpty,
},
// Computed resource
"id": {
Description: "The ID of this resource.",
Type: schema.TypeString,
Computed: true,
},
},
Create: resourceFirewallRuleCreate,
Read: resourceFirewallRuleRead,
Expand Down
5 changes: 0 additions & 5 deletions civo/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,6 @@ func resourceInstance() *schema.Resource {
ValidateFunc: validation.StringIsNotEmpty,
},
// Computed resource
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource.",
},
"cpu_cores": {
Type: schema.TypeInt,
Computed: true,
Expand Down
10 changes: 0 additions & 10 deletions civo/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ func resourceKubernetesCluster() *schema.Resource {
Description: "The existing firewall ID to use for this cluster",
},
// Computed resource
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource.",
},
"instances": instanceSchema(),
"installed_applications": applicationSchema(),
"pools": nodePoolSchema(),
Expand Down Expand Up @@ -190,11 +185,6 @@ func nodePoolSchema() *schema.Schema {
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Computed: true,
Description: "Nodepool ID",
},
"count": {
Type: schema.TypeInt,
Computed: true,
Expand Down
5 changes: 0 additions & 5 deletions civo/resource_kubernetes_cluster_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@ func resourceKubernetesClusterNodePool() *schema.Resource {
Computed: true,
Description: "the size of each node (optional, the default is currently g3.k3s.medium)",
},
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource.",
},
},
Create: resourceKubernetesClusterNodePoolCreate,
Read: resourceKubernetesClusterNodePoolRead,
Expand Down
5 changes: 0 additions & 5 deletions civo/resource_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ func resourceNetwork() *schema.Resource {
Computed: true,
Description: "If the network is default, this will be `true`",
},
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource",
},
},
Create: resourceNetworkCreate,
Read: resourceNetworkRead,
Expand Down
5 changes: 0 additions & 5 deletions civo/resource_ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ func resourceSSHKey() *schema.Resource {
Computed: true,
Description: "a string containing the SSH finger print.",
},
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource.",
},
},
Create: resourceSSHKeyCreate,
Read: resourceSSHKeyRead,
Expand Down
6 changes: 0 additions & 6 deletions civo/resource_volume_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ func resourceVolumeAttachment() *schema.Resource {
ForceNew: true,
Description: "The region for the volume attachment",
},
// Computed resource
"id": {
Type: schema.TypeString,
Computed: true,
Description: "The ID of this resource.",
},
},
Create: resourceVolumeAttachmentCreate,
Read: resourceVolumeAttachmentRead,
Expand Down

0 comments on commit 604a784

Please sign in to comment.