Skip to content

Commit 4f21c64

Browse files
authored
feat(container): add support for ContainerSandbox (#2116)
1 parent 990c078 commit 4f21c64

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

api/container/v1beta1/container_sdk.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,46 @@ func (enum *ContainerProtocol) UnmarshalJSON(data []byte) error {
156156
return nil
157157
}
158158

159+
type ContainerSandbox string
160+
161+
const (
162+
// Unknown sandbox.
163+
ContainerSandboxUnknownSandbox = ContainerSandbox("unknown_sandbox")
164+
ContainerSandboxV1 = ContainerSandbox("v1")
165+
ContainerSandboxV2 = ContainerSandbox("v2")
166+
)
167+
168+
func (enum ContainerSandbox) String() string {
169+
if enum == "" {
170+
// return default value if empty
171+
return "unknown_sandbox"
172+
}
173+
return string(enum)
174+
}
175+
176+
func (enum ContainerSandbox) Values() []ContainerSandbox {
177+
return []ContainerSandbox{
178+
"unknown_sandbox",
179+
"v1",
180+
"v2",
181+
}
182+
}
183+
184+
func (enum ContainerSandbox) MarshalJSON() ([]byte, error) {
185+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
186+
}
187+
188+
func (enum *ContainerSandbox) UnmarshalJSON(data []byte) error {
189+
tmp := ""
190+
191+
if err := json.Unmarshal(data, &tmp); err != nil {
192+
return err
193+
}
194+
195+
*enum = ContainerSandbox(ContainerSandbox(tmp).String())
196+
return nil
197+
}
198+
159199
type ContainerStatus string
160200

161201
const (
@@ -884,6 +924,10 @@ type Container struct {
884924
// Default value: unknown_http_option
885925
HTTPOption ContainerHTTPOption `json:"http_option"`
886926

927+
// Sandbox: execution environment of the container.
928+
// Default value: unknown_sandbox
929+
Sandbox ContainerSandbox `json:"sandbox"`
930+
887931
// Region: region in which the container will be deployed.
888932
Region scw.Region `json:"region"`
889933
}
@@ -1104,6 +1148,10 @@ type CreateContainerRequest struct {
11041148
// - enabled: Serve both HTTP and HTTPS traffic.
11051149
// Default value: unknown_http_option
11061150
HTTPOption ContainerHTTPOption `json:"http_option"`
1151+
1152+
// Sandbox: execution environment of the container.
1153+
// Default value: unknown_sandbox
1154+
Sandbox ContainerSandbox `json:"sandbox"`
11071155
}
11081156

11091157
// CreateCronRequest: create cron request.
@@ -1696,6 +1744,10 @@ type UpdateContainerRequest struct {
16961744
// - enabled: Serve both HTTP and HTTPS traffic.
16971745
// Default value: unknown_http_option
16981746
HTTPOption ContainerHTTPOption `json:"http_option"`
1747+
1748+
// Sandbox: execution environment of the container.
1749+
// Default value: unknown_sandbox
1750+
Sandbox ContainerSandbox `json:"sandbox"`
16991751
}
17001752

17011753
// UpdateCronRequest: update cron request.

api/function/v1beta1/function_sdk.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,46 @@ func (enum *FunctionRuntime) UnmarshalJSON(data []byte) error {
302302
return nil
303303
}
304304

305+
type FunctionSandbox string
306+
307+
const (
308+
// Unknown sandbox.
309+
FunctionSandboxUnknownSandbox = FunctionSandbox("unknown_sandbox")
310+
FunctionSandboxV1 = FunctionSandbox("v1")
311+
FunctionSandboxV2 = FunctionSandbox("v2")
312+
)
313+
314+
func (enum FunctionSandbox) String() string {
315+
if enum == "" {
316+
// return default value if empty
317+
return "unknown_sandbox"
318+
}
319+
return string(enum)
320+
}
321+
322+
func (enum FunctionSandbox) Values() []FunctionSandbox {
323+
return []FunctionSandbox{
324+
"unknown_sandbox",
325+
"v1",
326+
"v2",
327+
}
328+
}
329+
330+
func (enum FunctionSandbox) MarshalJSON() ([]byte, error) {
331+
return []byte(fmt.Sprintf(`"%s"`, enum)), nil
332+
}
333+
334+
func (enum *FunctionSandbox) UnmarshalJSON(data []byte) error {
335+
tmp := ""
336+
337+
if err := json.Unmarshal(data, &tmp); err != nil {
338+
return err
339+
}
340+
341+
*enum = FunctionSandbox(FunctionSandbox(tmp).String())
342+
return nil
343+
}
344+
305345
type FunctionStatus string
306346

307347
const (
@@ -1052,6 +1092,10 @@ type Function struct {
10521092
HTTPOption FunctionHTTPOption `json:"http_option"`
10531093

10541094
RuntimeMessage string `json:"runtime_message"`
1095+
1096+
// Sandbox: execution environment of the function.
1097+
// Default value: unknown_sandbox
1098+
Sandbox FunctionSandbox `json:"sandbox"`
10551099
}
10561100

10571101
// Namespace: namespace.
@@ -1246,6 +1290,10 @@ type CreateFunctionRequest struct {
12461290
// - enabled: Serve both HTTP and HTTPS traffic.
12471291
// Default value: unknown_http_option
12481292
HTTPOption FunctionHTTPOption `json:"http_option"`
1293+
1294+
// Sandbox: execution environment of the function.
1295+
// Default value: unknown_sandbox
1296+
Sandbox FunctionSandbox `json:"sandbox"`
12491297
}
12501298

12511299
// CreateNamespaceRequest: create namespace request.
@@ -1883,6 +1931,10 @@ type UpdateFunctionRequest struct {
18831931
// - enabled: Serve both HTTP and HTTPS traffic.
18841932
// Default value: unknown_http_option
18851933
HTTPOption FunctionHTTPOption `json:"http_option"`
1934+
1935+
// Sandbox: execution environment of the function.
1936+
// Default value: unknown_sandbox
1937+
Sandbox FunctionSandbox `json:"sandbox"`
18861938
}
18871939

18881940
// UpdateNamespaceRequest: update namespace request.

0 commit comments

Comments
 (0)