mirror of
https://gitea.com/gitea/act_runner
synced 2024-11-09 18:05:52 +01:00
Move docker.host
to container.docker_host
(#244)
Follow #242. Move `docker.host` to `container.docker_host`. There are already some options for docker/container in `container`, so developers could get confused about where to add options. It's breaking, but I think it's OK since `docker.host` was added just two days ago. Reviewed-on: https://gitea.com/gitea/act_runner/pulls/244 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
parent
9e4a5f7363
commit
054c8d912f
@ -68,9 +68,7 @@ container:
|
|||||||
# valid_volumes:
|
# valid_volumes:
|
||||||
# - '**'
|
# - '**'
|
||||||
valid_volumes: []
|
valid_volumes: []
|
||||||
|
|
||||||
docker:
|
|
||||||
# overrides the docker client host with the specified one.
|
# overrides the docker client host with the specified one.
|
||||||
# default value is the value of DOCKER_HOST environment variable.
|
# default value is the value of DOCKER_HOST environment variable.
|
||||||
# if DOCKER_HOST is not set, the default value is unix:///var/run/docker.sock
|
# if DOCKER_HOST is not set, the default value is unix:///var/run/docker.sock
|
||||||
host: ""
|
docker_host: ""
|
||||||
|
@ -48,11 +48,7 @@ type Container struct {
|
|||||||
Options string `yaml:"options"` // Options specifies additional options for the container.
|
Options string `yaml:"options"` // Options specifies additional options for the container.
|
||||||
WorkdirParent string `yaml:"workdir_parent"` // WorkdirParent specifies the parent directory for the container's working directory.
|
WorkdirParent string `yaml:"workdir_parent"` // WorkdirParent specifies the parent directory for the container's working directory.
|
||||||
ValidVolumes []string `yaml:"valid_volumes"` // ValidVolumes specifies the volumes (including bind mounts) can be mounted to containers.
|
ValidVolumes []string `yaml:"valid_volumes"` // ValidVolumes specifies the volumes (including bind mounts) can be mounted to containers.
|
||||||
}
|
DockerHost string `yaml:"docker_host"` // DockerHost specifies the Docker host. It overrides the value specified in environment variable DOCKER_HOST.
|
||||||
|
|
||||||
// Docker represents the configuration for Docker.
|
|
||||||
type Docker struct {
|
|
||||||
Host string `yaml:"host"` // Host specifies the Docker host.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config represents the overall configuration.
|
// Config represents the overall configuration.
|
||||||
@ -61,7 +57,6 @@ type Config struct {
|
|||||||
Runner Runner `yaml:"runner"` // Runner represents the configuration for the runner.
|
Runner Runner `yaml:"runner"` // Runner represents the configuration for the runner.
|
||||||
Cache Cache `yaml:"cache"` // Cache represents the configuration for caching.
|
Cache Cache `yaml:"cache"` // Cache represents the configuration for caching.
|
||||||
Container Container `yaml:"container"` // Container represents the configuration for the container.
|
Container Container `yaml:"container"` // Container represents the configuration for the container.
|
||||||
Docker Docker `yaml:"docker"` // Docker represents the configuration for Docker.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadDefault returns the default configuration.
|
// LoadDefault returns the default configuration.
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"gitea.com/gitea/act_runner/internal/pkg/config"
|
|
||||||
|
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
|
|
||||||
|
"gitea.com/gitea/act_runner/internal/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CheckIfDockerRunning(ctx context.Context, cfg *config.Config) error {
|
func CheckIfDockerRunning(ctx context.Context, cfg *config.Config) error {
|
||||||
@ -17,8 +17,8 @@ func CheckIfDockerRunning(ctx context.Context, cfg *config.Config) error {
|
|||||||
client.FromEnv,
|
client.FromEnv,
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.Docker.Host != "" {
|
if cfg.Container.DockerHost != "" {
|
||||||
opts = append(opts, client.WithHost(cfg.Docker.Host))
|
opts = append(opts, client.WithHost(cfg.Container.DockerHost))
|
||||||
}
|
}
|
||||||
|
|
||||||
cli, err := client.NewClientWithOpts(opts...)
|
cli, err := client.NewClientWithOpts(opts...)
|
||||||
|
Loading…
Reference in New Issue
Block a user