Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit 6c5d916

Browse files
author
Julien Neuhart
committed
first commit
0 parents  commit 6c5d916

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3647
-0
lines changed

.github/CODE_OF_CONDUCT.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
* Using welcoming and inclusive language
12+
* Being respectful of differing viewpoints and experiences
13+
* Gracefully accepting constructive criticism
14+
* Focusing on what is best for the community
15+
* Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
* Trolling, insulting/derogatory comments, and personal or political attacks
21+
* Public or private harassment
22+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
* Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at neuhart.julien@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

.github/CONTRIBUTING.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Contributing
2+
3+
Hi! Thank you for considering contributing to Gotenberg Go client. You'll
4+
find below useful information about how to contribute to the Gotenberg project.
5+
6+
## Contributing code
7+
8+
### Install from sources
9+
10+
1. Install and run the latest version of Docker
11+
2. Verify your Go version (>= 1.12)
12+
3. Fork this repository
13+
4. Clone it outside of your `GOPATH` (we're using Go modules)
14+
15+
### Working with git
16+
17+
1. Create your feature branch (`git checkout -b my-new-feature`)
18+
2. Commit your changes (`git commit -am 'Add some feature'`)
19+
3. Push to the branch (`git push origin my-new-feature`)
20+
4. Create a new pull request
21+
22+
### Testing
23+
24+
1. Run all linters (`make lint`)
25+
2. Run all tests (`make tests`)
26+
27+
## Reporting bugs and feature request
28+
29+
Your issue or feature request may already be reported!
30+
Please search on the [issue tracker](../../../issues) before creating one.
31+
32+
If you do not find any relevant issue or feature request, feel free to
33+
add a new one!
34+
35+
## Additional resources
36+
37+
* [Code of conduct](CODE_OF_CONDUCT.md)
38+
* [Issue template](ISSUE_TEMPLATE.md)
39+
* [Pull request template](PULL_REQUEST_TEMPLATE.md)

.github/ISSUE_TEMPLATE.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Your issue may already be reported!
2+
Please search on the [issue tracker](../../../issues) before creating one.
3+
4+
## Expected Behavior
5+
<!--- If you're describing a bug, tell us what should happen -->
6+
<!--- If you're suggesting a change/improvement, tell us how it should work -->
7+
8+
## Current Behavior
9+
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
10+
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
11+
12+
## Possible Solution
13+
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
14+
<!--- or ideas how to implement the addition or change -->
15+
16+
## Steps to Reproduce (for bugs)
17+
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
18+
<!--- reproduce this bug. Include code to reproduce, if relevant -->
19+
1.
20+
2.
21+
3.
22+
4.
23+
24+
## Context
25+
<!--- How has this issue affected you? What are you trying to accomplish? -->
26+
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
27+
28+
## Your Environment
29+
<!--- Include as many relevant details about the environment you experienced the bug in -->
30+
* Version used:
31+
* Operating System and version:
32+
* Link to your project:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
A similar PR may already be submitted!
2+
Please search among the [pull requests](../../../pulls) before creating one.
3+
4+
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:
5+
6+
For more information, see the [CONTRIBUTING](CONTRIBUTING.md) guide.
7+
8+
**Summary**
9+
10+
<!-- Summary of the PR -->
11+
12+
This PR fixes/implements the following **bugs/features**
13+
14+
* [ ] Bug 1
15+
* [ ] Bug 2
16+
* [ ] Feature 1
17+
* [ ] Feature 2
18+
* [ ] Breaking changes
19+
20+
<!-- You can skip this if you're fixing a typo or adding an app to the Showcase. -->
21+
22+
Explain the **motivation** for making this change. What existing problem does the pull request solve?
23+
24+
<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->
25+
26+
**Test plan (required)**
27+
28+
Demonstrate the code is solid. Example: The exact commands you ran and their output.
29+
30+
<!-- Make sure tests pass on Travis. -->
31+
32+
**Closing issues**
33+
34+
<!-- Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). -->
35+
Fixes #
36+
37+
**Checklist**
38+
39+
- [ ] Have you followed the guidelines in our [CONTRIBUTING](CONTRIBUTING.md) guide?
40+
- [ ] Have you lint your code locally prior to submission (`make lint`)?
41+
- [ ] Have you written new tests for your core changes, as applicable?
42+
- [ ] Have you successfully ran tests with your changes locally (`make tests`)?
43+
- [ ] I have squashed any insignificant commits
44+
- [ ] This change has comments for package types, values, functions, and non-obvious lines of code

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
sudo: required
2+
3+
language: generic
4+
5+
services:
6+
- docker
7+
8+
stages:
9+
- tests
10+
11+
jobs:
12+
include:
13+
- stage: tests
14+
script: make lint
15+
- stage: tests
16+
script: make tests

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
GOLANG_VERSION=1.12
2+
GOTENBERG_VERSION=4.2.1
3+
VERSION=snapshot
4+
5+
# gofmt and goimports all go files.
6+
fmt:
7+
go fmt ./...
8+
go mod tidy
9+
10+
# run all linters.
11+
lint:
12+
docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) -t thecodingmachine/gotenberg-go-client:lint -f build/lint/Dockerfile .
13+
docker run --rm -it -v "$(PWD):/lint" thecodingmachine/gotenberg-go-client:lint
14+
15+
# run all tests.
16+
tests:
17+
docker build --build-arg GOLANG_VERSION=$(GOLANG_VERSION) --build-arg GOTENBERG_VERSION=$(GOTENBERG_VERSION) -t thecodingmachine/gotenberg-go-client:tests -f build/tests/Dockerfile .
18+
docker run --rm -it -v "$(PWD):/tests" thecodingmachine/gotenberg-go-client:tests

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Gotenberg Go client
2+
3+
A simple Go client for interacting with a Gotenberg API.
4+
5+
## Install
6+
7+
```bash
8+
$ go get -u github.com/thecodingmachine/gotenberg-go-client/v4
9+
```
10+
11+
## Usage
12+
13+
```golang
14+
import "github.com/thecodingmachine/gotenberg-go-client/v4"
15+
16+
func main() {
17+
// HTML conversion example.
18+
c := &gotenberg.Client{Hostname: "http://localhost:3000"}
19+
req, _ := gotenberg.NewHTMLRequest("index.html")
20+
req.SetHeader("header.html")
21+
req.SetFooter("footer.html")
22+
req.SetAssets(
23+
"font.woff",
24+
"img.gif",
25+
"style.css",
26+
)
27+
req.SetPaperSize(gotenberg.A4)
28+
req.SetMargins(gotenberg.NormalMargins)
29+
req.SetLandscape(false)
30+
dest := "foo.pdf"
31+
c.Store(req, dest)
32+
}
33+
```
34+
35+
For more complete usages, head to the [documentation](https://thecodingmachine.github.io/gotenberg).
36+
37+
38+
## Badges
39+
40+
[![Travis CI](https://travis-ci.org/thecodingmachine/gotenberg-go-client.svg?branch=master)](https://travis-ci.org/thecodingmachine/gotenberg-go-client)
41+
[![GoDoc](https://godoc.org/github.com/thecodingmachine/gotenberg-go-client?status.svg)](https://godoc.org/github.com/thecodingmachine/gotenberg-go-client)
42+
[![Go Report Card](https://goreportcard.com/badge/github.com/thecodingmachine/gotenberg-go-client)](https://goreportcard.com/report/thecodingmachine/gotenberg-go-client)

build/lint/Dockerfile

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
ARG GOLANG_VERSION
2+
3+
FROM golang:${GOLANG_VERSION}-stretch
4+
5+
# |--------------------------------------------------------------------------
6+
# | GolangCI-Lint
7+
# |--------------------------------------------------------------------------
8+
# |
9+
# | Installs GolangCI-Lint, a linters Runner for Go. 5x faster
10+
# | than gometalinter.
11+
# |
12+
13+
ENV GOLANGCI_LINT_VERSION 1.15.0
14+
15+
RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b /usr/local/bin v${GOLANGCI_LINT_VERSION} &&\
16+
golangci-lint --version
17+
18+
# |--------------------------------------------------------------------------
19+
# | Final touch
20+
# |--------------------------------------------------------------------------
21+
# |
22+
# | Last instructions of this build.
23+
# |
24+
25+
# Define our workding outside of $GOPATH (we're using go modules).
26+
WORKDIR /lint
27+
28+
# Copy our module dependencies definitions.
29+
COPY go.mod .
30+
COPY go.sum .
31+
32+
# Install module dependencies.
33+
RUN go mod download
34+
35+
CMD [ "golangci-lint", "run" ,"--tests=false", "--enable-all", "--disable=dupl", "--disable=lll", "--disable=errcheck", "--disable=gosec", "--disable=gochecknoglobals", "--disable=gochecknoinits" ]

build/tests/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
ARG GOLANG_VERSION
2+
ARG GOTENBERG_VERSION
3+
4+
FROM golang:${GOLANG_VERSION}-stretch AS golang
5+
6+
FROM thecodingmachine/gotenberg:${GOTENBERG_VERSION}
7+
8+
# |--------------------------------------------------------------------------
9+
# | Common libraries
10+
# |--------------------------------------------------------------------------
11+
# |
12+
# | Libraries used in the build process of this image.
13+
# |
14+
15+
RUN apt-get install -y git gcc
16+
17+
# |--------------------------------------------------------------------------
18+
# | Golang
19+
# |--------------------------------------------------------------------------
20+
# |
21+
# | Installs Golang.
22+
# |
23+
24+
COPY --from=golang /usr/local/go /usr/local/go
25+
26+
RUN export PATH="/usr/local/go/bin:$PATH" &&\
27+
go version
28+
29+
ENV GOPATH /go
30+
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
31+
32+
# |--------------------------------------------------------------------------
33+
# | Final touch
34+
# |--------------------------------------------------------------------------
35+
# |
36+
# | Last instructions of this build.
37+
# |
38+
39+
# Define our workding outside of $GOPATH (we're using go modules).
40+
WORKDIR /tests
41+
42+
# Copy our module dependencies definitions.
43+
COPY go.mod .
44+
COPY go.sum .
45+
46+
# Install module dependencies.
47+
RUN go mod download
48+
49+
ENTRYPOINT [ "build/tests/docker-entrypoint.sh" ]

build/tests/docker-entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
# Testing Go client.
6+
gotenberg &
7+
sleep 10
8+
go test -race -cover -covermode=atomic github.com/thecodingmachine/gotenberg-go-client/v4
9+
sleep 10 # allows Gotenberg to remove generated files (concurrent requests).

0 commit comments

Comments
 (0)