mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
Merge pull request #315 from sivel/swift-empty-target
Make target optional in the swift publish plugin
This commit is contained in:
commit
5886e0fec1
@ -2,6 +2,7 @@ package publish
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/drone/drone/pkg/build/buildfile"
|
"github.com/drone/drone/pkg/build/buildfile"
|
||||||
)
|
)
|
||||||
@ -37,12 +38,18 @@ type Swift struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Swift) Write(f *buildfile.Buildfile) {
|
func (s *Swift) Write(f *buildfile.Buildfile) {
|
||||||
|
var target string
|
||||||
// All options are required, so ensure they are present
|
// All options are required, so ensure they are present
|
||||||
if len(s.Username) == 0 || len(s.Password) == 0 || len(s.AuthURL) == 0 || len(s.Region) == 0 || len(s.Source) == 0 || len(s.Container) == 0 || len(s.Target) == 0 {
|
if len(s.Username) == 0 || len(s.Password) == 0 || len(s.AuthURL) == 0 || len(s.Region) == 0 || len(s.Source) == 0 || len(s.Container) == 0 {
|
||||||
f.WriteCmdSilent(`echo "Swift: Missing argument(s)"`)
|
f.WriteCmdSilent(`echo "Swift: Missing argument(s)"`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If a target was provided, prefix it with a /
|
||||||
|
if len(s.Target) > 0 {
|
||||||
|
target = fmt.Sprintf("/%s", strings.TrimPrefix(s.Target, "/"))
|
||||||
|
}
|
||||||
|
|
||||||
// debugging purposes so we can see if / where something is failing
|
// debugging purposes so we can see if / where something is failing
|
||||||
f.WriteCmdSilent(`echo "Swift: Publishing..."`)
|
f.WriteCmdSilent(`echo "Swift: Publishing..."`)
|
||||||
|
|
||||||
@ -56,5 +63,5 @@ func (s *Swift) Write(f *buildfile.Buildfile) {
|
|||||||
f.WriteEnv("SWIFTLY_AUTH_KEY", s.Password)
|
f.WriteEnv("SWIFTLY_AUTH_KEY", s.Password)
|
||||||
f.WriteEnv("SWIFTLY_REGION", s.Region)
|
f.WriteEnv("SWIFTLY_REGION", s.Region)
|
||||||
|
|
||||||
f.WriteCmd(fmt.Sprintf(`swiftly put -i %s %s/%s`, s.Source, s.Container, s.Target))
|
f.WriteCmd(fmt.Sprintf(`swiftly put -i %s %s%s`, s.Source, s.Container, target))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user