Skip to content

Commit 43763b1

Browse files
authored
Merge pull request #21352 from docker/published-update
publish updates from main
2 parents a9d3b98 + 00b5254 commit 43763b1

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

_releaser/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ARG GO_VERSION=1.19
55
FROM scratch AS sitedir
66

77
FROM golang:${GO_VERSION}-alpine AS base
8-
RUN apk add --no-cache openssl
8+
RUN apk add --no-cache jq openssl
99
ENV CGO_ENABLED=0
1010
WORKDIR /src
1111
COPY go.mod go.sum ./
@@ -49,6 +49,6 @@ RUN --mount=type=bind,target=. \
4949
--mount=type=secret,id=AWS_SECRET_ACCESS_KEY \
5050
--mount=type=secret,id=AWS_SESSION_TOKEN \
5151
AWS_LAMBDA_FUNCTION_FILE=cloudfront-lambda-redirects.js \
52-
REDIRECTS_FILE="/site/redirects.json" \
53-
REDIRECTS_PREFIXES_FILE="redirects-prefixes.json" \
52+
REDIRECTS_JSON=$(jq -c '.' /site/redirects.json) \
53+
REDIRECTS_PREFIXES_JSON=$(jq -c '.' redirects-prefixes.json) \
5454
releaser aws cloudfront-update

_releaser/aws.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,17 @@ func (s *AwsLambdaInvokeCmd) Run() error {
9898
type AwsCloudfrontUpdateCmd struct {
9999
Region string `kong:"name='region',env='AWS_REGION'"`
100100
Function string `kong:"name='lambda-function',env='AWS_LAMBDA_FUNCTION'"`
101-
FunctionFile string `kong:"name='lambda-function-file',env='AWS_LAMBDA_FUNCTION_FILE',type=filecontent"`
101+
FunctionFile string `kong:"name='lambda-function-file',env='AWS_LAMBDA_FUNCTION_FILE'"`
102102
CloudfrontID string `kong:"name='cloudfront-id',env='AWS_CLOUDFRONT_ID'"`
103-
RedirectsFile string `kong:"name='redirects-file',env='REDIRECTS_FILE',type=filecontent"`
104-
RedirectsPrefixesFile string `kong:"name='redirects-prefixes-file',env='REDIRECTS_PREFIXES_FILE',type=filecontent"`
103+
RedirectsJSON string `kong:"name='redirects-json',env='REDIRECTS_JSON'"`
104+
RedirectsPrefixesJSON string `kong:"name='redirects-prefixes-json',env='REDIRECTS_PREFIXES_JSON'"`
105105
}
106106

107107
func (s *AwsCloudfrontUpdateCmd) Run() error {
108108
var err error
109109
ver := time.Now().UTC().Format(time.RFC3339)
110110

111-
zipdt, err := getLambdaFunctionZip(s.FunctionFile, s.RedirectsFile, s.RedirectsPrefixesFile)
111+
zipdt, err := getLambdaFunctionZip(s.FunctionFile, s.RedirectsJSON, s.RedirectsPrefixesJSON)
112112
if err != nil {
113113
return fmt.Errorf("cannot create lambda function zip: %w", err)
114114
}
@@ -228,15 +228,20 @@ func (s *AwsCloudfrontUpdateCmd) Run() error {
228228
return nil
229229
}
230230

231-
func getLambdaFunctionZip(funcdt, redirects, redirectsPrefixes string) ([]byte, error) {
231+
func getLambdaFunctionZip(funcFilename string, redirectsJSON string, redirectsPrefixesJSON string) ([]byte, error) {
232+
funcdt, err := os.ReadFile(funcFilename)
233+
if err != nil {
234+
return nil, fmt.Errorf("failed to read lambda function file %q: %w", funcFilename, err)
235+
}
236+
232237
var funcbuf bytes.Buffer
233-
functpl := template.Must(template.New("").Parse(funcdt))
234-
if err := functpl.Execute(&funcbuf, struct {
238+
functpl := template.Must(template.New("").Parse(string(funcdt)))
239+
if err = functpl.Execute(&funcbuf, struct {
235240
RedirectsJSON string
236241
RedirectsPrefixesJSON string
237242
}{
238-
redirects,
239-
redirectsPrefixes,
243+
redirectsJSON,
244+
redirectsPrefixesJSON,
240245
}); err != nil {
241246
return nil, err
242247
}

layouts/index.redirects.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
{{- $redirects.SetInMap "paths" . $target -}}
1313
{{- end -}}
1414
{{- end -}}
15-
{{- $opts := dict "noHTMLEscape" true }}
16-
{{- $redirects.Get "paths" | jsonify $opts }}
15+
{{ $redirects.Get "paths" | jsonify }}

0 commit comments

Comments
 (0)