This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add tags parameter to packet_reserved_ip_block #300
Add tags parameter to packet_reserved_ip_block #300
Changes from all commits
b7fe2c6
b73f9eb
0014127
8abeccc
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this helps. If the current TF state value is
nil
, we will ignore any fetched, updated, values from the API?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests passed, which makes me wonder if we are missing some worthwhile tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The d.Get() will return nil if the resource doesn't have the attribute defined.
This will filter out all the map items for attributes which are not defined in the target resource, avoiding the
* Invalid address to set: []string{"tags"}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as
nil
is not the default value for any type, this sounds good. I was worried thatnil
would be returned for optional fields.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at hashicorp/terraform#5108 (comment)
I think the problem here is that the TypeSet is not willing to take a
[]string{"tag"}
value, I think we may have to convert the tags to (something like)map[string]string{"0": "tag"}
to store it as tags, perhaps using a conversion function.DO seems to do this:
https://github.com/digitalocean/terraform-provider-digitalocean/blob/b3f3acbc88378f6b656735ae39e22dac59e753af/digitalocean/tags.go#L124-L135
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I'm not sure how https://github.com/packethost/terraform-provider-packet/pull/300/files#diff-d9548e89dc420c68f877077eab089bc0a1c4d380ece0ad32858280a8111d94caR96-R97 would be passing if that is the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@displague in the scheme types, nil is default only for TypeInvalid (not sure what TypeInvalid is used for but I think there's no point to set it in a resource)
https://github.com/hashicorp/terraform-plugin-sdk/blob/99085370a27805c4352748aefc0c0b3698cd72d7/helper/schema/schema.go#L2096
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@displague I think TypeSet accepts string slice. That's why tests succeed, and I just made a dev provider build from this PR, and I can see
.. in the tf state (after apply and clean plan).
I can alse change the order of the tags in main.tf, and the plan is clean (because tags are a TypeSet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashicorp/terraform#5108 (comment) is from 2016, and one of the last comments says it weas patched.