Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Conditionally disable steps in workflows #1927

Closed
noizwaves opened this issue Jul 2, 2020 · 2 comments · Fixed by #1985
Closed

[FEATURE]: Conditionally disable steps in workflows #1927

noizwaves opened this issue Jul 2, 2020 · 2 comments · Fixed by #1985

Comments

@noizwaves
Copy link
Contributor

Feature Request

Background / Motivation

In our usage of Garden, we need to run a task after deploying services. Before Garden 0.12, we would invoke garden CLI twice in a deploy.sh script. With 0.12, we upgraded to use Garden Workflows 🙌.

Now, we have a need to run this task conditionally. For my specific use case, it is conditional on whether a user has selected to deploy a specific application.

What should the user be able to do?

I could see it being useful for steps in Garden workflows to be conditionally disabled.

Why do they want to do this? What problem does it solve?

We've worked around this by making the task name conditional. In the case where the task should not be run, we instead run a noop task:

name: deploy
kind: Workflow
steps:
  - name: deploy-services
    command: [deploy]
  - name: initialize-database
    command: [run, task, "${local.env.APP_SELECTED == 'true' ? 'db-init' : 'noop-task'}"]

Suggested Implementation(s)

I imagine a new key in the step definition called disabled (to match the existing disabled option on other modules/services). It would look something like this:

name: deploy
kind: Workflow
description: deploy all applications
steps:
  - name: deploy-services
    command: [deploy]
  - name: initialize-database
    command: [run, task, db-init]
    disabled: ${var.environment == 'production'}

How important is this feature for you/your team?

🌹 It’s a nice to have, but nice things are nice 🙂

@thsig
Copy link
Collaborator

thsig commented Jul 14, 2020

Good idea—I think we should have a look at this one soon.

@eysi09
Copy link
Collaborator

eysi09 commented Jul 14, 2020

Hi @noizwaves and thanks for the feature request.

I agree that this makes sense. An alternative would be to add an environments field where you can select the environments in which the workflow step should run. This could also be available on the workflow as a whole.

That would make it easier to disable a step for more than one environment.

Of course we could also do both, if there's a use case for disabling a workflow or a workflow step in other contexts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants