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

Add project import regex #2069

Merged

Conversation

slevenick
Copy link
Contributor

Add project import regex to prevent users from importing by project number (which succeeds but then causes an immediate diff)

Release Note for Downstream PRs (will be copied)

google_project add checks to import to prevent importing by project number instead of id

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
This PR seems not to have generated downstream PRs before, as of 98ae489.

Pull request statuses

No diff detected in terraform-google-conversion.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I built this PR into one or more new PRs on other repositories, and when those are closed, this PR will also be merged and closed.
depends: hashicorp/terraform-provider-google-beta#954
depends: hashicorp/terraform-provider-google#4051

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, d776d22.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@slevenick slevenick requested a review from rileykarson July 17, 2019 20:21
Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so project IDs exist that are namespaced by an org. I think orgs are website URLs, and website URLs can start with numbers. I'm not sure how safe I feel this regex is, unless you can disprove that 123.com:my-project can exist. Validation is hard 🙃

I'd feel better about failing in the specific case of users entering entirely numbers, even if URLs starting with a number are generally not used.

@slevenick
Copy link
Contributor Author

Hmm, so project IDs exist that are namespaced by an org. I think orgs are website URLs, and website URLs can start with numbers. I'm not sure how safe I feel this regex is, unless you can disprove that 123.com:my-project can exist. Validation is hard 🙃

I'd feel better about failing in the specific case of users entering entirely numbers, even if URLs starting with a number are generally not used.

Is that a valid project id? I built the regex based on the assumption that the first character of a project id must be a letter, see description of projectId here https://cloud.google.com/resource-manager/reference/rest/v1/projects

I'm fine with changing it to only disallow number-only ids, as that should work similarly

Copy link
Member

@rileykarson rileykarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! There are legacy project ids floating around namespaced with URLs.

wdyt of changing this to something like ^[0-9]+$ (and flipping the conditional, to fail on a match) so it's more clear what case we're guarding for? It's a little unintuitive reading this that we're filtering for number-only values, since our match is for each non-digit in the string.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 65d169b.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician, I work on Magic Modules.
I see that this PR has already had some downstream PRs generated. Any open downstreams are already updated to your most recent commit, 7eb1501.

Pull request statuses

terraform-provider-google-beta already has an open PR.
No diff detected in terraform-google-conversion.
terraform-provider-google already has an open PR.
No diff detected in Ansible.
No diff detected in Inspec.

New Pull Requests

I didn't open any new pull requests because of this PR.

@modular-magician modular-magician merged commit 4f7e315 into GoogleCloudPlatform:master Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants