[BUGFIX] Do not attempt to clear approvals when there are none
parent
ce7a4aa161
commit
4d5eb50176
|
|
@ -36,6 +36,9 @@ type Manager interface {
|
|||
// Rejects Approval
|
||||
Reject(identifier string) (*types.Approval, error)
|
||||
|
||||
// If the approval exists
|
||||
Exists(identifier string) bool
|
||||
|
||||
Get(identifier string) (*types.Approval, error)
|
||||
List() ([]*types.Approval, error)
|
||||
Delete(*types.Approval) error
|
||||
|
|
@ -372,6 +375,14 @@ func (m *DefaultManager) Delete(approval *types.Approval) error {
|
|||
return m.store.DeleteApproval(existing)
|
||||
}
|
||||
|
||||
func (m *DefaultManager) Exists(identifier string) bool {
|
||||
_, err := m.Get(identifier)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (m *DefaultManager) Archive(identifier string) error {
|
||||
existing, err := m.Get(identifier)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,12 @@ func (p *Provider) checkForApprovals(event *types.Event, plans []*UpdatePlan) (a
|
|||
|
||||
// updateComplete is called after we successfully update resource
|
||||
func (p *Provider) updateComplete(plan *UpdatePlan) error {
|
||||
return p.approvalManager.Archive(getApprovalIdentifier(plan.Resource.Identifier, plan.NewVersion))
|
||||
approvalIdentifier := getApprovalIdentifier(plan.Resource.Identifier, plan.NewVersion)
|
||||
// There might be no approvals for this plan
|
||||
if p.approvalManager.Exists(approvalIdentifier) {
|
||||
return p.approvalManager.Archive(approvalIdentifier)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getInt(key string, labels map[string]string, annotations map[string]string) (int, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue