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 GCP validation for project and shared_vpc_project_number #11

Merged
merged 3 commits into from
Aug 10, 2020

Conversation

okrause
Copy link
Contributor

@okrause okrause commented Aug 2, 2020

This PR contains three commits.

  1. Fix typo (montly -> monthly) in variable name. Cosmetic

  2. Add validation for "project" and "shared_vpc_project_number" attributes
    On GCP, users often confuse project_ID (mostly used within GCP) and project_number (which the CVS API uses). This led to multiple annoyances when users specified the alpha-numerical project_ID , instead of the numerical project_number. When doing so, the error message is less than helpful:

netapp-gcp_volume.gcp-volume: Creating...

Error: invalid character '<' looking for beginning of value

  on volume.tf line 3, in resource "netapp-gcp_volume" "gcp-volume":
   3: resource "netapp-gcp_volume" "gcp-volume" {

This commit adds a validation to "project" and "shared_vpc_project_number" to be numeric. Since project_id needs to start with a lowercase letter, this will prevent users from specifying a project_id and will return an helpful error message. The commit misses tests to test the validation. Manual tests did work.

  1. Mark the password field of Active Directory username/password as sensitive. Terraform will stop printing its content, but will print "(sensitive value)" instead.

Additionally, my editor (VSCode) enforces some formatting rules automatically. Some lines got cleaned up.

Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile("^[0-9]+$"), "shared_vpc_project_number must be an numerical project number"),
Copy link
Contributor

Choose a reason for hiding this comment

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

an --> a

"log"
"time"

"github.com/fatih/structs"
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a convention here, I see that these lines keep moving around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Likely, but not directly enforced by myself. I am using VScode and it does a lot of formatting and adding imports automatically. See here: https://github.com/golang/vscode-go/blob/master/docs/features.md#format-and-organize-imports
Looks like it is eventually calling "goimport", which manages the import lines and organises them in a defined GO way.

@lonico lonico merged commit 9fea7b6 into NetApp:master Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants