|
2 | 2 | // |
3 | 3 | // * operators/operator_sdk/osdk-scorecard.adoc |
4 | 4 |
|
| 5 | +:osdk_ver: v1.3.0 |
| 6 | + |
5 | 7 | [id="osdk-scorecard-config_{context}"] |
6 | 8 | = Scorecard configuration |
7 | 9 |
|
8 | | -The scorecard tool uses a configuration file that allows you to configure internal plug-ins, as well as several global configuration options. |
9 | | - |
10 | | -[id="osdk-scorecard-config-file_{context}"] |
11 | | -== Configuration file |
12 | | - |
13 | | -The default location for the scorecard tool configuration is the `<project_dir>/.osdk-scorecard.*`. The following is an example of a YAML-formatted configuration file: |
| 10 | +The scorecard tool uses a configuration that allows you to configure internal plug-ins, as well as several global configuration options. Tests are driven by a configuration file named `config.yaml`, which is generated by the `make bundle` command, located in your `bundle/` directory: |
14 | 11 |
|
15 | | -.Scorecard configuration file |
16 | | -[source,yaml] |
| 12 | +[source,terminal] |
17 | 13 | ---- |
18 | | -scorecard: |
19 | | - output: json |
20 | | - plugins: |
21 | | - - basic: <1> |
22 | | - cr-manifest: |
23 | | - - "deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml" |
24 | | - - "deploy/crds/cache.example.com_v1alpha1_memcachedrs_cr.yaml" |
25 | | - - olm: <2> |
26 | | - cr-manifest: |
27 | | - - "deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml" |
28 | | - - "deploy/crds/cache.example.com_v1alpha1_memcachedrs_cr.yaml" |
29 | | - csv-path: "deploy/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml" |
| 14 | +./bundle |
| 15 | +... |
| 16 | +└── tests |
| 17 | + └── scorecard |
| 18 | + └── config.yaml |
30 | 19 | ---- |
31 | | -<1> `basic` tests configured to test two custom resources (CRs). |
32 | | -<2> `olm` tests configured to test two CRs. |
33 | | - |
34 | | -Configuration methods for global options take the following priority, highest to lowest: |
35 | | - |
36 | | -Command arguments (if available) -> configuration file -> default |
37 | | - |
38 | | -The configuration file must be in YAML format. As the configuration file might be extended to allow configuration of all `operator-sdk` subcommands in the future, the scorecard configuration must be under a `scorecard` subsection. |
39 | | - |
40 | | -[NOTE] |
41 | | -==== |
42 | | -Configuration file support is provided by the `viper` package. For more info on how `viper` configuration works, see the link:https://github.com/spf13/viper/blob/master/README.md[README]. |
43 | | -==== |
44 | | - |
45 | | -[id="osdk-scorecard-config-args_{context}"] |
46 | | -== Command arguments |
47 | | - |
48 | | -While most of the scorecard tool configuration is done using a configuration file, you can also use the following arguments: |
49 | | - |
50 | | -.Scorecard tool arguments |
51 | | -[cols="25%,20%,55%",options="header"] |
52 | | -|=== |
53 | | -|Flag |Type |Description |
54 | | - |
55 | | -|`--bundle`, `-b` |
56 | | -|string |
57 | | -|The path to a bundle directory used for the bundle validation test. |
58 | | - |
59 | | -|`--config` |
60 | | -|string |
61 | | -|The path to the scorecard configuration file. The default is `<project_dir>/.osdk-scorecard`. The file type and extension must be `.yaml`. If a configuration file is not provided or found at the default location, the scorecard exits with an error. |
62 | | - |
63 | | -|`--output`, `-o` |
64 | | -|string |
65 | | -|Output format. Valid options are `text` and `json`. The default format is `text`, which is designed to be a human readable format. The `json` format uses the JSON schema output format used for plug-ins defined later. |
66 | | - |
67 | | -|`--kubeconfig`, `-o` |
68 | | -|string |
69 | | -|The path to the `kubeconfig` file. It sets the `kubeconfig` for internal plug-ins. |
70 | | - |
71 | | -|`--version` |
72 | | -|string |
73 | | -|The version of scorecard to run. The default and only valid option is `v1alpha2`. |
74 | | - |
75 | | -|`--selector`, `-l` |
76 | | -|string |
77 | | -|The label selector to filter tests on. |
78 | | - |
79 | | -|`--list`, `-L` |
80 | | -|bool |
81 | | -|If `true`, only print the test names that would be run based on selector filtering. |
82 | | -|=== |
83 | | - |
84 | | -[id="osdk-scorecard-config-file-options_{context}"] |
85 | | -== Configuration file options |
86 | | - |
87 | | -The scorecard configuration file provides the following options: |
88 | | - |
89 | | -.Scorecard configuration file options |
90 | | -[cols="25%,20%,55%",options="header"] |
91 | | -|=== |
92 | | -|Option |Type |Description |
93 | | - |
94 | | -|`bundle` |
95 | | -|string |
96 | | -|Equivalent of the `--bundle` flag. Operator Lifecycle Manager (OLM) bundle directory path, when specified, runs bundle validation. |
97 | | - |
98 | | -|`output` |
99 | | -|string |
100 | | -|Equivalent of the `--output` flag. If this option is defined by both the configuration file and the flag, the flag value takes priority. |
101 | | - |
102 | | -|`kubeconfig` |
103 | | -|string |
104 | | -|Equivalent of the `--kubeconfig` flag. If this option is defined by both the configuration file and the flag, the flag value takes priority. |
105 | | - |
106 | | -|`plugins` |
107 | | -|array |
108 | | -|An array of plug-in names. |
109 | | -|=== |
110 | 20 |
|
111 | | -[id="osdk-scorecard-config-plugins_{context}"] |
112 | | -=== Basic and OLM plug-ins |
| 21 | +.Example scorecard configuration file |
| 22 | +[source,yaml,subs="attributes+"] |
| 23 | +---- |
| 24 | +kind: Configuration |
| 25 | +apiversion: scorecard.operatorframework.io/v1alpha3 |
| 26 | +metadata: |
| 27 | + name: config |
| 28 | +stages: |
| 29 | +- parallel: true |
| 30 | + tests: |
| 31 | + - image: quay.io/operator-framework/scorecard-test:{osdk_ver} |
| 32 | + entrypoint: |
| 33 | + - scorecard-test |
| 34 | + - basic-check-spec |
| 35 | + labels: |
| 36 | + suite: basic |
| 37 | + test: basic-check-spec-test |
| 38 | + - image: quay.io/operator-framework/scorecard-test:{osdk_ver} |
| 39 | + entrypoint: |
| 40 | + - scorecard-test |
| 41 | + - olm-bundle-validation |
| 42 | + labels: |
| 43 | + suite: olm |
| 44 | + test: olm-bundle-validation-test |
| 45 | +---- |
113 | 46 |
|
114 | | -The scorecard supports the internal `basic` and `olm` plug-ins, which are configured by a `plugins` section in the configuration file. |
| 47 | +The configuration file defines each test that scorecard can execute. The |
| 48 | +following fields of the scorecard configuration file define the test as follows: |
115 | 49 |
|
116 | | -.Plug-in options |
117 | | -[cols="25%,20%,55%",options="header"] |
| 50 | +[cols="3,7",options="header"] |
118 | 51 | |=== |
119 | | -|Option |Type |Description |
120 | | - |
121 | | -|`cr-manifest` |
122 | | -|[]string |
123 | | -|The path(s) for CRs being tested. Required if `olm-deployed` is unset or `false`. |
124 | | - |
125 | | -|`csv-path` |
126 | | -|string |
127 | | -|The path to the cluster service version (CSV) for the Operator. Required for OLM tests or if `olm-deployed` is set to `true`. |
128 | | - |
129 | | -|`olm-deployed` |
130 | | -|bool |
131 | | -|Indicates that the CSV and relevant CRDs have been deployed onto the cluster by OLM. |
132 | | - |
133 | | -|`kubeconfig` |
134 | | -|string |
135 | | -|The path to the `kubeconfig` file. If both the global `kubeconfig` and this field are set, this field is used for the plug-in. |
136 | | - |
137 | | -|`namespace` |
138 | | -|string |
139 | | -|The namespace to run the plug-ins in. If unset, the default specified by the `kubeconfig` file is used. |
140 | | - |
141 | | -|`init-timeout` |
142 | | -|int |
143 | | -|Time in seconds until a timeout during initialization of the Operator. |
| 52 | +|Configuration field |Description |
144 | 53 |
|
145 | | -|`crds-dir` |
146 | | -|string |
147 | | -|The path to the directory containing CRDs that must be deployed to the cluster. |
| 54 | +|`image` |
| 55 | +|Test container image name that implements a test |
148 | 56 |
|
149 | | -|`namespaced-manifest` |
150 | | -|string |
151 | | -|The manifest file with all resources that run within a namespace. By default, the scorecard combines the `service_account.yaml`, `role.yaml`, `role_binding.yaml`, and `operator.yaml` files from the `deploy` directory into a temporary manifest to use as the namespaced manifest. |
| 57 | +|`entrypoint` |
| 58 | +|Command and arguments that are invoked in the test image to execute a test |
152 | 59 |
|
153 | | -|`global-manifest` |
154 | | -|string |
155 | | -|The manifest containing required resources that run globally (not namespaced). By default, the scorecard combines all CRDs in the `crds-dir` directory into a temporary manifest to use as the global manifest. |
| 60 | +|`labels` |
| 61 | +|Scorecard-defined or custom labels that select which tests to run |
156 | 62 | |=== |
157 | 63 |
|
158 | | -[NOTE] |
159 | | -==== |
160 | | -Currently, using the scorecard with a CSV does not permit multiple CR manifests to be set through the CLI, configuration file, or CSV annotations. You must tear down your Operator in the cluster, re-deploy, and re-run the scorecard for each CR that is tested. |
161 | | -==== |
| 64 | +:!osdk_ver: |
0 commit comments