-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bohdan Siryk
authored and
Bohdan Siryk
committed
Jan 25, 2024
1 parent
b0b9418
commit 8760f16
Showing
18 changed files
with
747 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.