|
| 1 | +load("@rules_go//go:def.bzl", "go_binary", "go_library") |
| 2 | + |
| 3 | +RESOURCES = { |
| 4 | + "apikeys_key": { |
| 5 | + "service": "apikeys", |
| 6 | + "resource": "key", |
| 7 | + "docs": True, |
| 8 | + "sweeper": True, |
| 9 | + "test": True, |
| 10 | + }, |
| 11 | + "assured_workloads_workload": { |
| 12 | + "service": "assuredworkloads", |
| 13 | + "resource": "workload", |
| 14 | + "docs": True, |
| 15 | + "sweeper": False, |
| 16 | + "test": True, |
| 17 | + }, |
| 18 | + "cloudbuild_worker_pool": { |
| 19 | + "service": "cloudbuild", |
| 20 | + "resource": "worker_pool", |
| 21 | + "docs": False, |
| 22 | + "sweeper": True, |
| 23 | + "test": False, |
| 24 | + }, |
| 25 | + "clouddeploy_delivery_pipeline": { |
| 26 | + "service": "clouddeploy", |
| 27 | + "resource": "delivery_pipeline", |
| 28 | + "docs": True, |
| 29 | + "sweeper": True, |
| 30 | + "test": True, |
| 31 | + }, |
| 32 | + "clouddeploy_target": { |
| 33 | + "service": "clouddeploy", |
| 34 | + "resource": "target", |
| 35 | + "docs": True, |
| 36 | + "sweeper": True, |
| 37 | + "test": True, |
| 38 | + }, |
| 39 | + "container_aws_cluster": { |
| 40 | + "service": "containeraws", |
| 41 | + "resource": "cluster", |
| 42 | + "docs": True, |
| 43 | + "sweeper": False, |
| 44 | + "test": True, |
| 45 | + }, |
| 46 | + "container_aws_node_pool": { |
| 47 | + "service": "containeraws", |
| 48 | + "resource": "node_pool", |
| 49 | + "docs": True, |
| 50 | + "sweeper": False, |
| 51 | + "test": True, |
| 52 | + }, |
| 53 | + "container_azure_client": { |
| 54 | + "service": "containerazure", |
| 55 | + "resource": "client", |
| 56 | + "docs": True, |
| 57 | + "sweeper": False, |
| 58 | + "test": True, |
| 59 | + }, |
| 60 | + "container_azure_cluster": { |
| 61 | + "service": "containerazure", |
| 62 | + "resource": "cluster", |
| 63 | + "docs": True, |
| 64 | + "sweeper": False, |
| 65 | + "test": True, |
| 66 | + }, |
| 67 | + "container_azure_node_pool": { |
| 68 | + "service": "containerazure", |
| 69 | + "resource": "node_pool", |
| 70 | + "docs": True, |
| 71 | + "sweeper": False, |
| 72 | + "test": True, |
| 73 | + }, |
| 74 | + "dataplex_asset": { |
| 75 | + "service": "dataplex", |
| 76 | + "resource": "asset", |
| 77 | + "docs": True, |
| 78 | + "sweeper": False, |
| 79 | + "test": True, |
| 80 | + }, |
| 81 | + "dataplex_lake": { |
| 82 | + "service": "dataplex", |
| 83 | + "resource": "lake", |
| 84 | + "docs": True, |
| 85 | + "sweeper": True, |
| 86 | + "test": True, |
| 87 | + }, |
| 88 | + "dataplex_zone": { |
| 89 | + "service": "dataplex", |
| 90 | + "resource": "zone", |
| 91 | + "docs": True, |
| 92 | + "sweeper": False, |
| 93 | + "test": True, |
| 94 | + }, |
| 95 | + "dataproc_workflow_template": { |
| 96 | + "service": "dataproc", |
| 97 | + "resource": "workflow_template", |
| 98 | + "docs": False, |
| 99 | + "sweeper": True, |
| 100 | + "test": False, |
| 101 | + }, |
| 102 | + "firebaserules_release": { |
| 103 | + "service": "firebaserules", |
| 104 | + "resource": "release", |
| 105 | + "docs": True, |
| 106 | + "sweeper": True, |
| 107 | + "test": True, |
| 108 | + }, |
| 109 | + "firebaserules_ruleset": { |
| 110 | + "service": "firebaserules", |
| 111 | + "resource": "ruleset", |
| 112 | + "docs": True, |
| 113 | + "sweeper": True, |
| 114 | + "test": True, |
| 115 | + }, |
| 116 | + "gke_hub_feature_membership": { |
| 117 | + "service": "gkehub", |
| 118 | + "resource": "feature_membership", |
| 119 | + "docs": False, |
| 120 | + "sweeper": False, |
| 121 | + "test": False, |
| 122 | + }, |
| 123 | + "recaptcha_enterprise_key": { |
| 124 | + "service": "recaptchaenterprise", |
| 125 | + "resource": "key", |
| 126 | + "docs": True, |
| 127 | + "sweeper": True, |
| 128 | + "test": True, |
| 129 | + }, |
| 130 | +} |
| 131 | + |
| 132 | +SERVICES = set([v["service"] for k, v in RESOURCES.items()]) |
| 133 | + |
| 134 | +filegroup( |
| 135 | + name = "api", |
| 136 | + srcs = glob([ |
| 137 | + "api/**/*", |
| 138 | + ]), |
| 139 | +) |
| 140 | + |
| 141 | +filegroup( |
| 142 | + name = "overrides", |
| 143 | + srcs = glob([ |
| 144 | + "overrides/**/*", |
| 145 | + ]), |
| 146 | +) |
| 147 | + |
| 148 | +filegroup( |
| 149 | + name = "templates", |
| 150 | + srcs = glob([ |
| 151 | + "templates/**/*", |
| 152 | + ]), |
| 153 | +) |
| 154 | + |
| 155 | +genrule( |
| 156 | + name = "empty_serialization", |
| 157 | + srcs = [ |
| 158 | + "serialization.go.base", |
| 159 | + ], |
| 160 | + outs = ["empty_serialization.go"], |
| 161 | + cmd = "cp $< $@", |
| 162 | + visibility = ["//visibility:private"], |
| 163 | +) |
| 164 | + |
| 165 | +genrule( |
| 166 | + name = "bootstrapped_serialization", |
| 167 | + srcs = [ |
| 168 | + ":api", |
| 169 | + ":overrides", |
| 170 | + ":templates", |
| 171 | + ], |
| 172 | + outs = ["serialization.go"], |
| 173 | + cmd = "$(location :bootstrap_tpgtools) --overrides tpgtools/overrides --path tpgtools/api --templates tpgtools/templates --mode serialization --output $(@D)", |
| 174 | + tools = [":bootstrap_tpgtools"], |
| 175 | + visibility = ["//visibility:private"], |
| 176 | +) |
| 177 | + |
| 178 | +go_binary( |
| 179 | + name = "bootstrap_tpgtools", |
| 180 | + srcs = [ |
| 181 | + "documentation.go", |
| 182 | + "file_utils.go", |
| 183 | + "id.go", |
| 184 | + "main.go", |
| 185 | + "main_helpers.go", |
| 186 | + "misc_utils.go", |
| 187 | + "names.go", |
| 188 | + "override.go", |
| 189 | + "override_details.go", |
| 190 | + "product.go", |
| 191 | + "property.go", |
| 192 | + "property_helpers.go", |
| 193 | + "resource.go", |
| 194 | + "sample.go", |
| 195 | + "serialization_helpers.go", |
| 196 | + "strings.go", |
| 197 | + "type.go", |
| 198 | + "versions.go", |
| 199 | + ":empty_serialization", |
| 200 | + ], |
| 201 | + visibility = ["//visibility:private"], |
| 202 | + deps = [ |
| 203 | + "@com_github_golang_glog//:glog", |
| 204 | + "@com_github_googlecloudplatform_declarative_resource_client_library//dcl", |
| 205 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services", |
| 206 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager", |
| 207 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager/alpha", |
| 208 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager/beta", |
| 209 | + "@com_github_hashicorp_hcl//hcl/fmtcmd", |
| 210 | + "@com_github_kylelemons_godebug//pretty", |
| 211 | + "@com_github_nasa9084_go_openapi//:go-openapi", |
| 212 | + "@in_gopkg_yaml_v2//:yaml_v2", |
| 213 | + "@org_bitbucket_creachadair_stringset//:stringset", |
| 214 | + ], |
| 215 | +) |
| 216 | + |
| 217 | +go_binary( |
| 218 | + name = "tpgtools_compiler", |
| 219 | + srcs = [ |
| 220 | + "documentation.go", |
| 221 | + "file_utils.go", |
| 222 | + "id.go", |
| 223 | + "main.go", |
| 224 | + "main_helpers.go", |
| 225 | + "misc_utils.go", |
| 226 | + "names.go", |
| 227 | + "override.go", |
| 228 | + "override_details.go", |
| 229 | + "product.go", |
| 230 | + "property.go", |
| 231 | + "property_helpers.go", |
| 232 | + "resource.go", |
| 233 | + "sample.go", |
| 234 | + "serialization_helpers.go", |
| 235 | + "strings.go", |
| 236 | + "type.go", |
| 237 | + "versions.go", |
| 238 | + ":bootstrapped_serialization", |
| 239 | + ], |
| 240 | + visibility = ["//visibility:private"], |
| 241 | + deps = [ |
| 242 | + "@com_github_golang_glog//:glog", |
| 243 | + "@com_github_googlecloudplatform_declarative_resource_client_library//dcl", |
| 244 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services", |
| 245 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager", |
| 246 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager/alpha", |
| 247 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager/beta", |
| 248 | + "@com_github_hashicorp_hcl//hcl/fmtcmd", |
| 249 | + "@com_github_kylelemons_godebug//pretty", |
| 250 | + "@com_github_nasa9084_go_openapi//:go-openapi", |
| 251 | + "@in_gopkg_yaml_v2//:yaml_v2", |
| 252 | + "@org_bitbucket_creachadair_stringset//:stringset", |
| 253 | + ] + ["@com_github_googlecloudplatform_declarative_resource_client_library//services/google/" + s for s in SERVICES] + |
| 254 | + ["@com_github_googlecloudplatform_declarative_resource_client_library//services/google/" + s + "/beta" for s in SERVICES], |
| 255 | +) |
| 256 | + |
| 257 | +genrule( |
| 258 | + name = "tpgtools", |
| 259 | + srcs = [ |
| 260 | + ":api", |
| 261 | + ":overrides", |
| 262 | + ":templates", |
| 263 | + ], |
| 264 | + outs = [ |
| 265 | + "terraform-provider-google/google/provider/provider_dcl_resources.go", |
| 266 | + "terraform-provider-google/google/transport/provider_dcl_client_creation.go", |
| 267 | + ] + ["terraform-provider-google/google/services/{}/resource_{}.go".format( |
| 268 | + v["service"], |
| 269 | + k, |
| 270 | + ) for (k, v) in RESOURCES.items()] + |
| 271 | + ["terraform-provider-google/google/services/{}/resource_{}_sweeper.go".format( |
| 272 | + v["service"], |
| 273 | + k, |
| 274 | + ) for (k, v) in RESOURCES.items() if v["sweeper"] == True] + |
| 275 | + ["terraform-provider-google/google/services/{}/resource_{}_generated_test.go".format( |
| 276 | + v["service"], |
| 277 | + k, |
| 278 | + ) for (k, v) in RESOURCES.items() if v["test"] == True] + |
| 279 | + ["terraform-provider-google/website/docs/r/{}.html.markdown".format(k) for (k, v) in RESOURCES.items() if v["docs"] == True], |
| 280 | + cmd = "$(location :tpgtools_compiler) --overrides tpgtools/overrides --path tpgtools/api --templates tpgtools/templates --version ga --output $(RULEDIR)/terraform-provider-google", |
| 281 | + tools = [":tpgtools_compiler"], |
| 282 | + visibility = ["//visibility:public"], |
| 283 | +) |
| 284 | + |
| 285 | +genrule( |
| 286 | + name = "tpgtools_beta", |
| 287 | + srcs = [ |
| 288 | + ":api", |
| 289 | + ":overrides", |
| 290 | + ":templates", |
| 291 | + ], |
| 292 | + outs = [ |
| 293 | + "terraform-provider-google-beta/google-beta/provider/provider_dcl_resources.go", |
| 294 | + "terraform-provider-google-beta/google-beta/transport/provider_dcl_client_creation.go", |
| 295 | + ] + ["terraform-provider-google-beta/google-beta/services/{}/resource_{}.go".format( |
| 296 | + v["service"], |
| 297 | + k, |
| 298 | + ) for (k, v) in RESOURCES.items()] + |
| 299 | + ["terraform-provider-google-beta/google-beta/services/{}/resource_{}_sweeper.go".format( |
| 300 | + v["service"], |
| 301 | + k, |
| 302 | + ) for (k, v) in RESOURCES.items() if v["sweeper"] == True] + |
| 303 | + ["terraform-provider-google-beta/google-beta/services/{}/resource_{}_generated_test.go".format( |
| 304 | + v["service"], |
| 305 | + k, |
| 306 | + ) for (k, v) in RESOURCES.items() if v["test"] == True] + |
| 307 | + ["terraform-provider-google-beta/website/docs/r/{}.html.markdown".format(k) for (k, v) in RESOURCES.items() if v["docs"] == True], |
| 308 | + cmd = "$(location :tpgtools_compiler) --overrides tpgtools/overrides --path tpgtools/api --templates tpgtools/templates --version beta --output $(RULEDIR)/terraform-provider-google-beta", |
| 309 | + tools = [":tpgtools_compiler"], |
| 310 | + visibility = ["//visibility:public"], |
| 311 | +) |
| 312 | + |
| 313 | + |
| 314 | +# The tpgtools_lib is generated by gazelle but is unused by the other targets |
| 315 | +# in this file, which need to specifically depend on either the initial empty |
| 316 | +# version of serialization.go or the generated version. The `gazelle:exclude` |
| 317 | +# line here makes the target buildable even though it's unused, allowing |
| 318 | +# bazel build //tpgtools/... to succeed. |
| 319 | +# |
| 320 | +# gazelle:exclude serialization.go |
| 321 | +go_library( |
| 322 | + name = "tpgtools_lib", |
| 323 | + srcs = [ |
| 324 | + "documentation.go", |
| 325 | + "empty_serialization.go", |
| 326 | + "file_utils.go", |
| 327 | + "id.go", |
| 328 | + "main.go", |
| 329 | + "main_helpers.go", |
| 330 | + "misc_utils.go", |
| 331 | + "names.go", |
| 332 | + "override.go", |
| 333 | + "override_details.go", |
| 334 | + "product.go", |
| 335 | + "property.go", |
| 336 | + "property_helpers.go", |
| 337 | + "resource.go", |
| 338 | + "sample.go", |
| 339 | + "serialization_helpers.go", |
| 340 | + "strings.go", |
| 341 | + "type.go", |
| 342 | + "versions.go", |
| 343 | + ], |
| 344 | + importpath = "github.com/GoogleCloudPlatform/magic-modules/tpgtools", |
| 345 | + visibility = ["//visibility:private"], |
| 346 | + deps = [ |
| 347 | + "@com_github_golang_glog//:glog", |
| 348 | + "@com_github_googlecloudplatform_declarative_resource_client_library//dcl", |
| 349 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services", |
| 350 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager", |
| 351 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager/alpha", |
| 352 | + "@com_github_googlecloudplatform_declarative_resource_client_library//services/google/cloudresourcemanager/beta", |
| 353 | + "@com_github_hashicorp_hcl//hcl/fmtcmd", # keep |
| 354 | + "@com_github_kylelemons_godebug//pretty", |
| 355 | + "@com_github_nasa9084_go_openapi//:go-openapi", |
| 356 | + "@in_gopkg_yaml_v2//:yaml_v2", |
| 357 | + "@org_bitbucket_creachadair_stringset//:stringset", |
| 358 | + ], |
| 359 | +) |
0 commit comments