mirror of
https://github.com/openfaas/faas.git
synced 2025-06-15 19:56:47 +00:00
Handle constraints
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
44544d80ac
commit
3db2064d91
@ -62,6 +62,12 @@ func MakeNewFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Clie
|
|||||||
|
|
||||||
func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm.ServiceSpec {
|
func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm.ServiceSpec {
|
||||||
linuxOnlyConstraints := []string{"node.platform.os == linux"}
|
linuxOnlyConstraints := []string{"node.platform.os == linux"}
|
||||||
|
constraints := []string{}
|
||||||
|
if request.Constraints != nil && len(request.Constraints) > 0 {
|
||||||
|
constraints = request.Constraints
|
||||||
|
} else {
|
||||||
|
constraints = linuxOnlyConstraints
|
||||||
|
}
|
||||||
|
|
||||||
nets := []swarm.NetworkAttachmentConfig{
|
nets := []swarm.NetworkAttachmentConfig{
|
||||||
{Target: request.Network},
|
{Target: request.Network},
|
||||||
@ -81,7 +87,7 @@ func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm
|
|||||||
},
|
},
|
||||||
Networks: nets,
|
Networks: nets,
|
||||||
Placement: &swarm.Placement{
|
Placement: &swarm.Placement{
|
||||||
Constraints: linuxOnlyConstraints,
|
Constraints: constraints,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Annotations: swarm.Annotations{
|
Annotations: swarm.Annotations{
|
||||||
@ -105,6 +111,7 @@ func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm
|
|||||||
return spec
|
return spec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BuildEncodedAuthConfig for private registry
|
||||||
func BuildEncodedAuthConfig(basicAuthB64 string, dockerImage string) (string, error) {
|
func BuildEncodedAuthConfig(basicAuthB64 string, dockerImage string) (string, error) {
|
||||||
// extract registry server address
|
// extract registry server address
|
||||||
distributionRef, err := reference.ParseNormalizedNamed(dockerImage)
|
distributionRef, err := reference.ParseNormalizedNamed(dockerImage)
|
||||||
|
@ -7,10 +7,11 @@ package requests
|
|||||||
type CreateFunctionRequest struct {
|
type CreateFunctionRequest struct {
|
||||||
// Service corresponds to a Docker Service
|
// Service corresponds to a Docker Service
|
||||||
Service string `json:"service"`
|
Service string `json:"service"`
|
||||||
|
|
||||||
// Image corresponds to a Docker image
|
// Image corresponds to a Docker image
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
|
|
||||||
// Network is a Docker overlay network in Swarm - the default value is func_functions
|
// Network is specific to Docker Swarm - default overlay network is: func_functions
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
|
|
||||||
// EnvProcess corresponds to the fprocess variable for your container watchdog.
|
// EnvProcess corresponds to the fprocess variable for your container watchdog.
|
||||||
@ -23,40 +24,23 @@ type CreateFunctionRequest struct {
|
|||||||
// in the same encoded format as Docker native credentials
|
// in the same encoded format as Docker native credentials
|
||||||
// (see ~/.docker/config.json)
|
// (see ~/.docker/config.json)
|
||||||
RegistryAuth string `json:"registryAuth,omitempty"`
|
RegistryAuth string `json:"registryAuth,omitempty"`
|
||||||
|
|
||||||
|
// Constraints are specific to back-end orchestration platform
|
||||||
|
Constraints []string `json:"constraints"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteFunctionRequest delete a deployed function
|
||||||
type DeleteFunctionRequest struct {
|
type DeleteFunctionRequest struct {
|
||||||
FunctionName string `json:"functionName"`
|
FunctionName string `json:"functionName"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlexaSessionApplication struct {
|
// PrometheusInnerAlertLabel PrometheusInnerAlertLabel
|
||||||
ApplicationId string `json:"applicationId"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlexaSession struct {
|
|
||||||
SessionId string `json:"sessionId"`
|
|
||||||
Application AlexaSessionApplication `json:"application"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlexaIntent struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type AlexaRequest struct {
|
|
||||||
Intent AlexaIntent `json:"intent"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlexaRequestBody top-level request produced by Alexa SDK
|
|
||||||
type AlexaRequestBody struct {
|
|
||||||
Session AlexaSession `json:"session"`
|
|
||||||
Request AlexaRequest `json:"request"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PrometheusInnerAlertLabel struct {
|
type PrometheusInnerAlertLabel struct {
|
||||||
AlertName string `json:"alertname"`
|
AlertName string `json:"alertname"`
|
||||||
FunctionName string `json:"function_name"`
|
FunctionName string `json:"function_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrometheusInnerAlert PrometheusInnerAlert
|
||||||
type PrometheusInnerAlert struct {
|
type PrometheusInnerAlert struct {
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Labels PrometheusInnerAlertLabel `json:"labels"`
|
Labels PrometheusInnerAlertLabel `json:"labels"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user