Skip to content

Commit 57db13f

Browse files
committed
Consolidate the Version constant
This puts the Version in a single place, which is a setup for agones-dev#21, and means there will always be constant version information across all the moving pieces. Closes agones-dev#2
1 parent 469443d commit 57db13f

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

gameservers/controller/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"strings"
2020
"time"
2121

22+
"github.com/agonio/agon/pkg"
2223
"github.com/agonio/agon/pkg/client/clientset/versioned"
2324
"github.com/agonio/agon/pkg/client/informers/externalversions"
2425
"github.com/agonio/agon/pkg/signals"
@@ -32,9 +33,7 @@ import (
3233
"k8s.io/client-go/rest"
3334
)
3435

35-
// Version the release version of the gameserver controller
3636
const (
37-
Version = "0.1"
3837
sidecarFlag = "sidecar"
3938
pullSidecarFlag = "always-pull-sidecar"
4039
)
@@ -45,7 +44,7 @@ func init() {
4544

4645
// main starts the operator for the gameserver CRD
4746
func main() {
48-
viper.SetDefault(sidecarFlag, "gcr.io/agon-images/gameservers-sidecar:"+Version)
47+
viper.SetDefault(sidecarFlag, "gcr.io/agon-images/gameservers-sidecar:"+pkg.Version)
4948
viper.SetDefault(pullSidecarFlag, false)
5049

5150
pflag.String(sidecarFlag, viper.GetString(sidecarFlag), "Flag to overwrite the GameServer sidecar image that is used. Can also use SIDECAR env variable")
@@ -62,7 +61,7 @@ func main() {
6261

6362
logrus.WithField(sidecarFlag, sidecarImage).
6463
WithField("alwaysPullSidecarImage", alwaysPullSidecar).
65-
WithField("Version", Version).Info("starting gameServer operator...")
64+
WithField("Version", pkg.Version).Info("starting gameServer operator...")
6665

6766
config, err := rest.InClusterConfig()
6867
if err != nil {

gameservers/sidecar/main.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"net"
2121

2222
"github.com/agonio/agon/gameservers/sidecar/sdk"
23+
"github.com/agonio/agon/pkg"
2324
"github.com/agonio/agon/pkg/util/runtime"
2425
"github.com/sirupsen/logrus"
2526
"github.com/spf13/pflag"
@@ -29,9 +30,7 @@ import (
2930
)
3031

3132
const (
32-
// Version the release version of the sidecar
33-
Version = "0.1"
34-
port = 59357
33+
port = 59357
3534

3635
// gameServerNameEnv is the environment variable for the Game Server name
3736
gameServerNameEnv = "GAMESERVER_NAME"
@@ -58,7 +57,7 @@ func main() {
5857

5958
isLocal := viper.GetBool(localFlag)
6059

61-
logrus.WithField(localFlag, isLocal).WithField("version", Version).WithField("port", port).Info("Starting sdk sidecar")
60+
logrus.WithField(localFlag, isLocal).WithField("version", pkg.Version).WithField("port", port).Info("Starting sdk sidecar")
6261

6362
lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", port))
6463
if err != nil {

pkg/version.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2017 Google Inc. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package pkg
16+
17+
const (
18+
// Version is the global version for all binaries
19+
Version = "0.1"
20+
)

0 commit comments

Comments
 (0)