deploy: Implement include/exclude filters for deploy

Fixes #6922
This commit is contained in:
Robert van Gent 2020-02-26 22:26:05 -08:00 committed by GitHub
parent 33ae621083
commit 05a74eaec0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 151 additions and 5 deletions

View file

@ -38,18 +38,21 @@ order = ["o1", "o2"]
name = "name0"
url = "url0"
cloudfrontdistributionid = "cdn0"
include = "*.html"
# All uppercase.
[[deployment.targets]]
NAME = "name1"
URL = "url1"
CLOUDFRONTDISTRIBUTIONID = "cdn1"
INCLUDE = "*.jpg"
# Camelcase.
[[deployment.targets]]
name = "name2"
url = "url2"
cloudFrontDistributionID = "cdn2"
exclude = "*.png"
# All lowercase.
[[deployment.matchers]]
@ -90,11 +93,21 @@ force = true
// Targets.
c.Assert(len(dcfg.Targets), qt.Equals, 3)
wantInclude := []string{"*.html", "*.jpg", ""}
wantExclude := []string{"", "", "*.png"}
for i := 0; i < 3; i++ {
tgt := dcfg.Targets[i]
c.Assert(tgt.Name, qt.Equals, fmt.Sprintf("name%d", i))
c.Assert(tgt.URL, qt.Equals, fmt.Sprintf("url%d", i))
c.Assert(tgt.CloudFrontDistributionID, qt.Equals, fmt.Sprintf("cdn%d", i))
c.Assert(tgt.Include, qt.Equals, wantInclude[i])
if wantInclude[i] != "" {
c.Assert(tgt.includeGlob, qt.Not(qt.IsNil))
}
c.Assert(tgt.Exclude, qt.Equals, wantExclude[i])
if wantExclude[i] != "" {
c.Assert(tgt.excludeGlob, qt.Not(qt.IsNil))
}
}
// Matchers.