summaryrefslogtreecommitdiffstats
path: root/deploy/deploy.go
diff options
context:
space:
mode:
authorDavid Jones <david@davidejones.com>2020-03-08 16:35:32 +0000
committerGitHub <noreply@github.com>2020-03-08 17:35:32 +0100
commit51e178a6a28a3f305d89ebb489675743f80862ee (patch)
tree4bf767ca143528b3dac22f1189b9c6f283b7a8e5 /deploy/deploy.go
parentcb12f41a969a569cc00d5a45d5bfa846baffa45c (diff)
deploy: Add include and exclude support for remote
Diffstat (limited to 'deploy/deploy.go')
-rw-r--r--deploy/deploy.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/deploy/deploy.go b/deploy/deploy.go
index c0c6ed4f3..c7a4510c2 100644
--- a/deploy/deploy.go
+++ b/deploy/deploy.go
@@ -138,7 +138,7 @@ func (d *Deployer) Deploy(ctx context.Context) error {
d.summary.NumLocal = len(local)
// Load remote files from the target.
- remote, err := walkRemote(ctx, bucket)
+ remote, err := walkRemote(ctx, bucket, include, exclude)
if err != nil {
return err
}
@@ -499,7 +499,7 @@ func walkLocal(fs afero.Fs, matchers []*matcher, include, exclude glob.Glob) (ma
}
// walkRemote walks the target bucket and returns a flat list.
-func walkRemote(ctx context.Context, bucket *blob.Bucket) (map[string]*blob.ListObject, error) {
+func walkRemote(ctx context.Context, bucket *blob.Bucket, include, exclude glob.Glob) (map[string]*blob.ListObject, error) {
retval := map[string]*blob.ListObject{}
iter := bucket.List(nil)
for {
@@ -510,6 +510,15 @@ func walkRemote(ctx context.Context, bucket *blob.Bucket) (map[string]*blob.List
if err != nil {
return nil, err
}
+ // Check include/exclude matchers.
+ if include != nil && !include.Match(obj.Key) {
+ jww.INFO.Printf(" remote dropping %q due to include\n", obj.Key)
+ continue
+ }
+ if exclude != nil && exclude.Match(obj.Key) {
+ jww.INFO.Printf(" remote dropping %q due to exclude\n", obj.Key)
+ continue
+ }
// If the remote didn't give us an MD5, compute one.
// This can happen for some providers (e.g., fileblob, which uses the
// local filesystem), but not for the most common Cloud providers