-
Notifications
You must be signed in to change notification settings - Fork 481
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
builder: move kube config handling to k8s driver package #2606
Conversation
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
691c575
to
f6452c3
Compare
f6452c3
to
111de87
Compare
driver/kubernetes/factory.go
Outdated
var err error | ||
var cc ClientConfig | ||
cc, err = ctxkube.ConfigFromEndpoint(endpoint, contextStore) | ||
if err != nil { | ||
// err is returned if n.Endpoint is non-context name like "unix:///var/run/docker.sock". | ||
// try again with name="default". | ||
// FIXME(@AkihiroSuda): n should retain real context name. | ||
cc, err = ctxkube.ConfigFromEndpoint("default", contextStore) | ||
if err != nil { | ||
logrus.Error(err) | ||
} | ||
} | ||
|
||
tryToUseKubeConfigInCluster := false | ||
if cc == nil { | ||
tryToUseKubeConfigInCluster = true | ||
} else { | ||
if _, err := cc.ClientConfig(); err != nil { | ||
tryToUseKubeConfigInCluster = true | ||
} | ||
} | ||
if tryToUseKubeConfigInCluster { | ||
ccInCluster := ClientConfigInCluster{} | ||
if _, err := ccInCluster.ClientConfig(); err == nil { | ||
logrus.Debug("using kube config in cluster") | ||
cc = ccInCluster | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't touch this logic and just moved it from builder package for now but should look at it more closely as follow-up.
111de87
to
b74993b
Compare
@AkihiroSuda When you have time could you take another look please? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
driver/kubernetes/factory.go
Outdated
if err != nil { | ||
// err is returned if n.Endpoint is non-context name like "unix:///var/run/docker.sock". | ||
// try again with name="default". | ||
// FIXME(@AkihiroSuda): n should retain real context name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was "n"?
Maybe the variable was renamed since then? (hard to check from phone now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems it was the driver config
Line 90 in 63073b6
func(i int, n store.Node) { |
I will update this comment.
Also as we now have ContextStore
in driver InitConfig
maybe it would be fine to have ContextName
as well and use it here?
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
b74993b
to
acf0216
Compare
fixes #2597