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

Repo package cleanups/refactors #2387

Merged
merged 19 commits into from
Feb 2, 2021
Merged

Conversation

justaugustus
Copy link
Member

@justaugustus justaugustus commented Jan 30, 2021

I've reviewed a few PRs recently that I realized had issues that would've been caught by golangci-lint.

Done

  • enable strict checks
  • assert to require
  • yaml to v3
  • go mod to go1.16 and bump dependencies
  • import k/release/pkg/log + logrus
  • need OWNERS
  • add badges
  • why is cmd/kepval/main_test.go in cmd/ without a command
  • verify-go-mod is too strict
  • proper cobra structure
    • kepctl
    • kepval (does this actually exist anymore?)
  • pull PRR structs into API
  • cleanup makefile and hack directory

Follow-ups

  • stop calling directories hack/ (use scripts/)
  • split tests into:
    • go
    • content verification
    • build verification
  • migrate kepify to cobra
  • plumb logrus (replace fmt)
  • refactor out Person/Reviewer field
  • no references to API in commands (means we haven't encapsulated properly)
  • use k/release github token package, if exists
  • inconsistent flag choices

CI

  • use Makefile instead of hack/verify.sh in CI
  • need py3 for boilerplate script
  • need docker for shellcheck

k/release

  • update k/repo-infra version
  • go1.16 go.mod

Handoff (@jeremyrickard)

  • sweep TODOs
  • generate godoc?
  • no type assertions
  • no "helpers"
  • no util package

Not ready for review yet, but:
cc: @kubernetes/enhancements
/hold

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 30, 2021
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 30, 2021
@justaugustus
Copy link
Member Author

(don't review yet and ignore the CI failures... this will get worse before it gets better 🙃)

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 31, 2021
@justaugustus justaugustus added area/enhancements Issues or PRs related to the Enhancements subproject and removed sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. labels Jan 31, 2021
@k8s-ci-robot k8s-ci-robot added the sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. label Jan 31, 2021
},
}

func init() {

Choose a reason for hiding this comment

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

The use of init means no one can cherry pick this command to remix their own cli. I prefer explicitly adding commands and in this way: https://github.com/kubernetes-sigs/zeitgeist/blob/master/buoy/commands/commands.go

"k8s.io/enhancements/pkg/kepctl"
)

// TODO: Struct literal instead?

Choose a reason for hiding this comment

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

@justaugustus
Copy link
Member Author

(Rebased on top of #2388, which pulls out a lot of the non-go changes.)

@justaugustus justaugustus force-pushed the cleanup branch 2 times, most recently from b78806b to 82a4357 Compare February 1, 2021 04:56
@justaugustus
Copy link
Member Author

justaugustus commented Feb 1, 2021

I started rewriting the validation logic with github.com/go-playground/validator/v10.

82a4357 shows that off with a fake required field:

 --- FAIL: TestValidation (0.09s)
    --- FAIL: TestValidation/../keps/sig-api-machinery/1904-efficient-watch-resumption/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Alpha.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Stable.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-api-machinery/1904-efficient-watch-resumption/kep.yaml
    --- FAIL: TestValidation/../keps/sig-apps/2214-indexed-job/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Stable.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-apps/2214-indexed-job/kep.yaml
    --- FAIL: TestValidation/../keps/sig-apps/2255-pod-cost/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Stable.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-apps/2255-pod-cost/kep.yaml
    --- FAIL: TestValidation/../keps/sig-apps/592-ttl-after-finish/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Alpha.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Stable.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-apps/592-ttl-after-finish/kep.yaml
    --- FAIL: TestValidation/../keps/sig-apps/85-Graduate-PDB-to-Stable/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Alpha.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-apps/85-Graduate-PDB-to-Stable/kep.yaml
    --- FAIL: TestValidation/../keps/sig-auth/1393-oidc-discovery/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Alpha.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-auth/1393-oidc-discovery/kep.yaml
    --- FAIL: TestValidation/../keps/sig-network/2079-network-policy-port-range/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Stable.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-network/2079-network-policy-port-range/kep.yaml
    --- FAIL: TestValidation/../keps/sig-network/2200-externalips-admission/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Alpha.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-network/2200-externalips-admission/kep.yaml
    --- FAIL: TestValidation/../keps/sig-scheduling/1923-prefer-nominated-node/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Stable.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-scheduling/1923-prefer-nominated-node/kep.yaml
    --- FAIL: TestValidation/../keps/sig-storage/1412-immutable-secrets-and-configmaps/kep.yaml (0.00s)
        metadata_test.go:126: 
            	Error Trace:	metadata_test.go:126
            	Error:      	Expected nil, but got: validating PRR: running validation: Key: 'PRRApproval.Alpha.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.Beta.Approver' Error:Field validation for 'Approver' failed on the 'required' tag
            	            	Key: 'PRRApproval.FakeRequiredField' Error:Field validation for 'FakeRequiredField' failed on the 'required' tag
            	Test:       	TestValidation/../keps/sig-storage/1412-immutable-secrets-and-configmaps/kep.yaml
FAIL
FAIL	command-line-arguments	0.104s
FAIL
FAILED   verify-kep-metadata.sh	4s 

(not quite there yet, but getting closer!)

@justaugustus justaugustus force-pushed the cleanup branch 2 times, most recently from 2d4148b to faa7fce Compare February 1, 2021 07:06
@justaugustus justaugustus added this to the keps-beta milestone Feb 1, 2021
@justaugustus justaugustus changed the title [WIP] Repo package cleanups Repo package cleanups/refactors Feb 1, 2021
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 1, 2021
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
Signed-off-by: Stephen Augustus <foo@auggie.dev>
@justaugustus
Copy link
Member Author

/hold cancel
(rebased to pull in #2397)

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 2, 2021
@jeremyrickard
Copy link
Contributor

/lgtm

I took a look at this, I think it sets us up for a good state for future work. Thanks @justaugustus

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 2, 2021
@justaugustus
Copy link
Member Author

/pony party

@k8s-ci-robot
Copy link
Contributor

@justaugustus: pony image

In response to this:

/pony party

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@palnabarun
Copy link
Member

Thank you @justaugustus 👍🏽

/lgtm
/honk

@k8s-ci-robot
Copy link
Contributor

@palnabarun:
goose image

In response to this:

Thank you @justaugustus 👍🏽

/lgtm
/honk

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot merged commit 18903e5 into kubernetes:master Feb 2, 2021
@k8s-ci-robot k8s-ci-robot modified the milestones: keps-beta, v1.21 Feb 2, 2021
proposal.Error = errors.Wrap(err, "error validating KEP metadata")
return proposal
}
*/
Copy link
Member

Choose a reason for hiding this comment

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

@justaugustus - why this was commented out? We no longer validate e.g. if PRR approvers are from PRR approvers, etc....

@jeremyrickard

@johnbelamaric @deads2k - FYI

Copy link
Member Author

Choose a reason for hiding this comment

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

@wojtek-t -- Discussing on #enhancements and will send an updated PR later.

Thanks for flagging this!

justaugustus added a commit to justaugustus/enhancements that referenced this pull request Feb 4, 2021
k8s-ci-robot added a commit that referenced this pull request Feb 4, 2021
Revert "Merge pull request #2387 from justaugustus/cleanup"
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. area/enhancements Issues or PRs related to the Enhancements subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants