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

Starting a refactoring around RunContext and Docker local/remote Api #2497

Merged
merged 8 commits into from
Jul 26, 2019

Conversation

dgageot
Copy link
Contributor

@dgageot dgageot commented Jul 18, 2019

My goals are:

  • Make the code safer
  • Make is easier to mock
  • Reduce the number of parameters that are to be passed along such as insecureregistries

This is just the beginning of the refactoring but already improves a bit the codebase

@codecov
Copy link

codecov bot commented Jul 18, 2019

Codecov Report

Merging #2497 into master will increase coverage by 0.01%.
The diff coverage is 66.66%.

Impacted Files Coverage Δ
cmd/skaffold/app/cmd/cmd.go 67.74% <ø> (ø) ⬆️
pkg/skaffold/initializer/init.go 43.98% <ø> (ø) ⬆️
pkg/skaffold/debug/debug.go 43.33% <0%> (-1.5%) ⬇️
cmd/skaffold/app/tips/tips.go 0% <0%> (ø) ⬆️
pkg/skaffold/docker/parse.go 87.36% <0%> (-0.98%) ⬇️
pkg/skaffold/docker/image_util.go 0% <0%> (ø) ⬆️
pkg/skaffold/build/cache/cache.go 55.81% <100%> (+2.48%) ⬆️
pkg/skaffold/runner/util/util.go 92.3% <100%> (ø) ⬆️
pkg/skaffold/docker/client.go 73.73% <100%> (+2.16%) ⬆️
cmd/skaffold/app/cmd/build.go 82.5% <100%> (ø) ⬆️
... and 6 more

// NewAPIClient guesses the docker client to use based on current kubernetes context.
func NewAPIClient(forceRemove bool, insecureRegistries map[string]bool) (LocalDaemon, error) {
// NewAPIClientImpl guesses the docker client to use based on current kubernetes context.
func NewAPIClientImpl(runCtx *runcontext.RunContext) (LocalDaemon, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt about having a dockerCLIContext or something that contains just the necessary fields for this constructor? then that can live inside the runcontext and we can just pass that in here.

type DockerCLIContext struct {
  insecureRegistries map[string]bool
  prune bool
}

type RunContext struct {
  dockerCLIContext *DockerCLIContext
  ...
}

func NewAPIClientImpl(cliContext *docker.DockerCLIContext) (LocalDaemon, error) {
  ...
}

cli, err := docker.NewAPIClient(runctx.DockerCLIContext)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I could try that

@@ -197,11 +191,13 @@ func getDeployer(runCtx *runcontext.RunContext) (deploy.Deployer, error) {
}
}

func getTagger(t latest.TagPolicy, customTag string) (tag.Tagger, error) {
func getTagger(runCtx *runcontext.RunContext) (tag.Tagger, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so is the end goal here just to make everything consistent? maybe I'm mistaken but I thought that you wanted to move away from the runcontext in these constructors. just trying to understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:-) For now, I'm aiming at consistency.

@dgageot dgageot force-pushed the refactoring-start branch 4 times, most recently from 774b787 to 7cb0410 Compare July 24, 2019 09:50
Signed-off-by: David Gageot <[email protected]>
Signed-off-by: David Gageot <[email protected]>
Once those options are set by command line
flags, they are immutable.

Signed-off-by: David Gageot <[email protected]>
Signed-off-by: David Gageot <[email protected]>
@dgageot
Copy link
Contributor Author

dgageot commented Jul 24, 2019

@nkubala could you take another look? That would be awesome because this one is a bit painful to rebase.

@nkubala nkubala merged commit c1ff25a into GoogleContainerTools:master Jul 26, 2019
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.

3 participants