-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
209 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module Confer.API.Host where | ||
|
||
import Effectful | ||
import HsLua.Core (Exception) | ||
import HsLua.Core qualified as Lua | ||
import HsLua.Marshalling | ||
import HsLua.Module.System (arch, os) | ||
import HsLua.Packaging | ||
import Network.HostName | ||
|
||
mkHostModule :: (IOE :> es) => Eff es (Module Exception) | ||
mkHostModule = do | ||
hostname <- mkHostname | ||
pure Module | ||
{ moduleName = "host" | ||
, moduleFields = | ||
[ arch | ||
, os | ||
, hostname | ||
] | ||
, moduleFunctions = [] | ||
, moduleOperations = [] | ||
, moduleTypeInitializers = [] | ||
, moduleDescription = | ||
"Access to the system's information and file functionality." | ||
} | ||
|
||
-- | Module field containing the machine's hostname. | ||
mkHostname :: (IOE :> es) => Eff es (Field Exception) | ||
mkHostname = do | ||
hostnameString <- liftIO getHostName | ||
pure Field | ||
{ fieldName = "hostname" | ||
, fieldType = "string" | ||
, fieldDescription = | ||
"The machine's hostname." | ||
, fieldPushValue = pushString hostnameString | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Confer.API.User where | ||
|
||
import Effectful | ||
import Effectful.FileSystem qualified as FileSystem | ||
import Effectful.FileSystem (FileSystem) | ||
import HsLua.Core (Exception) | ||
import HsLua.Core qualified as Lua | ||
import HsLua.Marshalling | ||
import HsLua.Packaging | ||
|
||
mkUserModule :: (FileSystem :> es) => Eff es (Module Exception) | ||
mkUserModule = do | ||
home <- mkHome | ||
pure Module | ||
{ moduleName = "user" | ||
, moduleFields = | ||
[ home | ||
] | ||
, moduleFunctions = [] | ||
, moduleOperations = [] | ||
, moduleTypeInitializers = [] | ||
, moduleDescription = | ||
"Access to the user's information" | ||
} | ||
|
||
-- | Module field containing the machine's hostname. | ||
mkHome :: (FileSystem :> es) => Eff es (Field Exception) | ||
mkHome = do | ||
homeDirectory <- FileSystem.getHomeDirectory | ||
pure Field | ||
{ fieldName = "home" | ||
, fieldType = "string" | ||
, fieldDescription = | ||
"The user's HOME directory" | ||
, fieldPushValue = pushString homeDirectory | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
module Confer.Cmd.Check (check) where | ||
|
||
import Data.Foldable | ||
import Data.Text.Display | ||
import Data.Text.IO qualified as Text | ||
import Effectful | ||
import Effectful.FileSystem (FileSystem) | ||
import Effectful.FileSystem qualified as FileSystem | ||
import System.OsPath ((</>)) | ||
import System.OsPath qualified as OsPath | ||
|
||
import Confer.Effect.Symlink | ||
import Confer.Config.Evaluator | ||
import Confer.Config.Types | ||
|
||
check :: (IOE :> es, Symlink :> es) => Eff es () | ||
check :: (IOE :> es, FileSystem :> es) => Eff es () | ||
check = do | ||
loadConfiguration >>= liftIO . print | ||
loadConfiguration >>= \case | ||
Right deployments -> | ||
forM_ deployments $ \deployment -> | ||
forM_ deployment.facts $ \fact -> do | ||
liftIO $ Text.putStrLn $ "[+] Checking " <> display fact | ||
let osPath = (fact.destination </> fact.source) | ||
filePath <- (liftIO $ OsPath.decodeFS osPath) | ||
FileSystem.pathIsSymbolicLink filePath | ||
Left e -> error e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.