Skip to content

Commit

Permalink
Restructure packages
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed Apr 5, 2024
1 parent 2cadbda commit a7f4c85
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 25 deletions.
8 changes: 4 additions & 4 deletions azure-auth/src/Auth.hs → azure-auth/Azure/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

module Auth
module Azure.Auth
( defaultAzureCredential
, withManagedIdentity
) where

import Types (AccessToken (..), Token, readToken, updateToken)

import Control.Monad.IO.Class (MonadIO)
import Data.Data (Proxy (..))
import Data.Text (Text)
Expand All @@ -19,7 +17,9 @@ import Servant.API (Get, Header', JSON, Optional, QueryParam', Required, Strict,
import Servant.Client (BaseUrl (..), ClientM, Scheme (..), client, mkClientEnv, runClientM)
import UnliftIO (MonadIO (..), throwIO)
import UnliftIO.Environment (lookupEnv)
import Utils (isExpired)

import Azure.Utils (isExpired)
import Azure.Types (AccessToken (..), Token, readToken, updateToken)

import qualified Data.Text as Text

Expand Down
2 changes: 1 addition & 1 deletion azure-auth/src/Types.hs → azure-auth/Azure/Types.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Types
module Azure.Types
( ExpiresOn
, AccessToken (..)
, Token
Expand Down
5 changes: 3 additions & 2 deletions azure-auth/src/Utils.hs → azure-auth/Azure/Utils.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module Utils where
module Azure.Utils where

import Data.Time (addUTCTime, getCurrentTime, secondsToNominalDiffTime)
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Types (ExpiresOn)
import UnliftIO (MonadIO (..))

import Azure.Types (ExpiresOn)

import qualified Text.Read as Text
import qualified Data.Text as Text

Expand Down
11 changes: 3 additions & 8 deletions azure-auth/azure-auth.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,21 @@ common common-options

library
import: common-options
exposed-modules: Auth
Types
Utils
-- other-modules:
-- other-extensions:
exposed-modules: Azure.Auth
Azure.Types
Azure.Utils
build-depends: aeson
, http-client
, servant
, servant-client
, text
, time
, unliftio
hs-source-dirs: src
default-language: Haskell2010

test-suite azure-auth-test
import: common-options
default-language: Haskell2010
-- other-modules:
-- other-extensions:
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

module Secret
module Azure.Secret
( KeyVaultResponse (..)
, GetSecretFromVaultApi
, getSecretFromVault
Expand All @@ -18,8 +18,8 @@ import Servant.Client (BaseUrl (..), ClientM, Scheme (..), client, mkClientEnv,
import UnliftIO (MonadIO (..), throwIO)
import GHC.Generics (Generic)

import Auth (defaultAzureCredential)
import Types (AccessToken (..), Token)
import Azure.Auth (defaultAzureCredential)
import Azure.Types (AccessToken (..), Token)

import qualified Data.Text as Text

Expand Down Expand Up @@ -65,8 +65,7 @@ callKeyVaultClient action secretName vaultHost tokenStore = do
(action secretName 7.4 ("Bearer " <> atAccessToken authHeader))
(mkClientEnv manager $ BaseUrl Https (Text.unpack vaultHost) 443 "")
case res of
Left err -> do
Left err ->
throwIO err
Right response -> do
liftIO $ putStrLn $ "Successfully performed request: " <> show response
Right response ->
pure response
5 changes: 1 addition & 4 deletions azure-key-vault/azure-key-vault.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,14 @@ common common-options

library
import: common-options
exposed-modules: Secret
-- other-modules:
-- other-extensions:
exposed-modules: Azure.Secret
build-depends: aeson
, azure-auth
, http-client-tls
, servant
, servant-client
, text
, unliftio
hs-source-dirs: src
default-language: Haskell2010

test-suite azure-key-vault-test
Expand Down

0 comments on commit a7f4c85

Please sign in to comment.