mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-30 13:51:30 +00:00
b027bd8392
Run `go fmt ./...` [1] and add a test to the `test` make target that checks if `go fmt` has been run. [1]: http://blog.golang.org/go-fmt-your-code
39 lines
1 KiB
Go
39 lines
1 KiB
Go
package script
|
|
|
|
const (
|
|
DefaultDockerNetworkMode = "bridge"
|
|
)
|
|
|
|
// Docker stores the configuration details for
|
|
// configuring docker container.
|
|
type Docker struct {
|
|
// NetworkMode (also known as `--net` option)
|
|
// Could be set only if Docker is running in privileged mode
|
|
NetworkMode *string `yaml:"net,omitempty"`
|
|
|
|
// Hostname (also known as `--hostname` option)
|
|
// Could be set only if Docker is running in privileged mode
|
|
Hostname *string `yaml:"hostname,omitempty"`
|
|
}
|
|
|
|
// DockerNetworkMode returns DefaultNetworkMode
|
|
// when Docker.NetworkMode is empty.
|
|
// DockerNetworkMode returns Docker.NetworkMode
|
|
// when it is not empty.
|
|
func DockerNetworkMode(d *Docker) string {
|
|
if d == nil || d.NetworkMode == nil {
|
|
return DefaultDockerNetworkMode
|
|
}
|
|
return *d.NetworkMode
|
|
}
|
|
|
|
// DockerNetworkMode returns empty string
|
|
// when Docker.NetworkMode is empty.
|
|
// DockerNetworkMode returns Docker.NetworkMode
|
|
// when it is not empty.
|
|
func DockerHostname(d *Docker) string {
|
|
if d == nil || d.Hostname == nil {
|
|
return ""
|
|
}
|
|
return *d.Hostname
|
|
}
|