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

Reduce command line flag boilerplate #207

Closed
DirectXMan12 opened this issue Nov 13, 2018 · 8 comments
Closed

Reduce command line flag boilerplate #207

DirectXMan12 opened this issue Nov 13, 2018 · 8 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@DirectXMan12
Copy link
Contributor

We've so far been somewhat CLI-agnostic in controller runtime. However, considering that this is a common task, we may wish to set up some optional helpers (i.e. a pattern) for per-controller flag setup.

This pattern helps make controllers more distinct, which makes it easier to refactor large controllers managers out into smaller ones, choose to run certain controllers, but not all, and can clarify controller setup. It should be advantageous for larger controllers, but not necessarily mandatory for quickly getting up and running.

Something so that you can basically do:

type ControllerOneInit struct {
    Flag1 bool `flag:"flag-one"`
    Flag2 bool `flag:"flag-two"`
}

func (c *MyController) Register(mgr manager.Manager) error {
    return builder.SimpleController().
       ...
       .WithManager(mgr).
       .Reconcile(ControllerOne{
         Option1: c.Flag1,
         Option2: fmt.Sprintf("%v", c.Flag2),
       }).Build()
}

// elsewhere
func main() {
   builder.SimpleManager().
     Controller(&ControllerOneInit{}).
     ...
     .Run(signal.SetupSignals())
}

Perhaps this could be simplified (avoiding the separation between raw options and controller fields) to

type ControllerOne struct {
    Option1 bool `flag:"flag-one"`
    Option2 string `flag:"flag-two"`

    client.Client
}

func (c *ControllerOne) Register(mgr manager.Manager) error {
    return builder.SimpleController().
       ...
       .WithManager(mgr).
       .Reconcile(c).Build()
}

// elsewhere
func main() {
   builder.SimpleManager().
     Controller(&ControllerOne).
     ...
     .Run(signal.SetupSignals())
}

But the separation between raw options and controller fields may be advantageous enough to warrant the extra separation.

cc @cheftako

@DirectXMan12
Copy link
Contributor Author

DirectXMan12 commented Nov 13, 2018

/kind feature
/priority backlog

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. labels Nov 13, 2018
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 26, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 26, 2019
@DirectXMan12
Copy link
Contributor Author

/remove-lifecycle rotten

cc @luxas re componentconfig

@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jun 4, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 2, 2019
@DirectXMan12
Copy link
Contributor Author

/lifecycle frozen

see also #518

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Sep 3, 2019
@vincepri
Copy link
Member

Closing, superseded by #518 and friends

/close

@k8s-ci-robot
Copy link
Contributor

@vincepri: Closing this issue.

In response to this:

Closing, superseded by #518 and friends

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

4 participants