-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathrules.bzl
71 lines (67 loc) · 2.67 KB
/
rules.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
load("//packer:rules.bzl", "assemble_packer")
load("//common/generate_json_config:rules.bzl", "generate_json_config")
def assemble_gcp(name,
project_id,
install,
zone,
image_name,
image_family="",
files=None,
image_licenses=None,
disable_default_service_account=False,
source_image_family="ubuntu-1604-lts"):
"""Assemble files for GCP deployment
Args:
name: A unique name for this target.
project_id: Google project id
install: Bazel label for install file
zone: GCP zone to deploy image to
image_name: name of deployed image
image_family: family of deployed image
files: Files to include into GCP deployment
image_licenses: licenses to attach to deployed image
disable_default_service_account: disable default service account
source_image_family: Family of GCP base image
"""
if not files:
files = {}
install_fn = Label(install).name
generated_config_target_name = name + "__do_not_reference_config"
generate_json_config(
name = generated_config_target_name,
template = "@typedb_bazel_distribution//gcp:packer.template.json",
substitutions = {
"{project_id}": project_id,
"{zone}": zone,
"{image_name}": image_name,
"{image_family}": image_family,
"{image_licenses}": "[\"{}\"]".format(image_licenses) if image_licenses else "[]",
"{install}": install_fn,
"{source_image_family}": source_image_family,
"{disable_default_service_account}": str(disable_default_service_account).lower()
}
)
files[install] = install_fn
assemble_packer(
name = name,
config = generated_config_target_name,
files = files
)