Skip to content

Commit 9f431d4

Browse files
committed
Remove now-unnecessary conditionals in templates
1 parent e92bd51 commit 9f431d4

3 files changed

+5
-40
lines changed

Dockerfile-windows-nanoserver.template

+2-21
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,20 @@ SHELL ["cmd", "/S", "/C"]
55
# no Git installed (intentionally)
66
# -- Nano Server is "Windows Slim"
77

8-
{{
9-
def install_directory:
10-
if [ "1.15", "1.16" ] | index(env.version) then
11-
"C:\\go"
12-
else
13-
"C:\\Program Files\\Go"
14-
end
15-
-}}
16-
{{ if install_directory == "C:\\go" then ( -}}
17-
# ideally, this would be C:\go to match Linux a bit closer, but C:\go was the default install path for Go itself on Windows
18-
ENV GOPATH C:\\gopath
19-
# (https://golang.org/cl/283600)
20-
{{ ) else ( -}}
218
# for 1.17+, we'll follow the (new) Go upstream default for install (https://golang.org/cl/283600), which frees up C:\go to be the default GOPATH and thus match the Linux images more closely (https://github.com/docker-library/golang/issues/288)
229
ENV GOPATH C:\\go
2310
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
24-
{{ ) end -}}
2511

2612
# PATH isn't actually set in the Docker image, so we have to set it from within the container
2713
USER ContainerAdministrator
28-
RUN setx /m PATH "%GOPATH%\bin;{{ install_directory }}\bin;%PATH%"
14+
RUN setx /m PATH "%GOPATH%\bin;C:\Program Files\Go\bin;%PATH%"
2915
USER ContainerUser
3016
# doing this first to share cache across versions more aggressively
3117

3218
ENV GOLANG_VERSION {{ .version }}
3319

3420
# Docker's Windows path parsing is absolutely *cursed*; please just trust me on this one -Tianon
35-
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} {{
36-
install_directory
37-
| gsub("\\\\"; "\\\\")
38-
| [ . , . ]
39-
| @json
40-
}}
21+
COPY --from=golang:{{ .version }}-windowsservercore-{{ env.windowsRelease }} ["C:\\\\Program Files\\\\Go","C:\\\\Program Files\\\\Go"]
4122
RUN go version
4223

4324
WORKDIR $GOPATH

Dockerfile-windows-servercore.template

+2-18
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,12 @@ RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
3737
\
3838
Write-Host 'Complete.';
3939

40-
{{
41-
def install_directory:
42-
if [ "1.15", "1.16" ] | index(env.version) then
43-
"C:\\go"
44-
else
45-
"C:\\Program Files\\Go"
46-
end
47-
-}}
48-
{{ if install_directory == "C:\\go" then ( -}}
49-
# ideally, this would be C:\go to match Linux a bit closer, but C:\go was the default install path for Go itself on Windows
50-
ENV GOPATH C:\\gopath
51-
# (https://golang.org/cl/283600)
52-
{{ ) else ( -}}
5340
# for 1.17+, we'll follow the (new) Go upstream default for install (https://golang.org/cl/283600), which frees up C:\go to be the default GOPATH and thus match the Linux images more closely (https://github.com/docker-library/golang/issues/288)
5441
ENV GOPATH C:\\go
5542
# HOWEVER, please note that it is the Go upstream intention to remove GOPATH support entirely: https://blog.golang.org/go116-module-changes
56-
{{ ) end -}}
5743

5844
# PATH isn't actually set in the Docker image, so we have to set it from within the container
59-
RUN $newPath = ('{0}\bin;{{ install_directory }}\bin;{1}' -f $env:GOPATH, $env:PATH); \
45+
RUN $newPath = ('{0}\bin;C:\Program Files\Go\bin;{1}' -f $env:GOPATH, $env:PATH); \
6046
Write-Host ('Updating PATH: {0}' -f $newPath); \
6147
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
6248
# doing this first to share cache across versions more aggressively
@@ -77,11 +63,9 @@ RUN $url = '{{ .arches["windows-amd64"].url }}'; \
7763
\
7864
Write-Host 'Expanding ...'; \
7965
Expand-Archive go.zip -DestinationPath C:\; \
80-
{{ if install_directory != "C:\\go" then ( -}}
8166
\
8267
Write-Host 'Moving ...'; \
83-
Move-Item -Path C:\go -Destination '{{ install_directory }}'; \
84-
{{ ) else "" end -}}
68+
Move-Item -Path C:\go -Destination 'C:\Program Files\Go'; \
8569
\
8670
Write-Host 'Removing ...'; \
8771
Remove-Item go.zip -Force; \

versions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ goVersions="$(
7070
{ GOOS: .os, GOARCH: .arch }
7171
+ if .arch == "386" and .os == "linux" then
7272
# i386 in Debian is non-SSE2, Alpine appears to be similar (but interesting, not FreeBSD?)
73-
{ GO386: (if $major == "1.15" then "387" else "softfloat" end) }
73+
{ GO386: "softfloat" }
7474
elif $bashbrewArch | startswith("arm32v") then
7575
{ GOARCH: "arm", GOARM: ($bashbrewArch | ltrimstr("arm32v")) }
7676
else {} end

0 commit comments

Comments
 (0)