This repository has been archived by the owner on Aug 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic container runner, for quick $PWD:/tmp/workdir
Cannot re-use the `--image` flag, due to skybet/cali#55
- Loading branch information
Lucy Davinhart
committed
Aug 25, 2019
1 parent
415e5f4
commit 6c6d63a
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.14.1 | ||
0.15.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cmd | ||
|
||
import ( | ||
log "github.com/Sirupsen/logrus" | ||
"github.com/skybet/cali" | ||
) | ||
|
||
func init() { | ||
|
||
command := cli.NewCommand("generic [params]") | ||
command.SetShort("Very basic generic Container Runner") | ||
command.SetLong(`Runs containers as simply as possible. | ||
This is basically the equivalent of: | ||
docker run --rm -it -w /tmp/workdir -v $PWD:/tmp/workdir <image> "$@" | ||
i.e. not particularly useful for much beyond simply testing an image. | ||
Many images will require additional docker run parameters (and thus custom commands) | ||
`) | ||
|
||
// Empty string for now. Image will be set during Init | ||
task := command.Task("") | ||
|
||
// Flag to specify which image to use | ||
command.Flags().StringP("docker-image", "i", "centos:7", "Image to use") | ||
command.Flags().StringP("entrypoint", "e", "sh", "entrypoint to use") | ||
command.BindFlags() | ||
|
||
task.SetInitFunc(func(t *cali.Task, args []string) { | ||
// Select the image to use | ||
image := cli.FlagValues().GetString("docker-image") | ||
log.Infof("Using image: %s", image) | ||
t.SetImage(image) | ||
}) | ||
|
||
} |