Skip to content

Commit 0c409c7

Browse files
authored
Update docs for assert-artifact (#561)
1 parent f5ac071 commit 0c409c7

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

cmd/kosli/assertArtifact.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,29 @@ import (
1212
"github.com/spf13/cobra"
1313
)
1414

15-
const assertArtifactShortDesc = `Assert the compliance status of an artifact in Kosli ` +
16-
`(in its flow, against an environment or against one or more policies). `
15+
const assertArtifactShortDesc = `Assert the compliance status of an artifact in Kosli. ` +
16+
`
17+
There are four (mutually exclusive) ways to use ^kosli assert artifact^:
18+
19+
1. Against an environment. When ^--environment^ is specified,
20+
asserts against all policies currently attached to the given environment.
21+
2. Against one or more policies. When ^--policy^ is specified,
22+
asserts against all the given policies.
23+
3. Against a flow. When ^--flow^ is specified, asserts against the
24+
current template file of the given flow.
25+
4. Against many flows. When none of ^--environment^, ^--policy^, or ^--flow^
26+
are specified, asserts against the template files of *all* flows the artifact
27+
is found in (by fingerprint).
28+
`
1729

1830
const assertArtifactLongDesc = assertArtifactShortDesc + `
19-
Exits with non-zero code if the artifact has a non-compliant status.`
31+
Exits with zero code if the artifact has compliant status,
32+
non-zero code if non-compliant status.`
2033

2134
const assertArtifactExample = `
2235
# assert that an artifact meets all compliance requirements for an environment
2336
kosli assert artifact \
2437
--fingerprint 184c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0 \
25-
--flow yourFlowName \
2638
--environment prod \
2739
--api-token yourAPIToken \
2840
--org yourOrgName
@@ -34,17 +46,18 @@ kosli assert artifact \
3446
--api-token yourAPIToken \
3547
--org yourOrgName
3648
37-
# fail if an artifact has a non-compliant status (using the artifact fingerprint)
49+
# fail if an artifact has a non-compliant status in a single flow (using the artifact fingerprint)
50+
export KOSLI_FLOW=yourFlowName
3851
kosli assert artifact \
3952
--fingerprint 184c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0 \
4053
--flow yourFlowName \
4154
--api-token yourAPIToken \
4255
--org yourOrgName
4356
44-
# fail if an artifact has a non-compliant status (using the artifact name and type)
57+
# fail if an artifact has a non-compliant status in any flow (using the artifact name and type)
58+
unset KOSLI_FLOW
4559
kosli assert artifact library/nginx:1.21 \
4660
--artifact-type docker \
47-
--flow yourFlowName \
4861
--api-token yourAPIToken \
4962
--org yourOrgName
5063
`

0 commit comments

Comments
 (0)