Skip to content

Commit

Permalink
Get system architecture from code
Browse files Browse the repository at this point in the history
  • Loading branch information
srisco committed Jun 16, 2020
1 parent f8b9f38 commit ec30533
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM golang:1.14 as build

ARG VERSION
ARG GIT_COMMIT
ARG PLATFORM="x86_64"
ARG GOOS=linux

RUN mkdir /oscar
Expand All @@ -15,8 +14,7 @@ COPY pkg pkg

RUN GOOS=${GOOS} CGO_ENABLED=0 go build --ldflags "-s -w \
-X \"github.com/grycap/oscar/pkg/version.Version=${VERSION}\" \
-X \"github.com/grycap/oscar/pkg/version.GitCommit=${GIT_COMMIT}\" \
-X \"github.com/grycap/oscar/pkg/version.Platform=${PLATFORM}\"" \
-X \"github.com/grycap/oscar/pkg/version.GitCommit=${GIT_COMMIT}\"" \
-a -installsuffix cgo -o oscar .


Expand Down
2 changes: 1 addition & 1 deletion pkg/types/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package types
type Info struct {
Version string `json:"version"`
GitCommit string `json:"git_commit"`
Platform string `json:"platform"`
Architecture string `json:"architecture"`
KubeVersion string `json:"kubernetes_version"`
ServerlessBackendInfo *ServerlessBackendInfo `json:"serverless_backend,omitempty"`
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package version

import (
"runtime"

"github.com/grycap/oscar/pkg/types"
"k8s.io/client-go/kubernetes"
)
Expand All @@ -27,9 +29,6 @@ var (

// GitCommit SHA of last git commit
GitCommit string

// Platform architecture of the compiled binary
Platform string
)

// GetInfo returns version info
Expand All @@ -43,7 +42,7 @@ func GetInfo(kubeClientset *kubernetes.Clientset, back types.ServerlessBackend)
return types.Info{
Version: version,
GitCommit: GitCommit,
Platform: Platform,
Architecture: runtime.GOARCH,
KubeVersion: getKubeVersion(kubeClientset),
ServerlessBackendInfo: back.GetInfo(),
}
Expand Down

0 comments on commit ec30533

Please sign in to comment.