|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | 3 |
|
4 | | -STACKROX_REPO="" |
5 | | - |
6 | | -if [ -d "../stackrox" ]; then |
7 | | - STACKROX_REPO="../stackrox" |
8 | | -elif [ -d "../../stackrox" ]; then |
9 | | - STACKROX_REPO="../../stackrox" |
10 | | -elif [ -n "$STACKROX_REPO_PATH" ]; then |
11 | | - STACKROX_REPO="$STACKROX_REPO_PATH" |
12 | | -fi |
| 4 | +echo "Setting up proto files from go modules..." |
| 5 | + |
| 6 | +# Ensure go modules are downloaded |
| 7 | +go mod download |
13 | 8 |
|
14 | | -if [ -z "$STACKROX_REPO" ] || [ ! -d "$STACKROX_REPO" ]; then |
15 | | - echo "Error: StackRox repository not found" |
16 | | - echo "Set STACKROX_REPO_PATH or clone to ../stackrox" |
| 9 | +# Discover rox module location using go list |
| 10 | +ROX_DIR=$(go list -f '{{.Dir}}' -m github.com/stackrox/rox) |
| 11 | + |
| 12 | +if [ -z "$ROX_DIR" ]; then |
| 13 | + echo "Error: github.com/stackrox/rox module not found" |
| 14 | + echo "Run: go mod download" |
17 | 15 | exit 1 |
18 | 16 | fi |
19 | 17 |
|
20 | | -echo "Copying proto files from $STACKROX_REPO..." |
| 18 | +echo "Using proto files from: $ROX_DIR" |
21 | 19 |
|
| 20 | +# Create target directories |
22 | 21 | mkdir -p wiremock/proto/stackrox wiremock/proto/googleapis |
23 | 22 |
|
24 | | -cp -r "$STACKROX_REPO/proto/"* wiremock/proto/stackrox/ |
25 | | -cp -r "$STACKROX_REPO/third_party/googleapis/"* wiremock/proto/googleapis/ |
| 23 | +# Copy proto files from rox module |
| 24 | +# Note: Files from go mod cache are read-only, so we copy and chmod |
| 25 | +cp -r "$ROX_DIR/proto/"* wiremock/proto/stackrox/ |
| 26 | +cp -r "$ROX_DIR/third_party/googleapis/"* wiremock/proto/googleapis/ |
26 | 27 |
|
27 | | -mkdir -p wiremock/proto/stackrox/scanner/api/v1 |
28 | | -if [ -d "$STACKROX_REPO/qa-tests-backend/src/main/proto/scanner/api/v1" ]; then |
29 | | - cp "$STACKROX_REPO/qa-tests-backend/src/main/proto/scanner/api/v1/"*.proto wiremock/proto/stackrox/scanner/api/v1/ |
| 28 | +# Copy scanner protos from scanner module (following stackrox pattern) |
| 29 | +SCANNER_DIR=$(go list -f '{{.Dir}}' -m github.com/stackrox/scanner) |
| 30 | +if [ -n "$SCANNER_DIR" ] && [ -d "$SCANNER_DIR/proto/scanner" ]; then |
| 31 | + echo "Using scanner proto files from: $SCANNER_DIR" |
| 32 | + cp -r "$SCANNER_DIR/proto/scanner" wiremock/proto/stackrox/ |
30 | 33 | fi |
31 | 34 |
|
32 | | -echo "✓ Proto files copied" |
| 35 | +# Make files writable (go mod cache files are read-only) |
| 36 | +chmod -R u+w wiremock/proto/ |
| 37 | + |
| 38 | +echo "✓ Proto files copied from go mod cache" |
33 | 39 | echo "Next: ./scripts/generate-proto-descriptors.sh" |
0 commit comments