pkg/logging: Remove unneeded argument
This commit is contained in:
parent
d7847b5d69
commit
2493cbb078
15 changed files with 75 additions and 76 deletions
|
|
@ -64,7 +64,7 @@ func (exporter *Exporter) NewBackup(ctx context.Context, progress io.Writer, des
|
|||
backup.EndTime = time.Now().UTC()
|
||||
|
||||
return nil
|
||||
}, progress, ctx, "Writing backup files")
|
||||
}, progress, "Writing backup files")
|
||||
|
||||
return
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ func (backup *Backup) run(ctx context.Context, progress io.Writer, exporter *Exp
|
|||
}
|
||||
|
||||
return nil
|
||||
}, progress, ctx, "Backing up core components")
|
||||
}, progress, "Backing up core components")
|
||||
|
||||
// backup instances
|
||||
logging.LogOperation(func() error {
|
||||
|
|
@ -164,6 +164,6 @@ func (backup *Backup) run(ctx context.Context, progress io.Writer, exporter *Exp
|
|||
})
|
||||
|
||||
return nil
|
||||
}, progress, ctx, "Creating instance snapshots")
|
||||
}, progress, "Creating instance snapshots")
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
|
|||
}
|
||||
|
||||
// determine target paths
|
||||
logging.LogMessage(progress, ctx, "Determining target paths")
|
||||
logging.LogMessage(progress, "Determining target paths")
|
||||
var stagingDir, archivePath string
|
||||
if task.StagingOnly {
|
||||
stagingDir = task.Dest
|
||||
|
|
@ -76,7 +76,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
|
|||
fmt.Fprintf(progress, "Archive Path: %s\n", archivePath)
|
||||
|
||||
// create the staging directory
|
||||
logging.LogMessage(progress, ctx, "Creating staging directory")
|
||||
logging.LogMessage(progress, "Creating staging directory")
|
||||
err = fsx.Mkdir(stagingDir, fsx.DefaultDirPerm)
|
||||
if !errors.Is(err, fs.ErrExist) && err != nil {
|
||||
return err
|
||||
|
|
@ -86,7 +86,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
|
|||
// we need the staging directory to be deleted at the end
|
||||
if !task.StagingOnly {
|
||||
defer func() {
|
||||
logging.LogMessage(progress, ctx, "Removing staging directory")
|
||||
logging.LogMessage(progress, "Removing staging directory")
|
||||
os.RemoveAll(stagingDir)
|
||||
}()
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
|
|||
_, err := sl.Report(report)
|
||||
return err
|
||||
}
|
||||
}, progress, ctx, "Generating %s", Title)
|
||||
}, progress, "Generating %s", Title)
|
||||
|
||||
// if we only requested staging
|
||||
// all that is left is to write the log entry
|
||||
|
|
@ -155,12 +155,12 @@ func (exporter *Exporter) MakeExport(ctx context.Context, progress io.Writer, ta
|
|||
})
|
||||
|
||||
return err
|
||||
}, progress, ctx, "Writing archive"); err != nil {
|
||||
}, progress, "Writing archive"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// write out the log entry
|
||||
logging.LogMessage(progress, ctx, "Writing Log Entry")
|
||||
logging.LogMessage(progress, "Writing Log Entry")
|
||||
entry.Path = archivePath
|
||||
entry.Packed = true
|
||||
exporter.Dependencies.ExporterLogger.Add(ctx, entry)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ type Snapshot struct {
|
|||
// Snapshot creates a new snapshot of this instance into dest
|
||||
func (snapshots *Exporter) NewSnapshot(ctx context.Context, instance *wisski.WissKI, progress io.Writer, desc SnapshotDescription) (snapshot Snapshot) {
|
||||
|
||||
logging.LogMessage(progress, ctx, "Locking instance")
|
||||
logging.LogMessage(progress, "Locking instance")
|
||||
if !instance.Locker().TryLock(ctx) {
|
||||
err := locker.Locked
|
||||
fmt.Fprintln(progress, err)
|
||||
|
|
@ -57,7 +57,7 @@ func (snapshots *Exporter) NewSnapshot(ctx context.Context, instance *wisski.Wis
|
|||
}
|
||||
}
|
||||
defer func() {
|
||||
logging.LogMessage(progress, ctx, "Unlocking instance")
|
||||
logging.LogMessage(progress, "Unlocking instance")
|
||||
instance.Locker().Unlock(ctx)
|
||||
}()
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ func (snapshots *Exporter) NewSnapshot(ctx context.Context, instance *wisski.Wis
|
|||
|
||||
snapshot.EndTime = time.Now().UTC()
|
||||
return nil
|
||||
}, progress, ctx, "Writing snapshot files")
|
||||
}, progress, "Writing snapshot files")
|
||||
|
||||
slices.Sort(snapshot.Manifest)
|
||||
return
|
||||
|
|
@ -89,11 +89,11 @@ func (snapshot *Snapshot) makeParts(ctx context.Context, progress io.Writer, sna
|
|||
if !needsRunning && !snapshot.Description.Keepalive {
|
||||
stack := instance.Barrel().Stack()
|
||||
|
||||
logging.LogMessage(progress, ctx, "Stopping instance")
|
||||
logging.LogMessage(progress, "Stopping instance")
|
||||
snapshot.ErrStop = stack.Down(ctx, progress)
|
||||
|
||||
defer func() {
|
||||
logging.LogMessage(progress, ctx, "Starting instance")
|
||||
logging.LogMessage(progress, "Starting instance")
|
||||
snapshot.ErrStart = stack.Up(ctx, progress)
|
||||
}()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ var errPurgeGeneric = exit.Error{
|
|||
// Purge permanently purges an instance from the distillery.
|
||||
// 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, ctx, "Checking bookkeeping table")
|
||||
logging.LogMessage(out, "Checking bookkeeping table")
|
||||
instance, err := purger.Dependencies.Instances.WissKI(ctx, slug)
|
||||
if err == instances.ErrWissKINotFound {
|
||||
fmt.Fprintln(out, "Not found in bookkeeping table, assuming defaults")
|
||||
|
|
@ -44,13 +44,13 @@ func (purger *Purger) Purge(ctx context.Context, out io.Writer, slug string) err
|
|||
}
|
||||
|
||||
// remove docker stack
|
||||
logging.LogMessage(out, ctx, "Stopping and removing docker container")
|
||||
logging.LogMessage(out, "Stopping and removing docker container")
|
||||
if err := instance.Barrel().Stack().Down(ctx, out); err != nil {
|
||||
fmt.Fprintln(out, err)
|
||||
}
|
||||
|
||||
// remove the filesystem
|
||||
logging.LogMessage(out, ctx, "Removing from filesystem %s", instance.FilesystemBase)
|
||||
logging.LogMessage(out, "Removing from filesystem %s", instance.FilesystemBase)
|
||||
if err := os.RemoveAll(instance.FilesystemBase); err != nil {
|
||||
fmt.Fprintln(out, err)
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ func (purger *Purger) Purge(ctx context.Context, out io.Writer, slug string) err
|
|||
if err := logging.LogOperation(func() error {
|
||||
domain := instance.Domain()
|
||||
for _, pc := range purger.Dependencies.Provisionable {
|
||||
logging.LogMessage(out, ctx, "Purging %s resources", pc.Name())
|
||||
logging.LogMessage(out, "Purging %s resources", pc.Name())
|
||||
err := pc.Purge(ctx, instance.Instance, domain)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -67,18 +67,18 @@ func (purger *Purger) Purge(ctx context.Context, out io.Writer, slug string) err
|
|||
}
|
||||
|
||||
return nil
|
||||
}, out, ctx, "Purging instance-specific resources"); err != nil {
|
||||
}, out, "Purging instance-specific resources"); err != nil {
|
||||
return errPurgeGeneric.WithMessageF(slug, err)
|
||||
}
|
||||
|
||||
// remove from bookkeeping
|
||||
logging.LogMessage(out, ctx, "Removing instance from bookkeeping")
|
||||
logging.LogMessage(out, "Removing instance from bookkeeping")
|
||||
if err := instance.Bookkeeping().Delete(ctx); err != nil {
|
||||
fmt.Fprintln(out, err)
|
||||
}
|
||||
|
||||
// remove the filesystem
|
||||
logging.LogMessage(out, ctx, "Remove lock data")
|
||||
logging.LogMessage(out, "Remove lock data")
|
||||
if instance.Locker().TryUnlock(ctx) {
|
||||
fmt.Fprintln(out, "instance was not locked")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ var ErrInstanceAlreadyExists = errors.New("instance with provided slug already e
|
|||
// Provision provisions a new docker compose instance.
|
||||
func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags ProvisionFlags) (*wisski.WissKI, error) {
|
||||
// check that it doesn't already exist
|
||||
logging.LogMessage(progress, ctx, "Provisioning new WissKI instance %s", flags.Slug)
|
||||
logging.LogMessage(progress, "Provisioning new WissKI instance %s", flags.Slug)
|
||||
if exists, err := pv.Dependencies.Instances.Has(ctx, flags.Slug); err != nil || exists {
|
||||
return nil, ErrInstanceAlreadyExists
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags Pr
|
|||
}
|
||||
|
||||
// check that the base directory does not exist
|
||||
logging.LogMessage(progress, ctx, "Checking that base directory %s does not exist", instance.FilesystemBase)
|
||||
logging.LogMessage(progress, "Checking that base directory %s does not exist", instance.FilesystemBase)
|
||||
if fsx.IsDirectory(instance.FilesystemBase) {
|
||||
return nil, ErrInstanceAlreadyExists
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags Pr
|
|||
}
|
||||
|
||||
return nil
|
||||
}, progress, ctx, "Updating bookkeeping database"); err != nil {
|
||||
}, progress, "Updating bookkeeping database"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags Pr
|
|||
if err := logging.LogOperation(func() error {
|
||||
domain := instance.Domain()
|
||||
for _, pc := range pv.Dependencies.Provisionable {
|
||||
logging.LogMessage(progress, ctx, "Provisioning %s resources", pc.Name())
|
||||
logging.LogMessage(progress, "Provisioning %s resources", pc.Name())
|
||||
err := pc.Provision(ctx, instance.Instance, domain)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -70,19 +70,19 @@ func (pv *Provision) Provision(progress io.Writer, ctx context.Context, flags Pr
|
|||
}
|
||||
|
||||
return nil
|
||||
}, progress, ctx, "Provisioning instance-specific resources"); err != nil {
|
||||
}, progress, "Provisioning instance-specific resources"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// run the provision script
|
||||
if err := logging.LogOperation(func() error {
|
||||
return instance.Provisioner().Provision(ctx, progress)
|
||||
}, progress, ctx, "Running setup scripts"); err != nil {
|
||||
}, progress, "Running setup scripts"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// start the container!
|
||||
logging.LogMessage(progress, ctx, "Starting Container")
|
||||
logging.LogMessage(progress, "Starting Container")
|
||||
if err := instance.Barrel().Stack().Up(ctx, progress); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
|
|||
if err := sql.unsafeWaitShell(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
logging.LogMessage(progress, ctx, "Creating administrative user")
|
||||
logging.LogMessage(progress, "Creating administrative user")
|
||||
{
|
||||
username := sql.Config.SQL.AdminUsername
|
||||
password := sql.Config.SQL.AdminPassword
|
||||
|
|
@ -63,7 +63,7 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
|
|||
}
|
||||
|
||||
// create the admin user
|
||||
logging.LogMessage(progress, ctx, "Creating sql database")
|
||||
logging.LogMessage(progress, "Creating sql database")
|
||||
{
|
||||
if !sqlx.IsSafeDatabaseLiteral(sql.Config.SQL.Database) {
|
||||
return errSQLUnsafeDatabaseName
|
||||
|
|
@ -75,7 +75,7 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
|
|||
}
|
||||
|
||||
// wait for the database to come up
|
||||
logging.LogMessage(progress, ctx, "Waiting for database update to be complete")
|
||||
logging.LogMessage(progress, "Waiting for database update to be complete")
|
||||
if err := sql.WaitQueryTable(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
|
|||
return logging.LogOperation(func() error {
|
||||
for _, table := range sql.Dependencies.Tables {
|
||||
info := table.TableInfo()
|
||||
logging.LogMessage(progress, ctx, "migrating %q table", table.Name)
|
||||
logging.LogMessage(progress, "migrating %q table", table.Name)
|
||||
db, err := sql.queryTable(ctx, false, info.Name)
|
||||
if err != nil {
|
||||
return errSQLUnableToMigrate.WithMessageF(table.Name, "unable to access table")
|
||||
|
|
@ -97,5 +97,5 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
|
|||
}
|
||||
}
|
||||
return nil
|
||||
}, progress, ctx, "migrating database tables")
|
||||
}, progress, "migrating database tables")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ import (
|
|||
var errTriplestoreFailedSecurity = errors.New("failed to enable triplestore security: request did not succeed with HTTP 200 OK")
|
||||
|
||||
func (ts Triplestore) Update(ctx context.Context, progress io.Writer) error {
|
||||
logging.LogMessage(progress, ctx, "Waiting for Triplestore")
|
||||
logging.LogMessage(progress, "Waiting for Triplestore")
|
||||
if err := ts.Wait(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
logging.LogMessage(progress, ctx, "Resetting admin user password")
|
||||
logging.LogMessage(progress, "Resetting admin user password")
|
||||
{
|
||||
res, err := ts.OpenRaw(ctx, "PUT", "/rest/security/users/"+ts.Config.TS.AdminUsername, TriplestoreUserPayload{
|
||||
Password: ts.Config.TS.AdminPassword,
|
||||
|
|
@ -43,14 +43,14 @@ func (ts Triplestore) Update(ctx context.Context, progress io.Writer) error {
|
|||
case http.StatusUnauthorized:
|
||||
// a password is needed => security is already enabled.
|
||||
// the password may or may not work, but that's a problem for later
|
||||
logging.LogMessage(progress, ctx, "Security is already enabled")
|
||||
logging.LogMessage(progress, "Security is already enabled")
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("failed to create triplestore user: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
logging.LogMessage(progress, ctx, "Enabling Triplestore security")
|
||||
logging.LogMessage(progress, "Enabling Triplestore security")
|
||||
{
|
||||
res, err := ts.OpenRaw(ctx, "POST", "/rest/security", true, "", "")
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue