diff --git a/envd/api/runtime/__init__.py b/envd/api/runtime/__init__.py index 1b63078cd..c92bda272 100644 --- a/envd/api/runtime/__init__.py +++ b/envd/api/runtime/__init__.py @@ -48,8 +48,8 @@ def expose(envd_port: str, host_port: Optional[str], service: Optional[str]): Args: envd_port (str): port in `envd` container - host_port (Optional[str]): port in the host, if not provided, `envd` will - randomly choose a free port + host_port (Optional[str]): port in the host, if not provided or + `host_port=0`, `envd` will randomly choose a free port service (Optional[str]): service name """ diff --git a/pkg/lang/frontend/starlark/runtime/runtime.go b/pkg/lang/frontend/starlark/runtime/runtime.go index 199ada62d..6b5c0a1cd 100644 --- a/pkg/lang/frontend/starlark/runtime/runtime.go +++ b/pkg/lang/frontend/starlark/runtime/runtime.go @@ -95,7 +95,7 @@ func ruleFuncExpose(thread *starlark.Thread, _ *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { var ( envdPort starlark.Int - hostPort = starlark.MakeInt(0) + hostPort = starlark.MakeInt(0) // 0 means envd can randomly choose a free port serviceName = starlark.String("") ) @@ -108,8 +108,8 @@ func ruleFuncExpose(thread *starlark.Thread, _ *starlark.Builtin, return nil, errors.New("envd_port must be a positive integer less than 65535") } hostPortInt, ok := hostPort.Int64() - if !ok || hostPortInt < 1 || hostPortInt > 65535 { - return nil, errors.New("envd_port must be a positive integer less than 65535") + if !ok || hostPortInt < 0 || hostPortInt > 65535 { + return nil, errors.New("host_port must be a positive integer less than 65535") } serviceNameStr := serviceName.GoString()