-
Notifications
You must be signed in to change notification settings - Fork 84
Support constraint resource #1583
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
base: master
Are you sure you want to change the base?
Conversation
9c66200
to
08c6e8a
Compare
/test-all |
55d0970
to
a95e930
Compare
/test-all |
a95e930
to
8335adf
Compare
/test-all |
ee8bfdd
to
3491de5
Compare
/test-all |
3491de5
to
13c8872
Compare
/test-all |
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.
Everything looks good, just a question inline
@@ -178,7 +178,7 @@ func testAccNsxtVpcExists(displayName string, resourceName string) resource.Test | |||
return fmt.Errorf("Policy Vpc resource ID not set in resources") | |||
} | |||
|
|||
exists, err := resourceNsxtVpcExists(testAccGetProjectContext(), resourceID, connector) | |||
exists, err := resourceNsxtVpcExists(testAccGetMultitenancyContext(), resourceID, connector) |
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.
Is this change (and the other similar ones) unrelated to this commit?
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've renamed this helper as part of PR, for improved code readability.
13c8872
to
8ae9025
Compare
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.
Few nits
@@ -0,0 +1,137 @@ | |||
//nolint:revive |
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.
Do we store the updated api_list.yaml
anywhere?
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.
In the generator repository
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.
OK, I guess that the correct thing would be merging the one in the provider repo with the one in the generator repo (they are different), and delete the one in the provider repo. Makes sense?
docs/resources/policy_constraint.md
Outdated
* `description` - (Optional) Description of the resource. | ||
* `message` - (Optional) User friendly message to be shown to users upon violation. | ||
* `target` - (Optional) Targets for the constraints to be enforced | ||
* `path_prefix` - (Optional) Prefix match to the path, needs to end with `\` |
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.
Examples above start with /
. So I'm guessing that one of these is wrong.
Type: schema.TypeList, | ||
Elem: &metadata.ExtendedResource{ | ||
Schema: map[string]*metadata.ExtendedSchema{ | ||
"path_prefix": { |
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.
Can we validate that /
or \
suffix?
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.
No need to add the slash anymore, as per your suggestion below
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.
So now we can validatePolicyPath
here, I think.
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'd rather give the user an option to configure with trailing slash, in case they would want to follow the API exactly. Unless we want to deviate from the API and also rename this attribute to vpc_path
, assuming that NSX will not extend functionality to support other types of path prefixes
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.
To follow the API, they have to look into the API spec, I doubt that anyone will bother. But yeah it's not important.
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.
Users sometimes probe the API and copy values from response
|
||
## Target resource types | ||
|
||
|Object|project + VPC|project only|VPC only| |
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.
How do we maintain this list? Do we gather this from some doc?
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.
This is not documented anywhere as far as I know. I followed the UI to build the table
message = "%s" | ||
|
||
target { | ||
path_prefix = "${data.nsxt_vpc.test.path}/" |
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.
This is a bit ugly - if users will have to manipulate paths in that manner. Can we do that automatically if not suffixed by /
?
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.
Good point, done
2f2b05e
to
7d957c1
Compare
/test-all |
7d957c1
to
a6ff05a
Compare
/test-all |
docs/resources/policy_constraint.md
Outdated
message = "too many objects mate" | ||
|
||
target { | ||
path_prefix = "/orgs/default/projects/demo/" |
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.
So now we don't need the trailing slash in the example, right?
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.
Few other nits
docs/resources/policy_constraint.md
Outdated
display_name = "demo1-quota" | ||
|
||
target { | ||
path_prefix = "/orgs/default/projects/demo/vpcs/demo1/" |
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.
Same here
Type: schema.TypeList, | ||
Elem: &metadata.ExtendedResource{ | ||
Schema: map[string]*metadata.ExtendedSchema{ | ||
"path_prefix": { |
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.
So now we can validatePolicyPath
here, I think.
a6ff05a
to
7d68b46
Compare
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.
LGTM
Signed-off-by: Anna Khmelnitsky <[email protected]>
7d68b46
to
3be751f
Compare
No description provided.