@mikarinneoracle/oci-cdk-code-only-preview 0.0.4 → 0.0.5
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/bin/deploy-code-only.js
CHANGED
|
@@ -97,9 +97,13 @@ function jsonOci(args) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
function resourceDisplayName(resource) {
|
|
101
|
+
return resource.displayName || resource['display-name'] || '';
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
function findApplicationId(compartmentId, appName) {
|
|
101
105
|
const result = jsonOci(['fn', 'application', 'list', '--compartment-id', compartmentId, '--all']);
|
|
102
|
-
const matches = (result.data || []).filter((app) => app
|
|
106
|
+
const matches = (result.data || []).filter((app) => resourceDisplayName(app) === appName);
|
|
103
107
|
if (matches.length === 0) {
|
|
104
108
|
fail(`Functions Application "${appName}" was not found. Code-only deploy requires an existing application.`);
|
|
105
109
|
}
|
|
@@ -109,7 +113,7 @@ function findApplicationId(compartmentId, appName) {
|
|
|
109
113
|
|
|
110
114
|
function findFunctionId(applicationId, functionName) {
|
|
111
115
|
const result = jsonOci(['fn', 'function', 'list', '--application-id', applicationId, '--all']);
|
|
112
|
-
const matches = (result.data || []).filter((fn) => fn
|
|
116
|
+
const matches = (result.data || []).filter((fn) => resourceDisplayName(fn) === functionName);
|
|
113
117
|
if (matches.length > 1) fail(`multiple functions are named "${functionName}" in the selected application.`);
|
|
114
118
|
return matches[0]?.id;
|
|
115
119
|
}
|
package/bin/destroy-code-only.js
CHANGED
|
@@ -36,6 +36,10 @@ function yamlValue(contents, key) {
|
|
|
36
36
|
return (match?.[1] || match?.[2] || '').trim();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
function resourceDisplayName(resource) {
|
|
40
|
+
return resource.displayName || resource['display-name'] || '';
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
function main() {
|
|
40
44
|
const compartmentId = (process.env.OCI_COMPARTMENT_ID || process.env.OCI_COMPARTMENT_OCID || '').trim();
|
|
41
45
|
if (!compartmentId) fail('set OCI_COMPARTMENT_ID (or OCI_COMPARTMENT_OCID).');
|
|
@@ -48,13 +52,13 @@ function main() {
|
|
|
48
52
|
|
|
49
53
|
const version = runOci(['--version']).trim();
|
|
50
54
|
const apps = jsonOci(['fn', 'application', 'list', '--compartment-id', compartmentId, '--all']).data || [];
|
|
51
|
-
const app = apps.find((item) => item
|
|
55
|
+
const app = apps.find((item) => resourceDisplayName(item) === appName);
|
|
52
56
|
if (!app) {
|
|
53
57
|
console.log(`Functions Application ${appName} is absent; no code-only function needs deletion.`);
|
|
54
58
|
return;
|
|
55
59
|
}
|
|
56
60
|
const functions = jsonOci(['fn', 'function', 'list', '--application-id', app.id, '--all']).data || [];
|
|
57
|
-
const matches = functions.filter((item) => item
|
|
61
|
+
const matches = functions.filter((item) => resourceDisplayName(item) === functionName);
|
|
58
62
|
if (matches.length === 0) {
|
|
59
63
|
console.log(`Code-only function ${functionName} is absent; continuing with Terraform destroy.`);
|
|
60
64
|
return;
|