Skip to content

Commit

Permalink
add inverse flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sethpollack committed Dec 4, 2019
1 parent 411d3b8 commit fe1257a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 38 deletions.
59 changes: 30 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,35 +113,36 @@ Full applet spec:
You can also overide an applets settings at runtime with flags followed by a seperator. The default seperator is `--` and can be configured with the `DOCKERBOX_SEPARATOR` environment variable.

```
--after-hook strings Run container after
--all-envs Pass all envars to container
--before-hook strings Run container before
--command strings Command to run in container
--dependency strings Run container before
-d, --detach Run container in background and print container ID
--dns strings Set custom DNS servers
--dns-option strings Set DNS options
--dns-search strings Set custom DNS search domains
--entrypoint string Overwrite the default ENTRYPOINT of the image
--env-file strings Read in a file of environment variables
--env-filter string Filter env vars passed to container from --all-envs
-e, --environment strings Set environment variables
--hostname string Container host name
--image string Container image
-i, --interactive Keep STDIN open even if not attached
--kill Kill previous run on container with same name
--link strings Add link to another container
--name string Assign a name to the container
--network string Connect a container to a network
--privileged Give extended privileges to this container
-p, --publish strings Publish a container's port(s) to the host
--pull Pull image before running it
--restart string Restart policy to apply when a container exits
--rm Automatically remove the container when it exits
--tag string Container image tag
-t, --tty Allocate a pseudo-TTY
-v, --volume strings Bind mount a volume
-w, --workdir string
--after-hook strings Run container after
--all-envs Pass all envars to container
--before-hook strings Run container before
--command strings Command to run in container
--dependency strings Run container before
-d, --detach Run container in background and print container ID
--dns strings Set custom DNS servers
--dns-option strings Set DNS options
--dns-search strings Set custom DNS search domains
--entrypoint string Overwrite the default ENTRYPOINT of the image
--env-file strings Read in a file of environment variables
--env-filter string Filter env vars passed to container from --all-envs
-e, --environment strings Set environment variables
--hostname string Container host name
--image string Container image
-i, --interactive Keep STDIN open even if not attached
--inverse Inverse env-filter
--kill Kill previous run on container with same name
--link strings Add link to another container
--name string Assign a name to the container
--network string Connect a container to a network
--privileged Give extended privileges to this container
-p, --publish strings Publish a container's port(s) to the host
--pull Pull image before running it
--restart string Restart policy to apply when a container exits
--rm Automatically remove the container when it exits
--tag string Container image tag
-t, --tty Allocate a pseudo-TTY
-v, --volume strings Bind mount a volume
-w, --workdir string Working directory inside the container
```

## Usage
Expand Down
19 changes: 10 additions & 9 deletions repo/applet.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ type Applet struct {
Image string `yaml:"image" flag:"image" desc:"Container image"`
Tag string `yaml:"image_tag" flag:"tag" desc:"Container image tag"`

RM bool `yaml:"rm" flag:"rm" desc:"Automatically remove the container when it exits"`
TTY bool `yaml:"tty" flag:"tty t" desc:"Allocate a pseudo-TTY"`
Interactive bool `yaml:"interactive" flag:"interactive i" desc:"Keep STDIN open even if not attached"`
Privileged bool `yaml:"privileged" flag:"privileged" desc:"Give extended privileges to this container"`
Detach bool `yaml:"detach" flag:"detach d" desc:"Run container in background and print container ID"`
Kill bool `yaml:"kill" flag:"kill" desc:"Kill previous run on container with same name"`
AllEnvs bool `yaml:"all_envs" flag:"all-envs" desc:"Pass all envars to container"`
Pull bool `yaml:"pull" flag:"pull" desc:"Pull image before running it"`
RM bool `yaml:"rm" flag:"rm" desc:"Automatically remove the container when it exits"`
TTY bool `yaml:"tty" flag:"tty t" desc:"Allocate a pseudo-TTY"`
Interactive bool `yaml:"interactive" flag:"interactive i" desc:"Keep STDIN open even if not attached"`
Privileged bool `yaml:"privileged" flag:"privileged" desc:"Give extended privileges to this container"`
Detach bool `yaml:"detach" flag:"detach d" desc:"Run container in background and print container ID"`
Kill bool `yaml:"kill" flag:"kill" desc:"Kill previous run on container with same name"`
AllEnvs bool `yaml:"all_envs" flag:"all-envs" desc:"Pass all envars to container"`
Pull bool `yaml:"pull" flag:"pull" desc:"Pull image before running it"`
InverseEnvFilter bool `yaml:"inverse" flag:"inverse" desc:"Inverse env-filter"`

DNS []string `yaml:"dns" flag:"dns" desc:"Set custom DNS servers"`
DNSSearch []string `yaml:"dns_search" flag:"dns-search" desc:"Set custom DNS search domains"`
Expand Down Expand Up @@ -147,7 +148,7 @@ func (a *Applet) RunCmd(extra []string) *exec.Cmd {
}
if a.AllEnvs {
for _, f := range os.Environ() {
if matched, _ := regexp.MatchString(a.EnvFilter, f); matched {
if matched, _ := regexp.MatchString(a.EnvFilter, f); a.InverseEnvFilter != matched {
args = append(args, "-e", f)
}
}
Expand Down

0 comments on commit fe1257a

Please sign in to comment.