Make wasRunning a bool

This commit is contained in:
Joel Elkins 2022-08-15 01:06:05 -05:00
parent 3054f40223
commit ee6abfd1bb
No known key found for this signature in database
GPG Key ID: 133589DC38921AE2

View File

@ -61,7 +61,7 @@ type Container struct {
conn context.Context conn context.Context
cdata *define.InspectContainerData cdata *define.InspectContainerData
wasRunning null.Bool wasRunning bool
} }
func (c *Container) Init(conn context.Context, nets []network.Network) error { func (c *Container) Init(conn context.Context, nets []network.Network) error {
@ -106,7 +106,7 @@ func (c *Container) Init(conn context.Context, nets []network.Network) error {
} }
c.conn = conn c.conn = conn
err := c.populateCData() err := c.populateCData()
c.wasRunning.SetValid(c.IsRunning()) c.wasRunning = err != nil && c.IsRunning()
return err return err
} }
@ -329,7 +329,7 @@ func (c *Container) UpdateCommands() cmd.CommandSet {
func (c *Container) ConditionalStartCommands() cmd.CommandSet { func (c *Container) ConditionalStartCommands() cmd.CommandSet {
return c.newCommandSet("CONDSTART", cmd.Commands{ return c.newCommandSet("CONDSTART", cmd.Commands{
cmd.NewConditional("restart_if_was_running", cmd.NewConditional("restart_if_was_running",
c.wasRunning.ValueOrZero, func() bool { return c.wasRunning },
cmd.NewSet(c.StartCommands()), cmd.NewSet(c.StartCommands()),
cmd.NewNop(), cmd.NewNop(),
), ),