},
})
- cc.cmd.Flags().String("target", "default", "target deployment from deployments section in config file")
+ cc.cmd.Flags().String("target", "", "target deployment from deployments section in config file; defaults to the first one")
cc.cmd.Flags().Bool("confirm", false, "ask for confirmation before making changes to the target")
cc.cmd.Flags().Bool("dryRun", false, "dry run")
cc.cmd.Flags().Bool("force", false, "force upload of all files")
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,
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)
}