mirror of
https://github.com/strongdm/comply
synced 2024-11-21 23:24:53 +00:00
Fix error handling inside pandocPandoc func (#100)
Other changes: - Updated strongdm/pandoc image references to edge Co-authored-by: vassalo <vassalo@users.noreply.github.com>
This commit is contained in:
parent
3d8652f497
commit
c78f9007c2
@ -1,4 +1,4 @@
|
|||||||
FROM strongdm/pandoc:latest
|
FROM strongdm/pandoc:edge
|
||||||
|
|
||||||
# based on implementation by James Gregory <james@jagregory.com>
|
# based on implementation by James Gregory <james@jagregory.com>
|
||||||
MAINTAINER Comply <comply@strongdm.com>
|
MAINTAINER Comply <comply@strongdm.com>
|
||||||
|
4
Makefile
4
Makefile
@ -52,8 +52,8 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
cd build && docker build -t strongdm/pandoc .
|
cd build && docker build -t strongdm/pandoc:edge .
|
||||||
docker push strongdm/pandoc
|
docker push strongdm/pandoc:edge
|
||||||
|
|
||||||
cleanse:
|
cleanse:
|
||||||
git checkout --orphan newbranch
|
git checkout --orphan newbranch
|
||||||
|
@ -274,7 +274,7 @@ var pandocImageExists = func(ctx context.Context) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, image := range imageList {
|
for _, image := range imageList {
|
||||||
if strings.Contains(image.RepoTags[0], "strongdm/pandoc") {
|
if strings.Contains(image.RepoTags[0], "strongdm/pandoc:edge") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ func cleanContainers(c *cli.Context) error {
|
|||||||
|
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
// assume this container was leftover from previous aborted run
|
// assume this container was leftover from previous aborted run
|
||||||
if strings.HasPrefix(c.Image, "strongdm/pandoc") {
|
if strings.HasPrefix(c.Image, "strongdm/pandoc:edge") {
|
||||||
d := time.Second * 2
|
d := time.Second * 2
|
||||||
err = cli.ContainerStop(ctx, c.ID, &d)
|
err = cli.ContainerStop(ctx, c.ID, &d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -18,10 +18,7 @@ var pandocArgs = []string{"-f", "markdown+smart", "--toc", "-N", "--template", "
|
|||||||
|
|
||||||
func pandoc(outputFilename string, errOutputCh chan error) {
|
func pandoc(outputFilename string, errOutputCh chan error) {
|
||||||
if config.WhichPandoc() == config.UsePandoc {
|
if config.WhichPandoc() == config.UsePandoc {
|
||||||
err := pandocPandoc(outputFilename)
|
pandocPandoc(outputFilename, errOutputCh)
|
||||||
if err != nil {
|
|
||||||
errOutputCh <- err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dockerPandoc(outputFilename, errOutputCh)
|
dockerPandoc(outputFilename, errOutputCh)
|
||||||
}
|
}
|
||||||
@ -47,7 +44,7 @@ func dockerPandoc(outputFilename string, errOutputCh chan error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp, err := cli.ContainerCreate(ctx, &container.Config{
|
resp, err := cli.ContainerCreate(ctx, &container.Config{
|
||||||
Image: "strongdm/pandoc",
|
Image: "strongdm/pandoc:edge",
|
||||||
Cmd: pandocCmd},
|
Cmd: pandocCmd},
|
||||||
hc, nil, nil, "")
|
hc, nil, nil, "")
|
||||||
|
|
||||||
@ -95,12 +92,14 @@ func dockerPandoc(outputFilename string, errOutputCh chan error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 🐼
|
// 🐼
|
||||||
func pandocPandoc(outputFilename string) error {
|
func pandocPandoc(outputFilename string, errOutputCh chan error) error {
|
||||||
cmd := exec.Command("pandoc", append(pandocArgs, fmt.Sprintf("output/%s", outputFilename), fmt.Sprintf("output/%s.md", outputFilename))...)
|
cmd := exec.Command("pandoc", append(pandocArgs, fmt.Sprintf("output/%s", outputFilename), fmt.Sprintf("output/%s.md", outputFilename))...)
|
||||||
outputRaw, err := cmd.CombinedOutput()
|
outputRaw, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(string(outputRaw))
|
fmt.Println(string(outputRaw))
|
||||||
return errors.Wrap(err, "error calling pandoc")
|
errOutputCh <- errors.Wrap(err, "error calling pandoc")
|
||||||
|
} else {
|
||||||
|
errOutputCh <- nil
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user