File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import (
2828 "encoding/json"
2929 "errors"
3030 "io/ioutil"
31+ "net/url"
3132 "os"
3233 "path/filepath"
3334 "strconv"
@@ -220,7 +221,23 @@ func (s *Service) GetROSource() configuration.ROSource {
220221// response: but not all of them! some vars will likely only get parsed at deployment time i.e. right
221222// before pushing TaskInfos
222223func (s * Service ) GetDefaults () map [string ]string {
223- return s .getStringMap (filepath .Join (s .GetConsulPath (),"defaults" ))
224+ smap := s .getStringMap (filepath .Join (s .GetConsulPath (),"defaults" ))
225+
226+ // Fill in some global constants we want to make available everywhere
227+ globalConfigurationUri := viper .GetString ("globalConfigurationUri" )
228+ smap ["consul_base_uri" ] = globalConfigurationUri
229+ consulUrl , err := url .ParseRequestURI (globalConfigurationUri )
230+ if err == nil {
231+ smap ["consul_hostname" ] = consulUrl .Hostname ()
232+ smap ["consul_port" ] = consulUrl .Port ()
233+ smap ["consul_endpoint" ] = consulUrl .Host
234+ } else {
235+ log .WithField ("globalConfigurationUri" , globalConfigurationUri ).
236+ Warn ("cannot parse global configuration endpoint" )
237+ }
238+ smap ["framework_id" ], _ = s .GetMesosFID ()
239+ smap ["core_hostname" ], _ = os .Hostname ()
240+ return smap
224241}
225242
226243func (s * Service ) GetVars () map [string ]string {
You can’t perform that action at this time.
0 commit comments