-
Notifications
You must be signed in to change notification settings - Fork 359
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
Internal: Code Cleanup #456
Comments
@ozerovandrei I've updated this issue with some of the methods I used in the first few PRs. These aren't written in stone, though, so let me know if you want to see something changed. |
@jtopjian rules looks good for now. I think we will extend them with some additional cases about performing resource updates in several steps. I checked current PRs and I want to ask - can we also add simple unit tests for all new helpers in the |
Agreed - I think they'll be helpful. I've added some tests to those three resources where offline unit tests were possible. |
According to this comment we can use |
Another cleanup case: remove |
No, it's listed in the first point at the beginning of this issue: "Replace provider-specific validation code with core Terraform helpers (where applicable). Do not add new validation at this time!" However, please do submit changes which span resources. All PRs should work on individual resources. |
Note to self: before closing this issue, do one final sweep of |
re #592 CheckDeleted also should be added into the LBaaSv2 resources:
|
In my case the server was removed manually, therefore it is a minor issue. Do I need to send a PR or will it be covered by yet another cleanup task? UPD: In addition the |
I've intentionally been ignoring If you'd like, please submit a PR with just the addition of With regard to the |
* Added new resources openstack_keymanager_secret_v1 and openstack_keymanager_secret_metadata_v1 * Added import test and documentation * Refactor to comply with code cleanup (#456) * Secret metadata is no longer its own resource, various small bugfixes Removed secrets metadata resource from provider.go Fixed unit test that wasn't running Fixed unit test that wasn't running * Turned tabs into whitespaces * Fix style nits * Small style corrections, add security notice * vendor commit * Fix various nits Add content types to documentation * Add DiffSuppressFunc for the "payload" parameter * Bump vendor dependencies * Introduce setting the expiration date * Add base64 encoding support * Update secrets docs * Handle importing and applying with the metadata Avoid the "Conflict. Key in request is already in the secret metadata" error message after updating the imported secret with the metadata. * Fix the "payload_content_type" import * Docs typo fix * Update docs format * Fix code typos * Fix code typos * Make secret name optional, as it is mentioned in the docs
This issue will track some internal code cleanup we plan to do over the next while. All PRs related to code cleanup should link to this issue.
At the moment, we plan to:
Replace provider-specific validation code with core Terraform helpers (where applicable). Do not add new validation at this time!
Rename functions to use the "expand/flatten" pattern seen in other providers (example). More about flatten and expand can be read about here.
Attempt to standardize on log and error message formats. Where applicable, use the resource name and the ID of the resource in the message. Example:
Move non-CRUD functions to a separate. For example, functions in the
openstack_dns_zone_v2
resource that are not named*Create
,*Read
,*Update
, or*Delete
will be moved to a file calleddns_zone_v2.go
.Move custom types from
types.go
into the resource file. For example if there was a custom type used inopenstack_dns_zone_v2
, move it fromtypes.go
todns_zone_v2.go
.Ensure
CheckDeleted
is used when it's appropriate to do so.Remove
d.SetId("")
from the delete functions.Check for an error when setting aggregate types.
This list will be updated with any other cleanup items.
A note about naming functions:
Since this provider attempts to support all OpenStack projects, it's important to create names which relate to the specific project and resource in question. This is to prevent case where a Block Storage Key Pair would conflict with a Compute Key Pair (which won't happen - that was just an example). In addition, this provider attempts to support all versions of an OpenStack project. For example, Block Storage v1, v2, and v3.
Functions should be named like so:
resourceComputeKeypairV2
. This defines the*schema.Resource
function for theopenstack_compute_keypair_v2
function.dataSourceComputeKeypairV2
.resourceComputeKeypairV2Read
anddataSourceComputeKeypairV2Read
.expandComputeKeypairV2<Field>
.flattenComputeKeypairV2<Field>
computeKeypairV2<something something>
. Notice howresource
and/ordataSource
were dropped from the name.If a function can apply to more than one resource, name the function appropriately using your best judgement.
These changes should not alter the resources' behavior. If we come across refactoring that might alter the behavior, it will be done in a separate issue. If a change introduced a bug, we will fix it and create a new release as soon as possible.
The text was updated successfully, but these errors were encountered: