Extend the Function type with a memoryLimit field, create a conversion to k8s resource value and return it through the REST API.

Signed-off-by: Shikachuu <zcmate@gmail.com>
This commit is contained in:
Shikachuu
2021-09-18 00:42:19 +02:00
committed by Alex Ellis
parent ea62c1b12d
commit cbfefb6fa5
2 changed files with 5 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package handlers
import (
"encoding/json"
"k8s.io/apimachinery/pkg/api/resource"
"log"
"net/http"
@ -37,6 +38,7 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h
for _, fn := range fns {
annotations := &fn.annotations
labels := &fn.labels
memory := resource.NewQuantity(fn.memoryLimit, resource.BinarySI)
res = append(res, types.FunctionStatus{
Name: fn.name,
Image: fn.image,
@ -47,6 +49,7 @@ func MakeReadHandler(client *containerd.Client) func(w http.ResponseWriter, r *h
Secrets: fn.secrets,
EnvVars: fn.envVars,
EnvProcess: fn.envProcess,
Limits: &types.FunctionResources{Memory: memory.String()},
CreatedAt: fn.createdAt,
})
}