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

✨ Allow setting "UseExistingCluster" via environment #223

Closed
wants to merge 1 commit into from

Conversation

ichekrygin
Copy link
Contributor

@ichekrygin ichekrygin commented Nov 24, 2018

This PR is an attempt to address feature request: #222
Non-breaking feature: sparkles (:sparkles:)

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 24, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ichekrygin
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: pwittrock

If they are not already assigned, you can assign the PR to them by writing /assign @pwittrock in a comment when ready.

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 24, 2018
@DirectXMan12
Copy link
Contributor

/kind feature

Can you please tag the PR title according to https://github.com/kubernetes-sigs/controller-runtime/blob/master/VERSIONING.md#pr-process ? Thanks!

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 26, 2018
@DirectXMan12
Copy link
Contributor

We tend to try and favor using structs directly with sane defaults instead of constructors, when possible. Can you make this work with the existing setup? If you need to make a breaking change, now would be the time to do it ;-)

@ichekrygin
Copy link
Contributor Author

@DirectXMan12 thank you for looking into this.

I think I share the sentiment of using structs directly with sane defaults. In this case, however, the struct Environment already has a field UseExistingCluster which I am attempting to set on "client/user" behalf, hence the "constructor" implementation.
The motivation is(was) not to "leak" environment variable value testing into the "client" code.

The alternative, "constructor-less" solution may look a bit ugly and convoluted (or maybe not):

in server.go

func UseExistingCluster() bool {
	return strings.ToLower(os.Getenv(envUseExistingCluster)) == "true"
}

in client code:

func TestMain(m *testing.M) {
	t := &envtest.Environment{
		CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "..", "config", "crds")},
                UseExistingCluster: envtest.UseExistingCluster(),
	}
...

@DirectXMan12 would you be open to "contsturctor" like solion? If so - I will update the PR with...
I guess: "Non-breaking feature: sparkles (:sparkles:)" - is it?

@ichekrygin ichekrygin changed the title Allow setting "UseExistingCluster" via environment Allow setting "UseExistingCluster" via environment. Non-breaking feature: sparkles (:sparkles:) Nov 27, 2018
@ichekrygin ichekrygin changed the title Allow setting "UseExistingCluster" via environment. Non-breaking feature: sparkles (:sparkles:) Allow setting "UseExistingCluster" via environment Nov 27, 2018
@DirectXMan12 DirectXMan12 changed the title Allow setting "UseExistingCluster" via environment ✨ Allow setting "UseExistingCluster" via environment Nov 28, 2018
@DirectXMan12
Copy link
Contributor

So, the other option is changing UseExistingCluster bool to UseExistingCluster *bool, since most people probably don't want to set UseExistingCluster anyway, the awkwardness of builtin-pointers isn't super onerous. Sometimes I miss being able to write Option<bool>...

@ichekrygin
Copy link
Contributor Author

I think I am coming to a realization that this is best handled in each individual project, rather than being built in. Closing.

@ichekrygin ichekrygin closed this Dec 16, 2018
DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Update GitBook release instructions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants