File tree Expand file tree Collapse file tree 5 files changed +110
-6
lines changed
Expand file tree Collapse file tree 5 files changed +110
-6
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,11 @@ data:
267267 try_files "/install.sh" =404;
268268 }
269269
270+ location /bundle-oss.json {
271+ root /bundle;
272+ try_files "/bundle-oss.json" =404;
273+ }
274+
270275 location / {
271276 return 307 https://work.$domain_name$request_uri;
272277 }
@@ -334,6 +339,11 @@ data:
334339 try_files "/install.sh" =404;
335340 }
336341
342+ location /bundle-oss.json {
343+ root /bundle;
344+ try_files "/bundle-oss.json" =404;
345+ }
346+
337347 location / {
338348 gzip_static off;
339349 root /assets;
Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ container_layer(
3333 ],
3434)
3535
36+ container_layer (
37+ name = "script_bundle" ,
38+ directory = "/bundle" ,
39+ files = [
40+ "//src/pxl_scripts:script_bundle" ,
41+ ],
42+ )
43+
3644container_layer (
3745 name = "entrypoint" ,
3846 directory = "/scripts" ,
@@ -48,6 +56,7 @@ container_image(
4856 layers = [
4957 ":ui_assets" ,
5058 ":installer" ,
59+ ":script_bundle" ,
5160 ":entrypoint" ,
5261 ],
5362 visibility = [
Original file line number Diff line number Diff line change 1414#
1515# SPDX-License-Identifier: Apache-2.0
1616
17+ load ("@rules_foreign_cc//foreign_cc:make.bzl" , "make" )
18+
1719package (default_visibility = ["//src:__subpackages__" ])
1820
1921filegroup (
2022 name = "preset_queries" ,
21- srcs = glob ([
22- "**/*.pxl" ,
23- "**/*.json" ,
24- ]),
23+ srcs = glob (
24+ [
25+ "**/*.pxl" ,
26+ "**/*.json" ,
27+ "**/*.yaml" ,
28+ ],
29+ exclude = ["bundle-oss.json" ],
30+ ),
31+ visibility = ["//src:__subpackages__" ],
32+ )
33+
34+ genrule (
35+ name = "script_bundle" ,
36+ srcs = [
37+ ":Makefile" ,
38+ ":preset_queries" ,
39+ ],
40+ outs = ["bundle-oss.json" ],
41+ cmd = """
42+ export PATH_PREFIX=$$(dirname $(location //src/pxl_scripts:Makefile))/;
43+ EXECUTABLES=../../$(location //src/pixie_cli:px) make -C $$PATH_PREFIX bundle-oss.json;
44+ cp bundle-oss.json $(@D)/bundle-oss.json
45+ """ ,
46+ tools = [
47+ "//src/pixie_cli:px" ,
48+ ],
2549 visibility = ["//src:__subpackages__" ],
2650)
51+
52+ sh_test (
53+ name = "script_bundle_test" ,
54+ srcs = ["test_script_bundle.sh" ],
55+ args = [
56+ "$(location :script_bundle)" ,
57+ "$(location @com_github_mikefarah_yq_v4//:v4)" ,
58+ ],
59+ data = [
60+ ":script_bundle" ,
61+ "@com_github_mikefarah_yq_v4//:v4" ,
62+ ],
63+ )
Original file line number Diff line number Diff line change 1818dirs := bpftrace px pxbeta sotw
1919script_files := $(foreach dir,$(dirs ) ,$(wildcard $(dir ) /** /* ) )
2020
21- EXECUTABLES = px
21+ EXECUTABLES ? = px
2222K := $(foreach exec,$(EXECUTABLES ) ,\
2323 $(if $(shell which $(exec ) ) ,some string,$(error "No $(exec ) in PATH") ) )
2424
25+ # Optional path prefix to use for the script_files path. Used by bazel
26+ # to ensure the scripts are in the correct location.
27+ PATH_PREFIX ?= ""
28+
2529all : bundle-oss.json.gz
2630
2731bundle-oss.json : $(script_files )
28- px create-bundle --search_path $(PWD ) $(foreach dir,$(dirs ) ,--base $(dir ) ) -o $(PWD ) /bundle-oss.json
32+
33+ @# When run in CI, $HOME may not be set. This ensures that the
34+ @# px create-bundle command can run successfully.
35+ @if [ -z "$$HOME" ]; then \
36+ TMPDIR=$$(mktemp -d); \
37+ export HOME=$$TMPDIR; \
38+ trap "rm -rf $$TMPDIR" EXIT; \
39+ fi; \
40+ $(EXECUTABLES) create-bundle --search_path $(PWD) $(foreach dir,$(dirs),--base $(PATH_PREFIX)$(dir)) -o $(PWD)/bundle-oss.json
2941
3042bundle-oss.json.gz : bundle-oss.json
3143 gzip -c $< > $@
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Copyright 2018- The Pixie Authors.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+ #
16+ # SPDX-License-Identifier: Apache-2.0
17+
18+ set -e
19+
20+ BUNDLE_FILE=" $1 "
21+ YQ_BIN=" $2 "
22+
23+ if [ ! -f " $BUNDLE_FILE " ]; then
24+ echo " Error: Bundle file not found: $BUNDLE_FILE "
25+ exit 1
26+ fi
27+
28+ # Check that scripts object has keys
29+ NUM_SCRIPTS=$( " $YQ_BIN " eval ' .scripts | keys | length' " $BUNDLE_FILE " )
30+
31+ if [ " $NUM_SCRIPTS " -eq 0 ]; then
32+ echo " Error: No scripts found in bundle"
33+ exit 1
34+ fi
35+
36+ echo " Success: Found $NUM_SCRIPTS scripts in bundle"
You can’t perform that action at this time.
0 commit comments