diff --git a/gateway/handlers/createhandler.go b/gateway/handlers/createhandler.go index a5a11c0b..9be7fb6f 100644 --- a/gateway/handlers/createhandler.go +++ b/gateway/handlers/createhandler.go @@ -62,6 +62,12 @@ func MakeNewFunctionHandler(metricsOptions metrics.MetricOptions, c *client.Clie func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm.ServiceSpec { 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{ {Target: request.Network}, @@ -81,7 +87,7 @@ func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm }, Networks: nets, Placement: &swarm.Placement{ - Constraints: linuxOnlyConstraints, + Constraints: constraints, }, }, Annotations: swarm.Annotations{ @@ -105,6 +111,7 @@ func makeSpec(request *requests.CreateFunctionRequest, maxRestarts uint64) swarm return spec } +// BuildEncodedAuthConfig for private registry func BuildEncodedAuthConfig(basicAuthB64 string, dockerImage string) (string, error) { // extract registry server address distributionRef, err := reference.ParseNormalizedNamed(dockerImage) diff --git a/gateway/requests/requests.go b/gateway/requests/requests.go index 6f361db8..0701fbd9 100644 --- a/gateway/requests/requests.go +++ b/gateway/requests/requests.go @@ -7,10 +7,11 @@ package requests type CreateFunctionRequest struct { // Service corresponds to a Docker Service Service string `json:"service"` + // Image corresponds to a Docker 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"` // 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 // (see ~/.docker/config.json) 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 { FunctionName string `json:"functionName"` } -type AlexaSessionApplication struct { - 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"` -} - +// PrometheusInnerAlertLabel PrometheusInnerAlertLabel type PrometheusInnerAlertLabel struct { AlertName string `json:"alertname"` FunctionName string `json:"function_name"` } +// PrometheusInnerAlert PrometheusInnerAlert type PrometheusInnerAlert struct { Status string `json:"status"` Labels PrometheusInnerAlertLabel `json:"labels"`