hook up global networks
This commit is contained in:
24
.drone.yml
24
.drone.yml
@@ -78,6 +78,16 @@ steps:
|
|||||||
- refs/heads/master
|
- refs/heads/master
|
||||||
- refs/tags/*
|
- refs/tags/*
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: go
|
||||||
|
temp: {}
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: manifest
|
||||||
|
|
||||||
|
steps:
|
||||||
- name: manifest
|
- name: manifest
|
||||||
image: plugins/manifest
|
image: plugins/manifest
|
||||||
settings:
|
settings:
|
||||||
@@ -88,11 +98,11 @@ steps:
|
|||||||
from_secret: docker_password
|
from_secret: docker_password
|
||||||
username:
|
username:
|
||||||
from_secret: docker_username
|
from_secret: docker_username
|
||||||
when:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/tags/*
|
|
||||||
|
|
||||||
volumes:
|
depends_on:
|
||||||
- name: go
|
- linux
|
||||||
temp: {}
|
|
||||||
|
trigger:
|
||||||
|
ref:
|
||||||
|
- refs/heads/master
|
||||||
|
- refs/tags/*
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ func configureSerial(spec *engine.Spec) {
|
|||||||
func convertStaticEnv(src map[string]*manifest.Variable) map[string]string {
|
func convertStaticEnv(src map[string]*manifest.Variable) map[string]string {
|
||||||
dst := map[string]string{}
|
dst := map[string]string{}
|
||||||
for k, v := range src {
|
for k, v := range src {
|
||||||
|
if v == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if strings.TrimSpace(v.Secret) == "" {
|
if strings.TrimSpace(v.Secret) == "" {
|
||||||
dst[k] = v.Value
|
dst[k] = v.Value
|
||||||
}
|
}
|
||||||
@@ -76,6 +79,9 @@ func convertStaticEnv(src map[string]*manifest.Variable) map[string]string {
|
|||||||
func convertSecretEnv(src map[string]*manifest.Variable) []*engine.Secret {
|
func convertSecretEnv(src map[string]*manifest.Variable) []*engine.Secret {
|
||||||
dst := []*engine.Secret{}
|
dst := []*engine.Secret{}
|
||||||
for k, v := range src {
|
for k, v := range src {
|
||||||
|
if v == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if strings.TrimSpace(v.Secret) != "" {
|
if strings.TrimSpace(v.Secret) != "" {
|
||||||
dst = append(dst, &engine.Secret{
|
dst = append(dst, &engine.Secret{
|
||||||
Name: v.Secret,
|
Name: v.Secret,
|
||||||
|
|||||||
@@ -251,7 +251,9 @@ func toVolumeType(from *Volume) mount.Type {
|
|||||||
func toEnv(env map[string]string) []string {
|
func toEnv(env map[string]string) []string {
|
||||||
var envs []string
|
var envs []string
|
||||||
for k, v := range env {
|
for k, v := range env {
|
||||||
envs = append(envs, k+"="+v)
|
if v != "" {
|
||||||
|
envs = append(envs, k+"="+v)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return envs
|
return envs
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
|
|
||||||
"docker.io/go-docker"
|
"docker.io/go-docker"
|
||||||
"docker.io/go-docker/api/types"
|
"docker.io/go-docker/api/types"
|
||||||
|
"docker.io/go-docker/api/types/network"
|
||||||
"docker.io/go-docker/api/types/volume"
|
"docker.io/go-docker/api/types/volume"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -214,6 +215,19 @@ func (e *Docker) create(ctx context.Context, spec *Spec, step *Step, output io.W
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// attach the container to user-defined networks.
|
||||||
|
// primarily used to attach global user-defined networks.
|
||||||
|
if step.Network == "" {
|
||||||
|
for _, net := range step.Networks {
|
||||||
|
err = e.client.NetworkConnect(ctx, net, step.ID, &network.EndpointSettings{
|
||||||
|
Aliases: []string{net},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user