feat: initial release
This commit is contained in:
parent
a3cf21f5bd
commit
1e0ee5bffe
40 changed files with 2007 additions and 217 deletions
70
internal/config/host.go
Normal file
70
internal/config/host.go
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
type HostConfig struct {
|
||||
Domain string `toml:"domain"`
|
||||
IpAddress string `toml:"ip"`
|
||||
LocalAddress string `toml:"local_address"`
|
||||
InternalEntrypoint string `toml:"internal_entrypoint"`
|
||||
ExternalEntrypoint string `toml:"external_entrypoint"`
|
||||
baseRoleConfig
|
||||
}
|
||||
|
||||
func (c HostConfig) Validate() error {
|
||||
if c.Domain == "" {
|
||||
return errors.New("missing domain")
|
||||
}
|
||||
|
||||
if c.IpAddress == "" {
|
||||
return errors.New("missing ip")
|
||||
}
|
||||
|
||||
if net.ParseIP(c.IpAddress) == nil {
|
||||
return fmt.Errorf("invalid ip: %q", c.IpAddress)
|
||||
}
|
||||
|
||||
if c.LocalAddress == "" {
|
||||
return errors.New("missing local address")
|
||||
}
|
||||
|
||||
if c.InternalEntrypoint == "" {
|
||||
return errors.New("missing internal entrypoint")
|
||||
}
|
||||
|
||||
if c.ExternalEntrypoint == "" {
|
||||
return errors.New("missing external entrypoint")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *HostConfig) Merge(other HostConfig) {
|
||||
if other.set {
|
||||
c.set = other.set
|
||||
}
|
||||
|
||||
if other.Domain != "" {
|
||||
c.Domain = other.Domain
|
||||
}
|
||||
|
||||
if other.IpAddress != "" {
|
||||
c.IpAddress = other.IpAddress
|
||||
}
|
||||
|
||||
if other.LocalAddress != "" {
|
||||
c.LocalAddress = other.LocalAddress
|
||||
}
|
||||
|
||||
if other.InternalEntrypoint != "" {
|
||||
c.InternalEntrypoint = other.InternalEntrypoint
|
||||
}
|
||||
|
||||
if other.ExternalEntrypoint != "" {
|
||||
c.ExternalEntrypoint = other.ExternalEntrypoint
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue