sshpoke/pkg/dto/models.go

63 lines
1.2 KiB
Go
Raw Permalink Normal View History

package dto
import "net"
type EventType uint8
const (
EventStart EventType = iota
EventStop
EventShutdown
EventError
EventUnknown
)
var eventTypeNames = map[EventType]string{
EventStart: "start",
EventStop: "stop",
EventShutdown: "shutdown",
EventError: "error",
EventUnknown: "unknown",
}
func (e EventType) String() string {
name, ok := eventTypeNames[e]
if ok {
return name
}
return eventTypeNames[EventUnknown]
}
func TypeFromAction(action string) EventType {
switch action {
case "start":
return EventStart
case "stop", "die":
return EventStop
default:
return EventUnknown
}
}
2023-11-17 20:39:00 +03:00
type Event struct {
Type EventType
Container Container
}
type EventStatus struct {
Type EventType
ID string
Error string
Domain string
2023-11-17 20:39:00 +03:00
}
type Container struct {
2023-11-22 23:31:35 +03:00
ID string `json:"id" example:"49ec97b6a12560f98fe21a20a88c37d289c83b14cc0ada2a62b0e404512905ed"`
Names []string `json:"names" example:"service-web-1"`
IP net.IP `json:"ip" swaggertype:"string" format:"ipv4"`
Port uint16 `json:"port" example:"80"`
2023-11-18 21:23:29 +03:00
Server string `json:"-"`
2023-11-22 23:31:35 +03:00
RemoteHost string `json:"remote_host,omitempty" example:"hostname"`
Domain string `json:"domain" example:"https://service.localhost.run"`
}