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

Plumb rest config through from manager. #1334

Merged
merged 1 commit into from
Feb 5, 2020
Merged

Conversation

porridge
Copy link
Member

@porridge porridge commented Feb 5, 2020

What this PR does / why we need it:

Plumb the config through alongside the client object (since they convey
the same information really) all the way to pipe task.

This way we use the same explicit config everywhere, rather than rely on
config.GetConfig to guess the correct one. This is especially important
when running the controller outside of a cluster.

Fixes kudobuilder/operators#205

Plumb the config through alongside the client object (since they convey
the same information really) all the way to pipe task.

This way we use the same explicit config everywhere, rather than rely on
config.GetConfig to guess the correct one. This is especially important
when running the controller outside of a cluster.
@@ -15,6 +16,7 @@ import (
// Context is a engine.task execution context containing k8s client, templates parameters etc.
type Context struct {
Client client.Client
Config *rest.Config
Copy link
Member

Choose a reason for hiding this comment

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

Should this be a rest.Config and not a pointer? I'm not too sure about the go semantics when to use a pointer and when not, but a pointer indicates that the var can be modified?

Not a blocker for me though.

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 don't think using a pointer or not has any impact on mutability.
rest.Config is a struct, so one uses a pointer when you don't want to make a copy.
This seems consistent with how I see this object type being used elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

The struct member can always be modified here so this isn't a blocker. This is correct. For embedded structs, typically it's better to copy the ref rather than copy the entire struct (with exceptions). @ANeumann82 as a note for other code as well, interfaces are ALWAYS written as the interface value (not with a * for the pointer), but are ALWAYS a reference.

Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

I'd rather have a wrapper around client.Client that also includes rest.Config, but that would be a much larger refactoring. Let's use this as is to fix the current test issues.

@porridge porridge merged commit e2bc07e into master Feb 5, 2020
@porridge porridge deleted the plumb-rest-config branch February 5, 2020 12:53
ANeumann82 pushed a commit that referenced this pull request Feb 13, 2020
Plumb the config through alongside the client object (since they convey
the same information really) all the way to pipe task.

This way we use the same explicit config everywhere, rather than rely on
config.GetConfig to guess the correct one. This is especially important
when running the controller outside of a cluster.

Signed-off-by: Andreas Neumann <aneumann@mesosphere.com>
runyontr pushed a commit that referenced this pull request Mar 11, 2020
Plumb the config through alongside the client object (since they convey
the same information really) all the way to pipe task.

This way we use the same explicit config everywhere, rather than rely on
config.GetConfig to guess the correct one. This is especially important
when running the controller outside of a cluster.

Signed-off-by: Thomas Runyon <runyontr@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

e2e test fail with kind when operator is using pipe tasks
5 participants