Compare commits

..

5 Commits
3.0.0 ... 3.0.1

Author SHA1 Message Date
Julien Neuhart
7aeb072cc3 fixing issue with merge endpoint: was not returning file 2018-12-10 18:42:23 +01:00
Julien Neuhart
8a652761a3 fixing Go Report Card issues (rollback gocycly) 2018-12-10 17:03:23 +01:00
Julien Neuhart
be667575d5 fixing Go Report Card issues #2 2018-12-10 17:02:48 +01:00
Julien Neuhart
59ca8a44a0 fixing Go Report Card issues 2018-12-10 16:57:08 +01:00
Julien Neuhart
c9f0d3bfd8 fixes publishing Docker images in CI 2018-12-10 16:36:34 +01:00
6 changed files with 24 additions and 11 deletions

View File

@@ -20,4 +20,4 @@ jobs:
script: make lint
- stage: publish
if: tag IS present
script: make image VERSION=$TRAVIS_TAG && ./scripts/publish.sh $TRAVIS_TAG $DOCKER_USER $DOCKER_PASS
script: ./scripts/publish.sh $TRAVIS_TAG $DOCKER_USER $DOCKER_PASS

View File

@@ -15,7 +15,7 @@ At TheCodingMachine, we build a lot of web applications (intranets, extranets an
* Performance :zap:: Google Chrome and Libreoffice (unoconv) started once in the background thanks to PM2
* Failure prevention :broken_heart:: PM2 automatically restarts previous processes if they fail
* Assets :package:: send your header, footer, images, fonts, stylesheets and so on for converting your HTML and Markdown to beaufitul PDFs!
* Easily interact with the API using our [Go](/pkg) and [PHP](https://github.com/thecodingmachine/gotenberg-php-client) libraries
* Easily interact with the API using our [Go](/pkg) and [PHP](https://github.com/thecodingmachine/gotenberg-php-client) (**WIP**) libraries
## Quick start

View File

@@ -25,22 +25,25 @@ func merge(c echo.Context) error {
return fmt.Errorf("getting result file name: %v", err)
}
filename := fmt.Sprintf("%s.pdf", baseFilename)
dest := fmt.Sprintf("%s/%s", r.dirPath, filename)
fpath := fmt.Sprintf("%s/%s", r.dirPath, filename)
if r.webhookURL() == "" {
// if no webhook URL given, run merge
// and directly return the resulting PDF file
// or and error.
return printer.Merge(fpaths, dest)
if err := printer.Merge(fpaths, fpath); err != nil {
return err
}
return c.Attachment(fpath, filename)
}
// as a webhook URL has been given, we
// run the following lines in a goroutine so that
// it doesn't block.
go func() {
if err := printer.Merge(fpaths, dest); err != nil {
if err := printer.Merge(fpaths, fpath); err != nil {
c.Logger().Errorf("%v", err)
return
}
f, err := os.Open(dest)
f, err := os.Open(fpath)
if err != nil {
c.Logger().Errorf("%v", err)
return

View File

@@ -23,7 +23,7 @@ func Merge(fpaths []string, destination string) error {
func writeBytesToFile(dst string, b []byte) error {
if err := ioutil.WriteFile(dst, b, 0644); err != nil {
return fmt.Errorf("%s: writting file: %v", dst, err)
return fmt.Errorf("%s: writing file: %v", dst, err)
}
return nil
}

View File

@@ -148,7 +148,7 @@ func multipartForm(req Request) (*bytes.Buffer, string, error) {
}
for name, value := range req.getFormValues() {
if err := writer.WriteField(name, value); err != nil {
return nil, "", fmt.Errorf("%s: writting form field: %v", name, err)
return nil, "", fmt.Errorf("%s: writing form field: %v", name, err)
}
}
return body, writer.FormDataContentType(), nil

View File

@@ -2,6 +2,7 @@
set -e
GOLANG_VERSION=1.11.2
VERSION="$1"
DOCKER_USER="$2"
DOCKER_PASSWORD="$3"
@@ -16,6 +17,15 @@ if [ $VERSION_LENGTH -ne 3 ]; then
exit 1
fi
docker push thecodingmachine/gotenberg:${SEMVER[0]}
docker push thecodingmachine/gotenberg:${SEMVER[0]}.${SEMVER[1]}
docker push thecodingmachine/gotenberg:${SEMVER[0]}.${SEMVER[1]}.${SEMVER[2]}
docker build -t thecodingmachine/gotenberg:base -f build/base/Dockerfile .
docker build \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} \
--build-arg VERSION=${VERSION} \
-t thecodingmachine/gotenberg:${SEMVER[0]} \
-t thecodingmachine/gotenberg:${SEMVER[0]}.${SEMVER[1]} \
-t thecodingmachine/gotenberg:${SEMVER[0]}.${SEMVER[1]}.${SEMVER[2]} \
-f build/package/Dockerfile .
docker push "thecodingmachine/gotenberg:${SEMVER[0]}"
docker push "thecodingmachine/gotenberg:${SEMVER[0]}.${SEMVER[1]}"
docker push "thecodingmachine/gotenberg:${SEMVER[0]}.${SEMVER[1]}.${SEMVER[2]}"