mirror of
https://github.com/openziti/zrok.git
synced 2024-11-29 03:24:15 +01:00
zrok admin bootstrap now checks frontend entry for frontend identity (#131)
This commit is contained in:
parent
a0c50c68e5
commit
4c70212304
@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/openziti-test-kitchen/zrok/controller/store"
|
||||||
"github.com/openziti-test-kitchen/zrok/model"
|
"github.com/openziti-test-kitchen/zrok/model"
|
||||||
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
"github.com/openziti-test-kitchen/zrok/zrokdir"
|
||||||
"github.com/openziti/edge/rest_management_api_client"
|
"github.com/openziti/edge/rest_management_api_client"
|
||||||
@ -26,6 +27,12 @@ import (
|
|||||||
func Bootstrap(skipCtrl, skipFrontend bool, inCfg *Config) error {
|
func Bootstrap(skipCtrl, skipFrontend bool, inCfg *Config) error {
|
||||||
cfg = inCfg
|
cfg = inCfg
|
||||||
|
|
||||||
|
if v, err := store.Open(cfg.Store); err == nil {
|
||||||
|
str = v
|
||||||
|
} else {
|
||||||
|
return errors.Wrap(err, "error opening store")
|
||||||
|
}
|
||||||
|
|
||||||
edge, err := edgeClient()
|
edge, err := edgeClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -65,6 +72,22 @@ func Bootstrap(skipCtrl, skipFrontend bool, inCfg *Config) error {
|
|||||||
if err := assertErpForIdentity("frontend", frontendZId, edge); err != nil {
|
if err := assertErpForIdentity("frontend", frontendZId, edge); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tx, err := str.Begin()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer func() { _ = tx.Rollback() }()
|
||||||
|
publicFe, err := str.FindFrontendWithZId(frontendZId, tx)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Warnf("missing public frontend for ziti id '%v'; please use 'zrok admin create frontend' to create a frontend instance", frontendZId)
|
||||||
|
} else {
|
||||||
|
if publicFe.PublicName != nil && publicFe.UrlTemplate != nil {
|
||||||
|
logrus.Infof("found public frontend entry '%v' (%v) for ziti identity '%v'", *publicFe.PublicName, publicFe.Token, frontendZId)
|
||||||
|
} else {
|
||||||
|
logrus.Warnf("found frontend entry for ziti identity '%v'; missing either public name or url template")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := assertZrokProxyConfigType(edge); err != nil {
|
if err := assertZrokProxyConfigType(edge); err != nil {
|
||||||
|
@ -55,6 +55,14 @@ func (str *Store) FindFrontendWithToken(token string, tx *sqlx.Tx) (*Frontend, e
|
|||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (str *Store) FindFrontendWithZId(zId string, tx *sqlx.Tx) (*Frontend, error) {
|
||||||
|
i := &Frontend{}
|
||||||
|
if err := tx.QueryRowx("select frontends.* from frontends where z_id = $1", zId).StructScan(i); err != nil {
|
||||||
|
return nil, errors.Wrap(err, "error selecting frontend by ziti id")
|
||||||
|
}
|
||||||
|
return i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (str *Store) FindFrontendPubliclyNamed(publicName string, tx *sqlx.Tx) (*Frontend, error) {
|
func (str *Store) FindFrontendPubliclyNamed(publicName string, tx *sqlx.Tx) (*Frontend, error) {
|
||||||
i := &Frontend{}
|
i := &Frontend{}
|
||||||
if err := tx.QueryRowx("select frontends.* from frontends where public_name = $1", publicName).StructScan(i); err != nil {
|
if err := tx.QueryRowx("select frontends.* from frontends where public_name = $1", publicName).StructScan(i); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user