filer: add path-specific option to enforce readonly
This commit is contained in:
@@ -126,6 +126,9 @@ func mergePathConf(a, b *filer_pb.FilerConf_PathConf) {
|
||||
if b.VolumeGrowthCount > 0 {
|
||||
a.VolumeGrowthCount = b.VolumeGrowthCount
|
||||
}
|
||||
if b.ReadOnly {
|
||||
a.ReadOnly = b.ReadOnly
|
||||
}
|
||||
}
|
||||
|
||||
func (fc *FilerConf) ToProto() *filer_pb.FilerConf {
|
||||
|
||||
@@ -24,6 +24,18 @@ func TestFilerConf(t *testing.T) {
|
||||
LocationPrefix: "/buckets/",
|
||||
Replication: "001",
|
||||
},
|
||||
{
|
||||
LocationPrefix: "/buckets",
|
||||
ReadOnly: false,
|
||||
},
|
||||
{
|
||||
LocationPrefix: "/buckets/xxx",
|
||||
ReadOnly: true,
|
||||
},
|
||||
{
|
||||
LocationPrefix: "/buckets/xxx/yyy",
|
||||
ReadOnly: false,
|
||||
},
|
||||
}}
|
||||
fc.doLoadConf(conf)
|
||||
|
||||
@@ -31,4 +43,7 @@ func TestFilerConf(t *testing.T) {
|
||||
assert.Equal(t, "abcd", fc.MatchStorageRule("/buckets/abcd/jasdf").Collection)
|
||||
assert.Equal(t, "001", fc.MatchStorageRule("/buckets/abc/jasdf").Replication)
|
||||
|
||||
assert.Equal(t, true, fc.MatchStorageRule("/buckets/xxx/yyy/zzz").ReadOnly)
|
||||
assert.Equal(t, false, fc.MatchStorageRule("/buckets/other").ReadOnly)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user