Skip to content

Commit a2e272e

Browse files
feat: add excluded routes to functions (#541)
1 parent 2036c6a commit a2e272e

File tree

5 files changed

+131
-20
lines changed

5 files changed

+131
-20
lines changed

go/models/excluded_function_route.go

+49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/models/function_config.go

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/porcelain/deploy.go

+16-6
Original file line numberDiff line numberDiff line change
@@ -825,14 +825,24 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
825825
}
826826
}
827827

828-
hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0
828+
excludedRoutes := make([]*models.ExcludedFunctionRoute, len(function.ExcludedRoutes))
829+
for i, route := range function.ExcludedRoutes {
830+
excludedRoutes[i] = &models.ExcludedFunctionRoute{
831+
Pattern: route.Pattern,
832+
Literal: route.Literal,
833+
Expression: route.Expression,
834+
}
835+
}
836+
837+
hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(excludedRoutes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0
829838
if hasConfig {
830839
cfg := models.FunctionConfig{
831-
DisplayName: function.DisplayName,
832-
Generator: function.Generator,
833-
Routes: routes,
834-
BuildData: function.BuildData,
835-
Priority: int64(function.Priority),
840+
DisplayName: function.DisplayName,
841+
Generator: function.Generator,
842+
Routes: routes,
843+
ExcludedRoutes: excludedRoutes,
844+
BuildData: function.BuildData,
845+
Priority: int64(function.Priority),
836846
}
837847

838848
if function.TrafficRules != nil {

go/porcelain/functions_manifest.go

+21-14
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ type functionsManifest struct {
99
}
1010

1111
type functionsManifestEntry struct {
12-
MainFile string `json:"mainFile"`
13-
Name string `json:"name"`
14-
Path string `json:"path"`
15-
Runtime string `json:"runtime"`
16-
RuntimeVersion string `json:"runtimeVersion"`
17-
Schedule string `json:"schedule"`
18-
DisplayName string `json:"displayName"`
19-
Generator string `json:"generator"`
20-
Timeout int64 `json:"timeout"`
21-
BuildData map[string]interface{} `json:"buildData"`
22-
InvocationMode string `json:"invocationMode"`
23-
Routes []functionRoute `json:"routes"`
24-
Priority int `json:"priority"`
25-
TrafficRules *functionTrafficRules `json:"trafficRules"`
12+
MainFile string `json:"mainFile"`
13+
Name string `json:"name"`
14+
Path string `json:"path"`
15+
Runtime string `json:"runtime"`
16+
RuntimeVersion string `json:"runtimeVersion"`
17+
Schedule string `json:"schedule"`
18+
DisplayName string `json:"displayName"`
19+
Generator string `json:"generator"`
20+
Timeout int64 `json:"timeout"`
21+
BuildData map[string]interface{} `json:"buildData"`
22+
InvocationMode string `json:"invocationMode"`
23+
Routes []functionRoute `json:"routes"`
24+
ExcludedRoutes []excludedFunctionRoute `json:"excluded_routes"`
25+
Priority int `json:"priority"`
26+
TrafficRules *functionTrafficRules `json:"trafficRules"`
2627
}
2728

2829
type functionRoute struct {
@@ -33,6 +34,12 @@ type functionRoute struct {
3334
PreferStatic bool `json:"prefer_static"`
3435
}
3536

37+
type excludedFunctionRoute struct {
38+
Pattern string `json:"pattern"`
39+
Literal string `json:"literal"`
40+
Expression string `json:"expression"`
41+
}
42+
3643
type functionTrafficRules struct {
3744
Action struct {
3845
Type string `json:"type"`

swagger.yml

+13
Original file line numberDiff line numberDiff line change
@@ -3887,6 +3887,10 @@ definitions:
38873887
type: array
38883888
items:
38893889
$ref: '#/definitions/functionRoute'
3890+
excluded_routes:
3891+
type: array
3892+
items:
3893+
$ref: '#/definitions/excludedFunctionRoute'
38903894
priority:
38913895
type: integer
38923896
traffic_rules:
@@ -3907,6 +3911,15 @@ definitions:
39073911
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
39083912
prefer_static:
39093913
type: boolean
3914+
excludedFunctionRoute:
3915+
type: object
3916+
properties:
3917+
pattern:
3918+
type: string
3919+
literal:
3920+
type: string
3921+
expression:
3922+
type: string
39103923
trafficRulesConfig:
39113924
type: object
39123925
properties:

0 commit comments

Comments
 (0)