mirror of
https://github.com/openziti/ziti.git
synced 2026-10-12 23:32:02 +00:00
Add names to service and router. Add more store tests. Fixes GH-101
This commit is contained in:
@@ -25,8 +25,8 @@ import (
|
||||
func TestLifecycle(t *testing.T) {
|
||||
linkController := newLinkController()
|
||||
|
||||
r0 := NewRouter("r0", "")
|
||||
r1 := NewRouter("r1", "")
|
||||
r0 := NewRouter("r0", "", "")
|
||||
r1 := NewRouter("r1", "", "")
|
||||
l0 := &Link{
|
||||
Id: &identity.TokenId{Token: "l0"},
|
||||
Src: r0,
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
type Router struct {
|
||||
models.BaseEntity
|
||||
Name string
|
||||
Fingerprint *string
|
||||
AdvertisedListener string
|
||||
Control channel2.Channel
|
||||
@@ -42,6 +43,7 @@ func (entity *Router) fillFrom(_ Controller, _ *bbolt.Tx, boltEntity boltz.Entit
|
||||
if !ok {
|
||||
return errors.Errorf("unexpected type %v when filling model router", reflect.TypeOf(boltEntity))
|
||||
}
|
||||
entity.Name = boltRouter.Name
|
||||
entity.Fingerprint = boltRouter.Fingerprint
|
||||
entity.FillCommon(boltRouter)
|
||||
return nil
|
||||
@@ -50,13 +52,18 @@ func (entity *Router) fillFrom(_ Controller, _ *bbolt.Tx, boltEntity boltz.Entit
|
||||
func (entity *Router) toBolt() *db.Router {
|
||||
return &db.Router{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
Fingerprint: entity.Fingerprint,
|
||||
}
|
||||
}
|
||||
|
||||
func NewRouter(id, fingerprint string) *Router {
|
||||
func NewRouter(id, name, fingerprint string) *Router {
|
||||
if name == "" {
|
||||
name = id
|
||||
}
|
||||
return &Router{
|
||||
BaseEntity: models.BaseEntity{Id: id},
|
||||
Name: name,
|
||||
Fingerprint: &fingerprint,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
|
||||
type Service struct {
|
||||
models.BaseEntity
|
||||
Name string
|
||||
TerminatorStrategy string
|
||||
Terminators []*Terminator
|
||||
}
|
||||
@@ -38,6 +39,7 @@ func (entity *Service) fillFrom(ctrl Controller, tx *bbolt.Tx, boltEntity boltz.
|
||||
if !ok {
|
||||
return errors.Errorf("unexpected type %v when filling model service", reflect.TypeOf(boltEntity))
|
||||
}
|
||||
entity.Name = boltService.Name
|
||||
entity.TerminatorStrategy = boltService.TerminatorStrategy
|
||||
entity.FillCommon(boltService)
|
||||
|
||||
@@ -54,6 +56,7 @@ func (entity *Service) fillFrom(ctrl Controller, tx *bbolt.Tx, boltEntity boltz.
|
||||
func (entity *Service) toBolt() *db.Service {
|
||||
return &db.Service{
|
||||
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
|
||||
Name: entity.Name,
|
||||
TerminatorStrategy: entity.TerminatorStrategy,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user