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
10 changes: 10 additions & 0 deletions k8s/cloud/base/proxy_nginx_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ data:
try_files "/install.sh" =404;
}

location /bundle-oss.json {
root /bundle;
try_files "/bundle-oss.json" =404;
}

location / {
return 307 https://work.$domain_name$request_uri;
}
Expand Down Expand Up @@ -334,6 +339,11 @@ data:
try_files "/install.sh" =404;
}

location /bundle-oss.json {
root /bundle;
try_files "/bundle-oss.json" =404;
}

location / {
gzip_static off;
root /assets;
Expand Down
9 changes: 9 additions & 0 deletions src/cloud/proxy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ container_layer(
],
)

container_layer(
name = "script_bundle",
directory = "/bundle",
files = [
"//src/pxl_scripts:script_bundle",
],
)

container_layer(
name = "entrypoint",
directory = "/scripts",
Expand All @@ -48,6 +56,7 @@ container_image(
layers = [
":ui_assets",
":installer",
":script_bundle",
":entrypoint",
],
visibility = [
Expand Down
45 changes: 41 additions & 4 deletions src/pxl_scripts/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,50 @@
#
# SPDX-License-Identifier: Apache-2.0

load("@rules_foreign_cc//foreign_cc:make.bzl", "make")

package(default_visibility = ["//src:__subpackages__"])

filegroup(
name = "preset_queries",
srcs = glob([
"**/*.pxl",
"**/*.json",
]),
srcs = glob(
[
"**/*.pxl",
"**/*.json",
"**/*.yaml",
],
exclude = ["bundle-oss.json"],
),
visibility = ["//src:__subpackages__"],
)

genrule(
name = "script_bundle",
srcs = [
":Makefile",
":preset_queries",
],
outs = ["bundle-oss.json"],
cmd = """
export PATH_PREFIX=$$(dirname $(location //src/pxl_scripts:Makefile))/;
EXECUTABLES=../../$(location //src/pixie_cli:px) make -C $$PATH_PREFIX bundle-oss.json;
cp bundle-oss.json $(@D)/bundle-oss.json
""",
tools = [
"//src/pixie_cli:px",
],
visibility = ["//src:__subpackages__"],
)

sh_test(
name = "script_bundle_test",
srcs = ["test_script_bundle.sh"],
args = [
"$(location :script_bundle)",
"$(location @com_github_mikefarah_yq_v4//:v4)",
],
data = [
":script_bundle",
"@com_github_mikefarah_yq_v4//:v4",
],
)
16 changes: 14 additions & 2 deletions src/pxl_scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,26 @@
dirs := bpftrace px pxbeta sotw
script_files := $(foreach dir,$(dirs),$(wildcard $(dir)/**/*))

EXECUTABLES = px
EXECUTABLES ?= px
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))

# Optional path prefix to use for the script_files path. Used by bazel
# to ensure the scripts are in the correct location.
PATH_PREFIX ?= ""

all: bundle-oss.json.gz

bundle-oss.json: $(script_files)
px create-bundle --search_path $(PWD) $(foreach dir,$(dirs),--base $(dir)) -o $(PWD)/bundle-oss.json

@# When run in CI, $HOME may not be set. This ensures that the
@# px create-bundle command can run successfully.
@if [ -z "$$HOME" ]; then \
TMPDIR=$$(mktemp -d); \
export HOME=$$TMPDIR; \
trap "rm -rf $$TMPDIR" EXIT; \
fi; \
$(EXECUTABLES) create-bundle --search_path $(PWD) $(foreach dir,$(dirs),--base $(PATH_PREFIX)$(dir)) -o $(PWD)/bundle-oss.json

bundle-oss.json.gz: bundle-oss.json
gzip -c $< > $@
Expand Down
36 changes: 36 additions & 0 deletions src/pxl_scripts/test_script_bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash
# Copyright 2018- The Pixie Authors.
#
# Licensed 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.
#
# SPDX-License-Identifier: Apache-2.0

set -e

BUNDLE_FILE="$1"
YQ_BIN="$2"

if [ ! -f "$BUNDLE_FILE" ]; then
echo "Error: Bundle file not found: $BUNDLE_FILE"
exit 1
fi

# Check that scripts object has keys
NUM_SCRIPTS=$("$YQ_BIN" eval '.scripts | keys | length' "$BUNDLE_FILE")

if [ "$NUM_SCRIPTS" -eq 0 ]; then
echo "Error: No scripts found in bundle"
exit 1
fi

echo "Success: Found $NUM_SCRIPTS scripts in bundle"