first working version
This commit is contained in:
parent
372915e24d
commit
6da132106f
18 changed files with 519 additions and 96 deletions
|
|
@ -14,7 +14,7 @@ healthCheckNodePort
|
|||
const Version = "v1"
|
||||
|
||||
type LoadBalancer struct {
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name,omitempty"`
|
||||
IP string `json:"ip,omitempty"`
|
||||
Options Options `json:"options,omitempty"`
|
||||
Ports []Port `json:"ports,omitempty"`
|
||||
|
|
@ -37,13 +37,7 @@ type Server struct {
|
|||
Port int `json:"port,omitempty"`
|
||||
}
|
||||
|
||||
func (lb LoadBalancer) Validate() error {
|
||||
if lb.Name == "" {
|
||||
return errors.New("LoadBalancer.Name can not be empty")
|
||||
}
|
||||
if lb.IP == "" {
|
||||
return errors.New("LoadBalancer.IP can not be empty")
|
||||
}
|
||||
func (lb LoadBalancer) ValidateClient() error {
|
||||
for i, p := range lb.Ports {
|
||||
if p.Port < 0 || p.Port > 65535 {
|
||||
return fmt.Errorf("LoadBalancer.Ports[%d].Port is invalid (range 0-65535", i)
|
||||
|
|
@ -63,6 +57,16 @@ func (lb LoadBalancer) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (lb LoadBalancer) ValidateServer() error {
|
||||
if lb.Name == "" {
|
||||
return errors.New("LoadBalancer.Name can not be empty")
|
||||
}
|
||||
if lb.IP == "" {
|
||||
return errors.New("LoadBalancer.IP can not be empty")
|
||||
}
|
||||
return lb.ValidateClient()
|
||||
}
|
||||
|
||||
func (lb LoadBalancer) JSON() ([]byte, error) {
|
||||
return json.Marshal(lb)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue