builder: move kube config handling to k8s driver package#2606
Merged
crazy-max merged 2 commits intodocker:masterfrom Aug 7, 2024
Merged
builder: move kube config handling to k8s driver package#2606crazy-max merged 2 commits intodocker:masterfrom
crazy-max merged 2 commits intodocker:masterfrom
Conversation
Signed-off-by: CrazyMax <[email protected]>
691c575 to
f6452c3
Compare
f6452c3 to
111de87
Compare
crazy-max
commented
Jul 16, 2024
Comment on lines
+143
to
+170
| 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 | ||
| } | ||
| } |
Member
Author
There was a problem hiding this comment.
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
crazy-max
commented
Jul 17, 2024
Member
Author
|
@AkihiroSuda When you have time could you take another look please? Thanks |
AkihiroSuda
approved these changes
Aug 7, 2024
| 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. |
Collaborator
There was a problem hiding this comment.
What was "n"?
Maybe the variable was renamed since then? (hard to check from phone now)
Member
Author
There was a problem hiding this comment.
Seems it was the driver config
Line 90 in 63073b6
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 <[email protected]>
b74993b to
acf0216
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #2597