define PortSpec type for publishing ports

This commit is contained in:
Pavel Sviderski
2024-12-09 20:25:34 +10:00
parent 537789902b
commit 26df6740e3
+13
View File
@@ -4,6 +4,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/distribution/reference" "github.com/distribution/reference"
"net/netip"
"uncloud/internal/machine/api/pb" "uncloud/internal/machine/api/pb"
) )
@@ -38,6 +40,8 @@ type ContainerSpec struct {
Image string Image string
// Run a custom init inside the container. If nil, use the daemon's configured settings. // Run a custom init inside the container. If nil, use the daemon's configured settings.
Init *bool Init *bool
// Ports to publish from the container.
Ports []PortSpec
} }
func (s *ContainerSpec) Validate() error { func (s *ContainerSpec) Validate() error {
@@ -49,6 +53,15 @@ func (s *ContainerSpec) Validate() error {
return nil return nil
} }
type PortSpec struct {
Hostname string
HostIP netip.Addr
PublishedPort uint16
ContainerPort uint16
Protocol string
Mode string
}
type Service struct { type Service struct {
ID string ID string
Name string Name string