option to disable netrc for non-clone steps
This commit is contained in:
@@ -1,6 +1,14 @@
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
### Added
|
||||||
|
- option to disable netrc for non-clone steps
|
||||||
|
- option to customize docker bridge networks
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- upgrade docker client
|
||||||
|
|
||||||
## 1.4.0
|
## 1.4.0
|
||||||
### Added
|
### Added
|
||||||
- support for windows 1909
|
- support for windows 1909
|
||||||
|
|||||||
@@ -92,6 +92,10 @@ type Config struct {
|
|||||||
SkipVerify bool `envconfig:"DRONE_SECRET_PLUGIN_SKIP_VERIFY"`
|
SkipVerify bool `envconfig:"DRONE_SECRET_PLUGIN_SKIP_VERIFY"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Netrc struct {
|
||||||
|
CloneOnly bool `envconfig:"DRONE_NETRC_CLONE_ONLY"`
|
||||||
|
}
|
||||||
|
|
||||||
Registry struct {
|
Registry struct {
|
||||||
Endpoint string `envconfig:"DRONE_REGISTRY_PLUGIN_ENDPOINT"`
|
Endpoint string `envconfig:"DRONE_REGISTRY_PLUGIN_ENDPOINT"`
|
||||||
Token string `envconfig:"DRONE_REGISTRY_PLUGIN_TOKEN"`
|
Token string `envconfig:"DRONE_REGISTRY_PLUGIN_TOKEN"`
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
if err == context.Canceled {
|
if err == context.Canceled {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).
|
logrus.WithError(err).
|
||||||
Errorln("cannot ping the docker daemon")
|
Errorln("cannot ping the docker daemon")
|
||||||
@@ -111,6 +116,7 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
runner := &runtime.Runner{
|
runner := &runtime.Runner{
|
||||||
Client: cli,
|
Client: cli,
|
||||||
Machine: config.Runner.Name,
|
Machine: config.Runner.Name,
|
||||||
|
Environ: config.Runner.Environ,
|
||||||
Reporter: tracer,
|
Reporter: tracer,
|
||||||
Lookup: resource.Lookup,
|
Lookup: resource.Lookup,
|
||||||
Lint: linter.New().Lint,
|
Lint: linter.New().Lint,
|
||||||
@@ -120,11 +126,12 @@ func (c *daemonCommand) run(*kingpin.ParseContext) error {
|
|||||||
config.Limit.Trusted,
|
config.Limit.Trusted,
|
||||||
),
|
),
|
||||||
Compiler: &compiler.Compiler{
|
Compiler: &compiler.Compiler{
|
||||||
Clone: config.Runner.Clone,
|
Clone: config.Runner.Clone,
|
||||||
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
||||||
Networks: config.Runner.Networks,
|
Networks: config.Runner.Networks,
|
||||||
NetworkOpts: config.Runner.NetworkOpts,
|
NetworkOpts: config.Runner.NetworkOpts,
|
||||||
Volumes: config.Runner.Volumes,
|
NetrcCloneOnly: config.Netrc.CloneOnly,
|
||||||
|
Volumes: config.Runner.Volumes,
|
||||||
Resources: compiler.Resources{
|
Resources: compiler.Resources{
|
||||||
Memory: config.Resources.Memory,
|
Memory: config.Resources.Memory,
|
||||||
MemorySwap: config.Resources.MemorySwap,
|
MemorySwap: config.Resources.MemorySwap,
|
||||||
|
|||||||
@@ -66,15 +66,17 @@ func (c *processCommand) run(*kingpin.ParseContext) error {
|
|||||||
runner := &runtime.Runner{
|
runner := &runtime.Runner{
|
||||||
Client: cli,
|
Client: cli,
|
||||||
Machine: config.Runner.Name,
|
Machine: config.Runner.Name,
|
||||||
|
Environ: config.Runner.Environ,
|
||||||
Reporter: remote,
|
Reporter: remote,
|
||||||
Lookup: resource.Lookup,
|
Lookup: resource.Lookup,
|
||||||
Lint: linter.New().Lint,
|
Lint: linter.New().Lint,
|
||||||
Match: nil,
|
Match: nil,
|
||||||
Compiler: &compiler.Compiler{
|
Compiler: &compiler.Compiler{
|
||||||
Clone: config.Runner.Clone,
|
Clone: config.Runner.Clone,
|
||||||
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
Privileged: append(config.Runner.Privileged, compiler.Privileged...),
|
||||||
Networks: config.Runner.Networks,
|
Networks: config.Runner.Networks,
|
||||||
Volumes: config.Runner.Volumes,
|
NetrcCloneOnly: config.Netrc.CloneOnly,
|
||||||
|
Volumes: config.Runner.Volumes,
|
||||||
Resources: compiler.Resources{
|
Resources: compiler.Resources{
|
||||||
Memory: config.Resources.Memory,
|
Memory: config.Resources.Memory,
|
||||||
MemorySwap: config.Resources.MemorySwap,
|
MemorySwap: config.Resources.MemorySwap,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ package compiler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/drone-runners/drone-runner-docker/engine"
|
"github.com/drone-runners/drone-runner-docker/engine"
|
||||||
@@ -77,6 +76,10 @@ type Compiler struct {
|
|||||||
// are used when creating the docker network.
|
// are used when creating the docker network.
|
||||||
NetworkOpts map[string]string
|
NetworkOpts map[string]string
|
||||||
|
|
||||||
|
// NetrcCloneOnly instrucs the compiler to only inject
|
||||||
|
// the netrc file into the clone setp.
|
||||||
|
NetrcCloneOnly bool
|
||||||
|
|
||||||
// Volumes provides a set of volumes that should be
|
// Volumes provides a set of volumes that should be
|
||||||
// mounted to each pipeline container.
|
// mounted to each pipeline container.
|
||||||
Volumes map[string]string
|
Volumes map[string]string
|
||||||
@@ -215,17 +218,10 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
|||||||
envs["DRONE_DOCKER_VOLUME_PATH"] = volume.HostPath.Path
|
envs["DRONE_DOCKER_VOLUME_PATH"] = volume.HostPath.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the netrc environment variables
|
// create the .netrc environment variables if not
|
||||||
if args.Netrc != nil && args.Netrc.Machine != "" {
|
// explicitly disabled
|
||||||
envs["DRONE_NETRC_MACHINE"] = args.Netrc.Machine
|
if c.NetrcCloneOnly == false {
|
||||||
envs["DRONE_NETRC_USERNAME"] = args.Netrc.Login
|
envs = environ.Combine(envs, environ.Netrc(args.Netrc))
|
||||||
envs["DRONE_NETRC_PASSWORD"] = args.Netrc.Password
|
|
||||||
envs["DRONE_NETRC_FILE"] = fmt.Sprintf(
|
|
||||||
"machine %s login %s password %s",
|
|
||||||
args.Netrc.Machine,
|
|
||||||
args.Netrc.Login,
|
|
||||||
args.Netrc.Password,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match := manifest.Match{
|
match := manifest.Match{
|
||||||
@@ -250,6 +246,12 @@ func (c *Compiler) Compile(ctx context.Context, args runtime.CompilerArgs) runti
|
|||||||
step.Volumes = append(step.Volumes, mount)
|
step.Volumes = append(step.Volumes, mount)
|
||||||
spec.Steps = append(spec.Steps, step)
|
spec.Steps = append(spec.Steps, step)
|
||||||
|
|
||||||
|
// always set the .netrc file for the clone step.
|
||||||
|
// note that environment variables are only set
|
||||||
|
// if the .netrc file is not nil (it will always
|
||||||
|
// be nil for public repositories).
|
||||||
|
step.Envs = environ.Combine(step.Envs, environ.Netrc(args.Netrc))
|
||||||
|
|
||||||
// if the clone image is customized, override
|
// if the clone image is customized, override
|
||||||
// the default image.
|
// the default image.
|
||||||
if c.Clone != "" {
|
if c.Clone != "" {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -17,7 +17,7 @@ require (
|
|||||||
github.com/docker/go-connections v0.3.0 // indirect
|
github.com/docker/go-connections v0.3.0 // indirect
|
||||||
github.com/drone/drone-go v1.2.1-0.20200326064413-195394da1018
|
github.com/drone/drone-go v1.2.1-0.20200326064413-195394da1018
|
||||||
github.com/drone/envsubst v1.0.2
|
github.com/drone/envsubst v1.0.2
|
||||||
github.com/drone/runner-go v1.6.1-0.20200506182602-d2e6327ade15
|
github.com/drone/runner-go v1.6.1-0.20200813033918-b849bd35b2eb
|
||||||
github.com/drone/signal v1.0.0
|
github.com/drone/signal v1.0.0
|
||||||
github.com/ghodss/yaml v1.0.0
|
github.com/ghodss/yaml v1.0.0
|
||||||
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 // indirect
|
github.com/gogo/protobuf v0.0.0-20170307180453-100ba4e88506 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -42,6 +42,10 @@ github.com/drone/envsubst v1.0.2 h1:dpYLMAspQHW0a8dZpLRKe9jCNvIGZPhCPrycZzIHdqo=
|
|||||||
github.com/drone/envsubst v1.0.2/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0=
|
github.com/drone/envsubst v1.0.2/go.mod h1:bkZbnc/2vh1M12Ecn7EYScpI4YGYU0etwLJICOWi8Z0=
|
||||||
github.com/drone/runner-go v1.6.1-0.20200506182602-d2e6327ade15 h1:+oj5a9GdF1DeQ3+i1pxARZBCd2wjYPPZveerAcF+WZk=
|
github.com/drone/runner-go v1.6.1-0.20200506182602-d2e6327ade15 h1:+oj5a9GdF1DeQ3+i1pxARZBCd2wjYPPZveerAcF+WZk=
|
||||||
github.com/drone/runner-go v1.6.1-0.20200506182602-d2e6327ade15/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
|
github.com/drone/runner-go v1.6.1-0.20200506182602-d2e6327ade15/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
|
||||||
|
github.com/drone/runner-go v1.6.1-0.20200812000613-56f7972d3926 h1:3amY6XK13uKxSVEkl4qKXU6CZsEZnKYbY2c9glonlDw=
|
||||||
|
github.com/drone/runner-go v1.6.1-0.20200812000613-56f7972d3926/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
|
||||||
|
github.com/drone/runner-go v1.6.1-0.20200813033918-b849bd35b2eb h1:jypm+IUZsFW6rINKlYm+/PmdGXRB18ugDbBkZiuBh8I=
|
||||||
|
github.com/drone/runner-go v1.6.1-0.20200813033918-b849bd35b2eb/go.mod h1:+Zc4z9/xqlqkFkAcqOtuYjYS77d2PeuWh0PxxibHfNs=
|
||||||
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
|
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
|
||||||
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
|
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
|
||||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
|||||||
Reference in New Issue
Block a user