Skip to content
Permalink
Browse files

Add architecture to /system/info endpoint

With this change /system/info endpoint is going to give
information about the platform architecture it is running on
(arm64, armhf, x86_64)

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
  • Loading branch information...
ivanayov authored and alexellis committed Jun 26, 2019
1 parent cb21af4 commit 2420b387b5cb39738027596413001c3113dc6075
@@ -434,6 +434,10 @@ definitions:
type: string
format: semver
example: 0.8.9
arch:
type: string
description: "Platform architecture"
example: "x86_64"
required:
- provider
- version
@@ -2,6 +2,7 @@ FROM golang:1.10.4 as build
ARG GIT_COMMIT_SHA
ARG GIT_COMMIT_MESSAGE
ARG VERSION='dev'
ARG ARCH

RUN curl -sLSf \
https://raw.githubusercontent.com/teamserverless/license-check/master/get.sh | sh \
@@ -30,7 +31,8 @@ RUN license-check -path ./ --verbose=false "Alex Ellis" "OpenFaaS Project" "Open
&& CGO_ENABLED=0 GOOS=linux go build --ldflags "-s -w \
-X github.com/openfaas/faas/gateway/version.GitCommitSHA=${GIT_COMMIT_SHA}\
-X \"github.com/openfaas/faas/gateway/version.GitCommitMessage=${GIT_COMMIT_MESSAGE}\"\
-X github.com/openfaas/faas/gateway/version.Version=${VERSION}" \
-X \"github.com/openfaas/faas/gateway/version.Version=${VERSION}\" \
-X github.com/openfaas/faas/gateway/types.Arch=${ARCH}"\
-a -installsuffix cgo -o gateway .

FROM alpine:3.9
@@ -9,7 +9,9 @@ export eTAG="latest-dev"
if [ "$arch" = "armv7l" ] ; then
dockerfile="Dockerfile.armhf"
eTAG="latest-armhf-dev"
arch="armhf"
elif [ "$arch" = "aarch64" ] ; then
arch="arm64"
dockerfile="Dockerfile.arm64"
eTAG="latest-arm64-dev"
fi
@@ -35,4 +37,5 @@ VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags | se
docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \
--build-arg GIT_COMMIT_MESSAGE="$GIT_COMMIT_MESSAGE" --build-arg GIT_COMMIT_SHA=$GIT_COMMIT_SHA \
--build-arg VERSION=${VERSION:-dev} \
--build-arg ARCH=$arch \
-t $NS/gateway:$eTAG . -f $dockerfile --no-cache
@@ -48,6 +48,7 @@ func MakeInfoHandler(h http.Handler) http.HandlerFunc {
Name: provider["provider"].(string),
Orchestration: provider["orchestration"].(string),
},
Arch: types.Arch,
}

jsonOut, marshalErr := json.Marshal(gatewayInfo)
@@ -46,3 +46,23 @@ func Test_InfoEndpoint_Returns_Gateway_Version_SHA_And_Message(t *testing.T) {
t.Errorf("length of commit message should be greater than 0. Json body was %s", body)
}
}

func Test_InfoEndpoint_Returns_Arch(t *testing.T) {
body, _, err := fireRequest("http://localhost:8080/system/info", http.MethodGet, "")

if err != nil {
t.Log(err)
t.Fail()
}

gatewayInfo := &types.GatewayInfo{}
err = json.Unmarshal([]byte(body), gatewayInfo)
if err != nil {
t.Errorf("Could not unmarshal gateway info, response body:%s, error:%s", body, err.Error())
t.Fail()
}

if len(gatewayInfo.Arch) == 0 {
t.Errorf("value of arch should be non-empty")
}
}
@@ -1,9 +1,13 @@
package types

// Platform architecture the gateway is running on
var Arch string

// GatewayInfo provides information about the gateway and it's connected components
type GatewayInfo struct {
Provider *ProviderInfo `json:"provider"`
Version *VersionInfo `json:"version"`
Arch string `json:"arch"`
}

// ProviderInfo provides information about the configured provider

0 comments on commit 2420b38

Please sign in to comment.
You can’t perform that action at this time.