Skip to content

Commit

Permalink
yaml: add -tablet_config to read yaml
Browse files Browse the repository at this point in the history
Signed-off-by: Sugu Sougoumarane <[email protected]>
  • Loading branch information
sougou committed Apr 19, 2020
1 parent ea22e4e commit 8f93fc4
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions go/cmd/vttablet/vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package main

import (
"flag"
"io/ioutil"

"golang.org/x/net/context"
"sigs.k8s.io/yaml"
"vitess.io/vitess/go/vt/dbconfigs"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/mysqlctl"
Expand All @@ -39,6 +41,7 @@ var (
tableACLConfig = flag.String("table-acl-config", "", "path to table access checker config file; send SIGHUP to reload this file")
tableACLConfigReloadInterval = flag.Duration("table-acl-config-reload-interval", 0, "Ticker to reload ACLs")
tabletPath = flag.String("tablet-path", "", "tablet alias")
tabletConfig = flag.String("tablet_config", "", "YAML file config for tablet")

agent *tabletmanager.ActionAgent
)
Expand All @@ -53,11 +56,23 @@ func main() {

servenv.ParseFlags("vttablet")

if err := tabletenv.NewCurrentConfig().Verify(); err != nil {
config := tabletenv.NewCurrentConfig()
if err := config.Verify(); err != nil {
log.Exitf("invalid config: %v", err)
}

tabletenv.Init()
if *tabletConfig != "" {
bytes, err := ioutil.ReadFile(*tabletConfig)
if err != nil {
log.Exitf("error reading config file %s: %v", *tabletConfig, err)
}
if err := yaml.Unmarshal(bytes, config); err != nil {
log.Exitf("error parsing config file %s: %v", bytes, err)
}
gotBytes, _ := yaml.Marshal(config)
log.Infof("Loaded config file %s successfully:\n%s", *tabletConfig, gotBytes)
}

servenv.Init()

Expand Down Expand Up @@ -102,7 +117,7 @@ func main() {

// creates and registers the query service
ts := topo.Open()
qsc := tabletserver.NewServer("", ts, *tabletAlias)
qsc := tabletserver.NewTabletServer("", config, ts, *tabletAlias)
servenv.OnRun(func() {
qsc.Register()
addStatusParts(qsc)
Expand Down

0 comments on commit 8f93fc4

Please sign in to comment.