Skip to content

cli/compose: use go1.16 native embed functionality for schemas#3253

Merged
silvin-lubecki merged 1 commit intodocker:masterfrom
thaJeztah:native_embed
Aug 16, 2021
Merged

cli/compose: use go1.16 native embed functionality for schemas#3253
silvin-lubecki merged 1 commit intodocker:masterfrom
thaJeztah:native_embed

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Aug 14, 2021

This allows us to drop the //go:generate and use of the github.com/mjibson/esc utility.

worth noting that Go's native "embed" does not compress files. We could compress these files as part of a build / validate step (which would add some complexity when updating these files) if this is a concern, but not sure if the additional complexity is warranted.

Comparing before/after sizes (see below);

macOS: 54125840 - 54005264 = 120576 (+120.58 kB)
Linux: 52393231 - 52277701 = 115530 (+115.53 kB)

Before:

ls -l build/
total 208736
lrwxr-xr-x  1 sebastiaan  staff        19 Aug 15 09:36 docker@ -> docker-linux-amd64
-rwxr-xr-x  1 sebastiaan  staff  54005264 Aug 15 09:35 docker-darwin-amd64*
-rwxr-xr-x  1 sebastiaan  staff  52277701 Aug 15 09:36 docker-linux-amd64*

After:

ls -l build/
total 208960
lrwxr-xr-x  1 sebastiaan  staff        18 Aug 15 09:32 docker@ -> docker-linux-amd64
-rwxr-xr-x  1 sebastiaan  staff  54125840 Aug 15 09:31 docker-darwin-amd64*
-rwxr-xr-x  1 sebastiaan  staff  52393231 Aug 15 09:32 docker-linux-amd64*

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Aug 14, 2021
@thaJeztah thaJeztah added this to the 21.xx milestone Aug 14, 2021
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Aug 14, 2021

Codecov Report

Merging #3253 (818564a) into master (304a2dc) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3253   +/-   ##
=======================================
  Coverage   57.99%   57.99%           
=======================================
  Files         302      302           
  Lines       21748    21748           
=======================================
  Hits        12613    12613           
  Misses       8212     8212           
  Partials      923      923           

@thaJeztah
Copy link
Copy Markdown
Member Author

@cpuguy83 @silvin-lubecki ptal

This allows us to drop the `//go:generate` and use of the github.com/mjibson/esc
utility.

worth noting that Go's native "embed" does not compress files. We could compress
these files as part of a build / validate step (which would add some complexity
when updating these files) if this is a concern, but not sure if the additional
complexity is warranted.

Comparing before/after sizes (see below);

    macOS: 54125840 - 54005264 = 120576 (+120.58 kB)
    Linux: 52393231 - 52277701 = 115530 (+115.53 kB)

Before:

    ls -l build/
    total 208736
    lrwxr-xr-x  1 sebastiaan  staff        19 Aug 15 09:36 docker@ -> docker-linux-amd64
    -rwxr-xr-x  1 sebastiaan  staff  54005264 Aug 15 09:35 docker-darwin-amd64*
    -rwxr-xr-x  1 sebastiaan  staff  52277701 Aug 15 09:36 docker-linux-amd64*

After:

    ls -l build/
    total 208960
    lrwxr-xr-x  1 sebastiaan  staff        18 Aug 15 09:32 docker@ -> docker-linux-amd64
    -rwxr-xr-x  1 sebastiaan  staff  54125840 Aug 15 09:31 docker-darwin-amd64*
    -rwxr-xr-x  1 sebastiaan  staff  52393231 Aug 15 09:32 docker-linux-amd64*

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copy link
Copy Markdown
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM, I'm glad we removed the dependency on ESC tool 👍

@thaJeztah
Copy link
Copy Markdown
Member Author

I'm glad we removed the dependency on ESC tool 👍

Yes, I love the //go:embed feature. I wish it had a compress option for situations like this, although the size difference won't make much of a difference for the .deb and .rpm packages (which use compression); the binary is somewhat larger though (but with Go binaries already being large due to the runtime, it's only a tiny _percentage);

macOS: 54125840 - 54005264 = 120576 (+120.58 kB / 0.22%)
Linux: 52393231 - 52277701 = 115530 (+115.53 kB / 0.22%)

@silvin-lubecki silvin-lubecki merged commit e3dfc24 into docker:master Aug 16, 2021
@thaJeztah thaJeztah deleted the native_embed branch August 16, 2021 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants