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

tests(notebook-controller): fix unintended shadowing of cfg variable #7664

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jiridanek
Copy link
Member

This is a nasty Go gotcha, and we aren't the first to have trouble with it https://temporal.io/blog/go-shadowing-bad-choices#the-bug

Description

cfg is first declared here

var (
cfg *rest.Config
cli client.Client
envTest *envtest.Environment
ctx context.Context
cancel context.CancelFunc
testNamespaces = []string{}
)

and then the := operator shadows it, and the cfg we are setting is a different cfg. The top cfg remains nil.

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign thesuperzapper for approval. For more information see the Kubernetes Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

This is a nasty Go gotcha, and we aren't the first to have trouble with it
https://temporal.io/blog/go-shadowing-bad-choices#the-bug

Signed-off-by: Jiri Daněk <jdanek@redhat.com>
@jiridanek jiridanek force-pushed the jd_kubeflow_kubeflow_moonlight_shadow branch from 74bebb2 to b28ebd4 Compare November 24, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant