mirror of
https://github.com/openfaas/faas.git
synced 2025-06-08 16:26:47 +00:00
Update version info endpoint
This commits updates version endpoint to use ProviderInfo and VersionInfo structs from faas-provider.GatewayInfo now uses ProviderInfo and VersionInfo structs. GatewayInfo is left within gateway. Consumer of this endpoint should use typed struct GatewayInfo to parse response. Signed-off-by: Vivek Singh <vivekkmr45@yahoo.in>
This commit is contained in:
parent
11d28b14cc
commit
82cd46ef2a
2
Makefile
2
Makefile
@ -3,7 +3,7 @@ NS?=openfaas
|
||||
|
||||
.PHONY: build-gateway
|
||||
build-gateway:
|
||||
(cd gateway; docker buildx build --platform linux/amd64 -t $NS/gateway:latest-dev .)
|
||||
(cd gateway; docker buildx build --platform linux/amd64 -t ${NS}/gateway:latest-dev .)
|
||||
|
||||
# .PHONY: test-ci
|
||||
# test-ci:
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http/httptest"
|
||||
|
||||
providerTypes "github.com/openfaas/faas-provider/types"
|
||||
"github.com/openfaas/faas/gateway/types"
|
||||
"github.com/openfaas/faas/gateway/version"
|
||||
)
|
||||
@ -24,8 +25,7 @@ func MakeInfoHandler(h http.Handler) http.HandlerFunc {
|
||||
|
||||
defer upstreamCall.Body.Close()
|
||||
|
||||
provider := make(map[string]interface{})
|
||||
providerVersion := &types.VersionInfo{}
|
||||
var provider *providerTypes.ProviderInfo
|
||||
|
||||
upstreamBody, _ := ioutil.ReadAll(upstreamCall.Body)
|
||||
err := json.Unmarshal(upstreamBody, &provider)
|
||||
@ -33,22 +33,14 @@ func MakeInfoHandler(h http.Handler) http.HandlerFunc {
|
||||
log.Printf("Error unmarshalling provider json from body %s. Error %s\n", upstreamBody, err.Error())
|
||||
}
|
||||
|
||||
versionMap := provider["version"].(map[string]interface{})
|
||||
providerVersion.SHA = versionMap["sha"].(string)
|
||||
providerVersion.Release = versionMap["release"].(string)
|
||||
|
||||
gatewayInfo := &types.GatewayInfo{
|
||||
Version: &types.VersionInfo{
|
||||
Version: &providerTypes.VersionInfo{
|
||||
CommitMessage: version.GitCommitMessage,
|
||||
Release: version.BuildVersion(),
|
||||
SHA: version.GitCommitSHA,
|
||||
},
|
||||
Provider: &types.ProviderInfo{
|
||||
Version: providerVersion,
|
||||
Name: provider["provider"].(string),
|
||||
Orchestration: provider["orchestration"].(string),
|
||||
},
|
||||
Arch: types.Arch,
|
||||
Provider: provider,
|
||||
Arch: types.Arch,
|
||||
}
|
||||
|
||||
jsonOut, marshalErr := json.Marshal(gatewayInfo)
|
||||
|
@ -1,25 +1,13 @@
|
||||
package types
|
||||
|
||||
import providerTypes "github.com/openfaas/faas-provider/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
|
||||
type ProviderInfo struct {
|
||||
Name string `json:"provider"`
|
||||
Version *VersionInfo `json:"version"`
|
||||
Orchestration string `json:"orchestration"`
|
||||
}
|
||||
|
||||
// VersionInfo provides the commit message, sha and release version number
|
||||
type VersionInfo struct {
|
||||
CommitMessage string `json:"commit_message,omitempty"`
|
||||
SHA string `json:"sha"`
|
||||
Release string `json:"release"`
|
||||
Provider *providerTypes.ProviderInfo `json:"provider"`
|
||||
Version *providerTypes.VersionInfo `json:"version"`
|
||||
Arch string `json:"arch"`
|
||||
}
|
||||
|
2
gateway/vendor/modules.txt
vendored
2
gateway/vendor/modules.txt
vendored
@ -111,4 +111,4 @@ google.golang.org/protobuf/runtime/protoiface
|
||||
google.golang.org/protobuf/runtime/protoimpl
|
||||
google.golang.org/protobuf/types/known/anypb
|
||||
google.golang.org/protobuf/types/known/durationpb
|
||||
google.golang.org/protobuf/types/known/timestamppb
|
||||
google.golang.org/protobuf/types/known/timestamppb
|
Loading…
x
Reference in New Issue
Block a user