1
0
mirror of https://github.com/strongdm/comply synced 2025-12-06 14:24:12 +00:00

If pandoc appears in the path, it will be preferred over Docker.

The pandoc version must be 2.2.1 or greater.

Defaults can be overridden by an optional "pandoc: pandoc"
or "pandoc: docker" in the comply.yml.
This commit is contained in:
Justin McCarthy
2018-05-23 16:48:35 -07:00
parent ff350a2b89
commit 49e950c3c0
5 changed files with 151 additions and 133 deletions

View File

@@ -100,16 +100,16 @@ func ticketingMustBeConfigured(c *cli.Context) error {
}
func pandocMustExist(c *cli.Context) error {
pandocErr := fmt.Errorf("Please install either Docker or the pandoc package and re-run `%s`", c.Command.Name)
eitherMustExistErr := fmt.Errorf("Please install either Docker or the pandoc package and re-run `%s`", c.Command.Name)
err := pandocBinaryMustExist(c)
fmt.Println(err)
if err != nil {
err = dockerMustExist(c)
if err != nil {
return pandocErr
}
pandocExistErr := pandocBinaryMustExist(c)
dockerExistErr := dockerMustExist(c)
config.SetPandoc(pandocExistErr == nil, dockerExistErr == nil)
if pandocExistErr != nil && dockerExistErr != nil {
return eitherMustExistErr
}
return nil
}
@@ -197,12 +197,17 @@ func dockerMustExist(c *cli.Context) error {
}
func cleanContainers(c *cli.Context) error {
dockerErr := fmt.Errorf("Docker must be available in order to run `%s`", c.Command.Name)
ctx := context.Background()
cli, err := client.NewEnvClient()
if err != nil {
return dockerErr
// no Docker? nothing to clean.
return nil
}
_, err = cli.Ping(ctx)
if err != nil {
// no Docker? nothing to clean.
return nil
}
containers, err := cli.ContainerList(ctx, types.ContainerListOptions{All: true})