Skip to content

Commit 9cd448f

Browse files
authored
Merge pull request #566 from ampproject/main
Snapshot version 8 from main.
2 parents 8ae2d36 + 2841e01 commit 9cd448f

File tree

3,299 files changed

+343874
-134617
lines changed

Some content is hidden

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

3,299 files changed

+343874
-134617
lines changed

.github/workflows/prerequisites.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- name: Setup Go 1.16
8-
uses: actions/setup-go@v1
8+
uses: actions/setup-go@v2
99
with:
1010
go-version: '1.16'
1111

@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Setup Go 1.16
30-
uses: actions/setup-go@v1
30+
uses: actions/setup-go@v2
3131
with:
3232
go-version: '1.16'
3333

@@ -43,12 +43,15 @@ jobs:
4343
runs-on: ubuntu-latest
4444
steps:
4545
- name: Setup Go 1.16
46-
uses: actions/setup-go@v1
46+
uses: actions/setup-go@v2
4747
with:
4848
go-version: '1.16'
4949

5050
- name: Checkout the repository
5151
uses: actions/checkout@v2
5252

5353
- name: Run the tests
54-
run: go test ./...
54+
run: make test
55+
56+
- name: Run the build
57+
run: make build

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/amppkg
12
/amppkg.toml
23
/main
34
/fuzz_httpreq/fuzz.zip

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
2+
BUILDDATE ?= $(shell date --iso-8601=seconds)
3+
REVISION ?= $(shell git rev-parse HEAD)
4+
VERSION ?= $(shell git log --date=short --pretty=format:'%h@%cd' -n 1 .)
5+
6+
GOOPTS ?=
7+
ifneq (,$(wildcard vendor))
8+
GOOPTS := $(GOOPTS) -mod=vendor
9+
endif
10+
11+
VERSION_LDFLAGS := \
12+
-X github.com/prometheus/common/version.Branch=$(BRANCH) \
13+
-X github.com/prometheus/common/version.BuildDate=$(BUILDDATE) \
14+
-X github.com/prometheus/common/version.Revision=$(REVISION) \
15+
-X github.com/prometheus/common/version.Version=$(VERSION)
16+
17+
all: test build
18+
19+
.PHONY: test
20+
test:
21+
go test $(GOOPTS) ./...
22+
23+
build: amppkg
24+
25+
.PHONY: amppkg
26+
amppkg:
27+
go build $(GOOPTS) -ldflags "$(VERSION_LDFLAGS)" -o amppkg ./cmd/amppkg/...
28+
29+
.PHONY: update-go-deps
30+
update-go-deps:
31+
@for m in $$(go list -mod=readonly -m -f '{{ if and (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
32+
go get $$m; \
33+
done
34+
ifneq (,$(wildcard vendor))
35+
go mod vendor
36+
endif

README.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,34 +31,16 @@ own and can obtain certificates for.
3131

3232
##### Manual installation
3333

34-
1. Install Go version 1.10 or higher. Optionally, set
35-
[$GOPATH](https://github.com/golang/go/wiki/GOPATH) to something (default
36-
is `~/go`) and/or add `$GOPATH/bin` to `$PATH`.
34+
1. Install Go version 1.13 or higher.
3735
1. Get amppackager.
3836

39-
Check your Go version by running `go version`.
40-
41-
For Go 1.16 and higher run:
42-
4337
```
4438
git clone https://github.com/ampproject/amppackager.git my-amp-directory
4539
cd my-amp-directory
46-
go install github.com/ampproject/amppackager/cmd/amppkg
47-
```
48-
49-
For Go 1.14 and Go 1.15 run:
50-
51-
```
52-
go get -u github.com/ampproject/amppackager/cmd/amppkg
53-
```
54-
55-
For Go 1.13 and earlier versions run:
56-
57-
```
58-
go get -u -mod=vendor github.com/ampproject/amppackager/cmd/amppkg
40+
make build
5941
```
6042

61-
1. Optionally, move the built `~/go/bin/amppkg` wherever you like.
43+
1. Optionally, move the built `amppkg` wherever you like.
6244
1. Prepare a temporary certificate and private key pair to use for signing the
6345
exchange when testing your config. Follow WICG
6446
[instructions](https://github.com/WICG/webpackage/tree/master/go/signedexchange#creating-our-first-signed-exchange)
@@ -311,8 +293,8 @@ You can monitor the packager's error rates, as well as the rates of signed
311293
vs unsigned documents, via the tools discussed in the next section.
312294
313295
Specifically, you can monitor the requests that resulted in a signed or an
314-
unsigned document via `documents_signed_vs_unsigned` metric, and the ones that
315-
resulted in an error - via `total_requests_by_code_and_url` metric.
296+
unsigned document via `amppackager_signer_documents_total` metric, and the ones that
297+
resulted in an error - via `amppackager_http_duration_seconds_count` metric.
316298
317299
#### Monitoring `amppackager` in production via its Prometheus endpoints
318300

cmd/amppkg/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ import (
2525
"log"
2626
"net/http"
2727
"net/url"
28+
_ "net/http/pprof"
2829
"time"
2930

3031
"github.com/pkg/errors"
32+
"github.com/prometheus/client_golang/prometheus"
3133
"github.com/prometheus/client_golang/prometheus/promhttp"
34+
"github.com/prometheus/common/version"
3235

3336
"github.com/ampproject/amppackager/packager/certcache"
3437
"github.com/ampproject/amppackager/packager/certloader"
@@ -67,7 +70,13 @@ func (this logIntercept) ServeHTTP(resp http.ResponseWriter, req *http.Request)
6770
// - It exposes an API that allows people to sign any URL as any other URL.
6871
// - It is in cleartext.
6972
func main() {
73+
prometheus.MustRegister(version.NewCollector("amppackager"))
74+
showVersion := flag.Bool("version", false, "Print version info")
75+
7076
flag.Parse()
77+
if *showVersion {
78+
die(version.Print("amppackager"))
79+
}
7180
if *flagConfig == "" {
7281
die("must specify --config")
7382
}
@@ -164,7 +173,7 @@ func main() {
164173
}
165174

166175
// TODO(twifkak): Add monitoring (e.g. per the above Cloudflare blog).
167-
176+
log.Println("Starting amppackager", version.Info())
168177
log.Println("Serving on port", config.Port)
169178

170179
// TCP keep-alive timeout on ListenAndServe is 3 minutes. To shorten,

deploy/gcloud/Dockerfile.consumer

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# as a guide.
1717

1818
# Use an official Go runtime as a parent image
19-
FROM golang:1.13 as builder
19+
FROM golang:1.16 as builder
2020

2121
ENV GO111MODULE=on
2222

@@ -27,8 +27,8 @@ RUN apt-get update \
2727

2828
WORKDIR /data
2929

30-
# Run this if you clone from master branch.
31-
RUN git clone -b master https://github.com/ampproject/amppackager.git /data/amppackager
30+
# Run this if you clone from main branch.
31+
RUN git clone -b main https://github.com/ampproject/amppackager.git /data/amppackager
3232
# RUN git clone https://github.com/ampproject/amppackager.git /data/amppackager
3333

3434
WORKDIR /data/amppackager/cmd/amppkg

deploy/gcloud/Dockerfile.renewer

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# as a guide.
1717

1818
# Use an official Go runtime as a parent image
19-
FROM golang:1.13 as builder
19+
FROM golang:1.16 as builder
2020

2121
ENV GO111MODULE=on
2222

@@ -27,8 +27,8 @@ RUN apt-get update \
2727

2828
WORKDIR /data
2929

30-
# Run this if you clone from master branch.
31-
RUN git clone -b master https://github.com/ampproject/amppackager.git /data/amppackager
30+
# Run this if you clone from main branch.
31+
RUN git clone -b main https://github.com/ampproject/amppackager.git /data/amppackager
3232
# RUN git clone https://github.com/ampproject/amppackager.git /data/amppackager
3333

3434
WORKDIR /data/amppackager/cmd/amppkg

docker/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# limitations under the License.
1414

1515
# Use an official Go runtime as a parent image
16-
FROM golang:1.13
16+
FROM golang:1.16
1717

1818
ENV GO111MODULE=on
1919

2020
# Install AMP Packager
21-
# Run this if you want to go off master branch.
22-
# RUN go get -v github.com/ampproject/amppackager/cmd/amppkg@master
21+
# Run this if you want to go off main branch.
22+
# RUN go get -v github.com/ampproject/amppackager/cmd/amppkg@main
2323
RUN go get -v github.com/ampproject/amppackager/cmd/amppkg
2424

2525
# Install git

go.mod

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,22 @@ module github.com/ampproject/amppackager
33
go 1.13
44

55
require (
6-
github.com/WICG/webpackage v0.0.0-20190215052515-70386c3750f2
7-
github.com/ampproject/amphtml v0.0.0-20180912232012-d3df64d07ae9
8-
github.com/go-acme/lego/v3 v3.2.0
9-
github.com/gofrs/flock v0.7.1
10-
github.com/golang/protobuf v1.4.1
11-
github.com/google/go-cmp v0.5.0
6+
github.com/WICG/webpackage v0.0.0-20210623222345-39b429db6dac
7+
github.com/ampproject/amphtml v0.0.0-20210802160724-a648a87e5643
8+
github.com/go-acme/lego/v4 v4.4.0
9+
github.com/gofrs/flock v0.8.1
10+
github.com/golang/protobuf v1.5.2
11+
github.com/google/go-cmp v0.5.6
1212
github.com/kylelemons/godebug v1.1.0
13-
github.com/pelletier/go-toml v1.1.0
14-
github.com/pkg/errors v0.8.1
15-
github.com/pquerna/cachecontrol v0.0.0-20180306154005-525d0eb5f91d
16-
github.com/prometheus/client_golang v1.1.0
17-
github.com/stretchr/testify v1.4.0
13+
github.com/pelletier/go-toml v1.9.3
14+
github.com/pkg/errors v0.9.1
15+
github.com/pquerna/cachecontrol v0.1.0
16+
github.com/prometheus/client_golang v1.11.0
17+
github.com/prometheus/common v0.30.0
18+
github.com/stretchr/testify v1.7.0
1819
github.com/twifkak/crypto v0.0.0-20210326012946-1fce8924335d
19-
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
20-
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
21-
google.golang.org/grpc v1.27.0
22-
google.golang.org/protobuf v1.25.0
23-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
24-
gopkg.in/square/go-jose.v2 v2.3.1
20+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
21+
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985
22+
google.golang.org/grpc v1.39.0
23+
gopkg.in/square/go-jose.v2 v2.6.0
2524
)
26-
27-
replace github.com/davecgh/go-spew => github.com/davecgh/go-spew v1.1.0
28-
29-
replace github.com/stretchr/testify => github.com/stretchr/testify v1.2.1
30-
31-
replace golang.org/x/crypto => golang.org/x/crypto v0.0.0-20180820150726-614d502a4dac
32-
33-
replace golang.org/x/net => golang.org/x/net v0.0.0-20180808004115-f9ce57c11b24
34-
35-
replace golang.org/x/text => golang.org/x/text v0.3.0

0 commit comments

Comments
 (0)