feat(cmd): Added machine ID mode to zitadel start up logs (#8251)

# Which Problems Are Solved

Logs the type of sonyflake strategy used for generating unique machine
IDs

# How the Problems Are Solved

- Created function to log machine id strategy on the start up logs

# Additional Changes
- Added public function for retrieving current strategy set by
configuration

# Additional Context
- Closes #7750
This commit is contained in:
Norman-Lee
2024-07-16 04:53:57 -05:00
committed by GitHub
parent 7d0c7e5b54
commit 1e3b350042
2 changed files with 23 additions and 5 deletions

View File

@@ -89,6 +89,22 @@ func isPrivateIPv4(ip net.IP) bool {
(ip[0] == 10 || ip[0] == 172 && (ip[1] >= 16 && ip[1] < 32) || ip[0] == 192 && ip[1] == 168)
}
func MachineIdentificationMethod() string {
if GeneratorConfig.Identification.PrivateIp.Enabled {
return "Private Ip"
}
if GeneratorConfig.Identification.Hostname.Enabled {
return "Hostname"
}
if GeneratorConfig.Identification.Webhook.Enabled {
return "Webhook"
}
return "No machine identification method has been enabled"
}
func machineID() (uint16, error) {
if GeneratorConfig == nil {
logging.Panic("cannot create a unique id for the machine, generator has not been configured")