From 2b1c4fe300730b06328fa6dc7fc51aed96d993d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Wed, 13 May 2026 14:00:19 +0200 Subject: [PATCH] index command: allow passing insecure flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/search/pkg/command/index.go | 14 ++++++++++---- tests/acceptance/bootstrap/CliContext.php | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/services/search/pkg/command/index.go b/services/search/pkg/command/index.go index 64485d9740..3951ee6fd3 100644 --- a/services/search/pkg/command/index.go +++ b/services/search/pkg/command/index.go @@ -31,13 +31,14 @@ func Index(cfg *config.Config) *cobra.Command { allSpacesFlag, _ := cmd.Flags().GetBool("all-spaces") spaceFlag, _ := cmd.Flags().GetString("space") forceRescanFlag, _ := cmd.Flags().GetBool("force-rescan") - endpoint, _ := cmd.Flags().GetString("endpoint") + endpointFlag, _ := cmd.Flags().GetString("endpoint") + insecureFlag, _ := cmd.Flags().GetBool("insecure") if spaceFlag == "" && !allSpacesFlag { return errors.New("either --space or --all-spaces is required") } var dialOpts []grpc.DialOption - if cfg.GRPCClientTLS.Mode == "insecure" { + if cfg.GRPCClientTLS.Mode == "insecure" || insecureFlag { dialOpts = append(dialOpts, grpc.WithTransportCredentials(insecure.NewCredentials())) } else { dialOpts = append(dialOpts, grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{ @@ -45,9 +46,9 @@ func Index(cfg *config.Config) *cobra.Command { }))) } - conn, err := grpc.NewClient(endpoint, dialOpts...) + conn, err := grpc.NewClient(endpointFlag, dialOpts...) if err != nil { - return fmt.Errorf("failed to dial %s: %w", endpoint, err) + return fmt.Errorf("failed to dial %s: %w", endpointFlag, err) } defer conn.Close() @@ -88,6 +89,11 @@ func Index(cfg *config.Config) *cobra.Command { "127.0.0.1:9220", "the address of the search service gRPC endpoint.", ) + indexCmd.Flags().Bool( + "insecure", + false, + "disable TLS for the gRPC connection.", + ) return indexCmd } diff --git a/tests/acceptance/bootstrap/CliContext.php b/tests/acceptance/bootstrap/CliContext.php index cbc6d9b8f1..650e7e3a6b 100644 --- a/tests/acceptance/bootstrap/CliContext.php +++ b/tests/acceptance/bootstrap/CliContext.php @@ -283,7 +283,7 @@ class CliContext implements Context { */ public function theAdministratorReindexesAllSpacesUsingTheCli(): void { $endpoint = $this->featureContext->getBaseUrlHostName(); - $command = "search index --all-spaces --endpoint $endpoint:9220"; + $command = "search index --all-spaces --endpoint $endpoint:9220 --insecure"; $body = [ "command" => $command ]; @@ -300,7 +300,7 @@ class CliContext implements Context { public function theAdministratorReindexesASpaceUsingTheCli(string $spaceName): void { $spaceId = $this->spacesContext->getSpaceIdByName($this->featureContext->getAdminUsername(), $spaceName); $endpoint = $this->featureContext->getBaseUrlHostName(); - $command = "search index --space $spaceId --endpoint $endpoint:9220"; + $command = "search index --space $spaceId --endpoint $endpoint:9220 --insecure"; $body = [ "command" => $command ];