@mikarinneoracle/oci-cdk-code-only-preview 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/deploy-code-only.js +16 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -173,7 +173,7 @@ OCDK also runs this build automatically when no artifact exists yet, and searche
|
|
|
173
173
|
|
|
174
174
|
#### Find the available code-only runtimes
|
|
175
175
|
|
|
176
|
-
The exact `OCI_CODE_ONLY_RUNTIME_NAME` values are enabled per tenancy and region during this Limited Availability preview. For Python, OCDK queries this list automatically
|
|
176
|
+
The exact `OCI_CODE_ONLY_RUNTIME_NAME` values are enabled per tenancy and region during this Limited Availability preview. For Python, OCDK queries this list automatically. With `runtime: python`, it selects the version in `build_image` or `run_image` (for example `fnproject/python:3.12` selects `python312...`); without a versioned image, it selects the newest matching runtime. Set `OCI_CODE_ONLY_RUNTIME_NAME` to pin or override that choice. Query the Preview CLI to inspect available runtimes or when deploying another language:
|
|
177
177
|
|
|
178
178
|
```bash
|
|
179
179
|
# List every runtime available to the active OCI profile
|
package/bin/deploy-code-only.js
CHANGED
|
@@ -65,12 +65,23 @@ function pythonRuntimeSortKey(runtimeName) {
|
|
|
65
65
|
return match ? Number.parseInt(match[1], 10) : -1;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function
|
|
68
|
+
function pythonRuntimePrefix(runtime, yaml) {
|
|
69
69
|
// OCI's preview runtime names omit separators from the Python version:
|
|
70
70
|
// func.yaml's "python3.12" therefore maps to the runtime-list prefix
|
|
71
|
-
// "python312".
|
|
71
|
+
// "python312". For a plain "python", honor the version in Fn's
|
|
72
|
+
// build_image/run_image before falling back to the newest available version.
|
|
72
73
|
const normalizedRuntime = runtime.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
73
|
-
|
|
74
|
+
if (normalizedRuntime !== 'python') return normalizedRuntime;
|
|
75
|
+
for (const key of ['build_image', 'run_image']) {
|
|
76
|
+
const image = yamlValue(yaml, key);
|
|
77
|
+
const match = image.match(/(?:^|\/)python:(\d+)(?:\.(\d+))?(?:[-.]|$)/i);
|
|
78
|
+
if (match) return `python${match[1]}${match[2] || ''}`;
|
|
79
|
+
}
|
|
80
|
+
return 'python';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function resolvePythonRuntime(runtime, yaml) {
|
|
84
|
+
const namePrefix = pythonRuntimePrefix(runtime, yaml);
|
|
74
85
|
const result = jsonOci(['fn', 'runtime', 'list', '--all', '--name-starts-with', namePrefix]);
|
|
75
86
|
const candidates = listItems(result)
|
|
76
87
|
.map(runtimeResourceName)
|
|
@@ -83,7 +94,7 @@ function resolvePythonRuntime(runtime) {
|
|
|
83
94
|
return versionDifference || right.localeCompare(left);
|
|
84
95
|
});
|
|
85
96
|
const selected = candidates[0];
|
|
86
|
-
console.log(`Selected OCI code-only runtime ${selected} for func.yaml runtime ${runtime}. Set OCI_CODE_ONLY_RUNTIME_NAME to pin a different runtime.`);
|
|
97
|
+
console.log(`Selected OCI code-only runtime ${selected} for func.yaml runtime ${runtime} (runtime prefix ${namePrefix}). Set OCI_CODE_ONLY_RUNTIME_NAME to pin a different runtime.`);
|
|
87
98
|
return selected;
|
|
88
99
|
}
|
|
89
100
|
|
|
@@ -94,7 +105,7 @@ function readFunctionMetadata() {
|
|
|
94
105
|
const appName = (process.env.OCI_FUNCTION_APP_NAME || functionName).trim();
|
|
95
106
|
const configuredRuntime = yamlValue(yaml, 'runtime');
|
|
96
107
|
const runtimeName = (process.env.OCI_CODE_ONLY_RUNTIME_NAME || '').trim()
|
|
97
|
-
|| (configuredRuntime.toLowerCase().startsWith('python') ? resolvePythonRuntime(configuredRuntime) : '');
|
|
108
|
+
|| (configuredRuntime.toLowerCase().startsWith('python') ? resolvePythonRuntime(configuredRuntime, yaml) : '');
|
|
98
109
|
const configuredHandler = (process.env.OCI_FUNCTION_HANDLER || yamlValue(yaml, 'cmd') || yamlValue(yaml, 'entrypoint')).trim();
|
|
99
110
|
// The managed Node runtime already invokes `node`; its handler is the script
|
|
100
111
|
// path, whereas a conventional func.yaml entrypoint is `node func.js`.
|