Container-Image veröffentlichen / container (push) v1.4.0 wurde manuell veröffentlicht und verifiziert
51 lines
1.7 KiB
Go
51 lines
1.7 KiB
Go
package buildinfo
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestDockerfileMetadataMatchesRuntimeContracts(t *testing.T) {
|
|
t.Parallel()
|
|
content, err := os.ReadFile("../../Dockerfile")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
dockerfile := string(content)
|
|
wanted := []string{
|
|
"ARG VERSION=" + Version,
|
|
"ARG MINIMUM_UPDATE_VERSION=" + MinimumUpdateVersion,
|
|
"ARG MINIMUM_AGENT_PROTOCOL=" + strconv.Itoa(MinimumAgentProtocol),
|
|
"ARG RUNTIME_CONTRACT_VERSION=" + strconv.Itoa(RuntimeContractVersion),
|
|
"ARG DATABASE_CONTRACT_VERSION=" + strconv.Itoa(DatabaseContractVersion),
|
|
"ARG SCHEMA_VERSION=" + strconv.Itoa(CurrentSchemaVersion),
|
|
}
|
|
for _, line := range wanted {
|
|
if !strings.Contains(dockerfile, line+"\n") {
|
|
t.Errorf("Dockerfile is missing %q", line)
|
|
}
|
|
}
|
|
versionLinkerFlag := "-X github.com/root-kdw12/hetzner-api-dyndns-records-webinterface/internal/buildinfo.Version=${VERSION}"
|
|
if count := strings.Count(dockerfile, versionLinkerFlag); count != 1 {
|
|
t.Fatalf("release version must be linked into the control binary, found %d flags", count)
|
|
}
|
|
if !strings.Contains(dockerfile, "ln -s domain-control /usr/local/bin/update-agent") {
|
|
t.Fatal("Dockerfile is missing the v1.3 Compose compatibility symlink")
|
|
}
|
|
for path, marker := range map[string]string{
|
|
"../../compose.yml": "domain-control-webinterface-prod:" + Version,
|
|
"../../README.md": "domain-control-webinterface-prod:" + Version,
|
|
"../../UPDATE.md": "Compose-Version ist `" + Version + "`",
|
|
} {
|
|
data, readErr := os.ReadFile(path)
|
|
if readErr != nil {
|
|
t.Fatal(readErr)
|
|
}
|
|
if !strings.Contains(string(data), marker) {
|
|
t.Errorf("%s is not synchronized with %s", path, Version)
|
|
}
|
|
}
|
|
}
|