forked from TrueCloudLab/distribution
Bugfix: Make ipfilteredby not required
Signed-off-by: Vishesh Jindal <vishesh92@gmail.com>
(cherry picked from commit f9a0506191
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
cfd1309845
commit
afa91463d6
1 changed files with 24 additions and 18 deletions
|
@ -138,27 +138,33 @@ func newCloudFrontStorageMiddleware(storageDriver storagedriver.StorageDriver, o
|
||||||
|
|
||||||
// parse ipfilteredby
|
// parse ipfilteredby
|
||||||
var awsIPs *awsIPs
|
var awsIPs *awsIPs
|
||||||
if ipFilteredBy := options["ipfilteredby"].(string); ok {
|
if i, ok := options["ipfilteredby"]; ok {
|
||||||
switch strings.ToLower(strings.TrimSpace(ipFilteredBy)) {
|
if ipFilteredBy, ok := i.(string); ok {
|
||||||
case "", "none":
|
switch strings.ToLower(strings.TrimSpace(ipFilteredBy)) {
|
||||||
awsIPs = nil
|
case "", "none":
|
||||||
case "aws":
|
awsIPs = nil
|
||||||
newAWSIPs(ipRangesURL, updateFrequency, nil)
|
case "aws":
|
||||||
case "awsregion":
|
awsIPs = newAWSIPs(ipRangesURL, updateFrequency, nil)
|
||||||
var awsRegion []string
|
case "awsregion":
|
||||||
if regions, ok := options["awsregion"].(string); ok {
|
var awsRegion []string
|
||||||
for _, awsRegions := range strings.Split(regions, ",") {
|
if i, ok := options["awsregion"]; ok {
|
||||||
awsRegion = append(awsRegion, strings.ToLower(strings.TrimSpace(awsRegions)))
|
if regions, ok := i.(string); ok {
|
||||||
|
for _, awsRegions := range strings.Split(regions, ",") {
|
||||||
|
awsRegion = append(awsRegion, strings.ToLower(strings.TrimSpace(awsRegions)))
|
||||||
|
}
|
||||||
|
awsIPs = newAWSIPs(ipRangesURL, updateFrequency, awsRegion)
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("awsRegion must be a comma separated string of valid aws regions")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("awsRegion is not defined")
|
||||||
}
|
}
|
||||||
awsIPs = newAWSIPs(ipRangesURL, updateFrequency, awsRegion)
|
default:
|
||||||
} else {
|
return nil, fmt.Errorf("ipfilteredby only allows a string the following value: none|aws|awsregion")
|
||||||
return nil, fmt.Errorf("awsRegion must be a comma separated string of valid aws regions")
|
|
||||||
}
|
}
|
||||||
default:
|
} else {
|
||||||
return nil, fmt.Errorf("ipfilteredby only allows a string the following value: none|aws|awsregion")
|
return nil, fmt.Errorf("ipfilteredby only allows a string with the following value: none|aws|awsregion")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return nil, fmt.Errorf("ipfilteredby only allows a string with the following value: none|aws|awsregion")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &cloudFrontStorageMiddleware{
|
return &cloudFrontStorageMiddleware{
|
||||||
|
|
Loading…
Reference in a new issue