Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add exportConfigs Infra script #5235

Merged
merged 12 commits into from
Jan 24, 2025
30 changes: 30 additions & 0 deletions typescript/infra/scripts/warp-routes/export-warp-configs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { getRegistry } from '../../config/registry.js';
import { getWarpConfig, warpConfigGetterMap } from '../../config/warp.js';
import { getArgs, withOutputFile } from '../agent-utils.js';
import { getEnvironmentConfig, getHyperlaneCore } from '../core-utils.js';

async function main() {
const { environment } = await withOutputFile(getArgs()).argv;
const { multiProvider } = await getHyperlaneCore(environment);
const envConfig = getEnvironmentConfig(environment);
const registry = getRegistry();

const warpIdsToCheck = Object.keys(warpConfigGetterMap);
for (const warpRouteId of warpIdsToCheck) {
console.log(`Generating Warp config for ${warpRouteId}`);

const warpConfig = await getWarpConfig(
multiProvider,
envConfig,
warpRouteId,
);

const configFileName = `${warpRouteId}-deploy-config.yaml`;
registry.addWarpRouteConfig(warpConfig, configFileName);
console.log(
`Warp config successfully created at ${registry.getUri()}/${registry.getWarpRoutesPath()}/${configFileName}`,
);
}
}

main().catch((err) => console.error('Error:', err));
2 changes: 1 addition & 1 deletion typescript/infra/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function writeJsonAtPath(filepath: string, obj: any) {
}

export function writeYamlAtPath(filepath: string, obj: any) {
const content = stringifyObject(obj, 'yaml');
const content = stringifyObject(obj, 'yaml', 2);
writeToFile(filepath, content);
}

Expand Down
5 changes: 4 additions & 1 deletion typescript/utils/src/objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ export function stringifyObject(
if (format === 'json') {
return json;
}
return yamlStringify(JSON.parse(json), null, space);
return yamlStringify(JSON.parse(json), null, {
indent: space,
sortMapEntries: true,
ltyu marked this conversation as resolved.
Show resolved Hide resolved
});
}

interface ObjectDiffOutput {
Expand Down
Loading