Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove newly added id attributes in resources #102

Merged
merged 1 commit into from
Oct 27, 2021

Commits on Oct 27, 2021

  1. Remove newly added id attributes in resources

    As part of civo#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
    stack72 committed Oct 27, 2021
    Configuration menu
    Copy the full SHA
    43d0211 View commit details
    Browse the repository at this point in the history