mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
parse --publish ports into spec
This commit is contained in:
@@ -41,7 +41,8 @@ func (p *PortSpec) Validate() error {
|
||||
switch p.Protocol {
|
||||
case ProtocolHTTP, ProtocolHTTPS, ProtocolTCP, ProtocolUDP:
|
||||
default:
|
||||
return fmt.Errorf("invalid protocol: '%s'", p.Protocol)
|
||||
return fmt.Errorf("invalid protocol '%s', supported protocols: '%s', '%s', '%s', '%s'",
|
||||
p.Protocol, ProtocolHTTP, ProtocolHTTPS, ProtocolTCP, ProtocolUDP)
|
||||
}
|
||||
|
||||
switch p.Mode {
|
||||
|
||||
@@ -32,6 +32,8 @@ func (s *ServiceSpec) Validate() error {
|
||||
return fmt.Errorf("invalid mode: %q", s.Mode)
|
||||
}
|
||||
|
||||
// TODO: validate there is no conflict between ports.
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@ func TestPortSpec_Validate(t *testing.T) {
|
||||
ContainerPort: 8080,
|
||||
Protocol: "invalid",
|
||||
},
|
||||
wantErr: "invalid protocol: 'invalid'",
|
||||
wantErr: "invalid protocol 'invalid'",
|
||||
},
|
||||
{
|
||||
name: "invalid mode",
|
||||
|
||||
Reference in New Issue
Block a user