Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty secrets files and empty secrets blocks #145

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/SecretsFile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you are user, please see the README for more information.
-}
module SecretsFile where

import Control.Applicative.Combinators (some, option, optional)
import Control.Applicative.Combinators (some, many, option, optional)
import Control.Exception (try, displayException)
import Data.Char (toUpper, isSpace, isControl)
import Data.Functor (void)
Expand Down Expand Up @@ -111,8 +111,8 @@ secretsFileP = do
_ <- whitespace
version <- versionP
case version of
V1 -> some (secretP version "secret")
V2 -> concat <$> some secretBlockP
V1 -> many (secretP version "secret")
V2 -> concat <$> many secretBlockP

-- | Parse the file version
--
Expand All @@ -134,7 +134,7 @@ secretBlockP = do
_ <- symbol "MOUNT"
mountPath <- lexeme pathComponentP
_ <- newlines
some (MP.try (lexeme (secretP V2 mountPath)))
many (MP.try (lexeme (secretP V2 mountPath)))

-- | Parses legal Vault path components.
--
Expand Down
5 changes: 5 additions & 0 deletions test/golden/empty-block.secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VERSION 2
MOUNT empty
MOUNT nonempty
FOO_BAR=foo#bar
MOUNT empty2
Empty file added test/golden/empty-v1.secrets
Empty file.
1 change: 1 addition & 0 deletions test/golden/empty-v2.secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION 2