docker / docker-credential-helpers

Programs to keep Docker login credentials safe by storing in platform keystores
MIT License
1.06k stars 169 forks source link

Set version and revision at linked time #234

Closed crazy-max closed 2 years ago

crazy-max commented 2 years ago

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

codecov-commenter commented 2 years ago

Codecov Report

Merging #234 (a2d8aac) into master (5124911) will not change coverage. The diff coverage is 0.00%.

@@           Coverage Diff           @@
##           master     #234   +/-   ##
=======================================
  Coverage   55.25%   55.25%           
=======================================
  Files           9        9           
  Lines         666      666           
=======================================
  Hits          368      368           
  Misses        255      255           
  Partials       43       43           
Impacted Files Coverage Δ
credentials/credentials.go 52.33% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

thaJeztah commented 2 years ago

oh, sorry; needs a rebase now 😅

thaJeztah commented 2 years ago

Hmm... so for fun, I tried make deb (we need to update that one to something more current, and to not depend on the distro go package); that's something for a follow-up, but I think this part may be related to this PR:

 > [11/11] RUN /build/build-deb v0.6.4-39-geb147ed xenial:
#16 0.312 + set -e
#16 0.312 + version=v0.6.4-39-geb147ed
#16 0.312 + distro=xenial
#16 0.313 ++ awk -F ': ' '$1 == "Maintainer" { print $2; exit }' debian/control
#16 0.315 + maintainer='Docker <support@docker.com>'
#16 0.315 + cat
#16 0.317 ++ date --rfc-2822
#16 0.319 + mkdir -p src/github.com/docker/docker-credential-helpers
#16 0.321 + ln -s /build/credentials /build/src/github.com/docker/docker-credential-helpers/credentials
#16 0.322 + ln -s /build/secretservice /build/src/github.com/docker/docker-credential-helpers/secretservice
#16 0.323 + ln -s /build/pass /build/src/github.com/docker/docker-credential-helpers/pass
#16 0.324 + dpkg-buildpackage -us -uc
#16 0.402 dpkg-buildpackage: warning:     debian/changelog(l1): version 'v0.6.4-39-geb147ed' is invalid: version number does not start with digit
#16 0.402 LINE: docker-credential-helpers (v0.6.4-39-geb147ed) xenial; urgency=low
#16 0.403 dpkg-buildpackage: error: version number does not start with digit
#16 0.404 dpkg-buildpackage: source package docker-credential-helpers
#16 0.404 dpkg-buildpackage: source version v0.6.4-39-geb147ed
------
executor failed running [/bin/sh -c /build/build-deb ${VERSION} ${DISTRO}]: exit code: 255
make: *** [deb] Error 1
crazy-max commented 2 years ago

Hmm... so for fun, I tried make deb (we need to update that one to something more current, and to not depend on the distro go package); that's something for a follow-up, but I think this part may be related to this PR:

Yes I have a branch ready to fix this. Pretty much like https://github.com/docker/docker-credential-helpers/pull/209 but specs not inline.

thaJeztah commented 2 years ago

I tried changing https://github.com/docker/docker-credential-helpers/blob/51249117faffd23a443a45f160f9f20b8d95defe/deb/build-deb#L5

to

version=${1##v}

Which fixes the version issue:

#16 0.748 dpkg-source: info: building docker-credential-helpers in docker-credential-helpers_0.6.4-39-geb147ed.m.tar.gz
#16 0.778 dpkg-source: info: building docker-credential-helpers in docker-credential-helpers_0.6.4-39-geb147ed.m.dsc
#16 0.782  debian/rules build
#16 0.785 dh build

But then breaks because we added -trimpath (and the Go version is too old)

#16 0.932 flag provided but not defined: -trimpath

Yeah, looks like that needs more work (was hoping fixing that version would make it "somewhat" work); let's keep that for later

thaJeztah commented 2 years ago
make pass
./bin/build/docker-credential-pass version
docker-credential-pass (github.com/docker/docker-credential-helpers) v0.6.4-39-geb147ed.m
make VERSION=v1.2.3 pass
./bin/build/docker-credential-pass version
docker-credential-pass (github.com/docker/docker-credential-helpers) v1.2.3

Hm... this one doesn't look right;

make VERSION=v1.2.3 PKG=hello-package  pass
./bin/build/docker-credential-pass version
 (github.com/docker/docker-credential-helpers) v0.0.0+unknown

AH!

make VERSION=v1.2.3 PKG=hello pass
go build -trimpath -ldflags="-s -w -X hello/credentials.Version=v1.2.3 -X hello/credentials.Revision=eb147ed80c90ebba74d2e331daa47528e1578d67.m -X hello/credentials.Package=hello -X hello/credentials.Name=docker-credential-pass" -o ./bin/build/docker-credential-pass ./pass/cmd/

Looks like you're using PKG both for actual package, and for .Package

crazy-max commented 2 years ago

But then breaks because we added -trimpath (and the Go version is too old)

#16 0.932 flag provided but not defined: -trimpath

Yeah, looks like that needs more work (was hoping fixing that version would make it "somewhat" work); let's keep that for later

Yeah deb pkg is broken since Go 1.18.5. I made quick changes to fix that but I have another branch to merge that logic in the main Dockerfile.

Also added a simple gha job to check deb package builds correctly: https://github.com/docker/docker-credential-helpers/runs/8045166392?check_suite_focus=true