-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better automation for /sample-policies #23
Comments
Options for "getting OPA onto the machine": download & make executable (per platform) or maybe use the docker image? |
I am all for using jq https://stedolan.github.io/jq/download/ to do the capabilities files modifications (requiring it to be installed beforehand). Because we are going to use it with Unit Tests, the generated capabilities file must have a defined name. And the capabilities files from OPA change the file names per version. How about a command line along those lines (pun intended): concatcap.ps1 capabilities.json -merge v0.34.json -merge unittest1.json -merge sdkfuncs.json @iinuwa your take? |
Unless we use a temp file, right?
In this case, is (Can you specify an arg multiple times in PS? I thought it would have to be a comma-separated array. Away from computer now, so I can't test.) Also, since this is theoretically a tool that users could also use for generating their own capabilities files, it might be good to decide whether we are going to allow builtins to be defined multiple times? If so, we need to set some sort of precedence. I think "last-specified wins" is a natural rule. |
My command line sample might not be proper PS syntax; also, I am mostly only concerned to solve the unit test use case here, not creating a "general purpose one-size fits all tool". |
Oh, ok. Here's what I plan to use for myself; feel free to adapt it as you need: https://gist.github.com/iinuwa/af7f2f038ae817e640e2569e256c3268#file-mergecapabilities-ps1 (Examples are included in the script and can be viewed with |
I tried to make it work slightly dumbed-down on Windows:
I had to put everything on one line otherwise it complained. However
This is the $output line. For testing, my simple-custom-builtincall.capabilities.json looked like
'cause I know way too little about jq, could it be the allow_net thingy? |
Seems so because |
ok, at least I can diff it now - one thing does change, it doesn't merge the following:
|
Yeah, you got it; in order for it to merge, the keys must be present on all merging documents.
Oh, I hadn't noticed those keys before, but they can be merged using the same process as the |
Yes, I played around with diffs to figure out what I need and then it merged nicely. |
Maybe https://www.thorsten-hans.com/distribute-webassembly-modules-as-oci-artifacts/ is a viable option (store to ACR) |
Are you aware that GitHub Actions can cache the output of a job? I've never used it, but if the wasm files were all stored in a separate directory (e.g. build/sample-policies/), something like this seems like it would work: jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Cache OPA policy builds
id: cache-policy-builds
uses: actions/cache@v1
with:
path: build/sample-policies/
key: opa-policy-cache-${{ hashFiles('sample-policies/*.rego') }}
- name: Build OPA policies
run: pwsh ./sample-policies/build.ps1
if: steps.cache-packages.outputs.cache-hit != 'true' This should only run the the OPA build if one of the rego files changes. |
Currently
Ideally, I want this to be
with the following properties:
The text was updated successfully, but these errors were encountered: