-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
116 lines (95 loc) · 3.77 KB
/
justfile
File metadata and controls
116 lines (95 loc) · 3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Load environment variables from .env file if it exists
set dotenv-load := true
# Setup environment file from example
setup-env:
#!/usr/bin/env bash
set -euo pipefail
if [ -f "./.env" ]; then
echo "Environment file ./.env already exists."
echo "Remove it first if you want to recreate it from the example."
exit 1
fi
echo "Creating ./.env from example..."
cp ./.env.example ./.env
echo "Environment file created at ./.env"
echo "Please edit this file and add your actual API key and configuration."
# Build the upload-file binary locally
build-upload-file:
#!/usr/bin/env bash
set -euo pipefail
echo "--- :: Building upload-file binary"
cd upload-file
go build -o upload-file .
echo "Binary built: ./upload-file/upload-file"
# Test upload-file binary locally (requires .env file)
test-upload-file-local:
#!/usr/bin/env bash
set -euo pipefail
# Check if .env file exists
if [ ! -f "./.env" ]; then
echo "Error: ./.env file not found!"
echo "Please copy ./.env.example to ./.env and configure your values."
exit 1
fi
# Load environment variables
echo "--- :: Loading environment variables from ./.env"
set -a
source ./.env
set +a
# Build the binary first
just build-upload-file
echo "--- :: Creating test file"
echo '{"test": "data", "timestamp": "'$(date -Iseconds)'"}' > test-file.json
echo "--- :: Testing upload-file binary locally"
cd upload-file
INPUT_FILE_PATH="../test-file.json" \
INPUT_DESTINATION="${INPUT_DESTINATION:-temp-data/local-test-$(date +%s).json}" \
INPUT_SECURITY_AGENT_API_ENDPOINT="${INPUT_SECURITY_AGENT_API_ENDPOINT}" \
INPUT_SECURITY_AGENT_API_KEY="${INPUT_SECURITY_AGENT_API_KEY}" \
./upload-file
echo "--- :: Cleaning up test file"
rm -f ../test-file.json
echo "Local upload test completed successfully!"
# Test the upload-file Docker image
test-upload-file-docker:
#!/usr/bin/env bash
set -euo pipefail
# Load environment variables from .env file if it exists
if [ -f "./.env" ]; then
echo "--- :: Loading environment variables from ./.env"
set -a
source ./.env
set +a
else
echo "Warning: ./.env not found. Using default values."
echo "Copy ./.env.example to ./.env and configure your values."
fi
echo "--- :: Building upload-file Docker image"
docker build -t upload-file-test ./upload-file
echo "--- :: Creating test file"
echo '{"test": "data", "timestamp": "'$(date -Iseconds)'", "message": "Docker test file"}' > test-file.json
echo "--- :: Testing upload-file Docker image"
docker run --rm \
-v "$(pwd)/test-file.json:/test-file.json:ro" \
-e INPUT_FILE_PATH="/test-file.json" \
-e INPUT_DESTINATION="${INPUT_DESTINATION:-temp-data/test-$(date +%s).json}" \
-e INPUT_SECURITY_AGENT_API_ENDPOINT="${INPUT_SECURITY_AGENT_API_ENDPOINT}" \
-e INPUT_SECURITY_AGENT_API_KEY="${INPUT_SECURITY_AGENT_API_KEY}" \
--network host \
upload-file-test
echo "--- :: Cleaning up test file"
rm -f test-file.json
echo "Upload-file Docker test completed successfully!"
# Show available recipes
help:
@echo "security-agent-tools:"
@echo " Tools for working with the PromptQL Security Agent."
@echo " All tools are packaged as Docker image and GitHub Action."
@echo ""
@echo "Common commands:"
@echo " setup-env - Create .env file from example"
@echo ""
@echo "upload-file:"
@echo " build-upload-file - Build the upload-file binary locally"
@echo " test-upload-file-local - Test binary locally (requires .env)"
@echo " test-upload-file-docker - Test with Docker (uses .env if available)"