Skip to content

Commit 1e883ae

Browse files
committed
Refactor Tiltfile and improve configuration management
- Centralized reusable constants and defaults (e.g., `defaultEmail`, `defaultPassword`, `mainnet`, `testnet_beta`) into `cons.Tiltfile` to reduce hardcoding and improve maintainability. - Updated the main `Tiltfile` and others (`pgadmin`, `indexer`, `query`) to load values from `cons.Tiltfile`. - Enhanced Port Forward configurations for `indexer`, `pgadmin`, and `query` to include specific labels and metadata (e.g., links to documentation and tools). - Improved `pgadmin` setup by integrating fallback defaults for email and password, with warnings for clarity. - Streamlined configuration across Tiltfiles to improve code readability and consistency.
1 parent 5746616 commit 1e883ae

File tree

5 files changed

+57
-12
lines changed

5 files changed

+57
-12
lines changed

Tiltfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
load('ext://dotenv', 'dotenv')
22
load('./tilt/Tiltfile', 'pocketdex')
33
load('./tilt/utils.Tiltfile', 'build_indexer_params_overwrite')
4+
load(
5+
'.tilt/cons.Tiltfile',
6+
'mainnet',
7+
'testnet_beta',
8+
'testnet_alpha',
9+
'localnet',
10+
'genesisPath',
11+
'defaultEmail',
12+
'defaultPassword',
13+
'pgadminEnabled',
14+
'onlyDb'
15+
)
416

517
dotenv(fn=".env", verbose=True, showValues=False)
618

@@ -9,15 +21,15 @@ secret_settings(disable_scrub = True)
921

1022
# Default to mainnet since it is running longer than maybe alpha
1123
# and requires less setup than localnet.
12-
network = os.getenv('NETWORK', 'mainnet')
24+
network = os.getenv('NETWORK', mainnet)
1325
# Default to genesis.json at tilt folder
14-
genesis_path = os.getenv('GENESIS_PATH', './tilt/genesis.json')
26+
genesis_path = os.getenv('GENESIS_PATH', genesisPath)
1527

16-
only_db = os.getenv('ONLY_DB', 'no')
28+
only_db = os.getenv('ONLY_DB', onlyDb)
1729
# default=<> only applies if the ENV variable is unset
18-
pgadmin_enabled = os.getenv('PGADMIN_ENABLED', default='yes')
19-
pgadmin_email = os.getenv('PGADMIN_EMAIL')
20-
pgadmin_password = os.getenv('PGADMIN_PASSWORD')
30+
pgadmin_enabled = os.getenv('PGADMIN_ENABLED', default=pgadminEnabled)
31+
pgadmin_email = os.getenv('PGADMIN_EMAIL', defaultEmail)
32+
pgadmin_password = os.getenv('PGADMIN_PASSWORD', defaultPassword)
2133

2234
indexer_params_overwrite = build_indexer_params_overwrite()
2335

tilt/apps/indexer/Tiltfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ def deploy_indexer(
108108
k8s_resource(
109109
workload='indexer',
110110
labels=labels,
111-
resource_deps=rs_deps
111+
resource_deps=rs_deps,
112+
port_forwards=[
113+
port_forward(3001, 3000, name='Indexer Admin')
114+
],
115+
links=[
116+
link('https://subquery.network/doc/indexer/welcome.html', 'SubQuery Indexer SDK'),
117+
]
112118
)
113119

114120

tilt/apps/query/Tiltfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,11 @@ def deploy_query(
1414
k8s_resource(
1515
workload='query',
1616
resource_deps=['postgresql', 'commons', 'indexer'],
17-
labels=labels
17+
labels=labels,
18+
port_forwards=[
19+
port_forward(3000, 3000, name='GraphQL Playground')
20+
],
21+
links=[
22+
link('https://www.apollographql.com/docs/apollo-server/v2/testing/graphql-playground', 'GraphQL Playground Docs'),
23+
]
1824
)

tilt/cons.Tiltfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
pgadminEnabled = 'yes'
12
defaultEmail = '[email protected]'
23
defaultPassword = 'pocketdex'
34

45
localnet = 'localnet'
56
testnet_beta = 'beta'
67
testnet_alpha = 'alpha'
78
mainnet = 'mainnet'
9+
10+
genesisPath = './tilt/genesis.json'
11+
12+
# on-host development only
13+
onlyDb = 'no'

tilt/tools/pgadmin/Tiltfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
load('ext://helm_resource', 'helm_resource', 'helm_repo')
2+
load(
3+
'../../cons.Tiltfile',
4+
'defaultEmail',
5+
'defaultPassword'
6+
)
27

38
def deploy_pgadmin(
49
email,
@@ -10,6 +15,14 @@ def deploy_pgadmin(
1015
if not os.path.exists(values_path):
1116
fail('pgadmin4 values files does not exists at: {}'.format(values_path))
1217

18+
if not email:
19+
print('⚠️ Using default email for pgadmin4')
20+
email = defaultEmail
21+
22+
if not password:
23+
print('⚠️ Using default password for pgadmin4')
24+
password = defaultPassword
25+
1326
# Add runix/pgadmin4 repo https://artifacthub.io/packages/helm/runix/pgadmin4
1427
helm_repo(
1528
name='runix',
@@ -28,12 +41,14 @@ def deploy_pgadmin(
2841
'--set=env.email={}'.format(email),
2942
'--set=env.password={}'.format(password)
3043
],
31-
port_forwards=['5050:80'],
44+
port_forwards=[
45+
port_forward(5050, 50, name='PgAdmin4 Web')
46+
],
3247
pod_readiness='wait',
3348
resource_deps=['helm-repo-runix', 'postgresql'],
3449
labels=labels,
3550
links=[
36-
link('localhost:5050', 'User: {}'.format(email)),
37-
link('localhost:5050', 'Pass: {}'.format(password))
38-
]
51+
link('localhost:5050', 'User: {}'.format(email)),
52+
link('localhost:5050', 'Pwd: {}'.format(password)),
53+
]
3954
)

0 commit comments

Comments
 (0)