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

✨ Structured args in Testing #1541

Conversation

DirectXMan12
Copy link
Contributor

This adds structured arguments to the testing package, deprecating the old style where we do templating in favor of a fluent API with defaults that can be overridden.

This should make it easier for consumers to override individual arguments while not breaking the necessary flags that are required for the API server to function, and should make it easier for us to deal with upcoming changes in the k8s API server that requiring setting flags in some conditions, but not in others that are unrelated to the value of the flag (e.g. certain flags must be passed for older versions, but must NOT be passed for newer versions).

The new API looks roughly like:

apiServer.Configure().
  Disable("insecure-port").
  Append("vmodule", "httplog.go=10").
  Set("v", "5")

There's also a helper to merge the new arguments with the older style ones. To preserve existing behavior, if the end user explicitly passes a template, we'll consider those to be the "defaults", otherwise we'll use our normal new default logic.

Depends on #1540
Part of #1486

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 25, 2021
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 25, 2021
@DirectXMan12 DirectXMan12 force-pushed the feature/testing-structured-args branch from a0649c7 to e3b6d3c Compare May 25, 2021 21:08
This should make it a bit easier to manage argument overrides than the
set of templates we have now, especially while we wait for
componentconfig to be everywhere.

Arguments can be defaulted, and those defaults can be overriden or
appended to, and then finally render to a slice of strings to be passed
as arguments and such.

This should make it easier to configure the API server without needing
to splat out the existing default arguments, maybe splice some stuff
out, etc.

For example:

```go
apiServer.Configure().
  Disable("insecure-port").
  Append("vmodule", "httplog.go=10").
  Set("v", "5")
```
This converts the internal testing package to use structured arguments,
introducing a new helper to preserve compat when specifying legacy args.
@DirectXMan12 DirectXMan12 force-pushed the feature/testing-structured-args branch from e3b6d3c to ddfdfdf Compare May 26, 2021 20:58
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 26, 2021
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/lgtm
/retitle ✨ Structured args in Testing

@k8s-ci-robot k8s-ci-robot changed the title Structured Args in Testing ✨ Structured args in Testing May 26, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 26, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12, vincepri

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

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants