2022-10-30 07:58:16 +00:00
|
|
|
load("//rules_resf/internal/resf_bundle:resf_bundle.bzl", _resf_bundle = "resf_bundle", _resf_bundle_run = "resf_bundle_run")
|
|
|
|
load("//rules_resf/internal/k8s:k8s.bzl", _k8s_apply = "k8s_apply")
|
|
|
|
load("//rules_resf/internal/container:container.bzl", _container = "container", _migration_tar = "migration_tar")
|
2022-10-31 02:23:40 +00:00
|
|
|
load("//rules_resf/internal/helm:helm_chart.bzl", _helm_chart = "helm_chart")
|
2022-07-07 20:11:50 +00:00
|
|
|
load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_to_json")
|
|
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
|
|
|
|
load("@com_github_atlassian_bazel_tools//:multirun/def.bzl", "multirun")
|
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
resf_bundle = _resf_bundle
|
2022-07-07 20:11:50 +00:00
|
|
|
k8s_apply = _k8s_apply
|
|
|
|
container = _container
|
|
|
|
migration_tar = _migration_tar
|
2022-10-31 02:23:40 +00:00
|
|
|
helm_chart = _helm_chart
|
2022-07-07 20:11:50 +00:00
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
RESFDEPLOY_OUTS_BASE = [
|
2022-07-07 20:11:50 +00:00
|
|
|
"001-ns-sa.yaml",
|
|
|
|
"003-deployment.yaml",
|
|
|
|
"004-svc-vs-dr.yaml",
|
|
|
|
]
|
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
RESFDEPLOY_OUTS_MIGRATE = RESFDEPLOY_OUTS_BASE + [
|
2022-07-07 20:11:50 +00:00
|
|
|
"002-migrate.yaml",
|
|
|
|
]
|
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
RESFDEPLOY_OUTS_CUSTOM = RESFDEPLOY_OUTS_BASE + [
|
2022-07-07 20:11:50 +00:00
|
|
|
"005-custom.yaml",
|
|
|
|
]
|
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
RESFDEPLOY_OUTS_MIGRATE_CUSTOM = RESFDEPLOY_OUTS_BASE + [
|
2022-07-07 20:11:50 +00:00
|
|
|
"002-migrate.yaml",
|
|
|
|
"005-custom.yaml",
|
|
|
|
]
|
|
|
|
|
|
|
|
def tag_default_update(defaults, append):
|
|
|
|
tdict = defaults
|
|
|
|
tdict.update(append)
|
|
|
|
return tdict
|
|
|
|
|
2022-10-31 02:23:40 +00:00
|
|
|
def gen_from_jsonnet(name, src, outs, tags, force_normal_tags, helm_mode, **kwargs):
|
2022-07-07 20:11:50 +00:00
|
|
|
ext_str_nested = "{STABLE_OCI_REGISTRY_NO_NESTED_SUPPORT_IN_2022_SHAME_ON_YOU_AWS}"
|
|
|
|
if force_normal_tags:
|
|
|
|
ext_str_nested = "false"
|
|
|
|
ext_strs = {
|
|
|
|
"tag": "{STABLE_BUILD_TAG}",
|
|
|
|
"stage": "{STABLE_STAGE}",
|
|
|
|
"local_environment": "{STABLE_LOCAL_ENVIRONMENT}",
|
|
|
|
"user": "{BUILD_USER}",
|
|
|
|
"oci_registry": "{STABLE_OCI_REGISTRY}",
|
|
|
|
"oci_registry_repo": "{STABLE_OCI_REGISTRY_REPO}",
|
|
|
|
"oci_registry_docker": "{STABLE_OCI_REGISTRY_DOCKER}",
|
|
|
|
"oci_registry_no_nested_support_in_2022_shame_on_you_aws": ext_str_nested,
|
|
|
|
"domain_user": "{STABLE_DOMAIN_USER}",
|
|
|
|
"registry_secret": "{STABLE_REGISTRY_SECRET}",
|
|
|
|
"site": "{STABLE_SITE}",
|
2022-10-31 02:23:40 +00:00
|
|
|
"helm_mode": "false",
|
2022-07-07 20:11:50 +00:00
|
|
|
}
|
2022-10-31 02:23:40 +00:00
|
|
|
if helm_mode:
|
|
|
|
ext_strs["helm_mode"] = "true"
|
2022-07-07 20:11:50 +00:00
|
|
|
jsonnet_to_json(
|
|
|
|
name = name,
|
|
|
|
src = src,
|
|
|
|
outs = outs,
|
|
|
|
tags = tags + [
|
2022-10-30 01:59:25 +00:00
|
|
|
"manual",
|
2022-07-07 20:11:50 +00:00
|
|
|
"peridot_k8s",
|
|
|
|
],
|
|
|
|
ext_strs = select({
|
|
|
|
"//platforms:arm64": dict(ext_strs, arch = "arm64"),
|
|
|
|
"//platforms:x86_64": dict(ext_strs, arch = "amd64"),
|
|
|
|
"//platforms:s390x": dict(ext_strs, arch = "s390x"),
|
|
|
|
"//platforms:ppc64le": dict(ext_strs, arch = "ppc64le"),
|
|
|
|
}),
|
|
|
|
stamp_keys = [
|
|
|
|
"tag",
|
|
|
|
"stage",
|
|
|
|
"local_environment",
|
|
|
|
"user",
|
|
|
|
"oci_registry",
|
|
|
|
"oci_registry_repo",
|
|
|
|
"oci_registry_docker",
|
|
|
|
"oci_registry_no_nested_support_in_2022_shame_on_you_aws",
|
|
|
|
"domain_user",
|
|
|
|
"registry_secret",
|
|
|
|
"site",
|
|
|
|
],
|
|
|
|
multiple_outputs = True,
|
|
|
|
extra_args = ["-S"],
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
2022-10-31 02:23:40 +00:00
|
|
|
# to find the correct kind during ci run
|
|
|
|
def peridot_k8s(name, src, tags = [], outs = [], static = False, prod_only = False, dependent_push = [], force_normal_tags = False, chart_yaml = None, values_yaml = None, **kwargs):
|
|
|
|
gen_from_jsonnet(name, src, outs, tags, force_normal_tags, False, **kwargs)
|
|
|
|
if chart_yaml != None:
|
|
|
|
if values_yaml == None:
|
|
|
|
fail("values_yaml is required when chart_yaml is provided")
|
|
|
|
new_outs = ["helm-%s" % o for o in outs]
|
|
|
|
gen_from_jsonnet("%s-helm" % name, src, new_outs, tags, force_normal_tags, True, **kwargs)
|
|
|
|
|
|
|
|
helm_chart(
|
|
|
|
name = "%s.helm" % name,
|
|
|
|
package_name = name,
|
|
|
|
chart_yaml = chart_yaml,
|
|
|
|
values_yaml = values_yaml,
|
|
|
|
srcs = new_outs,
|
|
|
|
tags = ["manual"]
|
|
|
|
)
|
|
|
|
|
2022-07-07 20:11:50 +00:00
|
|
|
k8s_apply(
|
|
|
|
name = "%s.apply" % name,
|
|
|
|
srcs = [":%s" % name],
|
2022-10-30 01:59:25 +00:00
|
|
|
tags = ["manual"],
|
2022-07-07 20:11:50 +00:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
multirun(
|
2022-10-30 01:59:25 +00:00
|
|
|
name = "%s.push" % name,
|
|
|
|
commands = dependent_push + [":%s_container" % name],
|
|
|
|
tags = ["manual"],
|
2022-07-07 20:11:50 +00:00
|
|
|
)
|
|
|
|
multirun(
|
|
|
|
name = "%s.push_apply" % name,
|
|
|
|
commands = [
|
|
|
|
":%s.push" % name,
|
|
|
|
":%s.apply" % name,
|
|
|
|
],
|
2022-10-30 01:59:25 +00:00
|
|
|
tags = ["manual"],
|
2022-07-07 20:11:50 +00:00
|
|
|
)
|
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
def resf_frontend(name, tags = [], **kwargs):
|
|
|
|
_resf_bundle(
|
2022-07-07 20:11:50 +00:00
|
|
|
name = "{}.bundle".format(name),
|
|
|
|
build = True,
|
|
|
|
tags = tags + [
|
2022-10-30 01:59:25 +00:00
|
|
|
"manual",
|
2022-10-30 07:58:16 +00:00
|
|
|
"resf_frontend_bundle",
|
2022-07-07 20:11:50 +00:00
|
|
|
],
|
|
|
|
**kwargs
|
|
|
|
)
|
|
|
|
|
2022-10-30 07:58:16 +00:00
|
|
|
_resf_bundle_run(
|
2022-07-07 20:11:50 +00:00
|
|
|
name = "{}.server".format(name),
|
|
|
|
build = False,
|
|
|
|
tags = tags + [
|
2022-10-30 01:59:25 +00:00
|
|
|
"manual",
|
2022-10-30 07:58:16 +00:00
|
|
|
"resf_frontend_server",
|
2022-07-07 20:11:50 +00:00
|
|
|
"ibazel_notify_changes",
|
|
|
|
"ibazel_live_reload",
|
|
|
|
],
|
|
|
|
**kwargs
|
|
|
|
)
|