Debian Codegraph @

policy/testdata/errors/policy.yaml

raw symbols SCIP
1 # Copyright 2024 Google LLC
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 name: "errors"
16 imports:
17 - name: " untrimmed.Import1 "
18 - name: >
19 punc.Import!
20 - name: "bad import"
21 rule:
22 variables:
23 - name: want
24 expression: spec.labels
25 - name: want
26 expression: "2"
27 - name: missing
28 expression: variables.want.filter(l, !(lin resource.labels))
29 - name: bad_data
30 expression: "{1:305 2:569}"
31 - name: invalid
32 expression: >
33 resource.labels.filter(l,
34 l in variables.want && variables.want[l] != resource.labels[l])
35 match:
36 - condition: variables.missing.size() > 0
37 output: |
38 "missing one or more required labels: %s".format(variables.missing])
39 - condition: variables.invalid.size() > 0
40 output: |
41 "invalid values provided on one or more labels: %s".format([variables.invalid])
42 - condition: "1 > 0"
43 output: "true"
44 - condition: "1 < 0"
45 output: "'false'"