server läuft
This commit is contained in:
1 parent
c8df9d7651
commit
42f0c0accb
21 files changed
+4185
-10
No files matched your search
@@ -0,0 +1,50 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"sultan/pkg/license"
|
||||
"sultan/pkg/policy"
|
||||
"sultan/pkg/registry"
|
||||
"sultan/pkg/store"
|
||||
)
|
||||
|
||||
// directory liefert der Registry Mandant, Lizenz und Drain-Status eines
|
||||
// Knotens aus dem Store.
|
||||
//
|
||||
// Solange Migration v2 fehlt (Spec Abschnitt 9), wird die Lizenz aus dem
|
||||
// Mandanten-Datensatz abgeleitet: ohne Features und ohne Mahnstufe.
|
||||
type directory struct {
|
||||
store *store.Store
|
||||
}
|
||||
|
||||
func (d *directory) NodeContext(ctx context.Context, nodeID string) (registry.NodeContext, error) {
|
||||
node, err := d.store.GetNode(ctx, nodeID)
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
return registry.NodeContext{}, fmt.Errorf("%w: %s", registry.ErrUnknownNode, nodeID)
|
||||
}
|
||||
if err != nil {
|
||||
return registry.NodeContext{}, err
|
||||
}
|
||||
t, err := d.store.GetTenant(ctx, node.TenantID)
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
return registry.NodeContext{}, fmt.Errorf("%w: Mandant von %s fehlt", registry.ErrUnknownNode, nodeID)
|
||||
}
|
||||
if err != nil {
|
||||
return registry.NodeContext{}, err
|
||||
}
|
||||
return registry.NodeContext{
|
||||
Tenant: policy.Tenant{ID: t.ID, Status: t.Status},
|
||||
License: license.License{
|
||||
TenantID: t.ID,
|
||||
Tier: license.Tier(t.Tier),
|
||||
MaxRoutes: t.MaxRoutes,
|
||||
AllowedDomains: t.AllowedDomains,
|
||||
Features: []license.Feature{},
|
||||
ValidUntil: t.ValidUntil,
|
||||
},
|
||||
Drained: node.Status == store.NodeDrained,
|
||||
}, nil
|
||||
}
|
||||
Reference in new issue
Block a user