summaryrefslogtreecommitdiffhomepage
path: root/deploy
diff options
context:
space:
mode:
authorRobert van Gent <[email protected]>2019-05-31 10:10:38 -0700
committerBjørn Erik Pedersen <[email protected]>2019-06-08 00:41:59 +0200
commit9df57154ee3e3185d024bfe376101b404d8b7cc4 (patch)
tree4b4c1f33f363a8c0c9712d295bcc632e71c8e28c /deploy
parent35abce27cabee43cc751db55a75b927f26275833 (diff)
downloadhugo-9df57154ee3e3185d024bfe376101b404d8b7cc4.tar.gz
hugo-9df57154ee3e3185d024bfe376101b404d8b7cc4.zip
deploy: Default --target to the first deployment target
Diffstat (limited to 'deploy')
-rw-r--r--deploy/deploy.go22
1 files changed, 16 insertions, 6 deletions
diff --git a/deploy/deploy.go b/deploy/deploy.go
index e83410618..0512e352e 100644
--- a/deploy/deploy.go
+++ b/deploy/deploy.go
@@ -77,15 +77,24 @@ func New(cfg config.Provider, localFs afero.Fs) (*Deployer, error) {
return nil, err
}
+ if len(dcfg.Targets) == 0 {
+ return nil, errors.New("no deployment targets found")
+ }
+
// Find the target to deploy to.
var tgt *target
- for _, t := range dcfg.Targets {
- if t.Name == targetName {
- tgt = t
+ if targetName == "" {
+ // Default to the first target.
+ tgt = dcfg.Targets[0]
+ } else {
+ for _, t := range dcfg.Targets {
+ if t.Name == targetName {
+ tgt = t
+ }
+ }
+ if tgt == nil {
+ return nil, fmt.Errorf("deployment target %q not found", targetName)
}
- }
- if tgt == nil {
- return nil, fmt.Errorf("deployment target %q not found", targetName)
}
return &Deployer{
localFs: localFs,
@@ -105,6 +114,7 @@ func (d *Deployer) openBucket(ctx context.Context) (*blob.Bucket, error) {
if d.bucket != nil {
return d.bucket, nil
}
+ jww.FEEDBACK.Printf("Deploying to target %q (%s)\n", d.target.Name, d.target.URL)
return blob.OpenBucket(ctx, d.target.URL)
}