-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3635 from aduffeck/search
Add initial version of the search extension
- Loading branch information
Showing
79 changed files
with
6,258 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enhancement: Add initial version of the search extensions | ||
|
||
It is now possible to search for files and directories by their name using the web UI. Therefor new search extension indexes files in a persistent local index. | ||
|
||
https://github.com/owncloud/ocis/pull/3635 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/owncloud/ocis/extensions/search/pkg/command" | ||
"github.com/owncloud/ocis/extensions/search/pkg/config/defaults" | ||
) | ||
|
||
func main() { | ||
if err := command.Execute(defaults.DefaultConfig()); err != nil { | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/owncloud/ocis/extensions/search/pkg/config" | ||
"github.com/owncloud/ocis/extensions/search/pkg/config/parser" | ||
"github.com/owncloud/ocis/extensions/search/pkg/logging" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// Health is the entrypoint for the health command. | ||
func Health(cfg *config.Config) *cli.Command { | ||
return &cli.Command{ | ||
Name: "health", | ||
Usage: "check health status", | ||
Category: "info", | ||
Before: func(c *cli.Context) error { | ||
return parser.ParseConfig(cfg) | ||
}, | ||
Action: func(c *cli.Context) error { | ||
logger := logging.Configure(cfg.Service.Name, cfg.Log) | ||
|
||
resp, err := http.Get( | ||
fmt.Sprintf( | ||
"http://%s/healthz", | ||
cfg.Debug.Addr, | ||
), | ||
) | ||
|
||
if err != nil { | ||
logger.Fatal(). | ||
Err(err). | ||
Msg("Failed to request health check") | ||
} | ||
|
||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
logger.Fatal(). | ||
Int("code", resp.StatusCode). | ||
Msg("Health seems to be in bad state") | ||
} | ||
|
||
logger.Debug(). | ||
Int("code", resp.StatusCode). | ||
Msg("Health got a good state") | ||
|
||
return nil | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package command | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/urfave/cli/v2" | ||
|
||
"github.com/owncloud/ocis/extensions/search/pkg/config" | ||
"github.com/owncloud/ocis/extensions/search/pkg/config/parser" | ||
"github.com/owncloud/ocis/ocis-pkg/service/grpc" | ||
searchsvc "github.com/owncloud/ocis/protogen/gen/ocis/services/search/v0" | ||
) | ||
|
||
// Index is the entrypoint for the server command. | ||
func Index(cfg *config.Config) *cli.Command { | ||
return &cli.Command{ | ||
Name: "index", | ||
Usage: "index the files for one one more users", | ||
Category: "index management", | ||
Aliases: []string{"i"}, | ||
Flags: []cli.Flag{ | ||
&cli.StringFlag{ | ||
Name: "space", | ||
Aliases: []string{"s"}, | ||
Required: true, | ||
Usage: "the id of the space to travers and index the files of", | ||
}, | ||
&cli.StringFlag{ | ||
Name: "user", | ||
Aliases: []string{"u"}, | ||
Required: true, | ||
Usage: "the username of the user tha shall be used to access the files", | ||
}, | ||
}, | ||
Before: func(c *cli.Context) error { | ||
return parser.ParseConfig(cfg) | ||
}, | ||
Action: func(c *cli.Context) error { | ||
client := searchsvc.NewSearchProviderService("com.owncloud.api.search", grpc.DefaultClient) | ||
_, err := client.IndexSpace(context.Background(), &searchsvc.IndexSpaceRequest{ | ||
SpaceId: c.String("space"), | ||
UserId: c.String("user"), | ||
}) | ||
if err != nil { | ||
fmt.Println("failed to index space: " + err.Error()) | ||
return err | ||
} | ||
return nil | ||
}, | ||
} | ||
} |
Oops, something went wrong.