Overview
Configuration simplicity helps you customize HapiDeploy. You can set it and use later in each context.
Setters
As the example in Get started, it assigns a value to a key using put.
app.put('name', 'HapiDeploy')
app.put('year', 2025)
app.put('libraries', [
'typer',
'fabric'
])
You can also add more items into a list
app.add('libraries', [
'pyyaml',
'requests',
])
# Because frameworks key does not exist, it'll automatically create it like using put.
app.add('frameworks', [
'Laravel',
])
# frameworks does exist, it'll append to that list.
app.add('frameworks', [
'Symfony',
'CodeIgniter',
])
Getters
To use a configuration item, you can use Context.cook or Context.parse method.
@app.task(name='hello', desc='Hello')
def hello(c: Context):
v = c.cook('name') # v is "HapiDeploy"
msg = c.parse('Hello {{name}}') # msg is "Hello HapiDeploy"
You can also check if a configuration key exists
@app.task(name='hello', desc='Hello')
def hello(c: Context):
if c.check('name'):
c.info('name exists')
else:
c.info('name does not exist')
Context.parse only supports string or number.
List configuration
You can list global configuration using the config:list command
hapi config:list