@catladder/cli 0.0.0-main-0d4bc87f → 0.0.0-main-ee579532
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/dist/apps/cli/verify/migration/fromv2.js +19 -13
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +2 -2
- package/dist/apps/cli/verify/migration/migrateSecrets.js +28 -15
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/apps/cli/verify/migration/fromv2.ts +5 -2
- package/src/apps/cli/verify/migration/migrateSecrets.ts +18 -13
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@bitwarden/cli": "^1.8.0",
|
|
20
|
-
"@catladder/pipeline": "0.0.0-main-
|
|
20
|
+
"@catladder/pipeline": "0.0.0-main-ee579532",
|
|
21
21
|
"@kubernetes/client-node": "^0.16.1",
|
|
22
22
|
"child-process-promise": "^2.2.1",
|
|
23
23
|
"clipboardy": "^2.2.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"eslint": "^8.7.0",
|
|
61
61
|
"typescript": "^4.5.4"
|
|
62
62
|
},
|
|
63
|
-
"version": "0.0.0-main-
|
|
63
|
+
"version": "0.0.0-main-ee579532",
|
|
64
64
|
"stableVersion": "0.0.0-test7"
|
|
65
65
|
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getGitlabCiFilePath,
|
|
21
21
|
} from "../../../../config/getProjectConfig";
|
|
22
22
|
import { readYaml } from "../../../../utils/files";
|
|
23
|
+
import { syncBitwarden } from "../../../../utils/passwordstore";
|
|
23
24
|
import { getGitRoot } from "../../../../utils/projects";
|
|
24
25
|
import { writeConfig } from "../../config/writeConfig";
|
|
25
26
|
import { migrateSecrets } from "./migrateSecrets";
|
|
@@ -192,7 +193,7 @@ export const migrateV2 = async (vorpal: Vorpal) => {
|
|
|
192
193
|
}, Promise.resolve({}));
|
|
193
194
|
} else {
|
|
194
195
|
components = {
|
|
195
|
-
[COMPONENT_NAME]: await createComponent(
|
|
196
|
+
[COMPONENT_NAME]: await createComponent(APP_DIR, gitlabCi),
|
|
196
197
|
};
|
|
197
198
|
}
|
|
198
199
|
// we only have one component
|
|
@@ -222,8 +223,10 @@ export const migrateV2 = async (vorpal: Vorpal) => {
|
|
|
222
223
|
|
|
223
224
|
this.log("-------------------");
|
|
224
225
|
this.log("migrate secrets");
|
|
226
|
+
await syncBitwarden();
|
|
225
227
|
for (const env of LEGACY_ENVS) {
|
|
226
|
-
|
|
228
|
+
if (env === "stage" && !STAGING_ENABLED) return;
|
|
229
|
+
await migrateSecrets(this, config, env);
|
|
227
230
|
}
|
|
228
231
|
|
|
229
232
|
this.log("-------------------");
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
+
import { Config, getEnvironment } from "@catladder/pipeline";
|
|
1
2
|
import { load } from "js-yaml";
|
|
3
|
+
import { pick } from "lodash";
|
|
2
4
|
import { CommandInstance } from "vorpal";
|
|
3
5
|
import { upsertAllVariables } from "../../../../utils/gitlab";
|
|
4
6
|
import { readPass, trashItem } from "../../../../utils/passwordstore";
|
|
5
7
|
import { LEGACY_ENVS } from "./fromv2";
|
|
6
|
-
import { OldGitlabCiFile } from "./oldGitlabCi";
|
|
7
8
|
|
|
8
|
-
const getPassPath = (
|
|
9
|
-
return `${
|
|
9
|
+
const getPassPath = (newConfig: Config, env: string) => {
|
|
10
|
+
return `${newConfig.customerName}/${newConfig.appName}/${env}/secrets.yml`;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const migrateSecrets = async (
|
|
13
14
|
vorpal: CommandInstance,
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
newConfig: Config,
|
|
16
|
+
oldEnv: typeof LEGACY_ENVS[number]
|
|
16
17
|
) => {
|
|
17
|
-
const
|
|
18
|
+
const newEnv = oldEnv === "dev-local" ? "local" : oldEnv;
|
|
19
|
+
const path = getPassPath(newConfig, oldEnv);
|
|
18
20
|
try {
|
|
19
21
|
const yamlstring = await readPass(path);
|
|
20
22
|
const secrets = load(yamlstring);
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
Object.keys(newConfig.components).forEach(async (componentName) => {
|
|
25
|
+
const environment = getEnvironment(newConfig, componentName, newEnv);
|
|
26
|
+
await upsertAllVariables(
|
|
27
|
+
vorpal,
|
|
28
|
+
pick(secrets, environment.secretEnvVarKeys),
|
|
29
|
+
newEnv,
|
|
30
|
+
componentName
|
|
31
|
+
);
|
|
32
|
+
});
|
|
28
33
|
await trashItem(path);
|
|
29
34
|
} catch (e) {
|
|
30
|
-
console.warn(`could not migrate secrets for env '${
|
|
35
|
+
console.warn(`could not migrate secrets for env '${oldEnv}': ${e}`);
|
|
31
36
|
}
|
|
32
37
|
};
|