|
1 | 1 | // Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | | -import * as _ from 'lodash'; |
4 | | -import * as util from 'node:util'; |
5 | 3 | import { z } from 'zod'; |
6 | 4 |
|
7 | | -import { CHARTS_VERSION, CnChartVersion, parsedVersion } from '../artifacts'; |
| 5 | +import { CnChartVersion, parsedVersion } from '../artifacts'; |
8 | 6 | import { spliceEnvConfig } from './envConfig'; |
9 | 7 |
|
10 | 8 | export const defaultActiveMigration = { |
11 | 9 | id: 0, |
12 | | - version: CHARTS_VERSION, |
| 10 | + version: 'local', |
13 | 11 | sequencer: { |
14 | 12 | enableBftSequencer: false, |
15 | 13 | }, |
16 | 14 | }; |
17 | 15 |
|
18 | | -const migrationVersion = z |
19 | | - .string() |
20 | | - .optional() |
21 | | - .transform<CnChartVersion>((version, ctx) => { |
22 | | - if (!version && !CHARTS_VERSION && spliceEnvConfig.optionalEnv('SPLICE_OPERATOR_DEPLOYMENT')) { |
23 | | - ctx.addIssue({ |
24 | | - code: z.ZodIssueCode.custom, |
25 | | - message: `No active version or CHARTS_VERSION specified`, |
26 | | - }); |
27 | | - return z.NEVER; |
28 | | - } else { |
29 | | - return parsedVersion(version || CHARTS_VERSION); |
30 | | - } |
31 | | - }); |
| 16 | +const migrationVersion = z.string().transform<CnChartVersion>((version, ctx) => { |
| 17 | + if (version == 'local' && spliceEnvConfig.optionalEnv('SPLICE_OPERATOR_DEPLOYMENT')) { |
| 18 | + ctx.addIssue({ |
| 19 | + code: z.ZodIssueCode.custom, |
| 20 | + message: `Using a local version for the operator deployment is not supported.`, |
| 21 | + }); |
| 22 | + return z.NEVER; |
| 23 | + } else { |
| 24 | + return parsedVersion(version); |
| 25 | + } |
| 26 | +}); |
32 | 27 |
|
33 | 28 | export const GitReferenceSchema = z.object({ |
34 | 29 | repoUrl: z.string(), |
@@ -63,18 +58,7 @@ export const SynchronizerMigrationSchema = z |
63 | 58 | legacy: MigrationInfoSchema.optional(), |
64 | 59 | active: MigrationInfoSchema.extend({ |
65 | 60 | migratingFrom: z.number().optional(), |
66 | | - version: migrationVersion.transform((version, ctx) => { |
67 | | - const parsedChartsVersion = parsedVersion(CHARTS_VERSION); |
68 | | - if (CHARTS_VERSION && !_.isEqual(parsedChartsVersion, version)) { |
69 | | - ctx.addIssue({ |
70 | | - code: z.ZodIssueCode.custom, |
71 | | - message: `Specified different active version and CHARTS_VERSION: ${util.inspect(version)} - ${util.inspect(parsedChartsVersion)}`, |
72 | | - }); |
73 | | - return z.NEVER; |
74 | | - } else { |
75 | | - return version; |
76 | | - } |
77 | | - }), |
| 61 | + version: migrationVersion, |
78 | 62 | }) |
79 | 63 | .strict() |
80 | 64 | .default(defaultActiveMigration), |
|
0 commit comments