index command: allow passing insecure flag

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2026-05-13 14:00:19 +02:00
parent 13c7af7f7f
commit 2b1c4fe300
2 changed files with 12 additions and 6 deletions

View File

@@ -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
}

View File

@@ -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
];