forked from opendatahub-io/odh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservicemeshoperator.go
More file actions
68 lines (58 loc) · 2.36 KB
/
servicemeshoperator.go
File metadata and controls
68 lines (58 loc) · 2.36 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package servicemeshoperator
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/opendatahub-io/odh-cli/pkg/lint/check"
"github.com/opendatahub-io/odh-cli/pkg/lint/check/result"
"github.com/opendatahub-io/odh-cli/pkg/lint/check/validate"
"github.com/opendatahub-io/odh-cli/pkg/util/version"
)
const (
kind = "servicemesh-operator-v2"
checkType = "upgrade"
)
// Check validates that Service Mesh Operator v2 is not installed when upgrading to 3.x,
// as it is no longer required by RHOAI 3.x (OpenShift 4.19+ handles service mesh internally).
type Check struct {
check.BaseCheck
}
// NewCheck creates a new Service Mesh Operator v2 upgrade check.
func NewCheck() *Check {
return &Check{
BaseCheck: check.BaseCheck{
CheckGroup: check.GroupDependency,
Kind: kind,
Type: checkType,
CheckID: "dependencies.servicemeshoperator2.upgrade",
CheckName: "Dependencies :: ServiceMeshOperator2 :: Upgrade (3.x)",
CheckDescription: "Validates that Service Mesh Operator v2 is not installed when upgrading to RHOAI 3.x (no longer required, OpenShift 4.19+ handles service mesh internally)",
},
}
}
func (c *Check) CanApply(_ context.Context, target check.Target) (bool, error) {
return version.IsUpgradeFrom2xTo3x(target.CurrentVersion, target.TargetVersion), nil
}
func (c *Check) Validate(ctx context.Context, target check.Target) (*result.DiagnosticResult, error) {
tv := version.MajorMinorLabel(target.TargetVersion)
return validate.Operator(c, target).
WithNames("servicemeshoperator").
WithChannels("stable", "v2.x").
WithConditionBuilder(func(found bool, operatorVersion string) result.Condition {
// Inverted logic: NOT finding the operator is good.
if !found {
return check.NewCondition(
check.ConditionTypeCompatible,
metav1.ConditionTrue,
check.WithReason(check.ReasonVersionCompatible),
check.WithMessage("Service Mesh Operator v2 is not installed - ready for RHOAI %s upgrade", tv),
)
}
return check.NewCondition(
check.ConditionTypeCompatible,
metav1.ConditionFalse,
check.WithReason(check.ReasonVersionIncompatible),
check.WithMessage("Service Mesh Operator v2 (%s) is installed but no longer required by RHOAI %s and should be removed. OpenShift 4.19+ handles service mesh internally", operatorVersion, tv),
)
}).
Run(ctx)
}