Revert UUID purge
This commit is contained in:
parent
65d815aa8b
commit
c6465ec429
3
main.go
3
main.go
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/thefeli73/polemos/mtdaws"
|
"github.com/thefeli73/polemos/mtdaws"
|
||||||
"github.com/thefeli73/polemos/state"
|
"github.com/thefeli73/polemos/state"
|
||||||
)
|
)
|
||||||
@ -72,7 +73,9 @@ func indexInstance(config state.Config, cloudID string, serviceIP netip.Addr) (s
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
u := uuid.New()
|
||||||
newService := state.Service{
|
newService := state.Service{
|
||||||
|
ID: state.CustomUUID(u),
|
||||||
CloudID: cloudID,
|
CloudID: cloudID,
|
||||||
ServiceIP: serviceIP}
|
ServiceIP: serviceIP}
|
||||||
return newService, found
|
return newService, found
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"net/netip"
|
"net/netip"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ type mtdconf struct {
|
|||||||
|
|
||||||
// Service contains all necessary information about a service to identify it in the cloud as well as configuring a proxy for it
|
// Service contains all necessary information about a service to identify it in the cloud as well as configuring a proxy for it
|
||||||
type Service struct {
|
type Service struct {
|
||||||
|
ID CustomUUID `yaml:"id"`
|
||||||
CloudID string `yaml:"cloud_id"`
|
CloudID string `yaml:"cloud_id"`
|
||||||
EntryIP netip.Addr `yaml:"entry_ip"`
|
EntryIP netip.Addr `yaml:"entry_ip"`
|
||||||
EntryPort uint16 `yaml:"entry_port"`
|
EntryPort uint16 `yaml:"entry_port"`
|
||||||
@ -28,11 +30,29 @@ type Service struct {
|
|||||||
ServicePort uint16 `yaml:"service_port"`
|
ServicePort uint16 `yaml:"service_port"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CustomUUID is an alias for uuid.UUID to enable custom unmarshal function
|
||||||
|
type CustomUUID uuid.UUID
|
||||||
|
|
||||||
type aws struct {
|
type aws struct {
|
||||||
Regions []string `yaml:"regions"`
|
Regions []string `yaml:"regions"`
|
||||||
CredentialsPath string `yaml:"credentials_path"`
|
CredentialsPath string `yaml:"credentials_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshalYAML parses uuid in yaml to CustomUUID type
|
||||||
|
func (u *CustomUUID) UnmarshalYAML(value *yaml.Node) error {
|
||||||
|
id, err := uuid.Parse(value.Value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*u = CustomUUID(id)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalYAML parses CustomUUID type to uuid string for yaml
|
||||||
|
func (u CustomUUID) MarshalYAML() (interface{}, error) {
|
||||||
|
return uuid.UUID(u).String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
// LoadConf loads config from a yaml file
|
// LoadConf loads config from a yaml file
|
||||||
func LoadConf(filename string) (Config) {
|
func LoadConf(filename string) (Config) {
|
||||||
var config Config
|
var config Config
|
||||||
|
Loading…
Reference in New Issue
Block a user