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
14 changes: 13 additions & 1 deletion pkg/api/handle_admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ func (s *Server) handleUpdatePostgresSettings(w http.ResponseWriter, r *http.Req
}
defer close()

consul, err := state.NewStore()
if err != nil {
renderErr(w, err)
return
}

user := s.node.PGConfig.UserConfig()

var in map[string]interface{}
Expand Down Expand Up @@ -108,6 +114,12 @@ func (s *Server) handleUpdatePostgresSettings(w http.ResponseWriter, r *http.Req
}}
}

err = flypg.PushUserConfig(s.node.PGConfig, consul)
if err != nil {
renderErr(w, err)
return
}

renderJSON(w, res, http.StatusOK)
}

Expand All @@ -125,7 +137,7 @@ func (s *Server) handleApplyConfig(w http.ResponseWriter, r *http.Request) {
return
}

err = flypg.WriteUserConfig(s.node.PGConfig, consul)
err = flypg.SyncUserConfig(s.node.PGConfig, consul)
if err != nil {
renderErr(w, err)
return
Expand Down
9 changes: 9 additions & 0 deletions pkg/flypg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ func WriteUserConfig(c Config, consul *state.Store) error {
return nil
}

func PushUserConfig(c Config, consul *state.Store) error {
if c.UserConfig() != nil {
if err := pushToConsul(c, consul); err != nil {
return fmt.Errorf("failed to write to consul: %s", err)
}
}
return nil
}

func SyncUserConfig(c Config, consul *state.Store) error {
cfg, err := pullFromConsul(c, consul)
if err != nil {
Expand Down