Skip to content

Commit

Permalink
Merge pull request #27 from googleprivate/feature/consolidate-version
Browse files Browse the repository at this point in the history
Consolidate the Version constant
  • Loading branch information
markmandel authored Dec 13, 2017
2 parents 469443d + 57db13f commit 0c61acb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
7 changes: 3 additions & 4 deletions gameservers/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strings"
"time"

"github.com/agonio/agon/pkg"
"github.com/agonio/agon/pkg/client/clientset/versioned"
"github.com/agonio/agon/pkg/client/informers/externalversions"
"github.com/agonio/agon/pkg/signals"
Expand All @@ -32,9 +33,7 @@ import (
"k8s.io/client-go/rest"
)

// Version the release version of the gameserver controller
const (
Version = "0.1"
sidecarFlag = "sidecar"
pullSidecarFlag = "always-pull-sidecar"
)
Expand All @@ -45,7 +44,7 @@ func init() {

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

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

logrus.WithField(sidecarFlag, sidecarImage).
WithField("alwaysPullSidecarImage", alwaysPullSidecar).
WithField("Version", Version).Info("starting gameServer operator...")
WithField("Version", pkg.Version).Info("starting gameServer operator...")

config, err := rest.InClusterConfig()
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions gameservers/sidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net"

"github.com/agonio/agon/gameservers/sidecar/sdk"
"github.com/agonio/agon/pkg"
"github.com/agonio/agon/pkg/util/runtime"
"github.com/sirupsen/logrus"
"github.com/spf13/pflag"
Expand All @@ -29,9 +30,7 @@ import (
)

const (
// Version the release version of the sidecar
Version = "0.1"
port = 59357
port = 59357

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

isLocal := viper.GetBool(localFlag)

logrus.WithField(localFlag, isLocal).WithField("version", Version).WithField("port", port).Info("Starting sdk sidecar")
logrus.WithField(localFlag, isLocal).WithField("version", pkg.Version).WithField("port", port).Info("Starting sdk sidecar")

lis, err := net.Listen("tcp", fmt.Sprintf("localhost:%d", port))
if err != nil {
Expand Down
20 changes: 20 additions & 0 deletions pkg/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package pkg

const (
// Version is the global version for all binaries
Version = "0.1"
)

0 comments on commit 0c61acb

Please sign in to comment.