Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
cli: styra/cli@0.0.7
Use cli
elements in your existing workflows and jobs.
Opt-in to use of uncertified orbs on your organization’s Security settings page.
1
2
3
4
5
6
7
8
version: 2.1
orbs:
styra-orb: styra/cli
workflows:
version: 2.1
check-workflow:
jobs:
- styra-orb/styra-policy-check
Configures and runs the Styra cli
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
api_token | Styra API Token for your styra account | Yes | - | env_var_name |
tenant | Styra name of your styra account (e.g. test.styra.com) | Yes | - | env_var_name |
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
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: >
This orb is a wrapper for the Styra cli tool. The tool allows to run policy checks on your kubernetes configuration files (yaml).
To use this orb, you must have a Styra account, if you do not have one already, visit https://styra.com.
For detailed usage information, see https://github.com/styrainc/styra-cli-orb
examples:
check-system-policies:
usage:
version: 2.1
orbs:
styra-orb: styra/cli
workflows:
version: 2.1
check-workflow:
jobs:
- styra-orb/styra-policy-check
executors:
cli:
docker:
- image: styra/cli
commands:
policy-check:
description: Configures and runs the Styra cli
parameters:
api_token:
description: Styra API Token for your styra account
type: env_var_name
tenant:
description: Styra name of your styra account (e.g. test.styra.com)
type: env_var_name
steps:
- run: styra-cli configure -i ${<< parameters.tenant >>} -t ${<< parameters.api_token >>}
- run: |
mkdir test
styra-cli validate check-local -r . -o test/results.json
- run:
when: on_fail
command: cat test/results.json
- store_test_results:
path: test
- store_artifacts:
path: test
jobs:
styra-policy-check:
executor: cli
steps:
- checkout # check out the code in the project directory
- policy-check: # run the policy check cmd
api_token : STYRA_TOKEN
tenant: STYRA_TENANT