Skip to content

Commit f155d2a

Browse files
authored
Merge pull request #356 from erizocosmico/feature/readonly
cmd/gitbase: add readonly flag
2 parents 99c828e + 37d26f9 commit f155d2a

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

Gopkg.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
[[constraint]]
22
name = "gopkg.in/src-d/go-mysql-server.v0"
3+
<<<<<<< HEAD
34
revision = "dcc1c537eb7e2bc20ce69d03732e8aa8feaa8612"
5+
=======
6+
revision = "4785fe821326846e344bb2a77c8bcc34d717096e"
7+
>>>>>>> vendor: upgrade go-mysql-server
48

59
[[constraint]]
610
name = "github.com/jessevdk/go-flags"

cmd/gitbase/command/server.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/uber/jaeger-client-go/config"
1919
sqle "gopkg.in/src-d/go-mysql-server.v0"
2020
"gopkg.in/src-d/go-mysql-server.v0/server"
21+
"gopkg.in/src-d/go-mysql-server.v0/sql"
2122
"gopkg.in/src-d/go-mysql-server.v0/sql/analyzer"
2223
"gopkg.in/src-d/go-mysql-server.v0/sql/index/pilosa"
2324
"gopkg.in/src-d/go-vitess.v0/mysql"
@@ -45,7 +46,7 @@ type Server struct {
4546
IndexDir string `short:"i" long:"index" default:"/var/lib/gitbase/index" description:"Directory where the gitbase indexes information will be persisted." env:"GITBASE_INDEX_DIR"`
4647
DisableSquash bool `long:"no-squash" description:"Disables the table squashing."`
4748
TraceEnabled bool `long:"trace" env:"GITBASE_TRACE" description:"Enables jaeger tracing"`
48-
49+
ReadOnly bool `short:"r" long:"readonly" description:"Only allow read queries. This disables creating and deleting indexes as well." env:"GITBASE_READONLY"`
4950
// SkipGitErrors disables failing when Git errors are found.
5051
SkipGitErrors bool
5152

@@ -143,7 +144,13 @@ func (c *Server) Execute(args []string) error {
143144

144145
func (c *Server) buildDatabase() error {
145146
if c.engine == nil {
146-
c.engine = sqle.NewDefault()
147+
catalog := sql.NewCatalog()
148+
ab := analyzer.NewBuilder(catalog)
149+
if c.ReadOnly {
150+
ab = ab.ReadOnly()
151+
}
152+
a := ab.Build()
153+
c.engine = sqle.New(catalog, a)
147154
}
148155

149156
c.pool = gitbase.NewRepositoryPool()

docs/using-gitbase/functions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ To make some common tasks easier for the user, there are some functions to inter
1414

1515
## Standard functions
1616

17+
<<<<<<< HEAD
1718
You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/dcc1c537eb7e2bc20ce69d03732e8aa8feaa8612#custom-functions).
19+
=======
20+
You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/4785fe821326846e344bb2a77c8bcc34d717096e#custom-functions).
21+
>>>>>>> vendor: upgrade go-mysql-server

0 commit comments

Comments
 (0)