Generate data.json
that OPA uses to evaluate API Keys.
go run generate/keys.go
This stores the file in ./bundle/apikeys/data.json
Proceed to recreate the optimized OPA bundle.
bundle/bundle.sh
Next, we will validate OPA in two ways:
- Consume the Bundle locally
- Poll a WebServer that hosts the Bundle
Run the program:
go run localdata/local.go
Output:
Loading API Keys into memory...
API Keys loaded into memory.
Allowed count: 50
Rejected count: 50
2023/03/06 14:27:17 Avg evaluation took: 12ms
In a second terminal switch to the bundle
directory and run the following command:
cd bundle
python3 -m http.server 8981
In the first terminal, from the root of the repo run the following command:
go run polldata/poll.go