Attempt to dry up CLI client, add proepr config

This commit is trying to DRY up the initiation of the gRPC client in
each command:

It renames the function to CLI instead of GRPC as it actually set up a
CLI client, not a generic grpc client

It also moves the configuration of address, timeout (which is now
consistent) and api to use Viper, allowing users to set it via env vars
and configuration file
This commit is contained in:
Kristoffer Dalby 2021-11-07 09:41:14 +00:00
parent ce3f79a3bf
commit 2dfd42f80c
7 changed files with 54 additions and 75 deletions

9
app.go
View file

@ -86,6 +86,8 @@ type Config struct {
OIDC OIDCConfig
CLI CLIConfig
MaxMachineRegistrationDuration time.Duration
DefaultMachineRegistrationDuration time.Duration
}
@ -104,6 +106,13 @@ type DERPConfig struct {
UpdateFrequency time.Duration
}
type CLIConfig struct {
Address string
APIKey string
Insecure bool
Timeout time.Duration
}
// Headscale represents the base app of the service.
type Headscale struct {
cfg Config