Hello,
I have, I believe, a very simple use case: I want to create a task to build environment-specific docker images. I managed to put it together based on the tutorial and it largely works - except for the file dependencies.
It seems targets and actions happily accept the parameter, but I can't make the file dep paths dependent on the parameter. I'm pretty sure this is a fairly standard use case and that I'm missing something.
I've tried to look into the calculated dependencies, but have the same problem there to pass a parameter to calculate them based on the environment provided on the command line.
Below is what I'm trying to do. Can you please point me in the right direction to make the whole task (actions, target, file_dep) dynamic based on the parameter?
"""
def task_refresh_env():
"""Run script to refresh environment variables"""
def _create_env_files(task, environment, dependencies):
print(task, dependencies)
EnvironmentManagement.run(scope=environment, env_path='.envs/.global/.gitlab')
return {
'doc': "Generate .env files for Docker and Pycharm",
# 'file_dep': list(Path('.envs/.{environment}/').glob('.*')),
'file_dep': ['.envs/.{environment}/.django', '.envs/.{environment}/.traefik', ],
'targets': ['compose/{environment}/.env'],
'actions': [(_create_env_files,)],
'clean': True,
'params': [{'name': 'environment',
'short': 'e',
'type': str,
'choices': (('production', ''), ('staging', '')),
'default': 'production',
}],
'verbosity': 2,
'uptodate': [False], # for debugging
}
"""