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

Refactor writing Terraform resources #14723

Merged
merged 2 commits into from
Dec 6, 2022

Conversation

johngmyers
Copy link
Member

This is the big one; a lot of type combinations needed to be covered.

The risk is that there's some combination of types that exists in our code but isn't exercised by our integration tests. I tested a version where all nil pointers were replaced by zero values and all empty slices were replaced by a slice containing a zero value. That didn't produce any panics. So the risk would be a resource type that isn't exercised at all in the integration tests.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 5, 2022
@k8s-ci-robot k8s-ci-robot requested review from hakman and zetaab December 5, 2022 06:07
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 5, 2022
elem := v.Index(i)
if elem.Kind() == reflect.Pointer {
// TODO can these ever be nil?
elem = elem.Elem()
Copy link
Member

Choose a reason for hiding this comment

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

Agree that panic-ing here probably makes sense. It would be surprising to have a nil in a list of strings...


func (s *sliceObject) Write(buffer *bytes.Buffer, indent int, key string) {
for _, member := range s.members {
member.Write(buffer, indent, key)
Copy link
Member

Choose a reason for hiding this comment

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

I was surprised we didn't need [ or , here. But now I see that it's because these are slices of objects, which are just written without delimeters. Makes sense, but a comment might be helpful here.

@justinsb
Copy link
Member

justinsb commented Dec 5, 2022

This LGTM, and we do have test coverage.

/lgtm
/approve

/hold to give others a chance to comment, but I think you can self-remove the hold after a few hours @johngmyers

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 5, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 5, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 5, 2022
@johngmyers
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Dec 6, 2022
@johngmyers
Copy link
Member Author

Argh, pushed commit to wrong branch. Removed.

@hakman
Copy link
Member

hakman commented Dec 6, 2022

Argh, pushed commit to wrong branch. Removed.

You sure?

@johngmyers johngmyers force-pushed the refactor-tf-resource branch from 6864a99 to 272171e Compare December 6, 2022 03:49
@johngmyers
Copy link
Member Author

I'm having a bad git day, I suppose.

@hakman
Copy link
Member

hakman commented Dec 6, 2022

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 6, 2022
@johngmyers
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit 255713e into kubernetes:master Dec 6, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Dec 6, 2022
@johngmyers johngmyers deleted the refactor-tf-resource branch December 6, 2022 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants