Skip to content

Commit b7ba275

Browse files
authored
Revert "re-implement git-initializer component using git2go (#1939)" (#1950)
This reverts commit 340421d. Signed-off-by: Kent Rancourt <kent.rancourt@microsoft.com>
1 parent 340421d commit b7ba275

File tree

13 files changed

+446
-455
lines changed

13 files changed

+446
-455
lines changed

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ test-unit-go:
103103
cd sdk/v3 && \
104104
go test \
105105
-v \
106-
-tags testUnit \
107106
-timeout=60s \
108107
-race \
109108
-coverprofile=coverage.txt \
@@ -112,7 +111,6 @@ test-unit-go:
112111
cd ../../v2 && \
113112
go test \
114113
-v \
115-
-tags testUnit \
116114
-timeout=60s \
117115
-race \
118116
-coverprofile=coverage.txt \

golangci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
run:
22
concurrency: 1
33
deadline: 10m
4-
build-tags:
5-
- lint
4+
skip-files:
65

76
linters:
87
disable-all: true
Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,24 @@
1-
# escape=`
1+
FROM golang:1.17.2-windowsservercore-1809 as builder
22

3-
FROM brigadecore/win-go-tools:v0.2.0 as builder
3+
ARG VERSION
4+
ARG COMMIT
5+
ENV CGO_ENABLED=0
46

5-
# As of this writing, pacman installs a newer libgit2 than we are able to use.
6-
# Here, we download and install an older version.
7-
RUN curl `
8-
-L `
9-
https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-libgit2-1.2.0-3-any.pkg.tar.zst `
10-
-o C:\windows\temp/libgit2.pkg.tar.zst `
11-
&& bash -l -c "pacman --noconfirm -U /c/windows/temp/libgit2.pkg.tar.zst"
7+
WORKDIR /src
8+
COPY sdk/ sdk/
9+
WORKDIR /src/v2
10+
COPY v2/git-initializer/ git-initializer/
11+
COPY v2/internal/ internal/
12+
COPY v2/go.mod go.mod
13+
COPY v2/go.sum go.sum
1214

13-
WORKDIR C:\\msys64\\brigade
14-
COPY sdk\\ sdk\\
15-
WORKDIR C:\\msys64\\brigade\\v2
16-
COPY v2\\go.mod go.mod
17-
COPY v2\\go.sum go.sum
18-
RUN bash -l -c " `
19-
cd /brigade/v2 `
20-
&& PATH=$PATH:/mingw64/bin `
21-
GOROOT=/mingw64/lib/go `
22-
go mod download `
23-
"
24-
COPY v2\\git-initializer\\ git-initializer\\
25-
COPY v2\\internal\\ internal\\
15+
RUN go build \
16+
-o ../bin/git-initializer.exe \
17+
-ldflags \"-w -X github.com/brigadecore/brigade-foundations/version.version=$env:VERSION -X github.com/brigadecore/brigade-foundations/version.commit=$env:COMMIT\" \
18+
./git-initializer
2619

27-
# The `-tags static,system_libgit2` specified below instruct git2go on how to
28-
# locate libgit2. It does NOT imply our binary is statically linked -- in fact,
29-
# it is not. In theory, that can be accomplished by including
30-
# `-extldflags 'static'` in the `-ldflags`, but we've had no luck getting that
31-
# to work.
32-
RUN bash -l -c " `
33-
cd /brigade/v2 `
34-
&& PATH=$PATH:/mingw64/bin `
35-
GOROOT=/mingw64/lib/go `
36-
go build `
37-
-tags static,system_libgit2 `
38-
-ldflags \"-w -X github.com/brigadecore/brigade-foundations/version.version=$VERSION -X github.com/brigadecore/brigade-foundations/version.commit=$COMMIT\" `
39-
-o ../bin/git-initializer.exe `
40-
./git-initializer `
41-
"
20+
FROM mcr.microsoft.com/windows/nanoserver:1809
4221

43-
ENTRYPOINT [ "C:\\msys64\\brigade\\bin\\git-initializer.exe" ]
22+
COPY --from=builder /src/bin/ /brigade/bin/
4423

45-
FROM mcr.microsoft.com/windows/nanoserver:1809 AS final
46-
47-
USER ContainerAdministrator
48-
49-
# Note that because we were unable to produce a statically-linked binary, we
50-
# depend on a number of .dlls from the builder image, so we just copy them
51-
# all over and add them to the path.
52-
COPY --from=builder C:\\msys64\\mingw64\\bin\\ C:\\mingw64\\bin\\
53-
RUN setx /M PATH "%PATH%;C:\mingw64\bin"
54-
55-
COPY --from=builder C:\\msys64\\brigade\\bin\\ C:\\brigade\\bin\\
56-
57-
USER ContainerUser
58-
59-
ENTRYPOINT ["C:\\brigade\\bin\\git-initializer.exe"]
24+
ENTRYPOINT ["/brigade/bin/git-initializer.exe"]

v2/git-initializer/Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
FROM brigadecore/go-libgit2:v0.1.0 as builder
1+
FROM --platform=$BUILDPLATFORM brigadecore/go-tools:v0.9.0 as builder
22

33
ARG VERSION
44
ARG COMMIT
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
ENV CGO_ENABLED=0
58

69
WORKDIR /src
710
COPY sdk/ sdk/
@@ -12,15 +15,12 @@ RUN go mod download
1215
COPY v2/git-initializer/ git-initializer/
1316
COPY v2/internal/ internal/
1417

15-
# Despite CGO being involved, this builds a statically linked binary
16-
RUN go build \
17-
-tags static,system_libgit2 \
18+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build \
1819
-o ../bin/git-initializer \
19-
-ldflags "-extldflags '-static -lgcrypt -lgpg-error' -w -X github.com/brigadecore/brigade-foundations/version.version=$VERSION -X github.com/brigadecore/brigade-foundations/version.commit=$COMMIT" \
20+
-ldflags "-w -X github.com/brigadecore/brigade-foundations/version.version=$VERSION -X github.com/brigadecore/brigade-foundations/version.commit=$COMMIT" \
2021
./git-initializer
2122

22-
# Note: Cannot use gcr.io/distroless/static:nonroot because we still need glibc
23-
FROM gcr.io/distroless/base:nonroot as final
23+
FROM gcr.io/distroless/static:nonroot as final
2424

2525
COPY --from=builder /src/bin/ /brigade/bin/
2626

v2/git-initializer/credentials.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

v2/git-initializer/events.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)