-
Notifications
You must be signed in to change notification settings - Fork 106
[bugfix] fix child classes to be queried only when apic versions allows (DCNE-589) #1407
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
dc6fb13 to
a410de7
Compare
shrsr
left a comment
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
gen/templates/resource_test.go.tmpl
Outdated
| resource.TestCheckResourceAttrSet("aci_{{$.resourceName}}.test", "{{$key}}"), | ||
| {{- end}} | ||
| {{- range $key, $value := $.children}} | ||
| // foo |
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.
| // foo |
gmicol
left a comment
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
b6fb1ff to
1622edf
Compare
gmicol
left a comment
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
samiib
left a comment
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
shrsr
left a comment
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
shrsr
left a comment
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
shrsr
left a comment
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.
Needs rebase
cd1c8d8 to
0f40f27
Compare
shrsr
left a comment
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
anvitha-jain
left a comment
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
samiib
left a comment
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
gmicol
left a comment
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
gen/templates/provider.go.tmpl
Outdated
| } | ||
|
|
||
| func getVersionAPIC(ctx context.Context, diags *diag.Diagnostics, client *client.Client) string { | ||
| requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("/api/node/class/topSystem.json"), "GET", nil) |
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.
We should add a filter on the query for the role == controller to reduce size as this would query the whole set of switches which could be hundreds.
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 one, adjusted the query, which also simplifies the loop
| } | ||
|
|
||
| if requestData.Search("imdata").Search("topSystem").Data() != nil { | ||
| attributes := requestData.Search("imdata").Search("topSystem").Search("attributes").Data().([]interface{}) |
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.
Does this merge attributes with same value but not with different values?
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 am not sure what you mean by this comment but I did spot an issue with the version appending. The duplicates should be removed for the length check
gen/templates/provider.go.tmpl
Outdated
| ) | ||
| } else { | ||
| diags.AddError( | ||
| "Data for topSysytem class could not be retrieved", |
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.
| "Data for topSysytem class could not be retrieved", | |
| "Data for topSystem class could not be retrieved", |
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.
will change
internal/provider/versions.go
Outdated
|
|
||
| package provider | ||
|
|
||
| func classVersions() map[string]string { |
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.
Any reason to use function for this vs a constant?
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.
a constant is not possible because a map cannot be a constant in go, will leverage a package-level variable instead of a function
internal/provider/utils.go
Outdated
| @@ -17,6 +18,19 @@ import ( | |||
| "github.com/hashicorp/terraform-plugin-log/tflog" | |||
| ) | |||
|
|
|||
| func getChildClassesForGetRequest(childClasses []string) []string { | |||
| classVersions := classVersions() | |||
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 think this should be defined as a constant and not a function so we avoid re-addressing the list everytime.
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.
a constant is not possible because a map cannot be a constant in go, will leverage a package-level variable.
|
|
||
| func getAndSetInfraPortBlkAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraPortBlkResourceModel) { | ||
| requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraPortBlk,infraRsAccBndlSubgrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) | ||
| childClasses := getChildClassesForGetRequest([]string{"infraRsAccBndlSubgrp", "tagAnnotation", "tagTag"}) |
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.
Where did infraPortBlk go?
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.
infraPortBlk is the the class being requested in the resource via the DN set in data.Id.ValueString(), so not sure why this would be needed to be set in the rsp-subtree-class ?
|
|
||
| func getAndSetInfraHPortSAttributes(ctx context.Context, diags *diag.Diagnostics, client *client.Client, data *InfraHPortSResourceModel) { | ||
| requestData := DoRestRequest(ctx, diags, client, fmt.Sprintf("api/mo/%s.json?rsp-subtree=full&rsp-subtree-class=%s", data.Id.ValueString(), "infraHPortS,infraRsAccBaseGrp,tagAnnotation,tagTag,tagAnnotation,tagTag"), "GET", nil) | ||
| childClasses := getChildClassesForGetRequest([]string{"infraRsAccBaseGrp", "tagAnnotation", "tagTag"}) |
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.
Where did infraHPortS go?
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.
infraHPortS is the the class being requested in the resource via the DN set in data.Id.ValueString(), so not sure why this would be needed to be set in the rsp-subtree-class ?
| @@ -1,4 +1,4 @@ | |||
| class_version: 6.0(2h)-6.0(8g),6.1(3f)- | |||
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.
shouldn't it be defined for both?
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 was done only for testing, the commPol class itself is supported but there was some behaviour of the class which made us skip it in those versions of testing. I did not want to change this behaviour but I needed a way to mention deprecated class like the case of fvRsBDToRelayP. So the class_version is now use for overall override of the class version when not in meta. The class_version_tests is only applied to the tests.
…of possible response by filter the topSystem request
6a21e40
gmicol
left a comment
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
shrsr
left a comment
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
anvitha-jain
left a comment
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
sajagana
left a comment
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!
No description provided.