forked from tailscale/tailscale
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docker: add ALPINE.txt to manage alpine versions
The goal here is to 1. make it so that the number doesn't diverge between the various places we had it defined 2. not define the number in corp, only in oss Signed-off-by: Maisem Ali <[email protected]>
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package version | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"testing" | ||
|
||
ts "tailscale.com" | ||
) | ||
|
||
func TestAlpineTag(t *testing.T) { | ||
if tag := readAlpineTag(t, "../Dockerfile.base"); tag == "" { | ||
t.Fatal(`"FROM alpine:" not found in Dockerfile.base`) | ||
} else if tag != ts.AlpineDockerTag { | ||
t.Errorf("alpine version mismatch: Dockerfile.base has %q; ALPINE.txt has %q", tag, ts.AlpineDockerTag) | ||
} | ||
if tag := readAlpineTag(t, "../Dockerfile"); tag == "" { | ||
t.Fatal(`"FROM alpine:" not found in Dockerfile`) | ||
} else if tag != ts.AlpineDockerTag { | ||
t.Errorf("alpine version mismatch: Dockerfile has %q; ALPINE.txt has %q", tag, ts.AlpineDockerTag) | ||
} | ||
} | ||
|
||
func readAlpineTag(t *testing.T, file string) string { | ||
f, err := os.ReadFile(file) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
for _, line := range bytes.Split(f, []byte{'\n'}) { | ||
line = bytes.TrimSpace(line) | ||
_, suf, ok := bytes.Cut(line, []byte("FROM alpine:")) | ||
if !ok { | ||
continue | ||
} | ||
return string(suf) | ||
} | ||
return "" | ||
} |