-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Implement ConfigTree in approve plugin #12440
Conversation
Hmm, looks like I have to tweak |
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'm not sure I am the biggest fan of how this looks to use as a consumer and the loss of type safety. I wonder how complex the Go program would be to auto-generate a typed tree struct given a type?
I am not sure it's possible to generate types at runtime in Go... |
Sorry, not at runtime but at compile time -- we can check in the generated code. Something like this: https://github.com/taylorchu/generic The |
But this is a bit against what @cjwagner was saying here: #9757 (comment) |
Instead of having the leaf config struct type be type LeafConfig interface {
MarshalJSON() ([]byte, error)
UnmarshalJSON([]byte) error
Apply(parent LeafConfig) (LeafConfig, error)
} Concrete implementations of LeafConfig would have to use a type cast in the I'd also be ok with Steve's suggestion, but I'd prefer to use the features go provides instead of code generation if possible. |
Thanks, I will try my best :) |
I'm pretty sure the ast package et al are provided by the language specifically to allow people to do what I mentioned. Does the interface you expected still require the |
I'm not familiar with that package and https://golang.org/pkg/go/ast/#pkg-examples doesn't really make it clear how we would use the package for these purposes. How would you use the
No. I don't think that is even necessary with the current implementation. We can and should be applying the parent configs to child configs when the config is first loaded. We probably still want a getter func to retrieve the most specific config that is available given an org, repo, and branch (like we have for branch protection). |
You generate code by building the AST then printing it -- that's what is used for all of the generated clients, conversions, deep-copies for k8s, etc. If we have an interface-based approach that doesn't need the |
AST sounds cool and would likely provide the cleanest API, but I think the interface approach will be nearly as clean, will probably be simpler, and will allow for more flexible leaf config merging so thats what I'm leaning towards right now. |
Agreed -- the implementation in the PR today resolves the values at runtime and offloads that to the caller which I think is not the most clean implementation, but if we can get typed accessors and validation on config load I think the interface based approach would be perfect. |
1858660
to
5785601
Compare
@cjwagner one question though... what type should I put in If I put It seems (I might be wrong) that somehow I have to declare all the chain |
Hmmm, we can't unmarshal into a nil interface, but we should be able to unmarshal into a populated interface variable since it implements
|
Generation is what makes k8s apimachinery work and honestly I think it's a bit scary up-front but the output is really simple -- reviewable Go code, etc. I think it might be our best bet here. |
I will experiment, but it'll be later as I'm handling my KEP for 1.15 in priority... |
I was thinking of trying with https://github.com/google/gvisor/blob/master/tools/go_generics/generics.go any thoughts? |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
@BenTheElder I should present this work to the sig-testing meeting one day... to check if it still makes sense to modify the configuration format. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
PR needs rebase. 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. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closed this PR. In response to this:
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. |
/reopen |
@matthyx: Reopened this PR. In response to this:
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: matthyx The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@matthyx: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
Hello @matthyx, the Prow source code has been moved to https://github.com/kubernetes-sigs/prow on April 9, 2024. |
Yes thanks for the reminder I'll do this soon |
Fixes #9757
@cjwagner I couldn't make this work without encapsulating the config inside a config section... if you have any idea on how to make that work with
json.RawMessage
pls advise.