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

Docs update (using tfplugindocs tool) #92

Merged
merged 24 commits into from
Sep 23, 2021
Merged

Conversation

zulh-civo
Copy link
Member

@zulh-civo zulh-civo commented Sep 10, 2021

Replacement for #79

FYI: @saiyam1814 / @AnaisUrlichs

@zulh-civo zulh-civo self-assigned this Sep 10, 2021
@zulh-civo zulh-civo added the docs label Sep 10, 2021
@zulh-civo zulh-civo mentioned this pull request Sep 10, 2021
@zulh-civo zulh-civo changed the title [WIP] - Docs update (using tfplugindocs tool) Docs update (using tfplugindocs tool) Sep 21, 2021
@zulh-civo zulh-civo marked this pull request as ready for review September 21, 2021 08:31
@zulh-civo zulh-civo merged commit 5ab9131 into master Sep 23, 2021
stack72 added a commit to stack72/terraform-provider-civo that referenced this pull request Oct 27, 2021
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
alejandrojnm pushed a commit that referenced this pull request Oct 27, 2021
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
@alejandrojnm alejandrojnm deleted the docs-update-tfplugindocs branch November 10, 2022 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants