-
Notifications
You must be signed in to change notification settings - Fork 670
Expand file tree
/
Copy pathregistration.go
More file actions
27 lines (21 loc) · 982 Bytes
/
registration.go
File metadata and controls
27 lines (21 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright 2021 - 2025 Crunchy Data Solutions, Inc.
//
// SPDX-License-Identifier: Apache-2.0
package pgupgrade
import (
"k8s.io/apimachinery/pkg/api/meta"
"github.com/crunchydata/postgres-operator/internal/registration"
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
)
func (r *PGUpgradeReconciler) UpgradeAuthorized(upgrade *v1beta1.PGUpgrade) bool {
// Allow an upgrade in progress to complete, when the registration requirement is introduced.
// But don't allow new upgrades to be started until a valid token is applied.
progressing := meta.FindStatusCondition(upgrade.Status.Conditions, ConditionPGUpgradeProgressing) != nil
required := r.Registration.Required(r.Recorder, upgrade, &upgrade.Status.Conditions)
// If a valid token has not been applied, warn the user.
if required && !progressing {
registration.SetRequiredWarning(r.Recorder, upgrade, &upgrade.Status.Conditions)
return false
}
return true
}