|
| 1 | +/* |
| 2 | +Copyright 2026 The Tekton Authors |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 21 | + "knative.dev/pkg/apis" |
| 22 | +) |
| 23 | + |
| 24 | +var ( |
| 25 | + _ TektonComponentStatus = (*TektonSchedulerStatus)(nil) |
| 26 | +) |
| 27 | + |
| 28 | +// GroupVersionKind returns SchemeGroupVersion of a TektonScheduler |
| 29 | +func (Scheduler *TektonScheduler) GroupVersionKind() schema.GroupVersionKind { |
| 30 | + return SchemeGroupVersion.WithKind(KindTektonScheduler) |
| 31 | +} |
| 32 | + |
| 33 | +func (Scheduler *TektonScheduler) GetGroupVersionKind() schema.GroupVersionKind { |
| 34 | + return SchemeGroupVersion.WithKind(KindTektonScheduler) |
| 35 | +} |
| 36 | + |
| 37 | +// GetCondition returns the current condition of a given condition type |
| 38 | +func (Scheduler *TektonSchedulerStatus) GetCondition(t apis.ConditionType) *apis.Condition { |
| 39 | + return condSet.Manage(Scheduler).GetCondition(t) |
| 40 | +} |
| 41 | + |
| 42 | +// InitializeConditions initializes conditions of an TektonSchedulerStatus |
| 43 | +func (Scheduler *TektonSchedulerStatus) InitializeConditions() { |
| 44 | + condSet.Manage(Scheduler).InitializeConditions() |
| 45 | +} |
| 46 | + |
| 47 | +// IsReady looks at the conditions returns true if they are all true. |
| 48 | +func (Scheduler *TektonSchedulerStatus) IsReady() bool { |
| 49 | + return condSet.Manage(Scheduler).IsHappy() |
| 50 | +} |
| 51 | + |
| 52 | +func (Scheduler *TektonSchedulerStatus) MarkPreReconcilerComplete() { |
| 53 | + condSet.Manage(Scheduler).MarkTrue(PreReconciler) |
| 54 | +} |
| 55 | + |
| 56 | +func (Scheduler *TektonSchedulerStatus) MarkInstallerSetAvailable() { |
| 57 | + condSet.Manage(Scheduler).MarkTrue(InstallerSetAvailable) |
| 58 | +} |
| 59 | + |
| 60 | +func (Scheduler *TektonSchedulerStatus) MarkInstallerSetReady() { |
| 61 | + condSet.Manage(Scheduler).MarkTrue(InstallerSetReady) |
| 62 | +} |
| 63 | + |
| 64 | +func (Scheduler *TektonSchedulerStatus) MarkPostReconcilerComplete() { |
| 65 | + condSet.Manage(Scheduler).MarkTrue(PostReconciler) |
| 66 | +} |
| 67 | + |
| 68 | +// MarkDependenciesInstalled marks the DependenciesInstalled status as true. |
| 69 | +func (Scheduler *TektonSchedulerStatus) MarkDependenciesInstalled() { |
| 70 | + condSet.Manage(Scheduler).MarkTrue(DependenciesInstalled) |
| 71 | +} |
| 72 | + |
| 73 | +func (Scheduler *TektonSchedulerStatus) MarkNotReady(msg string) { |
| 74 | + condSet.Manage(Scheduler).MarkFalse( |
| 75 | + apis.ConditionReady, |
| 76 | + "Error", |
| 77 | + "Ready: %s", msg) |
| 78 | +} |
| 79 | + |
| 80 | +func (Scheduler *TektonSchedulerStatus) MarkPreReconcilerFailed(msg string) { |
| 81 | + Scheduler.MarkNotReady("PreReconciliation failed") |
| 82 | + condSet.Manage(Scheduler).MarkFalse( |
| 83 | + PreReconciler, |
| 84 | + "Error", |
| 85 | + "PreReconciliation failed with message: %s", msg) |
| 86 | +} |
| 87 | + |
| 88 | +func (Scheduler *TektonSchedulerStatus) MarkInstallerSetNotAvailable(msg string) { |
| 89 | + Scheduler.MarkNotReady("TektonScheduler not ready") |
| 90 | + condSet.Manage(Scheduler).MarkFalse( |
| 91 | + InstallerSetAvailable, |
| 92 | + "Error", |
| 93 | + "Installer set not ready: %s", msg) |
| 94 | +} |
| 95 | + |
| 96 | +func (Scheduler *TektonSchedulerStatus) MarkInstallerSetNotReady(msg string) { |
| 97 | + Scheduler.MarkNotReady("TektonScheduler not ready") |
| 98 | + condSet.Manage(Scheduler).MarkFalse( |
| 99 | + InstallerSetReady, |
| 100 | + "Error", |
| 101 | + "Installer set not ready: %s", msg) |
| 102 | +} |
| 103 | + |
| 104 | +func (Scheduler *TektonSchedulerStatus) MarkPostReconcilerFailed(msg string) { |
| 105 | + Scheduler.MarkNotReady("PostReconciliation failed") |
| 106 | + condSet.Manage(Scheduler).MarkFalse( |
| 107 | + PostReconciler, |
| 108 | + "Error", |
| 109 | + "PostReconciliation failed with message: %s", msg) |
| 110 | +} |
| 111 | + |
| 112 | +// MarkDependencyInstalling marks the DependenciesInstalled status as false with the |
| 113 | +// given message. |
| 114 | +func (Scheduler *TektonSchedulerStatus) MarkDependencyInstalling(msg string) { |
| 115 | + Scheduler.MarkNotReady("Dependencies installing") |
| 116 | + condSet.Manage(Scheduler).MarkFalse( |
| 117 | + DependenciesInstalled, |
| 118 | + "Error", |
| 119 | + "Dependency installing: %s", msg) |
| 120 | +} |
| 121 | + |
| 122 | +// MarkDependencyMissing marks the DependenciesInstalled status as false with the |
| 123 | +// given message. |
| 124 | +func (Scheduler *TektonSchedulerStatus) MarkDependencyMissing(msg string) { |
| 125 | + Scheduler.MarkNotReady("Missing Dependencies for TektonScheduler") |
| 126 | + condSet.Manage(Scheduler).MarkFalse( |
| 127 | + DependenciesInstalled, |
| 128 | + "Error", |
| 129 | + "Dependency missing: %s", msg) |
| 130 | +} |
| 131 | + |
| 132 | +func (Scheduler *TektonSchedulerStatus) GetTektonScheduler() string { |
| 133 | + return Scheduler.TektonScheduler |
| 134 | +} |
| 135 | + |
| 136 | +func (Scheduler *TektonSchedulerStatus) SetTektonScheduler(installerSet string) { |
| 137 | + Scheduler.TektonScheduler = installerSet |
| 138 | +} |
| 139 | + |
| 140 | +// GetVersion gets the currently installed version of the component. |
| 141 | +func (Scheduler *TektonSchedulerStatus) GetVersion() string { |
| 142 | + return Scheduler.Version |
| 143 | +} |
| 144 | + |
| 145 | +// SetVersion sets the currently installed version of the component. |
| 146 | +func (Scheduler *TektonSchedulerStatus) SetVersion(version string) { |
| 147 | + Scheduler.Version = version |
| 148 | +} |
0 commit comments