/* Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.gnu.org/licenses/agpl-3.0.html Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package status import ( "k8s.libre.sh/controller-utils/interfaces" ) // ApplicationStatus defines controller's the observed state of Application // +kubebuilder:object:generate=true type ApplicationStatus struct { Version string `json:"version,omitempty"` // Phase Phase `json:"phase,omitempty"` // ObservedGeneration is the most recent generation observed. It corresponds to the // Object's generation, which is updated on mutation by the API Server. ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,1,opt,name=observedGeneration"` // Conditions represents the latest state of the object Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,10,rep,name=conditions"` // Components is a list of object ComponentStatus Components map[string]ComponentStatus `json:"components,omitempty"` Settings map[string]ComponentStatus `json:"settings,omitempty"` // ComponentsReady: status of the components in the format ready/total ComponentsReady string `json:"componentsReady,omitempty"` Watched Resources `json:"watched,omitempty"` } func (app *ApplicationStatus) GetResources() *Resources { resources := &Resources{} for _, c := range app.Components { resources.Objects = append(resources.Objects, c.GetObjects()...) } return resources } // ApplicationStatus defines controller's the observed state of Application // +kubebuilder:object:generate=true type ComponentStatus struct { Name string `json:"name,omitempty"` // Resources embeds a list of object statuses Resources `json:",inline"` // ComponentsReady: status of the components in the format ready/total ComponentsReady string `json:"componentsReady,omitempty"` } // Object interface must be supported by all types that want to sync an object. // The object interface provides a mutate function and a runtime.Object that can be used in controller-runtime CreateOrUpdate type ObjectWithStatus interface { interfaces.Object GetApplicationStatus() ApplicationStatus SetApplicationStatus(conditions ApplicationStatus) }