Skip to content

Conversation

@inteon
Copy link
Member

@inteon inteon commented Jan 26, 2024

The install test was skipped because the file name did not end with _test.go.
Additionally, the flag parsing for the install and uninstall command was not working for the test because a mix of PreRun and PreRunE was used (cobra only runs PreRun OR PreRunE).
Lastly, the flags were parsed into a global variable, which does not play nicely with a test that calls the flag-parsing code multiple times.

The error was introduced in cert-manager/cert-manager#6562.

@jetstack-bot jetstack-bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 26, 2024
)

var (
kubeConfigFlags = genericclioptions.NewConfigFlags(true)
Copy link
Member Author

Choose a reason for hiding this comment

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

I made these global variables into local variables, so the test can parse flags multiple times without issues.

return n.ActionConfiguration.Init(
n.Factory.RESTClientGetter,
n.EnvSettings.Namespace(),
n.Factory.Namespace,
Copy link
Member Author

Choose a reason for hiding this comment

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

The n.Factory.Namespace seems like a better source-of-truth to get the namespace.

…rrectly

Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@ThatsMrTalbot
Copy link
Contributor

/lgtm

@jetstack-bot
Copy link
Contributor

@ThatsMrTalbot: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

/lgtm

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.

Comment on lines +80 to +81
// WARNING: Do not set PreRun on the command as cobra will not execute PreRun when
// PreRunE is set.
Copy link
Member Author

Choose a reason for hiding this comment

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

I only figured this out after reading their source-code.

@ThatsMrTalbot
Copy link
Contributor

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2024
@inteon
Copy link
Member Author

inteon commented Jan 26, 2024

/approve

@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon

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

The pull request process is described here

Details 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

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 26, 2024
@jetstack-bot jetstack-bot merged commit 34a4661 into cert-manager:main Jan 26, 2024
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. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants