mirror of
https://github.com/Luzifer/vault-user-token.git
synced 2024-12-20 21:01:20 +00:00
Support shortening hostnames to first part
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
53fc4b4ae3
commit
193e4d3884
1 changed files with 7 additions and 0 deletions
7
main.go
7
main.go
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Luzifer/rconfig"
|
"github.com/Luzifer/rconfig"
|
||||||
|
@ -16,6 +17,8 @@ var (
|
||||||
cfg = struct {
|
cfg = struct {
|
||||||
LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warning, error)"`
|
LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warning, error)"`
|
||||||
|
|
||||||
|
UseFullHostname bool `flag:"full-hostname" default:"true" description:"Use the full reported hostname (true) or only the first part (false)"`
|
||||||
|
|
||||||
VaultAddress string `flag:"vault-addr" env:"VAULT_ADDR" default:"https://127.0.0.1:8200" description:"Vault API address"`
|
VaultAddress string `flag:"vault-addr" env:"VAULT_ADDR" default:"https://127.0.0.1:8200" description:"Vault API address"`
|
||||||
VaultRoleID string `flag:"vault-role-id" env:"VAULT_ROLE_ID" default:"" description:"ID of the role to use"`
|
VaultRoleID string `flag:"vault-role-id" env:"VAULT_ROLE_ID" default:"" description:"ID of the role to use"`
|
||||||
|
|
||||||
|
@ -52,6 +55,10 @@ func init() {
|
||||||
if hostname, err = os.Hostname(); err != nil {
|
if hostname, err = os.Hostname(); err != nil {
|
||||||
log.Fatalf("Could not resolve hostname: %s", err)
|
log.Fatalf("Could not resolve hostname: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if parts := strings.Split(hostname, "."); !cfg.UseFullHostname && len(parts) > 1 {
|
||||||
|
hostname = parts[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue