Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion go/models/function_config.go

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

3 changes: 2 additions & 1 deletion go/porcelain/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
}
}

hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(excludedRoutes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0 || len(function.EventSubscriptions) > 0 || function.Region != "" || function.Memory != 0
hasConfig := function.DisplayName != "" || function.Generator != "" || len(routes) > 0 || len(excludedRoutes) > 0 || len(function.BuildData) > 0 || function.Priority != 0 || function.TrafficRules != nil || function.Timeout != 0 || len(function.EventSubscriptions) > 0 || function.Region != "" || function.Memory != 0 || function.Vcpu != 0
if hasConfig {
cfg := models.FunctionConfig{
DisplayName: function.DisplayName,
Expand All @@ -852,6 +852,7 @@ func bundleFromManifest(ctx context.Context, manifestFile *os.File, observer Dep
BuildData: function.BuildData,
Priority: int64(function.Priority),
EventSubscriptions: function.EventSubscriptions,
Vcpu: function.Vcpu,
}

if function.TrafficRules != nil {
Expand Down
1 change: 1 addition & 0 deletions go/porcelain/functions_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type functionsManifestEntry struct {
ExcludedRoutes []excludedFunctionRoute `json:"excludedRoutes"`
Priority int `json:"priority"`
TrafficRules *functionTrafficRules `json:"trafficRules"`
Vcpu float32 `json:"vcpu"`
}

type functionRoute struct {
Expand Down
8 changes: 7 additions & 1 deletion swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5558,7 +5558,7 @@ definitions:
memory:
type: integer
description: |
The function's memory allocation in MB.
The function's memory allocation in MB. Mutually exclusive with `vcpu`.
routes:
type: array
items:
Expand All @@ -5573,6 +5573,12 @@ definitions:
type: string
traffic_rules:
$ref: '#/definitions/trafficRulesConfig'
vcpu:
type: number
format: float
description: |
Number of vCPUs to provision for the function. Allowed range is
0.5–2.
Comment on lines +5576 to +5581
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add schema-level constraints for the vCPU range.

The vcpu field documents an allowed range of 0.5–2 in the description, but the schema lacks minimum and maximum constraints. Adding these constraints will enable client validation, improve generated documentation, and provide clearer API contract enforcement.

📋 Proposed fix to add range constraints
   vcpu:
     type: number
     format: float
+    minimum: 0.5
+    maximum: 2
     description: |
       Number of vCPUs to provision for the function. Allowed range is
       0.5–2.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
vcpu:
type: number
format: float
description: |
Number of vCPUs to provision for the function. Allowed range is
0.5–2.
vcpu:
type: number
format: float
minimum: 0.5
maximum: 2
description: |
Number of vCPUs to provision for the function. Allowed range is
0.5–2.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@swagger.yml` around lines 5576 - 5581, The OpenAPI schema for the vcpu
property currently only documents "0.5–2" in the description; add schema-level
numeric constraints to enforce this by adding minimum: 0.5 and maximum: 2 (keep
type: number and format: float) on the vcpu property so clients and generators
can validate the allowed range for the vcpu field.

event_subscriptions:
type: array
items:
Expand Down
Loading