Skip to content

Commit

Permalink
Remove client-go lines from go.sum before build
Browse files Browse the repository at this point in the history
When you build using the build script ./bin/build, the go.sum in the Docker image is using Linux dependencies. For some reason there is currently an issue with k8s.io/client-go where the checksum is different depending on your OS, so building on Linux results in a different checksum than building on Darwin. This can mean:
If you run ./bin/build to get an updated go.sum, and then run the keychain provider test locally on your mac, go.sum will be updated with the Darwin checksum. The next time you run ./bin/build, the build will fail due to checksum mismatch.

The solution puts back into place something we removed here (730dcf7#diff-f949e2d81c8076ebbf8af38fcbb72c1f) to ensure the Docker image always has the correct Linux checksum, and locally we can have whatever we like. Ideally this dependency can be removed at some point so that the in-repo go.sum will have more meaning, though they recently closed the related github issue (golang/go#27925) so I'm not sure what progress is being made on this.

In any case, this should prevent manual futzing with go.sum as you switch between Linux/Docker-based development and local Mac-based development.
  • Loading branch information
Geri Jennings committed Dec 4, 2018
1 parent 637b48d commit 3d44aaa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ apt update
$ apt install mercurial
```

### Go.sum fixes for `k8s/client-go`
### A note on go.sum fixes for `k8s/client-go`

`k8s/client-go` downloads a package with mismatching `go.sum` which may present itself
as something like this during builds or attempts to run the code:
Expand All @@ -54,6 +54,9 @@ repository-provided file with the following code and retry your build/run comman
sed -i '/^k8s.io\/client-go\ /d' go.sum
```

In general, we get around this problem for now by editing the go.sum lines related
to `k8s.io/client-go` in the Secretless Broker Dockerfiles.

## Pull Request Workflow

1. Search the [open issues][issues] in GitHub to find out what has been planned
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ ENV GOOS=linux \
CGO_ENABLED=1

COPY go.mod go.sum /secretless/

# There are checksum mismatches in various environments with client-go package
# so we for now manually remove it from the checksum file.
RUN sed -i '/^k8s.io\/client-go\ /d' /secretless/go.sum

RUN go mod download

COPY . /secretless

# There are checksum mismatches in various environments with client-go package
# so we for now manually remove it from the checksum file.
RUN sed -i '/^k8s.io\/client-go\ /d' /secretless/go.sum

RUN go build -o dist/$GOOS/$GOARCH/secretless-broker ./cmd/secretless-broker && \
go build -o dist/$GOOS/$GOARCH/summon2 ./cmd/summon2

Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ RUN go get -u github.com/jstemmer/go-junit-report && \
go get golang.org/x/tools/cmd/goimports

COPY go.mod go.sum /secretless/

# There are checksum mismatches in various environments with client-go package
# so we for now manually remove it from the checksum file.
RUN sed -i '/^k8s.io\/client-go\ /d' /secretless/go.sum

RUN go mod download

# TODO: Expand this with build args when we support other arches
Expand All @@ -38,6 +43,10 @@ ENV GOOS=linux \

COPY . .

# There are checksum mismatches in various environments with client-go package
# so we for now manually remove it from the checksum file.
RUN sed -i '/^k8s.io\/client-go\ /d' /secretless/go.sum

# Not strictly needed but we might as well do this step too since
# the dev may want to run the binary
RUN go build -o dist/$GOOS/$GOARCH/secretless-broker ./cmd/secretless-broker && \
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ RUN apk add -u curl \
musl-dev

COPY go.mod go.sum /secretless/

# There are checksum mismatches in various environments with client-go package
# so we for now manually remove it from the checksum file.
RUN sed -i '/^k8s.io\/client-go\ /d' /secretless/go.sum

RUN go mod download

COPY . .

# There are checksum mismatches in various environments with client-go package
# so we for now manually remove it from the checksum file.
RUN sed -i '/^k8s.io\/client-go\ /d' /secretless/go.sum

0 comments on commit 3d44aaa

Please sign in to comment.