Pull request: all: imp dev version handling

Merge in DNS/adguard-home from fix-version to master

Squashed commit of the following:

commit ecef63315fb49ae33b4c3f13c0e0be0668340e2b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jan 22 18:59:17 2021 +0300

    updater: imp tests

commit f5243918567430e467c44a48e45169db4560b58b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Jan 22 18:48:10 2021 +0300

    all: imp dev version handling
This commit is contained in:
Ainar Garipov 2021-01-25 14:09:29 +03:00
parent fb9acf4cbd
commit e71019a1f3
4 changed files with 19 additions and 9 deletions

View File

@ -179,7 +179,7 @@ func initConfig() {
config.DHCP.Conf4.ICMPTimeout = 1000 config.DHCP.Conf4.ICMPTimeout = 1000
config.DHCP.Conf6.LeaseDuration = 86400 config.DHCP.Conf6.LeaseDuration = 86400
if ch := version.Channel(); ch == "edge" || ch == "development" { if ch := version.Channel(); ch == version.ChannelEdge || ch == version.ChannelDevelopment {
config.BetaBindPort = 3001 config.BetaBindPort = 3001
} }
} }

View File

@ -126,7 +126,8 @@ func Main() {
func setupContext(args options) { func setupContext(args options) {
Context.runningAsService = args.runningAsService Context.runningAsService = args.runningAsService
Context.disableUpdate = args.disableUpdate Context.disableUpdate = args.disableUpdate ||
version.Channel() == version.ChannelDevelopment
Context.firstRun = detectFirstRun() Context.firstRun = detectFirstRun()
if Context.firstRun { if Context.firstRun {

View File

@ -12,6 +12,7 @@ import (
"testing" "testing"
"github.com/AdguardTeam/AdGuardHome/internal/testutil" "github.com/AdguardTeam/AdGuardHome/internal/testutil"
"github.com/AdguardTeam/AdGuardHome/internal/version"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
@ -72,7 +73,7 @@ func TestUpdateGetVersion(t *testing.T) {
u := NewUpdater(&Config{ u := NewUpdater(&Config{
Client: &http.Client{}, Client: &http.Client{},
Version: "v0.103.0-beta.1", Version: "v0.103.0-beta.1",
Channel: "beta", Channel: version.ChannelBeta,
GOARCH: "arm", GOARCH: "arm",
GOOS: "linux", GOOS: "linux",
}) })
@ -80,7 +81,7 @@ func TestUpdateGetVersion(t *testing.T) {
fakeURL := &url.URL{ fakeURL := &url.URL{
Scheme: "http", Scheme: "http",
Host: net.JoinHostPort("127.0.0.1", lport), Host: net.JoinHostPort("127.0.0.1", lport),
Path: path.Join("adguardhome", "beta", "version.json"), Path: path.Join("adguardhome", version.ChannelBeta, "version.json"),
} }
u.versionCheckURL = fakeURL.String() u.versionCheckURL = fakeURL.String()
@ -258,7 +259,7 @@ func TestUpdater_VersionInto_ARM(t *testing.T) {
u := NewUpdater(&Config{ u := NewUpdater(&Config{
Client: &http.Client{}, Client: &http.Client{},
Version: "v0.103.0-beta.1", Version: "v0.103.0-beta.1",
Channel: "beta", Channel: version.ChannelBeta,
GOARCH: "arm", GOARCH: "arm",
GOOS: "linux", GOOS: "linux",
GOARM: "7", GOARM: "7",
@ -267,7 +268,7 @@ func TestUpdater_VersionInto_ARM(t *testing.T) {
fakeURL := &url.URL{ fakeURL := &url.URL{
Scheme: "http", Scheme: "http",
Host: net.JoinHostPort("127.0.0.1", lport), Host: net.JoinHostPort("127.0.0.1", lport),
Path: path.Join("adguardhome", "beta", "version.json"), Path: path.Join("adguardhome", version.ChannelBeta, "version.json"),
} }
u.versionCheckURL = fakeURL.String() u.versionCheckURL = fakeURL.String()
@ -297,7 +298,7 @@ func TestUpdater_VersionInto_MIPS(t *testing.T) {
u := NewUpdater(&Config{ u := NewUpdater(&Config{
Client: &http.Client{}, Client: &http.Client{},
Version: "v0.103.0-beta.1", Version: "v0.103.0-beta.1",
Channel: "beta", Channel: version.ChannelBeta,
GOARCH: "mips", GOARCH: "mips",
GOOS: "linux", GOOS: "linux",
GOMIPS: "softfloat", GOMIPS: "softfloat",
@ -306,7 +307,7 @@ func TestUpdater_VersionInto_MIPS(t *testing.T) {
fakeURL := &url.URL{ fakeURL := &url.URL{
Scheme: "http", Scheme: "http",
Host: net.JoinHostPort("127.0.0.1", lport), Host: net.JoinHostPort("127.0.0.1", lport),
Path: path.Join("adguardhome", "beta", "version.json"), Path: path.Join("adguardhome", version.ChannelBeta, "version.json"),
} }
u.versionCheckURL = fakeURL.String() u.versionCheckURL = fakeURL.String()

View File

@ -13,12 +13,20 @@ import (
// TODO(a.garipov): Find out if we can get GOARM and GOMIPS values the same way // TODO(a.garipov): Find out if we can get GOARM and GOMIPS values the same way
// we can GOARCH and GOOS. // we can GOARCH and GOOS.
var ( var (
channel string channel string = ChannelDevelopment
goarm string goarm string
gomips string gomips string
version string version string
) )
// Channel constants.
const (
ChannelDevelopment = "development"
ChannelEdge = "edge"
ChannelBeta = "beta"
ChannelRelease = "release"
)
// Channel returns the current AdGuard Home release channel. // Channel returns the current AdGuard Home release channel.
func Channel() (v string) { func Channel() (v string) {
return channel return channel