Skip to content

Commit

Permalink
opensearch cr status was updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Siryk authored and Bohdan Siryk committed Jan 25, 2024
1 parent b0b9418 commit 8760f16
Show file tree
Hide file tree
Showing 18 changed files with 747 additions and 266 deletions.
86 changes: 86 additions & 0 deletions apis/clusters/v1beta1/generic_status_fields.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package v1beta1

import (
"k8s.io/utils/strings/slices"

"github.com/instaclustr/operator/apis/clusterresources/v1beta1"
"github.com/instaclustr/operator/pkg/models"
)

type GenericStatus struct {
ID string `json:"id,omitempty"`
Status string `json:"status,omitempty"`
CurrentClusterOperationStatus string `json:"currentClusterOperationStatus,omitempty"`

MaintenanceEvents []*v1beta1.ClusteredMaintenanceEventStatus `json:"maintenanceEvents,omitempty"`
}

func (s *GenericStatus) Equals(o *GenericStatus) bool {
return s.ID == o.ID &&
s.Status == o.Status &&
s.CurrentClusterOperationStatus == o.CurrentClusterOperationStatus
}

func (s *GenericStatus) FromInstAPI(model *models.GenericClusterFields) {
s.ID = model.ID
s.Status = model.Status
s.CurrentClusterOperationStatus = model.CurrentClusterOperationStatus
}

func (s *GenericStatus) MaintenanceEventsEqual(events []*v1beta1.ClusteredMaintenanceEventStatus) bool {
if len(s.MaintenanceEvents) != len(events) {
return false
}

for i := range events {
if !areEventStatusesEqual(events[i], s.MaintenanceEvents[i]) {
return false
}
}

return true
}

type GenericDataCentreStatus struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`

ResizeOperations []*ResizeOperation `json:"resizeOperations,omitempty"`
}

func (s *GenericDataCentreStatus) Equals(o *GenericDataCentreStatus) bool {
return s.Name == o.Name &&
s.Status == o.Status &&
s.ID == o.ID
}

type Node struct {
ID string `json:"id,omitempty"`
Size string `json:"size,omitempty"`
PublicAddress string `json:"publicAddress,omitempty"`
PrivateAddress string `json:"privateAddress,omitempty"`
Status string `json:"status,omitempty"`
Roles []string `json:"roles,omitempty"`
Rack string `json:"rack,omitempty"`
}

func (n *Node) Equals(o *Node) bool {
return n.ID == o.ID &&
n.Size == o.Size &&
n.PublicAddress == o.PublicAddress &&
n.PrivateAddress == o.PrivateAddress &&
n.Status == o.Status &&
n.Rack == o.Rack &&
slices.Equal(n.Roles, o.Roles)
}

func (n *Node) FromInstAPI(model *models.Node) {
n.ID = model.ID
n.Size = model.Size
n.PublicAddress = model.PublicAddress
n.PrivateAddress = model.PrivateAddress
n.Status = model.Status
n.Roles = model.Roles
n.Rack = model.Rack
}
Loading

0 comments on commit 8760f16

Please sign in to comment.