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

Access Zone Datasource #2

Merged
merged 1 commit into from
Jul 25, 2023
Merged

Access Zone Datasource #2

merged 1 commit into from
Jul 25, 2023

Conversation

doriac11
Copy link
Collaborator

@doriac11 doriac11 commented Jul 17, 2023

Description

Read Access Zone Datasource using an OpenAPI Client

ISSUE TYPE

  • Feature Pull Request
RESOURCE OR DATASOURCE NAME

Access Zone Datasource

OUTPUT

Apply, Plan and Destroy

mintty_1J3KxgGfRY

ADDITIONAL INFORMATION

Tests

``
TF_ACC=1 go test -v -run TestAccAccessZoneDataSourceAll
=== RUN TestAccAccessZoneDataSourceAll
provider_test.go:86:
provider "powerscale" {
username = "user"
password = "pass"
endpoint = "https://xxxx:8080"
insecure = true
group = ""
volume_path = ""
volume_path_permissions = ""
ignore_unresolvable_hosts = "true"
auth_type = "0"
verbose_logging = "0"
}

config {Host: Scheme: DefaultHeader:map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8] UserAgent:terraform-powermax-provider/1.0.0 Debug:false Servers:[{URL:https://10.225.108.6:8080 Description:https://10.225.108.6:8080 Variables:map[]}] OperationServers:map[] HTTPClient:0xc00032a120} header map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8]config {Host: Scheme: DefaultHeader:map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8] UserAgent:terraform-powermax-provider/1.0.0 Debug:false Servers:[{URL:https://10.225.108.6:8080 Description:https://10.225.108.6:8080 Variables:map[]}] OperationServers:map[] HTTPClient:0xc000516360} header map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8]config {Host: Scheme: DefaultHeader:map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8] UserAgent:terraform-powermax-provider/1.0.0 Debug:false Servers:[{URL:https://10.225.108.6:8080 Description:https://10.225.108.6:8080 Variables:map[]}] OperationServers:map[] HTTPClient:0xc00023a5a0} header map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8]config {Host: Scheme: DefaultHeader:map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8] UserAgent:terraform-powermax-provider/1.0.0 Debug:false Servers:[{URL:https://10.225.108.6:8080 Description:https://10.225.108.6:8080 Variables:map[]}] OperationServers:map[] HTTPClient:0xc0002bf260} header map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8]config {Host: Scheme: DefaultHeader:map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8] UserAgent:terraform-powermax-provider/1.0.0 Debug:false Servers:[{URL:https://10.225.108.6:8080 Description:https://10.225.108.6:8080 Variables:map[]}] OperationServers:map[] HTTPClient:0xc0005175f0} header map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8]config {Host: Scheme: DefaultHeader:map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8] UserAgent:terraform-powermax-provider/1.0.0 Debug:false Servers:[{URL:https://10.225.108.6:8080 Description:https://10.225.108.6:8080 Variables:map[]}] OperationServers:map[] HTTPClient:0xc0003a0270} header map[Accept:application/json; charset=utf-8 Content-Type:application/json; charset=utf-8]--- PASS: TestAccAccessZoneDataSourceAll (10.75s)
PASS
ok terraform-provider-powerscale/powerscale/provider 13.586s

# Checklist:

- [x] I have performed a self-review of my own code to ensure there are no formatting, vetting, linting, or security issues
- [x] I have verified that new and existing unit tests pass locally with my changes
- [x] I have not allowed coverage numbers to degenerate
- [x] I have maintained at least 80% code coverage
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have maintained backward compatibility
.

# How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

- [x] Unit tests
- [x] Acceptance tests

@doriac11
Copy link
Collaborator Author

run e2e test

@NavisJ
Copy link
Contributor

NavisJ commented Jul 20, 2023

Hi @doriac11 The generated openapi code is using int32 for all integers, but it cannot meet our needs, for example

bytes:
          description: Total device storage bytes.
          maximum: 18446744073709552000
          minimum: 0
          type: integer

How can we handle that issue?

And as we discussed before, generating with int64 will cause error.
https://delloneisg.slack.com/archives/C0533BZGVT4/p1688463075276389

FYI @P-Cao @taohe1012 @forrestxia @RayLiu7

@doriac11
Copy link
Collaborator Author

doriac11 commented Jul 20, 2023

Hi @doriac11 The generated openapi code is using int32 for all integers, but it cannot meet our needs, for example

bytes:
          description: Total device storage bytes.
          maximum: 18446744073709552000
          minimum: 0
          type: integer

How can we handle that issue?

And as we discussed before, generating with int64 will cause error. https://delloneisg.slack.com/archives/C0533BZGVT4/p1688463075276389

FYI @P-Cao @taohe1012 @forrestxia @RayLiu7

@shekhar-j lowered the max values for these so we could generate the code (it is in the zip file in the PR). We can use this for now and in the meantime (to extract use make build or make extract-client) we need to reach out to the PowerScale team so they can update their json to include the format: "int64" tags on all of the long values which need to be bigger than then just an int32. For reference: https://swagger.io/specification/ look in the section Data Types the powerscale team needs to mark those fields as format:"int64"

@doriac11
Copy link
Collaborator Author

@NavisJ If you all review and approve this PR we can merge it so you all have a baseline with the client code to work from.

powerscale/helper/helper.go Outdated Show resolved Hide resolved
powerscale/models/access_zone.go Show resolved Hide resolved
powerscale/provider/access_zone_datasource.go Outdated Show resolved Hide resolved
@NavisJ
Copy link
Contributor

NavisJ commented Jul 21, 2023

Hi @doriac11 The generated openapi code is using int32 for all integers, but it cannot meet our needs, for example

bytes:
          description: Total device storage bytes.
          maximum: 18446744073709552000
          minimum: 0
          type: integer

How can we handle that issue?
And as we discussed before, generating with int64 will cause error. https://delloneisg.slack.com/archives/C0533BZGVT4/p1688463075276389
FYI @P-Cao @taohe1012 @forrestxia @RayLiu7

@shekhar-j lowered the max values for these so we could generate the code (it is in the zip file in the PR). We can use this for now and in the meantime (to extract use make build or make extract-client) we need to reach out to the PowerScale team so they can update their json to include the format: "int64" tags on all of the long values which need to be bigger than then just an int32. For reference: https://swagger.io/specification/ look in the section Data Types the powerscale team needs to mark those fields as format:"int64"

The overall workflow looks good to me. But the type issue blocks the development of cluster datasource. error is like

Unable to read cluster nodes, got error: json: cannot unmarshal number
17179869184 into Go struct field
V10ClusterNodeStatusNvram.nodes.status.nvram.supported_size of type int32

Manually change the type can resolve the issue. Can we manually change the type and rezip the code for now?

@doriac11
Copy link
Collaborator Author

Manually change the type can resolve the issue. Can we manually change the type and rezip the code for now?
@NavisJ Yes I guess just manually change for now and rezip. I am going to include the json file we used to generate this code in my next PR. I think we should make the updates in the json file specifically going forward and regenerate so we dont have to change the actual generated code. Then down the line we can always regenerate and have a solid copy of the changes we needed to make.

nikitajoshi1
nikitajoshi1 previously approved these changes Jul 21, 2023
NavisJ
NavisJ previously approved these changes Jul 24, 2023
taohe1012
taohe1012 previously approved these changes Jul 24, 2023
@forrestxia
Copy link
Collaborator

run e2e test

3 similar comments
@forrestxia
Copy link
Collaborator

run e2e test

@forrestxia
Copy link
Collaborator

run e2e test

@forrestxia
Copy link
Collaborator

run e2e test

@forrestxia
Copy link
Collaborator

@doriac11 gosec check has failure
image

And please do the local checks defined in the Makefile and ensure they all pass before raising PR. Sample local check command line is like this:
make clean extract-client check gosec generate build

Makefile Show resolved Hide resolved
@doriac11
Copy link
Collaborator Author

@forrestxia Should we make a pipeline step for gosec, I made sure I was passing all of the other tests before raising, I didnt realize gosec was a test. Will make the changes now

@doriac11
Copy link
Collaborator Author

@doriac11 gosec check has failure image

And please do the local checks defined in the Makefile and ensure they all pass before raising PR. Sample local check command line is like this: make clean extract-client check gosec generate build

@forrestxia , thanks for bringing these to the attention!
I have fixed the first 3 issue (not in the open API generated code).
There was only one repeated issue in the Generated code CME-703 which gosec has actually retired as a rule.
See section Retired Rules https://github.com/securego/gosec#available-rules Rule Maps to G104 https://github.com/securego/gosec/blob/master/issue/issue.go#L60
So I have just added it as an exclusion in the make gosec command.
Thanks!

@forrestxia
Copy link
Collaborator

run e2e test

@forrestxia
Copy link
Collaborator

@forrestxia Should we make a pipeline step for gosec, I made sure I was passing all of the other tests before raising, I didnt realize gosec was a test. Will make the changes now

gosec check was integrated in "Build" stage of terraform pipeline since the beginning.

Copy link
Collaborator

@forrestxia forrestxia left a comment

Choose a reason for hiding this comment

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

the test coverage is below 80%
image

@doriac11
Copy link
Collaborator Author

doriac11 commented Jul 25, 2023

the test coverage is below 80%

@forrestxia I added 2 more tests and now I am at 84%.
Sorry for the additional checks on your part.
image

@doriac11
Copy link
Collaborator Author

run e2e test

@doriac11 doriac11 merged commit b43f96f into main Jul 25, 2023
6 checks passed
@doriac11 doriac11 deleted the accesszone-datasource branch July 25, 2023 13:43
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.

6 participants