Skip to content

Commit

Permalink
Updated stack lts, updated impacted code
Browse files Browse the repository at this point in the history
  • Loading branch information
verifiedtm committed May 13, 2022
1 parent f9c7df0 commit 95e5f01
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-18.10
resolver: lts-19.6
flags: {}
packages:
- vault-tool
Expand Down
12 changes: 12 additions & 0 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file was autogenerated by Stack.
# You should not edit this file by hand.
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files

packages: []
snapshots:
- completed:
size: 618876
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/6.yaml
sha256: fb634b19f31da06684bb07ce02a20c75a3162138f279b388905b03ebd57bb50f
original: lts-19.6
15 changes: 8 additions & 7 deletions vault-tool/src/Data/Aeson/Utils.hs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{-# LANGUAGE OverloadedStrings #-}

module Data.Aeson.Utils (
object,
(.=!),
(.=?),
DataWrapper (..)
DataWrapper (..),
) where

import Data.Aeson (FromJSON, KeyValue, ToJSON, Value, (.=), (.:), withObject)
import Data.Aeson (FromJSON, Key, KeyValue, ToJSON, Value, withObject, (.:), (.=))
import qualified Data.Aeson as Aeson
import Data.Aeson.Types (Pair)
import Data.Maybe (catMaybes)
import Data.Text (Text)

object :: [Maybe (Text, Value)] -> Value
object :: [Maybe Pair] -> Value
object = Aeson.object . catMaybes

(.=!) :: (KeyValue a, ToJSON b) => Text -> b -> Maybe a
(.=!) :: (KeyValue a, ToJSON b) => Key -> b -> Maybe a
k .=! v = Just $ k .= v

(.=?) :: (Functor f, KeyValue a, ToJSON b) => Text -> f b -> f a
(.=?) :: (Functor f, KeyValue a, ToJSON b) => Key -> f b -> f a
k .=? v = (k .=) <$> v

newtype DataWrapper a = DataWrapper { unDataWrapper :: a }
newtype DataWrapper a = DataWrapper {unDataWrapper :: a}

instance ToJSON a => ToJSON (DataWrapper a) where
toJSON (DataWrapper x) = object ["data" .=! x]
Expand Down
6 changes: 4 additions & 2 deletions vault-tool/src/Network/VaultTool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import Data.Aeson (
FromJSON,
ToJSON,
Value (..),
Key,
(.:),
(.=),
(.:?),
Expand All @@ -75,6 +76,7 @@ import Data.Aeson (
parseJSON,
withObject,
)
import qualified Data.Aeson.KeyMap as KM
import Data.Aeson.Types (parseEither, Pair)
import Data.List (sortOn)
import Data.Text (Text)
Expand Down Expand Up @@ -321,7 +323,7 @@ instance ToJSON VaultAppRoleParameters where
, "period" .=? _VaultAppRoleParameters_Period v
]
where
(.=?) :: ToJSON x => Text -> Maybe x -> Maybe Pair
(.=?) :: ToJSON x => Key -> Maybe x -> Maybe Pair
t .=? x = (t .=) <$> x

instance FromJSON VaultAppRoleParameters where
Expand Down Expand Up @@ -483,7 +485,7 @@ vaultMounts conn = do
-- See <https://github.com/hashicorp/vault/issues/1965>
--
-- We do some detection to support both the new and the old format:
let root = case H.lookup "data" rspObj of
let root = case KM.lookup "data" rspObj of
Nothing -> Object rspObj
Just v -> v

Expand Down

0 comments on commit 95e5f01

Please sign in to comment.