mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
feat: follow-up compose 'ports' support: use ingress mode by default (closes #81)
This commit is contained in:
+1
-18
@@ -34,23 +34,6 @@ type PortSpec struct {
|
||||
Mode string
|
||||
}
|
||||
|
||||
func (p *PortSpec) isHTTP() bool {
|
||||
return p.Protocol == ProtocolHTTP || p.Protocol == ProtocolHTTPS
|
||||
}
|
||||
|
||||
// AdjustUncloudMode makes adjustments for uncloud compatibility
|
||||
func (p *PortSpec) AdjustUncloudMode() {
|
||||
if p.Protocol == "" {
|
||||
p.Protocol = "tcp"
|
||||
}
|
||||
if p.Mode == "" {
|
||||
p.Mode = PortModeIngress
|
||||
}
|
||||
if p.Mode == PortModeIngress && !p.isHTTP() && p.PublishedPort != 0 {
|
||||
p.Mode = PortModeHost
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PortSpec) Validate() error {
|
||||
if p.ContainerPort == 0 {
|
||||
return fmt.Errorf("container port must be non-zero")
|
||||
@@ -73,7 +56,7 @@ func (p *PortSpec) Validate() error {
|
||||
return fmt.Errorf("host IP cannot be specified in %s mode", PortModeIngress)
|
||||
}
|
||||
if p.Hostname != "" {
|
||||
if !p.isHTTP() {
|
||||
if p.Protocol != ProtocolHTTP && p.Protocol != ProtocolHTTPS {
|
||||
return fmt.Errorf("hostname is only valid with '%s' or '%s' protocols", ProtocolHTTP, ProtocolHTTPS)
|
||||
}
|
||||
if err := validateHostname(p.Hostname); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user