Skip to content

script: Add script autocomplete functionality #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025

Conversation

dylandreimerink
Copy link
Member

This commit updates the hive dependency and adds autocomplete functionality for the script commands.

A practical example of the proposed hive script tab completion.

This PR is blocked on cilium/hive#57, we should bump hive dependency to a proper release as soon as the PR merges.

Copy link

github-actions bot commented Jul 14, 2025

$ make
go build ./...
go: downloading go1.24.0 (linux/amd64)
go: downloading go.yaml.in/yaml/v3 v3.0.3
go: downloading github.com/cilium/hive v0.0.0-20250731144630-28e7a35ed227
go: downloading golang.org/x/time v0.5.0
go: downloading github.com/spf13/cobra v1.8.0
go: downloading github.com/spf13/pflag v1.0.5
go: downloading github.com/cilium/stream v0.0.0-20240209152734-a0792b51812d
go: downloading github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de
go: downloading github.com/spf13/viper v1.18.2
go: downloading go.uber.org/dig v1.17.1
go: downloading golang.org/x/term v0.16.0
go: downloading github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
go: downloading github.com/mitchellh/mapstructure v1.5.0
go: downloading golang.org/x/sys v0.17.0
go: downloading golang.org/x/tools v0.17.0
go: downloading github.com/spf13/cast v1.6.0
go: downloading github.com/fsnotify/fsnotify v1.7.0
go: downloading github.com/sagikazarmark/slog-shim v0.1.0
go: downloading github.com/spf13/afero v1.11.0
go: downloading golang.org/x/text v0.14.0
go: downloading github.com/subosito/gotenv v1.6.0
go: downloading github.com/hashicorp/hcl v1.0.0
go: downloading gopkg.in/ini.v1 v1.67.0
go: downloading github.com/magiconair/properties v1.8.7
go: downloading github.com/pelletier/go-toml/v2 v2.1.0
go: downloading gopkg.in/yaml.v3 v3.0.1
go test ./... -cover -vet=all -test.count 1
go: downloading github.com/stretchr/testify v1.8.4
go: downloading go.uber.org/goleak v1.3.0
go: downloading golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
go: downloading github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
ok  	github.com/cilium/statedb	22.141s	coverage: 80.9% of statements
ok  	github.com/cilium/statedb/index	0.005s	coverage: 28.7% of statements
ok  	github.com/cilium/statedb/internal	0.017s	coverage: 46.7% of statements
ok  	github.com/cilium/statedb/part	5.013s	coverage: 87.6% of statements
ok  	github.com/cilium/statedb/reconciler	0.258s	coverage: 89.7% of statements
	github.com/cilium/statedb/reconciler/benchmark		coverage: 0.0% of statements
	github.com/cilium/statedb/reconciler/example		coverage: 0.0% of statements
go test -race ./... -test.count 1
ok  	github.com/cilium/statedb	101.069s
ok  	github.com/cilium/statedb/index	1.013s
ok  	github.com/cilium/statedb/internal	1.030s
ok  	github.com/cilium/statedb/part	35.718s
ok  	github.com/cilium/statedb/reconciler	1.332s
?   	github.com/cilium/statedb/reconciler/benchmark	[no test files]
?   	github.com/cilium/statedb/reconciler/example	[no test files]
go test ./... -bench . -benchmem -test.run xxx
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb
cpu: AMD EPYC 7763 64-Core Processor                
BenchmarkDB_WriteTxn_1-4                    	  541855	      2209 ns/op	    452759 objects/sec	    1416 B/op	      26 allocs/op
BenchmarkDB_WriteTxn_10-4                   	 1429582	       847.2 ns/op	   1180299 objects/sec	     481 B/op	       9 allocs/op
BenchmarkDB_WriteTxn_100-4                  	 1911676	       628.1 ns/op	   1592043 objects/sec	     400 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_1000-4                 	 1822786	       659.4 ns/op	   1516427 objects/sec	     363 B/op	       7 allocs/op
BenchmarkDB_WriteTxn_100_SecondaryIndex-4   	  560982	      1994 ns/op	    501382 objects/sec	    1213 B/op	      37 allocs/op
BenchmarkDB_NewWriteTxn-4                   	 1464766	       819.0 ns/op	     544 B/op	       8 allocs/op
BenchmarkDB_NewReadTxn-4                    	550353666	         2.189 ns/op	       0 B/op	       0 allocs/op
BenchmarkDB_Modify-4                        	    1687	    723964 ns/op	   1381285 objects/sec	  423352 B/op	    8143 allocs/op
BenchmarkDB_GetInsert-4                     	    1500	    814111 ns/op	   1228333 objects/sec	  405181 B/op	    8140 allocs/op
BenchmarkDB_RandomInsert-4                  	    1767	    693277 ns/op	   1442425 objects/sec	  397912 B/op	    7142 allocs/op
BenchmarkDB_RandomReplace-4                 	     373	   3221898 ns/op	    310376 objects/sec	 1975302 B/op	   49160 allocs/op
BenchmarkDB_SequentialInsert-4              	    1878	    663899 ns/op	   1506253 objects/sec	  363668 B/op	    7113 allocs/op
BenchmarkDB_SequentialInsert_Prefix-4       	     376	   3022220 ns/op	    330883 objects/sec	 3718046 B/op	   58568 allocs/op
BenchmarkDB_Changes_Baseline-4              	    1406	    848535 ns/op	   1178502 objects/sec	  433539 B/op	   10214 allocs/op
BenchmarkDB_Changes-4                       	     799	   1494116 ns/op	    669292 objects/sec	  755501 B/op	   14420 allocs/op
BenchmarkDB_RandomLookup-4                  	   21578	     55746 ns/op	  17938658 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_SequentialLookup-4              	   25136	     47753 ns/op	  20941154 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_Prefix_SecondaryIndex-4         	    6564	    163026 ns/op	   6134009 objects/sec	  125114 B/op	    1031 allocs/op
BenchmarkDB_FullIteration_All-4             	    1153	   1052084 ns/op	  95049461 objects/sec	     320 B/op	      11 allocs/op
BenchmarkDB_FullIteration_Get-4             	     207	   5962520 ns/op	  16771433 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_FullIteration_ReadTxnGet-4      	     184	   6484649 ns/op	  15421036 objects/sec	       0 B/op	       0 allocs/op
BenchmarkDB_PropagationDelay-4              	  607340	      1975 ns/op	        17.00 50th_µs	        20.00 90th_µs	        41.00 99th_µs	    1070 B/op	      22 allocs/op
BenchmarkWatchSet_4-4                       	 1330206	       899.0 ns/op	     499 B/op	       7 allocs/op
BenchmarkWatchSet_16-4                      	  509937	      2385 ns/op	    1699 B/op	       8 allocs/op
BenchmarkWatchSet_128-4                     	   62520	     19249 ns/op	   13406 B/op	       8 allocs/op
BenchmarkWatchSet_1024-4                    	    6007	    193289 ns/op	  106414 B/op	       8 allocs/op
PASS
ok  	github.com/cilium/statedb	33.715s
PASS
ok  	github.com/cilium/statedb/index	0.003s
PASS
ok  	github.com/cilium/statedb/internal	0.003s
goos: linux
goarch: amd64
pkg: github.com/cilium/statedb/part
cpu: AMD EPYC 7763 64-Core Processor                
Benchmark_Uint64Map_Random-4        	    1288	    892129 ns/op	   1120914 items/sec	 2811861 B/op	   11026 allocs/op
Benchmark_Uint64Map_Sequential-4    	    1424	    832662 ns/op	   1200968 items/sec	 2591251 B/op	   11749 allocs/op
Benchmark_Insert_RootOnlyWatch-4    	   10000	    120547 ns/op	   8295529 objects/sec	   74539 B/op	    2044 allocs/op
Benchmark_Insert-4                  	    6842	    175225 ns/op	   5706939 objects/sec	  190508 B/op	    3076 allocs/op
Benchmark_Modify-4                  	   10000	    103408 ns/op	   9670410 objects/sec	   72042 B/op	    1028 allocs/op
Benchmark_GetInsert-4               	    8293	    142392 ns/op	   7022878 objects/sec	   72170 B/op	    1028 allocs/op
Benchmark_Replace-4                 	27658749	        42.97 ns/op	  23269495 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Replace_RootOnlyWatch-4   	27551245	        42.97 ns/op	  23274688 objects/sec	       0 B/op	       0 allocs/op
Benchmark_txn_1-4                   	 3211732	       372.2 ns/op	   2686969 objects/sec	     280 B/op	       5 allocs/op
Benchmark_txn_10-4                  	 8437656	       140.7 ns/op	   7107560 objects/sec	      97 B/op	       2 allocs/op
Benchmark_txn_100-4                 	10502764	       114.7 ns/op	   8721567 objects/sec	      91 B/op	       2 allocs/op
Benchmark_txn_1000-4                	 9540454	       125.2 ns/op	   7987880 objects/sec	      78 B/op	       2 allocs/op
Benchmark_txn_delete_1-4            	 1539588	       777.1 ns/op	   1286826 objects/sec	    3272 B/op	       8 allocs/op
Benchmark_txn_delete_10-4           	 7060257	       167.3 ns/op	   5977180 objects/sec	     368 B/op	       2 allocs/op
Benchmark_txn_delete_100-4          	11077084	       107.7 ns/op	   9288902 objects/sec	      82 B/op	       1 allocs/op
Benchmark_txn_delete_1000-4         	11793723	       100.5 ns/op	   9948604 objects/sec	      28 B/op	       1 allocs/op
Benchmark_Get-4                     	   33933	     35405 ns/op	  28244785 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Iterate-4                 	  168440	      7260 ns/op	 137741887 objects/sec	     104 B/op	       4 allocs/op
Benchmark_Hashmap_Insert-4          	   14868	     80650 ns/op	  12399268 objects/sec	   74265 B/op	      20 allocs/op
Benchmark_Hashmap_Get_Uint64-4      	  138403	      8634 ns/op	 115827331 objects/sec	       0 B/op	       0 allocs/op
Benchmark_Hashmap_Get_Bytes-4       	  110961	     10809 ns/op	  92514137 objects/sec	       0 B/op	       0 allocs/op
PASS
ok  	github.com/cilium/statedb/part	26.854s
PASS
ok  	github.com/cilium/statedb/reconciler	0.004s
?   	github.com/cilium/statedb/reconciler/benchmark	[no test files]
?   	github.com/cilium/statedb/reconciler/example	[no test files]
go run ./reconciler/benchmark -quiet
1000000 objects reconciled in 2.36 seconds (batch size 1000)
Throughput 423397.11 objects per second
1167MB total allocated, 6011130 in-use objects, 353MB bytes in use

@dylandreimerink dylandreimerink force-pushed the feature/shell-autocomplete branch 2 times, most recently from 0d2601c to 5f61250 Compare July 24, 2025 08:54
This commit updates the hive dependency and adds autocomplete
functionality for the script commands.

Signed-off-by: Dylan Reimerink <dylan.reimerink@isovalent.com>
@dylandreimerink dylandreimerink force-pushed the feature/shell-autocomplete branch from 5f61250 to 990a577 Compare July 31, 2025 15:13
@dylandreimerink dylandreimerink marked this pull request as ready for review July 31, 2025 15:14
@dylandreimerink dylandreimerink requested a review from a team as a code owner July 31, 2025 15:14
@dylandreimerink dylandreimerink requested review from derailed and removed request for a team July 31, 2025 15:14
@dylandreimerink dylandreimerink merged commit cef60d5 into main Jul 31, 2025
1 check passed
@dylandreimerink dylandreimerink deleted the feature/shell-autocomplete branch July 31, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants