2021-09-19 12:00:00 +00:00
|
|
|
// Copyright (c) 2019, Drone IO Inc.
|
|
|
|
// Copyright (c) 2021, Robert Kaussow <mail@thegeeklab.de>
|
2019-02-10 19:00:16 +00:00
|
|
|
|
2019-01-22 23:44:17 +00:00
|
|
|
package yaml
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
|
|
|
// Port represents a network port in a single container.
|
|
|
|
Port struct {
|
|
|
|
Port int `json:"port,omitempty"`
|
|
|
|
Host int `json:"host,omitempty"`
|
|
|
|
Protocol string `json:"protocol,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
port struct {
|
|
|
|
Port int
|
|
|
|
Host int
|
|
|
|
Protocol string
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
// UnmarshalYAML implements yaml unmarshalling.
|
|
|
|
func (p *Port) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
|
|
out := new(port)
|
2023-02-08 09:14:20 +00:00
|
|
|
|
2019-01-22 23:44:17 +00:00
|
|
|
err := unmarshal(&out.Port)
|
|
|
|
if err != nil {
|
|
|
|
err = unmarshal(&out)
|
|
|
|
}
|
2023-02-08 09:14:20 +00:00
|
|
|
|
2019-01-22 23:44:17 +00:00
|
|
|
p.Port = out.Port
|
|
|
|
p.Host = out.Host
|
|
|
|
p.Protocol = out.Protocol
|
2023-02-08 09:14:20 +00:00
|
|
|
|
2019-01-22 23:44:17 +00:00
|
|
|
return err
|
|
|
|
}
|