mirror of
https://github.com/openziti/zrok.git
synced 2025-02-19 19:51:15 +01:00
Merge branch 'main' into v1_0_0
This commit is contained in:
commit
0ad64ee326
@ -22,6 +22,8 @@ CHANGE: The protocol for determining valid client versions has been changed. Pre
|
||||
|
||||
## v0.4.48
|
||||
|
||||
FEATURE: The controller configuration now supports a `disable_auto_migration` boolean in the `store` stanza. When set to `true`, the controller will not attempt to auto-migrate (or otherwise validate the migration state) of the underlying database. Leaving `disable_auto_migration` out, or setting it to false will retain the default behavior of auto-migrating when starting the zrok controller. The `zrok admin migrate` command will still perform a migration regardless of how this setting is configured in the controller configuration (https://github.com/openziti/zrok/issues/866)
|
||||
|
||||
FIX: the Python SDK erroneously assumed the enabled zrok environment contained a config.json file, and was changed to only load it if the file was present (https://github.com/openziti/zrok/pull/853/).
|
||||
|
||||
## v0.4.47
|
||||
|
@ -33,7 +33,12 @@ func (cmd *adminMigrate) run(_ *cobra.Command, args []string) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
logrus.Info(cf.Dump(inCfg, cf.DefaultOptions()))
|
||||
|
||||
// override the 'disable_auto_migration' setting... the user is requesting a migration here.
|
||||
inCfg.Store.DisableAutoMigration = false
|
||||
|
||||
if _, err := store.Open(inCfg.Store); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -44,39 +44,44 @@ func (str *Store) CreateGlobalFrontend(f *Frontend, tx *sqlx.Tx) (int, error) {
|
||||
}
|
||||
|
||||
func (str *Store) GetFrontend(id int, tx *sqlx.Tx) (*Frontend, error) {
|
||||
utrx := tx.Unsafe()
|
||||
i := &Frontend{}
|
||||
if err := tx.QueryRowx("select * from frontends where id = $1", id).StructScan(i); err != nil {
|
||||
if err := utrx.QueryRowx("select * from frontends where id = $1", id).StructScan(i); err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting frontend by id")
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (str *Store) FindFrontendWithToken(token string, tx *sqlx.Tx) (*Frontend, error) {
|
||||
utrx := tx.Unsafe()
|
||||
i := &Frontend{}
|
||||
if err := tx.QueryRowx("select frontends.* from frontends where token = $1 and not deleted", token).StructScan(i); err != nil {
|
||||
if err := utrx.QueryRowx("select frontends.* from frontends where token = $1 and not deleted", token).StructScan(i); err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting frontend by name")
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (str *Store) FindFrontendWithZId(zId string, tx *sqlx.Tx) (*Frontend, error) {
|
||||
utrx := tx.Unsafe()
|
||||
i := &Frontend{}
|
||||
if err := tx.QueryRowx("select frontends.* from frontends where z_id = $1 and not deleted", zId).StructScan(i); err != nil {
|
||||
if err := utrx.QueryRowx("select frontends.* from frontends where z_id = $1 and not deleted", 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) {
|
||||
utrx := tx.Unsafe()
|
||||
i := &Frontend{}
|
||||
if err := tx.QueryRowx("select frontends.* from frontends where public_name = $1 and not deleted", publicName).StructScan(i); err != nil {
|
||||
if err := utrx.QueryRowx("select frontends.* from frontends where public_name = $1 and not deleted", publicName).StructScan(i); err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting frontend by public_name")
|
||||
}
|
||||
return i, nil
|
||||
}
|
||||
|
||||
func (str *Store) FindFrontendsForEnvironment(envId int, tx *sqlx.Tx) ([]*Frontend, error) {
|
||||
rows, err := tx.Queryx("select frontends.* from frontends where environment_id = $1 and not deleted", envId)
|
||||
utrx := tx.Unsafe()
|
||||
rows, err := utrx.Queryx("select frontends.* from frontends where environment_id = $1 and not deleted", envId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting frontends by environment_id")
|
||||
}
|
||||
@ -92,7 +97,8 @@ func (str *Store) FindFrontendsForEnvironment(envId int, tx *sqlx.Tx) ([]*Fronte
|
||||
}
|
||||
|
||||
func (str *Store) FindPublicFrontends(tx *sqlx.Tx) ([]*Frontend, error) {
|
||||
rows, err := tx.Queryx("select frontends.* from frontends where environment_id is null and reserved = true and not deleted")
|
||||
utrx := tx.Unsafe()
|
||||
rows, err := utrx.Queryx("select frontends.* from frontends where environment_id is null and reserved = true and not deleted")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting public frontends")
|
||||
}
|
||||
@ -108,7 +114,8 @@ func (str *Store) FindPublicFrontends(tx *sqlx.Tx) ([]*Frontend, error) {
|
||||
}
|
||||
|
||||
func (str *Store) FindFrontendsForPrivateShare(shrId int, tx *sqlx.Tx) ([]*Frontend, error) {
|
||||
rows, err := tx.Queryx("select frontends.* from frontends where private_share_id = $1 and not deleted", shrId)
|
||||
utrx := tx.Unsafe()
|
||||
rows, err := utrx.Queryx("select frontends.* from frontends where private_share_id = $1 and not deleted", shrId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error selecting frontends by private_share_id")
|
||||
}
|
||||
|
@ -22,9 +22,10 @@ type Model struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Path string `cf:"+secret"`
|
||||
Type string
|
||||
EnableLocking bool
|
||||
Path string `cf:"+secret"`
|
||||
Type string
|
||||
EnableLocking bool
|
||||
DisableAutoMigration bool
|
||||
}
|
||||
|
||||
type Store struct {
|
||||
@ -57,8 +58,10 @@ func Open(cfg *Config) (*Store, error) {
|
||||
dbx.MapperFunc(strcase.ToSnake)
|
||||
|
||||
store := &Store{cfg: cfg, db: dbx}
|
||||
if err := store.migrate(cfg); err != nil {
|
||||
return nil, errors.Wrapf(err, "error migrating database '%v'", cfg.Path)
|
||||
if !cfg.DisableAutoMigration {
|
||||
if err := store.migrate(cfg); err != nil {
|
||||
return nil, errors.Wrapf(err, "error migrating database '%v'", cfg.Path)
|
||||
}
|
||||
}
|
||||
return store, nil
|
||||
}
|
||||
|
@ -148,6 +148,7 @@ reset_password:
|
||||
#store:
|
||||
# path: "host=127.0.0.1 user=zrok password=zrok dbname=zrok"
|
||||
# type: "postgres"
|
||||
# disable_auto_migration: true
|
||||
#
|
||||
store:
|
||||
path: zrok.db
|
||||
|
Loading…
Reference in New Issue
Block a user