@starship-ci/generator
Version:
Kubernetes manifest generator for Starship deployments
38 lines (37 loc) • 1.58 kB
JavaScript
import { ScriptManager } from '../../../scripts';
import { CosmosConfigMapGenerator, GlobalConfigMapGenerator } from './configmap';
import { CosmosServiceGenerator } from './service';
import { CosmosStatefulSetGenerator } from './statefulset';
/**
* Main Cosmos builder
* Orchestrates ConfigMap, Service, and StatefulSet generation for all Cosmos chains
*/
export class CosmosBuilder {
config;
scriptManager;
generators;
constructor(config) {
this.config = config;
this.scriptManager = new ScriptManager(undefined, config.configDir);
this.generators = [];
// Filter cosmos chains (exclude ethereum chains)
const cosmosChains = this.config.chains?.filter((chain) => chain.name !== 'ethereum' && typeof chain.id === 'string') || [];
if (cosmosChains.length === 0) {
return; // No cosmos chains to process
}
// Global ConfigMaps (keys, global scripts)
this.generators.push(new GlobalConfigMapGenerator(this.config));
// Per-chain generators
cosmosChains.forEach((chain) => {
// Services
this.generators.push(new CosmosServiceGenerator(chain, this.config));
// StatefulSets
this.generators.push(new CosmosStatefulSetGenerator(chain, this.config, this.scriptManager));
// ConfigMaps
this.generators.push(new CosmosConfigMapGenerator(chain, this.config, this.scriptManager));
});
}
generate() {
return this.generators.flatMap((generator) => generator.generate());
}
}