Skip to content

Commit 8e65af4

Browse files
Fix download signatures
Signed-off-by: Lukasz Gryglicki <[email protected]>
1 parent 7de5b91 commit 8e65af4

File tree

5 files changed

+101
-6
lines changed

5 files changed

+101
-6
lines changed

cla-backend-go/cmd/zipbuilder_lambda/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ func main() {
102102
log.Info("Lambda server starting...")
103103
printBuildInfo()
104104
if os.Getenv("LOCAL_MODE") == "true" {
105-
if len(os.Args) != 3 {
106-
log.Fatal("invalid number of args. first arg should be icla or ccla and 2nd arg should be cla_group_id")
105+
if len(os.Args) != 4 {
106+
log.Fatal("invalid number of args. first arg should be icla or ccla, 2nd should be pdf or csv and 3rd arg should be cla_group_id")
107107
}
108-
err := handler(utils.NewContext(), BuildZipEvent{SignatureType: os.Args[1], ClaGroupID: os.Args[2]})
108+
err := handler(utils.NewContext(), BuildZipEvent{SignatureType: os.Args[1], FileType: os.Args[2], ClaGroupID: os.Args[3]})
109109
if err != nil {
110110
log.Fatal(err)
111111
}

cla-backend-go/cmd/zipbuilder_scheduler_lambda/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ func handler(ctx context.Context, event events.CloudWatchEvent) {
114114

115115
func invokeLambda(wg *sync.WaitGroup, lambdaClient *lambda.Lambda, stage string, buildZipEvent BuildZipEvent) {
116116
defer wg.Done()
117-
log.WithField("buildZipEvent", buildZipEvent).Debug("invoking zipbuilder-lambda")
117+
log.WithField("buildZipEvent", buildZipEvent).Debug("invoking zip-builder-lambda")
118118
payload, err := json.Marshal(buildZipEvent)
119119
if err != nil {
120120
log.Error("Error marshalling BuildZip request", err)
121121
return
122122
}
123-
functionName := fmt.Sprintf("cla-backend-%s-zipbuilder-lambda", stage)
123+
functionName := fmt.Sprintf("cla-backend-%s-zip-builder-lambda", stage)
124124

125125
_, err = lambdaClient.Invoke(&lambda.InvokeInput{FunctionName: aws.String(functionName), Payload: payload})
126126
if err != nil {

cla-backend-go/v2/signatures/zip_builder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,11 @@ type DownloadFileInput struct {
186186

187187
func writeFileToZip(writer *zip.Writer, filesInput chan *FileContent) bool {
188188
var zipUpdated bool
189+
log.Infof("writing files")
189190
for fileContent := range filesInput {
190191
filename := fileContent.filename
191192
buff := fileContent.buff
192-
log.Debugf("Adding file : %s to zip", filename)
193+
log.Infof("Adding file: %s to zip", filename)
193194
header := &zip.FileHeader{
194195
Name: filename,
195196
Method: zip.Deflate,

utils/signatures_ccla_pdfs.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
3+
# company_sfid='0016s000006Uq9VAAS'
4+
# TOKEN='...' - Auth0 JWT bearer token
5+
# XACL='...' - X-ACL
6+
# DEBUG=1 XACL="$(cat ./x-acl.secret)" TOKEN="$(cat ./auth0.token.secret)" ./utils/signatures_ccla_pdfs.sh 01af041c-fa69-4052-a23c-fb8c1d3bef24
7+
8+
if [ -z "$TOKEN" ]
9+
then
10+
# source ./auth0_token.secret
11+
TOKEN="$(cat ./auth0.token.secret)"
12+
fi
13+
14+
if [ -z "$TOKEN" ]
15+
then
16+
echo "$0: TOKEN not specified and unable to obtain one"
17+
exit 1
18+
fi
19+
20+
if [ -z "$XACL" ]
21+
then
22+
XACL="$(cat ./x-acl.secret)"
23+
fi
24+
25+
if [ -z "$XACL" ]
26+
then
27+
echo "$0: XACL not specified and unable to obtain one"
28+
exit 2
29+
fi
30+
31+
if [ -z "$API_URL" ]
32+
then
33+
export API_URL="http://localhost:5000"
34+
fi
35+
36+
if [ -z "$1" ]
37+
then
38+
echo "$0: you need to specify company_sfid as a 1st parameter"
39+
exit 1
40+
fi
41+
export cla_group_id="$1"
42+
43+
if [ ! -z "$DEBUG" ]
44+
then
45+
echo "curl -s -XPOST -H 'X-ACL: ${XACL}' -H 'Authorization: Bearer ${TOKEN}' -H 'Content-Type: application/json' '${API_URL}/v4/signatures/project/${cla_group_id}/ccla/pdfs' | jq -r '.'"
46+
fi
47+
curl -s -XGET -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" "${API_URL}/v4/signatures/project/${cla_group_id}/ccla/pdfs" | jq -r '.'

utils/signatures_icla_pdfs.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# API_URL=https://[xyz].ngrok-free.app (defaults to localhost:5000)
3+
# company_sfid='0016s000006Uq9VAAS'
4+
# TOKEN='...' - Auth0 JWT bearer token
5+
# XACL='...' - X-ACL
6+
# DEBUG=1 XACL="$(cat ./x-acl.secret)" TOKEN="$(cat ./auth0.token.secret)" ./utils/signatures_icla_pdfs.sh 01af041c-fa69-4052-a23c-fb8c1d3bef24
7+
8+
if [ -z "$TOKEN" ]
9+
then
10+
# source ./auth0_token.secret
11+
TOKEN="$(cat ./auth0.token.secret)"
12+
fi
13+
14+
if [ -z "$TOKEN" ]
15+
then
16+
echo "$0: TOKEN not specified and unable to obtain one"
17+
exit 1
18+
fi
19+
20+
if [ -z "$XACL" ]
21+
then
22+
XACL="$(cat ./x-acl.secret)"
23+
fi
24+
25+
if [ -z "$XACL" ]
26+
then
27+
echo "$0: XACL not specified and unable to obtain one"
28+
exit 2
29+
fi
30+
31+
if [ -z "$API_URL" ]
32+
then
33+
export API_URL="http://localhost:5000"
34+
fi
35+
36+
if [ -z "$1" ]
37+
then
38+
echo "$0: you need to specify company_sfid as a 1st parameter"
39+
exit 1
40+
fi
41+
export cla_group_id="$1"
42+
43+
if [ ! -z "$DEBUG" ]
44+
then
45+
echo "curl -s -XPOST -H 'X-ACL: ${XACL}' -H 'Authorization: Bearer ${TOKEN}' -H 'Content-Type: application/json' '${API_URL}/v4/signatures/project/${cla_group_id}/icla/pdfs' | jq -r '.'"
46+
fi
47+
curl -s -XGET -H "X-ACL: ${XACL}" -H "Authorization: Bearer ${TOKEN}" -H "Content-Type: application/json" "${API_URL}/v4/signatures/project/${cla_group_id}/icla/pdfs" | jq -r '.'

0 commit comments

Comments
 (0)