mirror of
https://github.com/docker/docs.git
synced 2026-11-04 10:01:00 +00:00
## Summary
The CloudFront redirect Lambda (`cloudfront-lambda-redirects.js`)
dropped the request query string when issuing 301 responses, so UTM tags
and other params were lost on redirected URLs. This appends the query
string to the `Location` header of both the exact-match and prefix
redirects (the directory/markdown rewrite branch already forwards the
request, so params survive there).
Adds unit tests (`node --test`, zero dependencies) that render the Go
template the same way `aws.go` does and exercise the handler. The tests
run in CI via a new `releaser-test` Dockerfile stage / bake target,
baked alongside `releaser-build` in the existing `releaser` job.
## Learnings
- The redirect Lambda source is a Go `text/template`
(`{{.RedirectsJSON}}` / `{{.RedirectsPrefixesJSON}}`), rendered and
zipped by `hack/releaser/aws.go`. To unit-test it, substitute the
placeholders the same way `aws.go` does, then evaluate the result as a
CommonJS module.
- `test-go-redirects` validates redirect *data* against the built
`public/` site, so it's the wrong host for a fast pure-JS test — the
`releaser` job, which already builds from `hack/releaser`, is the
natural home and has no Hugo dependency.
Generated by Claude Code
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
192 lines
3.3 KiB
HCL
192 lines
3.3 KiB
HCL
variable "HUGO_ENV" {
|
|
default = null
|
|
}
|
|
|
|
variable "DOCS_URL" {
|
|
default = null
|
|
}
|
|
|
|
variable "DOCS_SITE_DIR" {
|
|
default = "public"
|
|
}
|
|
|
|
variable "DRY_RUN" {
|
|
default = null
|
|
}
|
|
|
|
variable "GITHUB_ACTIONS" {
|
|
default = null
|
|
}
|
|
|
|
group "default" {
|
|
targets = ["release"]
|
|
}
|
|
|
|
target "index" {
|
|
# generate a new local search index
|
|
target = "index"
|
|
output = ["type=local,dest=static/pagefind"]
|
|
provenance = false
|
|
}
|
|
|
|
target "release" {
|
|
args = {
|
|
HUGO_ENV = HUGO_ENV
|
|
DOCS_URL = DOCS_URL
|
|
}
|
|
target = "release"
|
|
output = [DOCS_SITE_DIR]
|
|
provenance = false
|
|
}
|
|
|
|
group "validate" {
|
|
targets = ["lint", "test", "unused-media", "test-go-redirects", "dockerfile-lint", "validate-vendor"]
|
|
}
|
|
|
|
target "test" {
|
|
target = "test"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|
|
|
|
target "lint" {
|
|
target = "lint"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|
|
|
|
target "vale" {
|
|
target = "vale"
|
|
args = {
|
|
GITHUB_ACTIONS = GITHUB_ACTIONS
|
|
}
|
|
output = ["./tmp"]
|
|
provenance = false
|
|
}
|
|
|
|
target "unused-media" {
|
|
target = "unused-media"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|
|
|
|
target "test-go-redirects" {
|
|
target = "test-go-redirects"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|
|
|
|
target "releaser-test" {
|
|
context = "hack/releaser"
|
|
target = "releaser-test"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|
|
|
|
target "dockerfile-lint" {
|
|
call = "check"
|
|
}
|
|
|
|
#
|
|
# releaser targets are defined in hack/releaser/Dockerfile
|
|
# and are used for AWS S3 deployment
|
|
#
|
|
|
|
target "releaser-build" {
|
|
context = "hack/releaser"
|
|
target = "releaser"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|
|
|
|
variable "AWS_REGION" {
|
|
default = ""
|
|
}
|
|
variable "AWS_S3_BUCKET" {
|
|
default = ""
|
|
}
|
|
variable "AWS_S3_CONFIG" {
|
|
default = ""
|
|
}
|
|
variable "AWS_CLOUDFRONT_ID" {
|
|
default = ""
|
|
}
|
|
variable "AWS_LAMBDA_FUNCTION" {
|
|
default = ""
|
|
}
|
|
|
|
target "_common-aws" {
|
|
args = {
|
|
DRY_RUN = DRY_RUN
|
|
AWS_REGION = AWS_REGION
|
|
AWS_S3_BUCKET = AWS_S3_BUCKET
|
|
AWS_S3_CONFIG = AWS_S3_CONFIG
|
|
AWS_CLOUDFRONT_ID = AWS_CLOUDFRONT_ID
|
|
AWS_LAMBDA_FUNCTION = AWS_LAMBDA_FUNCTION
|
|
}
|
|
secret = [
|
|
"id=AWS_ACCESS_KEY_ID,env=AWS_ACCESS_KEY_ID",
|
|
"id=AWS_SECRET_ACCESS_KEY,env=AWS_SECRET_ACCESS_KEY",
|
|
"id=AWS_SESSION_TOKEN,env=AWS_SESSION_TOKEN"
|
|
]
|
|
provenance = false
|
|
}
|
|
|
|
target "aws-lambda-invoke" {
|
|
inherits = ["_common-aws"]
|
|
context = "hack/releaser"
|
|
target = "aws-lambda-invoke"
|
|
no-cache-filter = ["aws-lambda-invoke"]
|
|
output = ["type=cacheonly"]
|
|
}
|
|
|
|
target "aws-cloudfront-update" {
|
|
inherits = ["_common-aws"]
|
|
context = "hack/releaser"
|
|
target = "aws-cloudfront-update"
|
|
contexts = {
|
|
sitedir = DOCS_SITE_DIR
|
|
}
|
|
no-cache-filter = ["aws-cloudfront-update"]
|
|
output = ["type=cacheonly"]
|
|
}
|
|
|
|
variable "VENDOR_MODULE" {
|
|
default = null
|
|
}
|
|
|
|
target "vendor" {
|
|
target = "vendor"
|
|
args = {
|
|
MODULE = VENDOR_MODULE
|
|
}
|
|
output = ["."]
|
|
provenance = false
|
|
}
|
|
|
|
target "validate-vendor" {
|
|
target = "validate-vendor"
|
|
output = ["type=cacheonly"]
|
|
}
|
|
|
|
variable "UPSTREAM_MODULE_NAME" {
|
|
default = null
|
|
}
|
|
variable "UPSTREAM_REPO" {
|
|
default = null
|
|
}
|
|
variable "UPSTREAM_COMMIT" {
|
|
default = null
|
|
}
|
|
|
|
target "validate-upstream" {
|
|
args {
|
|
UPSTREAM_MODULE_NAME = UPSTREAM_MODULE_NAME
|
|
UPSTREAM_REPO = UPSTREAM_REPO
|
|
UPSTREAM_COMMIT = UPSTREAM_COMMIT
|
|
}
|
|
target = "validate-upstream"
|
|
output = ["type=cacheonly"]
|
|
provenance = false
|
|
}
|