Skip to content

Commit

Permalink
feat: add excluded routes to functions (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas authored Jun 17, 2024
1 parent 2036c6a commit a2e272e
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 20 deletions.
49 changes: 49 additions & 0 deletions go/models/excluded_function_route.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions go/models/function_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 16 additions & 6 deletions go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,14 +825,24 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
}
}

hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0
excludedRoutes := make([]*models.ExcludedFunctionRoute, len(function.ExcludedRoutes))
for i, route := range function.ExcludedRoutes {
excludedRoutes[i] = &models.ExcludedFunctionRoute{
Pattern: route.Pattern,
Literal: route.Literal,
Expression: route.Expression,
}
}

hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(excludedRoutes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0
if hasConfig {
cfg := models.FunctionConfig{
DisplayName: function.DisplayName,
Generator: function.Generator,
Routes: routes,
BuildData: function.BuildData,
Priority: int64(function.Priority),
DisplayName: function.DisplayName,
Generator: function.Generator,
Routes: routes,
ExcludedRoutes: excludedRoutes,
BuildData: function.BuildData,
Priority: int64(function.Priority),
}

if function.TrafficRules != nil {
Expand Down
35 changes: 21 additions & 14 deletions go/porcelain/functions_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ type functionsManifest struct {
}

type functionsManifestEntry struct {
MainFile string `json:"mainFile"`
Name string `json:"name"`
Path string `json:"path"`
Runtime string `json:"runtime"`
RuntimeVersion string `json:"runtimeVersion"`
Schedule string `json:"schedule"`
DisplayName string `json:"displayName"`
Generator string `json:"generator"`
Timeout int64 `json:"timeout"`
BuildData map[string]interface{} `json:"buildData"`
InvocationMode string `json:"invocationMode"`
Routes []functionRoute `json:"routes"`
Priority int `json:"priority"`
TrafficRules *functionTrafficRules `json:"trafficRules"`
MainFile string `json:"mainFile"`
Name string `json:"name"`
Path string `json:"path"`
Runtime string `json:"runtime"`
RuntimeVersion string `json:"runtimeVersion"`
Schedule string `json:"schedule"`
DisplayName string `json:"displayName"`
Generator string `json:"generator"`
Timeout int64 `json:"timeout"`
BuildData map[string]interface{} `json:"buildData"`
InvocationMode string `json:"invocationMode"`
Routes []functionRoute `json:"routes"`
ExcludedRoutes []excludedFunctionRoute `json:"excluded_routes"`
Priority int `json:"priority"`
TrafficRules *functionTrafficRules `json:"trafficRules"`
}

type functionRoute struct {
Expand All @@ -33,6 +34,12 @@ type functionRoute struct {
PreferStatic bool `json:"prefer_static"`
}

type excludedFunctionRoute struct {
Pattern string `json:"pattern"`
Literal string `json:"literal"`
Expression string `json:"expression"`
}

type functionTrafficRules struct {
Action struct {
Type string `json:"type"`
Expand Down
13 changes: 13 additions & 0 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3887,6 +3887,10 @@ definitions:
type: array
items:
$ref: '#/definitions/functionRoute'
excluded_routes:
type: array
items:
$ref: '#/definitions/excludedFunctionRoute'
priority:
type: integer
traffic_rules:
Expand All @@ -3907,6 +3911,15 @@ definitions:
enum: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
prefer_static:
type: boolean
excludedFunctionRoute:
type: object
properties:
pattern:
type: string
literal:
type: string
expression:
type: string
trafficRulesConfig:
type: object
properties:
Expand Down

0 comments on commit a2e272e

Please sign in to comment.