mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
add Mode to Service entity
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
const (
|
||||
LabelServiceID = "uncloud.service.id"
|
||||
LabelServiceName = "uncloud.service.name"
|
||||
LabelServiceMode = "uncloud.service.mode"
|
||||
)
|
||||
|
||||
type Container struct {
|
||||
@@ -24,6 +25,11 @@ func (c *Container) ServiceName() string {
|
||||
return c.Labels[LabelServiceName]
|
||||
}
|
||||
|
||||
// ServiceMode returns the replication mode of the service that the container is part of.
|
||||
func (c *Container) ServiceMode() string {
|
||||
return c.Labels[LabelServiceMode]
|
||||
}
|
||||
|
||||
// runningStatusRegex matches the status string of a running container.
|
||||
// - "Up 3 minutes (healthy)" -> groups: ["Up 3 minutes (healthy)", "healthy"]
|
||||
// - "Up 5 seconds" -> groups: ["Up 5 seconds", ""]
|
||||
|
||||
@@ -14,6 +14,7 @@ const (
|
||||
type Service struct {
|
||||
ID string
|
||||
Name string
|
||||
Mode string
|
||||
Containers []MachineContainer
|
||||
}
|
||||
|
||||
@@ -35,6 +36,7 @@ func FromProto(s *pb.Service) (Service, error) {
|
||||
return Service{
|
||||
ID: s.Id,
|
||||
Name: s.Name,
|
||||
Mode: s.Mode,
|
||||
Containers: containers,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user