Skip to content

[19.03 backport] Allow vendorers of docker/cli to avoid transitively pulling in a big chunk if k8s too - #1894

Merged
silvin-lubecki merged 2 commits into
docker:19.03from
thaJeztah:19.03_backport_reduce_vendoring_impact
May 24, 2019
Merged

[19.03 backport] Allow vendorers of docker/cli to avoid transitively pulling in a big chunk if k8s too#1894
silvin-lubecki merged 2 commits into
docker:19.03from
thaJeztah:19.03_backport_reduce_vendoring_impact

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

backport of #1887 for 19.03

The first commit is a (somewhat unrelated) minor cleanup, the second commit is the interesting one:

    Use underlying `NewKubernetesConfig` directly from compose-on-kubernetes.
    
    The comment on `github.com/docker/cli/kubernetes.NewKubernetesConfig` said:
    
        // Deprecated: Use github.com/docker/compose-on-kubernetes/api.NewKubernetesConfig instead
    
    By making this switch in `github.com/docker/cli/context/kubernetes/load.go` we
    break a vendoring chain:
    
    `github.com/docker/cli/cli/command`
    → `vendor/github.com/docker/cli/cli/context/kubernetes/load.go`
      → `vendor/github.com/docker/cli/kubernetes`
         → `github.com/docker/compose-on-kubernetes/api/compose/...`
    
    This means that projects which just want `github.com/docker/cli/cli/command`
    (which is itself pulled in transitively by
    `github.com/docker/cli/cli-plugins/plugin`) which do not themselves need the
    compose-on-kubernetes API avoid a huge pile of transitive dependencies.
    
    On one of my private projects the diff on the vendor dir is:
    
        280 files changed, 21 insertions(+), 211346 deletions(-)
    
    and includes dropping:
    
    * `github.com/docker/compose-on-kubernetes/api/compose/{clone,impersonation}`
    * `github.com/docker/compose-on-kubernetes/api/compose/{v1alpha3,v1beta1,v1beta2,v1beta3}`
    * `github.com/google/btree`
    * `github.com/googleapis/gnostic`
    * `github.com/gregjones/httpcache`
    * `github.com/peterbourgon/diskv`
    * `k8s.io/api/*` (_lots_ of subpackages)
    * `k8s.io/client-go/{discovery,kubernetes/scheme}`
    
    and I've gone from:
    
        $ du -sh vendor/k8s.io/
        8.1M        vendor/k8s.io/
    
    to:
    
        $ du -sh vendor/k8s.io/
        2.1M        vendor/k8s.io/
    
    (overall I went from 36M → 29M of vendor dir for this particular project)
    
    The change to `cli/command/system/version.go` is just for consistency and
    allows us to drop the now unused alias.
    
    Signed-off-by: Ian Campbell <ijc@docker.com>

Ian Campbell added 2 commits May 20, 2019 18:14
The (small number) of other places which name this import use `kubecontext`,
make it consistent.

Signed-off-by: Ian Campbell <ijc@docker.com>
(cherry picked from commit 1e5129f)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…tes.

The comment on `github.com/docker/cli/kubernetes.NewKubernetesConfig` said:

    // Deprecated: Use github.com/docker/compose-on-kubernetes/api.NewKubernetesConfig instead

By making this switch in `github.com/docker/cli/context/kubernetes/load.go` we
break a vendoring chain:

`github.com/docker/cli/cli/command`
→ `vendor/github.com/docker/cli/cli/context/kubernetes/load.go`
  → `vendor/github.com/docker/cli/kubernetes`
     → `github.com/docker/compose-on-kubernetes/api/compose/...`

This means that projects which just want `github.com/docker/cli/cli/command`
(which is itself pulled in transitively by
`github.com/docker/cli/cli-plugins/plugin`) which do not themselves need the
compose-on-kubernetes API avoid a huge pile of transitive dependencies.

On one of my private projects the diff on the vendor dir is:

    280 files changed, 21 insertions(+), 211346 deletions(-)

and includes dropping:

* `github.com/docker/compose-on-kubernetes/api/compose/{clone,impersonation}`
* `github.com/docker/compose-on-kubernetes/api/compose/{v1alpha3,v1beta1,v1beta2,v1beta3}`
* `github.com/google/btree`
* `github.com/googleapis/gnostic`
* `github.com/gregjones/httpcache`
* `github.com/peterbourgon/diskv`
* `k8s.io/api/*` (_lots_ of subpackages)
* `k8s.io/client-go/{discovery,kubernetes/scheme}`

and I've gone from:

    $ du -sh vendor/k8s.io/
    8.1M	vendor/k8s.io/

to:

    $ du -sh vendor/k8s.io/
    2.1M	vendor/k8s.io/

(overall I went from 36M → 29M of vendor dir for this particular project)

The change to `cli/command/system/version.go` is just for consistency and
allows us to drop the now unused alias.

Signed-off-by: Ian Campbell <ijc@docker.com>
(cherry picked from commit 8635abd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah

Copy link
Copy Markdown
Member Author

ping @ijc @silvin-lubecki @vdemeester PTAL

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #1894 into 19.03 will not change coverage.
The diff coverage is 0%.

@@           Coverage Diff           @@
##            19.03    #1894   +/-   ##
=======================================
  Coverage   56.73%   56.73%           
=======================================
  Files         309      309           
  Lines       21666    21666           
=======================================
  Hits        12292    12292           
  Misses       8477     8477           
  Partials      897      897

1 similar comment
@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #1894 into 19.03 will not change coverage.
The diff coverage is 0%.

@@           Coverage Diff           @@
##            19.03    #1894   +/-   ##
=======================================
  Coverage   56.73%   56.73%           
=======================================
  Files         309      309           
  Lines       21666    21666           
=======================================
  Hits        12292    12292           
  Misses       8477     8477           
  Partials      897      897

@vdemeester vdemeester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@silvin-lubecki silvin-lubecki left a comment

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.

LGTM

@silvin-lubecki
silvin-lubecki merged commit a1b83ff into docker:19.03 May 24, 2019
@thaJeztah
thaJeztah deleted the 19.03_backport_reduce_vendoring_impact branch May 24, 2019 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants