Hostname as name by default
diff --git a/data.go b/data.go index e93971b..6e9fc2b 100644 --- a/data.go +++ b/data.go
@@ -11,17 +11,17 @@ var ( unsafeDB apid.DB - dbMux sync.RWMutex + dbMux sync.RWMutex ) type dataApidCluster struct { ChangeSelector, ID, Name, OrgAppName, CreatedBy, UpdatedBy, Description string - Updated, Created string + Updated, Created string } type dataDataScope struct { ChangeSelector, ID, ClusterID, Scope, Org, Env, CreatedBy, UpdatedBy string - Updated, Created string + Updated, Created string } /* @@ -266,11 +266,7 @@ db.Exec("INSERT INTO APID (instance_id) VALUES (?)", info.InstanceID) } } - - // if name not explicitly configured, just use InstanceID - config.SetDefault(configName, info.InstanceID) info.InstanceName = config.GetString(configName) - // not stored in DB info.ClusterID = config.GetString(configApidClusterId) @@ -304,6 +300,8 @@ /* * generates a random uuid (mix of timestamp & crypto random string) */ + +//TODO: Change to https://tools.ietf.org/html/rfc4122 based implementation such as https://github.com/google/uuid func generateUUID() string { buff := make([]byte, 16)
diff --git a/init.go b/init.go index 22371fa..0a04525 100644 --- a/init.go +++ b/init.go
@@ -4,6 +4,7 @@ "encoding/json" "fmt" "github.com/30x/apid" + "os" ) const ( @@ -48,6 +49,15 @@ config = services.Config() config.SetDefault(configPollInterval, 120) + log.Infof("Setting defaults") + { + name, errh := os.Hostname() + if errh != nil & config.GetString(configName) == nil { + panic(fmt.Errorf("Not able to get hostname for kernel. Please set '%s' property in config",configName)) + } + log.Infof("Hostname reported by kernel : %s", name) + config.SetDefault(configName, name) + } data = services.Data() events = services.Events()