Add context

This commit adds and passes context around to (almost) every function.
This allows cancelling (almost) every function call globally.
This commit is contained in:
Tom Wiesing 2022-11-28 13:30:08 +01:00
parent 996ecb9f80
commit 3455f491ca
No known key found for this signature in database
104 changed files with 836 additions and 511 deletions

View file

@ -46,7 +46,7 @@ func (r reserve) Run(context wisski_distillery.Context) error {
// check that it doesn't already exist
logging.LogMessage(context.IOStream, "Reserving new WissKI instance %s", slug)
if exists, err := dis.Instances().Has(slug); err != nil || exists {
if exists, err := dis.Instances().Has(context.Context, slug); err != nil || exists {
return errProvisionAlreadyExists.WithMessageF(slug)
}
@ -66,13 +66,13 @@ func (r reserve) Run(context wisski_distillery.Context) error {
s := instance.Reserve().Stack()
{
if err := logging.LogOperation(func() error {
return s.Install(context.IOStream, component.InstallationContext{})
return s.Install(context.Context, context.IOStream, component.InstallationContext{})
}, context.IOStream, "Installing docker stack"); err != nil {
return err
}
if err := logging.LogOperation(func() error {
return s.Update(context.IOStream, true)
return s.Update(context.Context, context.IOStream, true)
}, context.IOStream, "Updating docker stack"); err != nil {
return err
}