mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-16 15:20:38 +00:00
31 lines
588 B
Go
31 lines
588 B
Go
|
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)
|
||
|
err := unmarshal(&out.Port)
|
||
|
if err != nil {
|
||
|
err = unmarshal(&out)
|
||
|
}
|
||
|
p.Port = out.Port
|
||
|
p.Host = out.Host
|
||
|
p.Protocol = out.Protocol
|
||
|
return err
|
||
|
}
|