Debian Codegraph @

policy/BUILD.bazel

raw
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 load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
16 load("@rules_proto//proto:defs.bzl", "proto_descriptor_set")
17 load("//test:cel_go_test.bzl", "cel_go_test")
18
19 package(
20 default_visibility = [
21 "//policy:__subpackages__",
22 "//tools:__subpackages__"
23 ],
24 licenses = ["notice"],
25 )
26
27 go_library(
28 name = "go_default_library",
29 srcs = [
30 "compiler.go",
31 "conformance.go",
32 "composer.go",
33 "config.go",
34 "parser.go",
35 "source.go",
36 "test_tag_handler_k8s.go",
37 ],
38 importpath = "github.com/google/cel-go/policy",
39 deps = [
40 "//cel:go_default_library",
41 "//common:go_default_library",
42 "//common/ast:go_default_library",
43 "//common/containers:go_default_library",
44 "//common/decls:go_default_library",
45 "//common/env:go_default_library",
46 "//common/operators:go_default_library",
47 "//common/types:go_default_library",
48 "//common/types/ref:go_default_library",
49 "//ext:go_default_library",
50 "@in_yaml_go_yaml_v3//:go_default_library",
51 "@org_golang_google_protobuf//proto:go_default_library",
52 ],
53 )
54
55 go_test(
56 name = "go_default_test",
57 size = "small",
58 srcs = [
59 "compiler_test.go",
60 "composer_test.go",
61 "config_test.go",
62 "helper_test.go",
63 "parser_test.go",
64 ],
65 data = glob(["testdata/**"]),
66 embed = [":go_default_library"],
67 deps = [
68 "//cel:go_default_library",
69 "//test:go_default_library",
70 "//common/debug:go_default_library",
71 "//common/types:go_default_library",
72 "//interpreter:go_default_library",
73 "//common/types/ref:go_default_library",
74 "//test/proto3pb:go_default_library",
75 "@in_yaml_go_yaml_v3//:go_default_library",
76 "@com_github_google_go_cmp//cmp:go_default_library",
77 "@org_golang_google_genproto_googleapis_api//expr/v1alpha1:go_default_library",
78 "@org_golang_google_protobuf//encoding/prototext:go_default_library",
79 ],
80 )
81
82 filegroup(
83 name = "testdata",
84 srcs = glob(["testdata/**"]),
85 )
86
87 proto_descriptor_set(
88 name = "test_all_types_fds",
89 deps = [
90 "//test/proto3pb:test_all_types_proto",
91 ],
92 )
93
94 cel_go_test(
95 name = "context_pb_policy",
96 cel_expr = "testdata/context_pb/policy.yaml",
97 config = "testdata/context_pb/config.yaml",
98 enable_coverage = True,
99 file_descriptor_set = ":test_all_types_fds",
100 test_src = "//policy/test:cel_test_runner.go",
101 test_suite = "testdata/context_pb/tests.yaml",
102 )
103
104 cel_go_test(
105 name = "k8s_policy",
106 cel_expr = "testdata/k8s/policy.yaml",
107 config = "testdata/k8s/config.yaml",
108 deps = ["//policy:go_default_library"],
109 enable_coverage = True,
110 test_src = "//policy/test:k8s_cel_test_runner.go",
111 test_suite = "testdata/k8s/tests.yaml",
112 )
113
114 cel_go_test(
115 name = "limits_policy",
116 cel_expr = "testdata/limits/policy.yaml",
117 config = "testdata/limits/config.yaml",
118 enable_coverage = True,
119 test_src = "//policy/test:cel_test_runner.go",
120 test_suite = "testdata/limits/tests.yaml",
121 )
122
123 cel_go_test(
124 name = "nested_rule_policy",
125 cel_expr = "testdata/nested_rule/policy.yaml",
126 config = "testdata/nested_rule/config.yaml",
127 enable_coverage = True,
128 test_src = "//policy/test:cel_test_runner.go",
129 test_suite = "testdata/nested_rule/tests.yaml",
130 )
131
132 cel_go_test(
133 name = "nested_rule2_policy",
134 cel_expr = "testdata/nested_rule2/policy.yaml",
135 config = "testdata/nested_rule2/config.yaml",
136 enable_coverage = True,
137 test_src = "//policy/test:cel_test_runner.go",
138 test_suite = "testdata/nested_rule2/tests.yaml",
139 )
140
141 cel_go_test(
142 name = "nested_rule3_policy",
143 cel_expr = "testdata/nested_rule3/policy.yaml",
144 config = "testdata/nested_rule3/config.yaml",
145 enable_coverage = True,
146 test_src = "//policy/test:cel_test_runner.go",
147 test_suite = "testdata/nested_rule3/tests.yaml",
148 )
149
150 cel_go_test(
151 name = "nested_rule4_policy",
152 cel_expr = "testdata/nested_rule4/policy.yaml",
153 config = "testdata/nested_rule4/config.yaml",
154 enable_coverage = True,
155 test_src = "//policy/test:cel_test_runner.go",
156 test_suite = "testdata/nested_rule4/tests.yaml",
157 )
158
159 cel_go_test(
160 name = "nested_rule5_policy",
161 cel_expr = "testdata/nested_rule5/policy.yaml",
162 config = "testdata/nested_rule5/config.yaml",
163 enable_coverage = True,
164 test_src = "//policy/test:cel_test_runner.go",
165 test_suite = "testdata/nested_rule5/tests.yaml",
166 )
167
168 cel_go_test(
169 name = "nested_rule6_policy",
170 cel_expr = "testdata/nested_rule6/policy.yaml",
171 config = "testdata/nested_rule6/config.yaml",
172 enable_coverage = True,
173 test_src = "//policy/test:cel_test_runner.go",
174 test_suite = "testdata/nested_rule6/tests.yaml",
175 )
176
177 cel_go_test(
178 name = "nested_rule7_policy",
179 cel_expr = "testdata/nested_rule7/policy.yaml",
180 config = "testdata/nested_rule7/config.yaml",
181 enable_coverage = True,
182 test_src = "//policy/test:cel_test_runner.go",
183 test_suite = "testdata/nested_rule7/tests.yaml",
184 )
185
186 cel_go_test(
187 name = "pb_policy",
188 cel_expr = "testdata/pb/policy.yaml",
189 config = "testdata/pb/config.yaml",
190 file_descriptor_set = ":test_all_types_fds",
191 enable_coverage = True,
192 test_src = "//policy/test:cel_test_runner.go",
193 test_suite = "testdata/pb/tests.yaml",
194 )
195
196 cel_go_test(
197 name = "required_labels_policy",
198 cel_expr = "testdata/required_labels/policy.yaml",
199 config = "testdata/required_labels/config.yaml",
200 enable_coverage = True,
201 test_src = "//policy/test:cel_test_runner.go",
202 test_suite = "testdata/required_labels/tests.yaml",
203 )
204
205 cel_go_test(
206 name = "restricted_destinations_policy",
207 cel_expr = "testdata/restricted_destinations/policy.yaml",
208 config = "testdata/restricted_destinations/config.yaml",
209 enable_coverage = True,
210 test_src = "//policy/test:cel_test_runner.go",
211 test_suite = "testdata/restricted_destinations/tests.yaml",
212 )
213
214 cel_go_test(
215 name = "unnest_policy",
216 cel_expr = "testdata/unnest/policy.yaml",
217 config = "testdata/unnest/config.yaml",
218 enable_coverage = True,
219 test_src = "//policy/test:cel_test_runner.go",
220 test_suite = "testdata/unnest/tests.yaml",
221 )