Skip to content

Commit 0c99576

Browse files
committed
add remaining default values, try to override them in config
1 parent 0747cfb commit 0c99576

File tree

3 files changed

+225
-23
lines changed

3 files changed

+225
-23
lines changed

packages/packages/generator/configs/defaults.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,3 +1011,91 @@ defaultFaucet:
10111011

10121012
defaultCometmock:
10131013
image: ghcr.io/informalsystems/cometmock:v0.37.x
1014+
1015+
images:
1016+
imagePullPolicy: IfNotPresent
1017+
1018+
resources:
1019+
node:
1020+
# Default values for resources for chain and validator nodes
1021+
# Preference would be given to the resources directive in chain/relayer
1022+
cpu: "0.5"
1023+
memory: "500M"
1024+
wait:
1025+
cpu: "0.1"
1026+
memory: "100M"
1027+
1028+
exposer:
1029+
image: ghcr.io/hyperweb-io/starship/exposer:20250205-544757d
1030+
ports:
1031+
rest: 8081
1032+
resources:
1033+
cpu: "0.2"
1034+
memory: "200M"
1035+
1036+
# Chain timeouts
1037+
timeouts:
1038+
time_iota_ms: 10
1039+
timeout_propose: 400ms
1040+
timeout_propose_delta: 400ms
1041+
timeout_prevote: 400ms
1042+
timeout_prevote_delta: 400ms
1043+
timeout_precommit: 400ms
1044+
timeout_precommit_delta: 400ms
1045+
timeout_commit: 800ms
1046+
1047+
1048+
explorer:
1049+
# Flag to enable explorer for cluster
1050+
enabled: false
1051+
type: ping-pub
1052+
image: ghcr.io/cosmology-tech/starship/ping-pub:6b7b0d096946b6bcd75d15350c7345da0d4576db
1053+
localhost: true
1054+
ports:
1055+
rest: 8080
1056+
# Currently the ping-pub explorer is using alot of memory dues to building the site
1057+
# at runtime (with custom configs). Anything bellow 2Gi will crash the pods on startup
1058+
# todo: make this more efficient with faster startuptime
1059+
resources:
1060+
cpu: "1"
1061+
memory: "2Gi"
1062+
1063+
registry:
1064+
enabled: false
1065+
image: ghcr.io/hyperweb-io/starship/registry:20250205-544757d
1066+
localhost: true
1067+
ports:
1068+
rest: 6060
1069+
grpc: 7070
1070+
resources:
1071+
cpu: "0.2"
1072+
memory: "200M"
1073+
1074+
faucet:
1075+
enabled: true
1076+
type: starship
1077+
ports:
1078+
rest: 8000
1079+
resources:
1080+
cpu: "0.2"
1081+
memory: "200M"
1082+
1083+
# monitoring directive is used to setup prometheus and grafana dashboard,
1084+
# connected to all chains, relayers and k8s apis itself
1085+
monitoring:
1086+
enabled: false
1087+
ports:
1088+
prometheus: 8011
1089+
grafana: 9011
1090+
resources:
1091+
cpu: "0.2"
1092+
memory: "400M"
1093+
1094+
ingress:
1095+
enabled: false
1096+
type: nginx
1097+
# host must be a wildcard entry, so that we can use the wildcard to create
1098+
# service specific ingress rules
1099+
host: "*.thestarship.io"
1100+
certManager:
1101+
issuer: "cert-issuer"

packages/packages/generator/src/defaults.ts

Lines changed: 116 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import {
33
FaucetConfig,
44
Relayer,
55
Script,
6-
StarshipConfig
6+
StarshipConfig,
7+
Exposer
78
} from '@starship-ci/types';
89
import * as fs from 'fs';
910
import * as yaml from 'js-yaml';
1011
import * as path from 'path';
1112

1213
import { TemplateHelpers } from './helpers';
13-
import { DefaultsConfig, ProcessedChain } from './types';
14-
15-
export { ProcessedChain };
14+
import { DefaultsConfig } from './types';
1615

1716
/**
1817
* Deep merge utility for nested objects
@@ -125,6 +124,96 @@ export class DefaultsManager {
125124
return this.defaultsData.defaultCometmock || {};
126125
}
127126

127+
/**
128+
* Process explorer configuration by merging with defaults
129+
*/
130+
processExplorer(explorerConfig?: any): any {
131+
if (!explorerConfig) return undefined;
132+
133+
const defaultExplorer = this.defaultsData.explorer || {};
134+
return deepMerge(defaultExplorer, explorerConfig);
135+
}
136+
137+
/**
138+
* Process registry configuration by merging with defaults
139+
*/
140+
processRegistry(registryConfig?: any): any {
141+
if (!registryConfig) return undefined;
142+
143+
const defaultRegistry = this.defaultsData.registry || {};
144+
return deepMerge(defaultRegistry, registryConfig);
145+
}
146+
147+
/**
148+
* Process faucet configuration by merging with defaults
149+
*/
150+
processFaucet(faucetConfig?: any): any {
151+
if (!faucetConfig) return undefined;
152+
153+
const defaultFaucet = this.defaultsData.faucet || {};
154+
return deepMerge(defaultFaucet, faucetConfig);
155+
}
156+
157+
/**
158+
* Process monitoring configuration by merging with defaults
159+
*/
160+
processMonitoring(monitoringConfig?: any): any {
161+
if (!monitoringConfig) return undefined;
162+
163+
const defaultMonitoring = this.defaultsData.monitoring || {};
164+
return deepMerge(defaultMonitoring, monitoringConfig);
165+
}
166+
167+
/**
168+
* Process ingress configuration by merging with defaults
169+
*/
170+
processIngress(ingressConfig?: any): any {
171+
if (!ingressConfig) return undefined;
172+
173+
const defaultIngress = this.defaultsData.ingress || {};
174+
return deepMerge(defaultIngress, ingressConfig);
175+
}
176+
177+
/**
178+
* Process exposer configuration by merging with defaults
179+
*/
180+
processExposer(exposerConfig?: Exposer): Exposer {
181+
if (!exposerConfig) return undefined;
182+
183+
const defaultExposer = this.defaultsData.exposer || {};
184+
return deepMerge(defaultExposer, exposerConfig);
185+
}
186+
187+
/**
188+
* Process images configuration by merging with defaults
189+
*/
190+
processImages(imagesConfig?: any): any {
191+
if (!imagesConfig) return undefined;
192+
193+
const defaultImages = this.defaultsData.images || {};
194+
return deepMerge(defaultImages, imagesConfig);
195+
}
196+
197+
/**
198+
* Process resources configuration by merging with defaults
199+
*/
200+
processResources(resourcesConfig?: any): any {
201+
if (!resourcesConfig) return undefined;
202+
203+
const defaultResources = this.defaultsData.resources || {};
204+
return deepMerge(defaultResources, resourcesConfig);
205+
}
206+
207+
/**
208+
* Process timeouts configuration by merging with defaults
209+
*/
210+
processTimeouts(timeoutsConfig?: any): any {
211+
if (!timeoutsConfig) return undefined;
212+
213+
const defaultTimeouts = this.defaultsData.timeouts || {};
214+
return deepMerge(defaultTimeouts, timeoutsConfig);
215+
}
216+
128217
/**
129218
* Process a relayer configuration by merging with defaults
130219
* This handles partial overrides properly using deep merge
@@ -230,25 +319,39 @@ export class DefaultsManager {
230319

231320
/**
232321
* Apply defaults to a StarshipConfig
233-
* This is a standalone function that processes all chains and returns a fully configured StarshipConfig
322+
* This is a standalone function that processes all chains, relayers, and global configs
234323
*/
235324
export function applyDefaults(config: StarshipConfig): StarshipConfig {
236325
const defaultsManager = new DefaultsManager();
237-
const processedChains = config.chains?.map((chain: Chain) =>
326+
327+
// Process chains with defaults
328+
const processedChains: Chain[] = config.chains?.map((chain: Chain) =>
238329
defaultsManager.processChain(chain)
239330
);
240331

241-
const processedConfig: StarshipConfig = {
242-
...config,
243-
chains: processedChains
244-
};
245-
332+
// Process relayers with defaults
333+
let processedRelayers: Relayer[] | undefined;
246334
if (config.relayers && config.relayers?.length > 0) {
247-
const processedRelayers = config.relayers.map((relayer: Relayer) =>
335+
processedRelayers = config.relayers.map((relayer: Relayer) =>
248336
defaultsManager.processRelayer(relayer)
249337
);
250-
processedConfig.relayers = processedRelayers;
251338
}
252339

340+
// Process global configurations individually to maintain type safety
341+
const processedConfig = {
342+
...config,
343+
chains: processedChains,
344+
relayers: processedRelayers,
345+
...(config.explorer && { explorer: defaultsManager.processExplorer(config.explorer) }),
346+
...(config.registry && { registry: defaultsManager.processRegistry(config.registry) }),
347+
...(config.faucet && { faucet: defaultsManager.processFaucet(config.faucet) }),
348+
...(config.monitoring && { monitoring: defaultsManager.processMonitoring(config.monitoring) }),
349+
...(config.ingress && { ingress: defaultsManager.processIngress(config.ingress) }),
350+
...(config.exposer && { exposer: defaultsManager.processExposer(config.exposer) }),
351+
...(config.images && { images: defaultsManager.processImages(config.images) }),
352+
...(config.resources && { resources: defaultsManager.processResources(config.resources) }),
353+
...(config.timeouts && { timeouts: defaultsManager.processTimeouts(config.timeouts) })
354+
};
355+
253356
return processedConfig;
254357
}

packages/packages/generator/src/types.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import {
33
FaucetConfig,
44
Relayer,
55
Script,
6-
StarshipConfig
6+
StarshipConfig,
7+
Images,
8+
Resources,
9+
Exposer,
10+
TimeoutConfig,
11+
Explorer,
12+
Registry,
13+
Monitoring,
14+
Ingress
715
} from '@starship-ci/types';
816

917
export interface EnvVar {
@@ -41,13 +49,16 @@ export interface DefaultsConfig {
4149
defaultRelayers: Record<string, Relayer>;
4250
defaultScripts: Record<string, Script>;
4351
defaultCometmock: CometmockDefault;
44-
}
45-
46-
export interface ProcessedChain extends Chain {
47-
hostname: string;
48-
accounts: Array<{
49-
name: string;
50-
mnemonic: string;
51-
address: string;
52-
}>;
52+
images?: Images;
53+
resources?: {
54+
node: Resources;
55+
wait: Resources;
56+
};
57+
exposer?: Exposer;
58+
timeouts?: TimeoutConfig;
59+
explorer?: Explorer;
60+
registry?: Registry;
61+
faucet?: FaucetConfig;
62+
monitoring?: Monitoring;
63+
ingress?: Ingress;
5364
}

0 commit comments

Comments
 (0)