Skip to content

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

Merged
nkubala merged 8 commits intoGoogleContainerTools:masterfrom
dgageot:refactoring-start
Jul 26, 2019
Merged

Starting a refactoring around RunContext and Docker local/remote Api#2497
nkubala merged 8 commits intoGoogleContainerTools:masterfrom
dgageot:refactoring-start

Conversation

@dgageot
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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

}

func getTagger(t latest.TagPolicy, customTag string) (tag.Tagger, error) {
func getTagger(runCtx *runcontext.RunContext) (tag.Tagger, error) {
Copy link
Copy Markdown
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
Copy Markdown
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
dgageot added 8 commits July 24, 2019 18:43
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Once those options are set by command line
flags, they are immutable.

Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
Signed-off-by: David Gageot <david@gageot.net>
@dgageot dgageot force-pushed the refactoring-start branch from 7cb0410 to 916c7d9 Compare July 24, 2019 16:46
@dgageot
Copy link
Copy Markdown
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