Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ BAZEL_BUILD_OPTIONS+=(
bazel build "${BAZEL_BUILD_OPTIONS[@]}" //tools/docs:extensions_security_rst

# Generate RST for external dependency docs in intro/arch_overview/security.
bazel run "${BAZEL_BUILD_OPTIONS[@]}" //tools/dependency:generate_external_dep_rst
bazel build "${BAZEL_BUILD_OPTIONS[@]}" //tools/docs:external_deps_rst

function generate_api_rst() {
local proto_target
Expand Down Expand Up @@ -145,8 +145,9 @@ rsync -av \
"${SCRIPT_DIR}"/_ext \
"${GENERATED_RST_DIR}"

# TODO(phlax): once all of above jobs are moved to bazel build genrules this can be done as part of the sphinx build
tar -xf bazel-out/k8-fastbuild/bin/tools/docs/extensions_security_rst.tar -C "${GENERATED_RST_DIR}"
# TODO(phlax): once all of above jobs are moved to bazel build genrules these can be done as part of the sphinx build
tar -xf bazel-bin/tools/docs/extensions_security_rst.tar -C "${GENERATED_RST_DIR}"
tar -xf bazel-bin/tools/docs/external_deps_rst.tar -C "${GENERATED_RST_DIR}"

# Merge generated redirects
jq -r 'with_entries(.key |= sub("^envoy/";"api-v3/")) | with_entries(.value |= sub("^envoy/";"api-v2/")) | to_entries[] | "\(.value)\t\t\(.key)"' docs/v2_mapping.json >> "${GENERATED_RST_DIR}"/redirects.txt
Expand Down
17 changes: 6 additions & 11 deletions tools/dependency/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
load("@deps_pip3//:requirements.bzl", "requirement")
load("//bazel:envoy_build_system.bzl", "envoy_package")
load("//tools/base:envoy_python.bzl", "envoy_py_binary")
Expand All @@ -7,7 +7,7 @@ licenses(["notice"]) # Apache 2

envoy_package()

py_binary(
py_library(
name = "exports",
srcs = ["exports.py"],
data = [
Expand All @@ -17,15 +17,10 @@ py_binary(
],
)

py_binary(
name = "generate_external_dep_rst",
srcs = [
"generate_external_dep_rst.py",
"utils.py",
],
data = [
":exports",
],
py_library(
name = "utils",
srcs = ["utils.py"],
deps = [":exports"],
)

py_binary(
Expand Down
2 changes: 1 addition & 1 deletion tools/dependency/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections import namedtuple

from exports import (
from tools.dependency.exports import (
api_repository_locations, envoy_repository_locations, repository_locations_utils)


Expand Down
25 changes: 25 additions & 0 deletions tools/docs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,28 @@ genrule(
),
tools = [":generate_extensions_security_rst"],
)

py_binary(
name = "generate_external_deps_rst",
srcs = [
"generate_external_deps_rst.py",
],
deps = [
"//tools/dependency:exports",
"//tools/dependency:utils",
],
)

genrule(
name = "external_deps_rst",
srcs = [
"//bazel:repository_locations.bzl",
"@envoy_api_canonical//bazel:repository_locations.bzl",
"@envoy_api_canonical//bazel:repository_locations_utils.bzl",
],
outs = ["external_deps_rst.tar"],
cmd = (
"$(location generate_external_deps_rst) $@"
),
tools = [":generate_external_deps_rst"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import pathlib
import sys
import tarfile
import urllib.parse

from tools.dependency import utils as dep_utils
Expand Down Expand Up @@ -67,13 +68,13 @@ def get_version_url(metadata):
return f'{github_repo}/tree/{github_release.version}'


if __name__ == '__main__':
try:
generated_rst_dir = os.getenv("GENERATED_RST_DIR") or sys.argv[1]
except IndexError:
raise SystemExit(
"Output dir path must be either specified as arg or with GENERATED_RST_DIR env var")
def csv_row(dep):
return [dep.name, dep.version, dep.release_date, dep.cpe]


def main():
output_filename = sys.argv[1]
generated_rst_dir = os.path.dirname(output_filename)
security_rst_root = os.path.join(generated_rst_dir, "intro/arch_overview/security")

pathlib.Path(security_rst_root).mkdir(parents=True, exist_ok=True)
Expand All @@ -97,9 +98,6 @@ def get_version_url(metadata):
for ext in v.get('extensions', ['core']):
use_categories[category][ext].append(dep)

def csv_row(dep):
return [dep.name, dep.version, dep.release_date, dep.cpe]

# Generate per-use category RST with CSV tables.
for category, exts in use_categories.items():
content = ''
Expand All @@ -110,3 +108,10 @@ def csv_row(dep):
content += csv_table(['Name', 'Version', 'Release date', 'CPE'], [2, 1, 1, 2],
[csv_row(dep) for dep in sorted(deps, key=lambda d: d.sort_name)])
output_path.write_text(content)

with tarfile.open(output_filename, "w") as tar:
tar.add(generated_rst_dir, arcname=".")


if __name__ == '__main__':
sys.exit(main())