Allow unsetting of FileContentFlag values.

This commit is contained in:
Alec Thomas
2020-07-10 13:52:32 +10:00
parent 047801d760
commit e10381694b
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
bin
+5
View File
@@ -704,6 +704,11 @@ func (f *FileContentFlag) Decode(ctx *DecodeContext) error { // nolint: golint
if err != nil {
return err
}
// This allows unsetting of file content flags.
if filename == "" {
*f = nil
return nil
}
filename = ExpandPath(filename)
data, err := ioutil.ReadFile(filename) // nolint: gosec
if err != nil {