forked from openfaas/faas-netes
/
info.go
46 lines (38 loc) · 1.07 KB
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2020 OpenFaaS Author(s)
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
package handlers
import (
"encoding/json"
"net/http"
"github.com/innoobijr/faas-provider/types"
)
const (
//OrchestrationIdentifier identifier string for provider orchestration
OrchestrationIdentifier = "kubernetes"
//ProviderName name of the provider
ProviderName = "faas-netes-ce"
)
// MakeInfoHandler creates handler for /system/info endpoint
func MakeInfoHandler(version, sha string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Body != nil {
defer r.Body.Close()
}
infoResponse := types.ProviderInfo{
Orchestration: OrchestrationIdentifier,
Name: ProviderName,
Version: &types.VersionInfo{
Release: version,
SHA: sha,
},
}
jsonOut, err := json.Marshal(infoResponse)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(jsonOut)
}
}