-
Notifications
You must be signed in to change notification settings - Fork 227
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
POC: Standardize and verify ID formats #1380
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, resource ID formats are all over the place. The separator is mostly `:`, but sometimes it's `_`, `/` or `;` In this PR, I create a helper struct to manage IDs: - It defines a default separator (with retrocompatibility with the old formats - It provides validation for the number of fields provided. Currently, it panics in most resources if you provide not enough fields - It does auto-generation of the `import.sh` files If this looks good, I can expand this to all resources and then validate that the ID is set this way for all resources. Providing consistent import and ID management for all resources!
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
julienduchesne
commented
Feb 26, 2024
Comment on lines
+44
to
+64
// Import with different ID formats (Legacy and current) | ||
{ | ||
ResourceName: "grafana_cloud_plugin_installation.test-installation", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateId: fmt.Sprintf("%s_%s", stackSlug, pluginSlug), | ||
}, | ||
{ | ||
ResourceName: "grafana_cloud_plugin_installation.test-installation", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateId: fmt.Sprintf("%s:%s", stackSlug, pluginSlug), | ||
}, | ||
// Test import with invalid ID | ||
{ | ||
ResourceName: "grafana_cloud_plugin_installation.test-installation", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateId: "noseparator", | ||
ExpectError: regexp.MustCompile("Error: id \"noseparator\" does not match expected format. Should be in the format: stackSlug:pluginSlug"), | ||
}, |
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 helper is essentially tested here
K-Phoen
approved these changes
Feb 28, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently, resource ID formats are all over the place. The separator is mostly
:
, but sometimes it's_
,/
or;
In this PR, I create a helper struct to manage IDs:
import.sh
filesIf this looks good, I can expand this to all resources and then validate that the ID is set this way for all resources. Providing consistent import and ID management for all resources!