Migrate to latest faas-provider version

Adds CRUD for namespaces and moves namespace for delete/
scale to the body from the query string.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alex@openfaas.com>
This commit is contained in:
Alex Ellis (OpenFaaS Ltd)
2023-07-07 09:51:38 +01:00
parent c0d710c97f
commit 68ec0f59d6
243 changed files with 7719 additions and 4258 deletions

View File

@ -12,27 +12,42 @@ const (
// FaaSHandlers provide handlers for OpenFaaS
type FaaSHandlers struct {
// ListNamespace lists namespaces which are annotated for OpenFaaS
ListNamespaces http.HandlerFunc
// MutateNamespace mutates a namespace to be annotated for OpenFaaS
// each namespace must contain an annotation of "openfaas=1"
MutateNamespace http.HandlerFunc
// FunctionProxy provides the function invocation proxy logic. Use proxy.NewHandlerFunc to
// use the standard OpenFaaS proxy implementation or provide completely custom proxy logic.
FunctionProxy http.HandlerFunc
FunctionReader http.HandlerFunc
DeployHandler http.HandlerFunc
// FunctionLister lists deployed functions within a namespace
FunctionLister http.HandlerFunc
DeleteHandler http.HandlerFunc
ReplicaReader http.HandlerFunc
ReplicaUpdater http.HandlerFunc
SecretHandler http.HandlerFunc
// LogHandler provides streaming json logs of functions
LogHandler http.HandlerFunc
// DeployFunction deploys a function which doesn't exist
DeployFunction http.HandlerFunc
// UpdateHandler an existing function/service
UpdateHandler http.HandlerFunc
// HealthHandler defines the default health endpoint bound to "/healthz
// UpdateFunction updates an existing function
UpdateFunction http.HandlerFunc
DeleteFunction http.HandlerFunc
FunctionStatus http.HandlerFunc
ScaleFunction http.HandlerFunc
Secrets http.HandlerFunc
// Logs provides streaming json logs of functions
Logs http.HandlerFunc
// Health defines the default health endpoint bound to "/healthz
// If the handler is not set, then the "/healthz" path will not be configured
HealthHandler http.HandlerFunc
InfoHandler http.HandlerFunc
ListNamespaceHandler http.HandlerFunc
Health http.HandlerFunc
Info http.HandlerFunc
}
// FaaSConfig set config for HTTP handlers

View File

@ -1,6 +1,7 @@
package types
import (
"errors"
"fmt"
"os"
"strconv"
@ -55,6 +56,26 @@ func ParseIntOrDurationValue(val string, fallback time.Duration) time.Duration {
return duration
}
// ParseIntOrDurationValue interprets a string representing an int or duration and returns
// an int as the number of seconds. An error is returned if val can not be parsed as int or duration.
func ParseIntOrDuration(val string) (int, error) {
i, err := strconv.ParseInt(val, 10, 0)
if err == nil {
return int(i), nil
}
if err != nil && errors.Is(err, strconv.ErrRange) {
return int(i), err
}
d, err := time.ParseDuration(val)
if err != nil {
return 0, err
}
return int(d.Seconds()), nil
}
// ParseBoolValue parses the the boolean in val or, if there is an error, returns the
// specified default value
func ParseBoolValue(val string, fallback bool) bool {

View File

@ -3,15 +3,17 @@
package types
// ScaleServiceRequest scales the service to the requested replcia count.
// ScaleServiceRequest scales the service to the requested replica count.
type ScaleServiceRequest struct {
ServiceName string `json:"serviceName"`
Replicas uint64 `json:"replicas"`
Namespace string `json:"namespace,omitempty"`
}
// DeleteFunctionRequest delete a deployed function
type DeleteFunctionRequest struct {
FunctionName string `json:"functionName"`
Namespace string `json:"namespace,omitempty"`
}
// ProviderInfo provides information about the configured provider
@ -27,3 +29,11 @@ type VersionInfo struct {
SHA string `json:"sha"`
Release string `json:"release"`
}
// FunctionNamespace is the namespace for a function
type FunctionNamespace struct {
Name string `json:"name"`
Annotations map[string]string `json:"annotations,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}