Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Boucey committed Jun 7, 2019
1 parent b2b4a5a commit decf4fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
12 changes: 12 additions & 0 deletions Database/Vault/KVv2/Client/Lens.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Database.Vault.KVv2.Client.Lens (
import Control.Lens
import qualified Data.Aeson as A
import Data.Aeson.Lens
-- import Data.Text as T hiding (foldl)

import Database.Vault.KVv2.Client.Types

Expand All @@ -25,3 +26,14 @@ secret (Right v) =
A.Error e -> fail e
Nothing -> fail "Not a secret data JSON object"

{-
listKeys :: [A.Value] -> ([VaultKey],[VaultKey])
listKeys =
foldl lks ([],[])
where
lks (ks,fs) (A.String t) =
if T.last t == '/'
then (ks,fs++[VaultFolder t])
else (ks++[VaultKey t],fs)
lks p _ = p
-}
22 changes: 0 additions & 22 deletions Database/Vault/KVv2/Client/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,25 +87,3 @@ data VaultKey
| VaultFolder T.Text
deriving (Show)

{-
instance FromJSON VaultKey where
parseJSON (Object o)
parseJSON (A.Object v) = do
ar <- v A..: "keys"
return listKeys V.toList ar
parseJSON _ = mzero
Right (Object (fromList [("lease_duration",Number 0.0),("wrap_info",Null),("auth",Null),("data",Object (fromList [("keys",Array [String "dfdfg",String "sdf",String "sub/"])])),("request_id",String "e14a36ca-2893-2526-f976-0a7b9d4735c2"),("warnings",Null),("lease_id",String ""),("renewable",Bool False)]))
-}

listKeys :: [Value] -> ([VaultKey],[VaultKey])
listKeys =
foldl lks ([],[])
where
lks (ks,fs) (String t) =
if T.last t == '/'
then (ks,fs++[VaultFolder t])
else (ks++[VaultKey t],fs)
lks p _ = p

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Gothic - Copyright (c) 2019, Michel Boucey
gothic - Copyright (c) 2019, Michel Boucey
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -11,7 +11,7 @@ modification, are permitted provided that the following conditions are met:
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Gothic nor the names of its
* Neither the name of gothic nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

Expand Down

0 comments on commit decf4fc

Please sign in to comment.