File tree 4 files changed +49
-2
lines changed
4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 72
72
if : success() || failure() # always run even if the previous step fails
73
73
with :
74
74
report_paths : ' **/target/surefire-reports/TEST-*.xml'
75
+
76
+ readme-ci :
77
+ runs-on : ubuntu-latest
78
+ name : CI - Readme
79
+ steps :
80
+ - name : checkout
81
+ uses : actions/checkout@v4
82
+ - name : Set up Java
83
+ uses : actions/setup-java@v4
84
+ with :
85
+ distribution : ' temurin'
86
+ java-version : ' 17'
87
+ cache : maven
88
+ - name : Build Opa Java Wasm
89
+ run : mvn clean install -DskipTests
90
+ env :
91
+ MAVEN_OPTS : " -Dmaven.repo.local=${{ github.workspace }}/repository"
92
+ # Test root Readme
93
+ - name : jbang
94
+ uses : jbangdev/jbang-action@9f8c55e0a2b6b297711162b20c209c5e07076e59 # tag=v0.117.1
95
+ with :
96
+ script : Readme.md
97
+ env :
98
+ JBANG_REPO : " ${{ github.workspace }}/repository"
99
+ - name : compare results
100
+ run : diff -r Readme.result TestReadme.result
Original file line number Diff line number Diff line change 1
1
target
2
2
.idea
3
3
testcases.tar.gz
4
+ policy.wasm
5
+ TestReadme.result
Original file line number Diff line number Diff line change @@ -29,14 +29,26 @@ With Maven add the core module dependency:
29
29
</dependency >
30
30
```
31
31
32
+ <!--
33
+ ```java
34
+ //DEPS com.styra.opa:opa-java-wasm:999-SNAPSHOT
35
+
36
+ var policyPath = Path.of("core/src/main/resources/demo-policy.wasm");
37
+ var targetPath = Path.of("policy.wasm");
38
+ Files.copy(policyPath, targetPath, StandardCopyOption.REPLACE_EXISTING);
39
+
40
+ var policyWasm = new File("policy.wasm");
41
+ ```
42
+ -->
43
+
32
44
## Usage
33
45
34
46
There are only a couple of steps required to start evaluating the policy.
35
47
36
48
### Import the module
37
49
38
50
``` java
39
- import com.styra.opa.wasm.Opa ;
51
+ import com.styra.opa.wasm.OpaPolicy ;
40
52
```
41
53
42
54
### Load the policy
@@ -71,13 +83,19 @@ APIs for policy evaluation:
71
83
Example:
72
84
73
85
``` java
74
- input = ' { "path": "/ ", "role": "admin"} ' ;
86
+ var input = " { \ " path\ " : \" / \ " , \ " role\ " : \ " admin\" } " ;
75
87
76
88
var policy = OpaPolicy . builder(). withPolicy(policyWasm). build();
77
89
var result = policy. evaluate(input);
78
90
System . out. println(" Result is: " + result);
79
91
```
80
92
93
+ <!--
94
+ ```java
95
+ Files.write(Paths.get("TestReadme.result"), (result + "\n").getBytes());
96
+ ```
97
+ -->
98
+
81
99
> For any ` opa build ` created WASM binaries the result set, when defined, will
82
100
> contain a ` result ` key with the value of the compiled entrypoint. See
83
101
> [ https://www.openpolicyagent.org/docs/latest/wasm/ ] ( https://www.openpolicyagent.org/docs/latest/wasm/ )
Original file line number Diff line number Diff line change
1
+ [{"result":false}]
You can’t perform that action at this time.
0 commit comments