From a45c189a0aae89c49467e0c56231f7d2b0bc92a7 Mon Sep 17 00:00:00 2001 From: Sam Batschelet Date: Tue, 14 May 2024 17:21:55 -0400 Subject: [PATCH] client: add helper to return rollback deployment Signed-off-by: Sam Batschelet --- pkg/client/client.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/client/client.go b/pkg/client/client.go index f240862..3b2f8ff 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -175,6 +175,17 @@ func (s *Status) GetStagedDeployment() *Deployment { return nil } +// GetRollbackDeployment finds the rollback deployment, or returns nil if none is found. +func (s *Status) GetRollbackDeployment() *Deployment { + for num := range s.Deployments { + deployment := s.Deployments[num] + if !deployment.Booted && !deployment.Staged { + return &deployment + } + } + return nil +} + // GetBaseChecksum returns the ostree commit used as a base. func (s *Deployment) GetBaseChecksum() string { if s.BaseChecksum != nil {