Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go/cmd/vtgate/vtgate.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ func main() {
vtg := vtgate.Init(context.Background(), healthCheck, resilientServer, *cell, *retryCount, tabletTypes)

servenv.OnRun(func() {
// Flags are parsed now. Parse the template using the actual flag value and overwrite the current template.
discovery.ParseTabletURLTemplateFromFlag()
addStatusParts(vtg)
})
servenv.RunDefault()
Expand Down
8 changes: 4 additions & 4 deletions go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ const (
)

func init() {
loadTabletURLTemplate()
// Flags are not parsed at this point and the default value of the flag (just the hostname) will be used.
ParseTabletURLTemplateFromFlag()
}

// loadTabletURLTemplate loads or reloads the URL template.
// Should only be used independently for testing.
func loadTabletURLTemplate() {
// ParseTabletURLTemplateFromFlag loads or reloads the URL template.
func ParseTabletURLTemplateFromFlag() {
tabletURLTemplate = template.New("")
_, err := tabletURLTemplate.Parse(*tabletURLTemplateString)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go/vt/discovery/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func TestTemplate(t *testing.T) {

func TestDebugURLFormatting(t *testing.T) {
flag.Set("tablet_url_template", "https://{{.GetHostNameLevel 0}}.bastion.{{.Tablet.Alias.Cell}}.corp")
loadTabletURLTemplate()
ParseTabletURLTemplateFromFlag()

tablet := topo.NewTablet(0, "cell", "host.dc.domain")
ts := []*TabletStats{
Expand Down