Campaigns: src actions schema: add ability to reference config file from Docker Action
Created by: beyang
Here's the scenario: I would like to use Campaigns with Comby to initiate a refactor. The Comby transformation involves rewrite rules. I used https://comby.live to compose it:
It converts log.Printf calls like this:
log.Printf("Add %v as a temporary child of root %v", t.Span.ID, root.Span.ID)
into log15.Warn calls like this:
log15.Warn("Add as a temporary child of root", "t.Span.ID,", t.Span.ID, "root.Span.ID", root.Span.ID)
I would like to use the comby/comby Docker container as an Action in the Campaign. To do so, I need to specify Action JSON like the following:
{
"scopeQuery": "repo:^github\.com/sourcegraph/ log.Printf",
"steps": [
{
"type": "docker",
"image": "comby/comby",
"args": [...]
}
]
}
However, specifying the Comby transformation entirely as command-line args will be quite verbose. And when I click the "copy" button on https://comby.live, it gives me a blob of shell script to run:
COMBY_M="$(cat <<"MATCH"
log.Printf(":[format]", :[args])
MATCH
)"
COMBY_R="$(cat <<"REWRITE"
log15.Warn(":[format]", :[args])
REWRITE
)"
COMBY_RULE="$(cat <<"RULE"
where
rewrite :[format] { "%:[[_]] " -> "" },
rewrite :[format] { " %:[[_]]" -> "" },
rewrite :[args] { ":[arg.]" -> "\":[arg]\", :[arg]" }
RULE
)"
# Install comby with `bash <(curl -sL get.comby.dev)` or see github.com/comby-tools/comby && \
comby "$COMBY_M" "$COMBY_R" -rule "$COMBY_RULE" -stats
I would like to run this shell script in the comby/comby Docker container as the Action in my Campaign. To do this, it seems like we need 2 additions to the src actions CLI:
- Mount the current working directory on the host into some directory in the container, so it can be referenced
- Add a
entrypointfield to the Actions JSON schema, so I can override the entrypoint, as well as pass arguments to the default entrypoint.
These 2 things would let me create the shell script file (what I copied from https://comby.live) on my host machine and then reference it from the Comby Action (which is a Docker-based Action).
An obvious workaround is to use a Command-type Action, but it seems like there might be cases where the user doesn't have the command available on their host machine and wants to use a Docker Action while passing in a configuration file from their host FS to that container.
