Add retries option to the clone step (#44)
* Add retries option to the clone step Used to support https://github.com/drone/drone-git/pull/43 Will require a go mod update to add the arg to the manifest: https://github.com/drone/runner-go/pull/22 * Update `runner-go` to v1.12.0 * Add test
This commit is contained in:
@@ -34,6 +34,9 @@ func cloneParams(src manifest.Clone) map[string]string {
|
|||||||
if depth := src.Depth; depth > 0 {
|
if depth := src.Depth; depth > 0 {
|
||||||
dst["PLUGIN_DEPTH"] = strconv.Itoa(depth)
|
dst["PLUGIN_DEPTH"] = strconv.Itoa(depth)
|
||||||
}
|
}
|
||||||
|
if retries := src.Retries; retries > 0 {
|
||||||
|
dst["PLUGIN_RETRIES"] = strconv.Itoa(retries)
|
||||||
|
}
|
||||||
if skipVerify := src.SkipVerify; skipVerify {
|
if skipVerify := src.SkipVerify; skipVerify {
|
||||||
dst["GIT_SSL_NO_VERIFY"] = "true"
|
dst["GIT_SSL_NO_VERIFY"] = "true"
|
||||||
dst["PLUGIN_SKIP_VERIFY"] = "true"
|
dst["PLUGIN_SKIP_VERIFY"] = "true"
|
||||||
|
|||||||
@@ -134,10 +134,17 @@ func TestCloneParams(t *testing.T) {
|
|||||||
if len(params) != 0 {
|
if len(params) != 0 {
|
||||||
t.Errorf("Expect zero depth ignored")
|
t.Errorf("Expect zero depth ignored")
|
||||||
}
|
}
|
||||||
params = cloneParams(manifest.Clone{Depth: 50, SkipVerify: true})
|
params = cloneParams(manifest.Clone{Retries: 0})
|
||||||
|
if len(params) != 0 {
|
||||||
|
t.Errorf("Expect zero retries ignored")
|
||||||
|
}
|
||||||
|
params = cloneParams(manifest.Clone{Depth: 50, SkipVerify: true, Retries: 4})
|
||||||
if params["PLUGIN_DEPTH"] != "50" {
|
if params["PLUGIN_DEPTH"] != "50" {
|
||||||
t.Errorf("Expect clone depth 50")
|
t.Errorf("Expect clone depth 50")
|
||||||
}
|
}
|
||||||
|
if params["PLUGIN_RETRIES"] != "4" {
|
||||||
|
t.Errorf("Expect clone retries 4")
|
||||||
|
}
|
||||||
if params["GIT_SSL_NO_VERIFY"] != "true" {
|
if params["GIT_SSL_NO_VERIFY"] != "true" {
|
||||||
t.Errorf("Expect GIT_SSL_NO_VERIFY is true")
|
t.Errorf("Expect GIT_SSL_NO_VERIFY is true")
|
||||||
}
|
}
|
||||||
|
|||||||
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.7.1
|
github.com/drone/drone-go v1.7.1
|
||||||
github.com/drone/envsubst v1.0.3
|
github.com/drone/envsubst v1.0.3
|
||||||
github.com/drone/runner-go v1.11.0
|
github.com/drone/runner-go v1.12.0
|
||||||
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
|
||||||
|
|||||||
6
go.sum
6
go.sum
@@ -41,10 +41,8 @@ github.com/drone/drone-go v1.7.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRp
|
|||||||
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/envsubst v1.0.3 h1:PCIBwNDYjs50AsLZPYdfhSATKaRg/FJmDc2D6+C2x8g=
|
github.com/drone/envsubst v1.0.3 h1:PCIBwNDYjs50AsLZPYdfhSATKaRg/FJmDc2D6+C2x8g=
|
||||||
github.com/drone/envsubst v1.0.3/go.mod h1:N2jZmlMufstn1KEqvbHjw40h1KyTmnVzHcSc9bFiJ2g=
|
github.com/drone/envsubst v1.0.3/go.mod h1:N2jZmlMufstn1KEqvbHjw40h1KyTmnVzHcSc9bFiJ2g=
|
||||||
github.com/drone/runner-go v1.10.0 h1:IVfdfZi/p36D0hgXiVUieGJoLrvJTL02Kk3CXDVFInE=
|
github.com/drone/runner-go v1.12.0 h1:zUjDj9ylsJ4n4Mvy4znddq/Z4EBzcUXzTltpzokKtgs=
|
||||||
github.com/drone/runner-go v1.10.0/go.mod h1:vu4pPPYDoeN6vdYQAY01GGGsAIW4aLganJNaa8Fx8zE=
|
github.com/drone/runner-go v1.12.0/go.mod h1:vu4pPPYDoeN6vdYQAY01GGGsAIW4aLganJNaa8Fx8zE=
|
||||||
github.com/drone/runner-go v1.11.0 h1:zcn8Hmi0H1I4pxdJCauykG5teu3AH84Uw4WM7VrKlIM=
|
|
||||||
github.com/drone/runner-go v1.11.0/go.mod h1:vu4pPPYDoeN6vdYQAY01GGGsAIW4aLganJNaa8Fx8zE=
|
|
||||||
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