Update to new goprogram version
This commit is contained in:
parent
7bd9570bc0
commit
873fdcd5c2
106 changed files with 478 additions and 825 deletions
|
|
@ -19,7 +19,7 @@ import (
|
|||
// Instances manages multiple WissKI Instances.
|
||||
type Instances struct {
|
||||
component.Base
|
||||
Dependencies struct {
|
||||
dependencies struct {
|
||||
Malt *malt.Malt
|
||||
SQL *sql.SQL
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ var errSQL = exit.Error{
|
|||
|
||||
// use uses the non-nil wisski instance with this instances
|
||||
func (instances *Instances) use(wisski *wisski.WissKI) {
|
||||
wisski.Liquid.Malt = instances.Dependencies.Malt
|
||||
wisski.Liquid.Malt = instances.dependencies.Malt
|
||||
}
|
||||
|
||||
// WissKI returns the WissKI with the provided slug, if it exists.
|
||||
|
|
@ -51,12 +51,12 @@ func (instances *Instances) WissKI(ctx context.Context, slug string) (wissKI *wi
|
|||
return nil, ErrWissKINotFound
|
||||
}
|
||||
|
||||
sql := instances.Dependencies.SQL
|
||||
sql := instances.dependencies.SQL
|
||||
if err := sql.WaitQueryTable(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
table, err := sql.QueryTable(ctx, instances.Dependencies.InstanceTable)
|
||||
table, err := sql.QueryTable(ctx, instances.dependencies.InstanceTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -91,12 +91,12 @@ func (instances *Instances) Instance(ctx context.Context, instance models.Instan
|
|||
// Has checks if a WissKI with the provided slug exists inside the database.
|
||||
// It does not perform any checks on the WissKI itself.
|
||||
func (instances *Instances) Has(ctx context.Context, slug string) (ok bool, err error) {
|
||||
sql := instances.Dependencies.SQL
|
||||
sql := instances.dependencies.SQL
|
||||
if err := sql.WaitQueryTable(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
table, err := sql.QueryTable(ctx, instances.Dependencies.InstanceTable)
|
||||
table, err := sql.QueryTable(ctx, instances.dependencies.InstanceTable)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -135,13 +135,13 @@ func (instances *Instances) Load(ctx context.Context, slugs ...string) ([]*wissk
|
|||
|
||||
// find finds instances based on the provided query
|
||||
func (instances *Instances) find(ctx context.Context, order bool, query func(table *gorm.DB) *gorm.DB) (results []*wisski.WissKI, err error) {
|
||||
sql := instances.Dependencies.SQL
|
||||
sql := instances.dependencies.SQL
|
||||
if err := sql.WaitQueryTable(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// open the bookkeeping table
|
||||
table, err := sql.QueryTable(ctx, instances.Dependencies.InstanceTable)
|
||||
table, err := sql.QueryTable(ctx, instances.dependencies.InstanceTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ import (
|
|||
type Malt struct {
|
||||
component.Base
|
||||
|
||||
SQL *sql.SQL `auto:"true"`
|
||||
InstanceTable *sql.InstanceTable `auto:"true"`
|
||||
LockTable *sql.LockTable `auto:"true"`
|
||||
SQL *sql.SQL `inject:"true"`
|
||||
InstanceTable *sql.InstanceTable `inject:"true"`
|
||||
LockTable *sql.LockTable `inject:"true"`
|
||||
|
||||
TS *triplestore.Triplestore `auto:"true"`
|
||||
Meta *meta.Meta `auto:"true"`
|
||||
ExporterLog *logger.Logger `auto:"true"`
|
||||
Policy *policy.Policy `auto:"true"`
|
||||
TS *triplestore.Triplestore `inject:"true"`
|
||||
Meta *meta.Meta `inject:"true"`
|
||||
ExporterLog *logger.Logger `inject:"true"`
|
||||
Policy *policy.Policy `inject:"true"`
|
||||
|
||||
Docker *docker.Docker `auto:"true"`
|
||||
Docker *docker.Docker `inject:"true"`
|
||||
|
||||
Keys *sshkeys.SSHKeys `auto:"true"`
|
||||
Keys *sshkeys.SSHKeys `inject:"true"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import (
|
|||
// Purger purges instances from the distillery
|
||||
type Purger struct {
|
||||
component.Base
|
||||
Dependencies struct {
|
||||
dependencies struct {
|
||||
Instances *instances.Instances
|
||||
Provisionable []component.Provisionable
|
||||
}
|
||||
|
|
@ -35,10 +35,10 @@ var errPurgeGeneric = exit.Error{
|
|||
// The instance does not have to exist; in which case the resources are also deleted.
|
||||
func (purger *Purger) Purge(ctx context.Context, out io.Writer, slug string) error {
|
||||
logging.LogMessage(out, "Checking bookkeeping table")
|
||||
instance, err := purger.Dependencies.Instances.WissKI(ctx, slug)
|
||||
instance, err := purger.dependencies.Instances.WissKI(ctx, slug)
|
||||
if err == instances.ErrWissKINotFound {
|
||||
fmt.Fprintln(out, "Not found in bookkeeping table, assuming defaults")
|
||||
instance, err = purger.Dependencies.Instances.Create(slug, models.System{})
|
||||
instance, err = purger.dependencies.Instances.Create(slug, models.System{})
|
||||
}
|
||||
if err != nil {
|
||||
return errPurgeNoDetails.WithMessageF(err)
|
||||
|
|
@ -59,7 +59,7 @@ func (purger *Purger) Purge(ctx context.Context, out io.Writer, slug string) err
|
|||
// purge all the instance specific resources
|
||||
if err := logging.LogOperation(func() error {
|
||||
domain := instance.Domain()
|
||||
for _, pc := range purger.Dependencies.Provisionable {
|
||||
for _, pc := range purger.dependencies.Provisionable {
|
||||
logging.LogMessage(out, "Purging %s resources", pc.Name())
|
||||
err := pc.Purge(ctx, instance.Instance, domain)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue