MCPcopy Create free account
hub / github.com/conforma/cli / fetchPolicyCmd

Function fetchPolicyCmd

cmd/fetch/fetch_policy.go:30–138  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28)
29
30func fetchPolicyCmd() *cobra.Command {
31 var (
32 sourceUrls []string
33 dataSourceUrls []string
34 destDir string
35 useWorkDir bool
36 )
37
38 cmd := &cobra.Command{
39 Use: "policy --source <source-url> --data-source <source-url>",
40 Short: "Fetch policy rules from a git repository or other source",
41
42 Long: hd.Doc(`
43 Fetch policy rules (rego files) from a git repository or other source.
44
45 Each policy source will be downloaded into a separate unique directory inside
46 the "policy" directory under the destination directory specified. The
47 destination directory is either an automatically generated temporary work dir
48 if --work-dir is set, the directory specified with the --dest flag, or the
49 current directory if neither flag is specified.
50
51 This command is based on 'conftest pull' so you can refer to the conftest pull
52 documentation for more usage examples and for details on the different types of
53 supported source URLs.
54
55 Note that this command is not typically required to evaluate policies.
56 It has been made available for troubleshooting and debugging purposes.
57 `),
58
59 Example: hd.Doc(`
60 Fetching policies from multiple sources to a specific directory:
61
62 ec fetch policy --dest fetched-policies \
63 --source github.com/conforma/policy//policy/lib \
64 --source github.com/conforma/policy//policy/release
65
66 Fetching policies and data from multiple sources to the current directory:
67
68 ec fetch policy \
69 --source github.com/conforma/policy//policy/lib \
70 --source github.com/conforma/policy//policy/release \
71 --data-source git::https://github.com/conforma/policy//example/data
72
73 Fetching policies from multiple sources to an automatically generated temporary
74 work directory:
75
76 ec fetch policy --work-dir \
77 --source github.com/conforma/policy//policy/lib \
78 --source github.com/conforma/policy//policy/release
79
80 Different style url formats are supported. In this example "policy" is treated as
81 a subdirectory even without the go-getter style // delimiter:
82
83 ec fetch policy --source https://github.com/conforma/policy/policy
84
85 Fetching policies from an OPA bundle (OCI image):
86
87 ec fetch policy --source quay.io/enterprise-contract/ec-release-policy:latest

Callers 1

initFunction · 0.85

Calls 2

CreateWorkDirFunction · 0.92
GetPolicyMethod · 0.65

Tested by

no test coverage detected