mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-25 06:29:15 -05:00
index command: allow passing insecure flag
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user