GeezerVison is showing github.com — Commit for release 0.0.7.1 · nstack/nstack@9e394d5
This repository was archived by the owner on Feb 7, 2024. It is now read-only.
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: nstack-cli/app/NStackCLI.hs +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,12 +92,12 @@ formatNotebook module_name fn_name = DSLSource $ | 92 | 92 |
| 93 | 93 | run :: Command -> CCmd () | 94 | 94 | run (InitCommand initStack mBase gitRepo) = CLI.initCommand initStack mBase gitRepo | 95 | | -run (StartCommand debug module_name fn_name) = callServer startCommand (formatNotebook module_name fn_name, debug) CLI.showStartMessage | 96 | | -run (NotebookCommand debug mDsl) = do | | 95 | +run (StartCommand debugOpt module_name fn_name) = callServer startCommand (formatNotebook module_name fn_name, debugOpt) CLI.showStartMessage | | 96 | +run (NotebookCommand debugOpt mDsl) = do | 97 | 97 | liftInput . HL.outputStrLn $ "NStack Notebook - import modules, write a workflow, and press " <> endStream <> " when finished to start it: " | 98 | 98 | dsl <- maybe (liftIO $ DSLSource <$> TIO.getContents) pure mDsl | 99 | 99 | liftInput . HL.outputStrLn $ "Building and running NStack Workflow. Please wait. This may take some time." | 100 | | - callServer startCommand (dsl, debug) CLI.showStartMessage | | 100 | + callServer startCommand (dsl, debugOpt) CLI.showStartMessage | 101 | 101 | where endStream = if os == "mingw32" then "<Ctrl-Z>" else "<Ctrl-D>" | 102 | 102 | run (StopCommand pId) = callServer stopCommand pId CLI.showStopMessage | 103 | 103 | run (LogsCommand pId) = callServer logsCommand pId catLogs | |
Collapse file Copy file name to clipboardExpand all lines: nstack-cli/nstack-cli.cabal +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | name: nstack-cli | 2 | | -version: 0.0.7 | | 2 | +version: 0.0.7.1 | 3 | 3 | cabal-version: >=1.22 | 4 | 4 | build-type: Simple | 5 | 5 | license: BSD3 | |
Collapse file Copy file name to clipboardExpand all lines: nstack-prelude/nstack-prelude.cabal +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | name: nstack-prelude | 2 | | -version: 0.0.7 | | 2 | +version: 0.0.7.1 | 3 | 3 | cabal-version: >=1.22 | 4 | 4 | build-type: Simple | 5 | 5 | license: BSD3 | |
Collapse file Copy file name to clipboardExpand all lines: nstack-prelude/src/NStack/Prelude/Exception.hs +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2,10 +2,12 @@ module NStack.Prelude.Exception | 2 | 2 | ( TransientError(..) | 3 | 3 | , PermanentError(..) | 4 | 4 | , throwPermanentError | | 5 | + , throwPermanentErrorT | 5 | 6 | ) | 6 | 7 | where | 7 | 8 |
| 8 | 9 | import Control.Exception | | 10 | +import Data.Text (unpack, Text) | 9 | 11 | import Data.Typeable (Typeable) | 10 | 12 | import Control.Monad.IO.Class (MonadIO(..)) | 11 | 13 |
| @@ -24,3 +26,6 @@ instance Exception PermanentError where | 24 | 26 | -- | A shortcut for commonly-occurring @liftIO . throwIO . PermanentError@. | 25 | 27 | throwPermanentError :: MonadIO m => String -> m a | 26 | 28 | throwPermanentError = liftIO . throwIO . PermanentError | | 29 | + | | 30 | +throwPermanentErrorT :: MonadIO m => Text -> m a | | 31 | +throwPermanentErrorT = throwPermanentError . unpack |
Collapse file Copy file name to clipboardExpand all lines: nstack/nstack.cabal +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | name: nstack | 2 | | -version: 0.0.7 | | 2 | +version: 0.0.7.1 | 3 | 3 | cabal-version: >=1.22 | 4 | 4 | build-type: Simple | 5 | 5 | license: BSD3 | |
Collapse file Copy file name to clipboardExpand all lines: nstack/src/NStack/Module/Types.hs +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -6,7 +6,7 @@ import Data.ByteString (ByteString) | 6 | 6 | import qualified Data.ByteString as BS | 7 | 7 | import qualified Data.ByteString.Base16 as Base16 | 8 | 8 | import Data.Coerce (coerce) | 9 | | -import Data.SafeCopy (base, deriveSafeCopy, extension, Migrate(..)) | | 9 | +import Data.SafeCopy (base, deriveSafeCopy, extension, Migrate(..), SafeCopy(..), safePut, safeGet, contain) | 10 | 10 | import Data.Semigroup | 11 | 11 | import Data.Serialize (Serialize(..)) | 12 | 12 | import Data.Serialize.Get (getListOf) | @@ -161,6 +161,8 @@ instance Serialize FnName where | 161 | 161 | put = coerce putText | 162 | 162 | get = coerce getText | 163 | 163 |
| | 164 | +$(deriveSafeCopy 0 'base ''FnName) | | 165 | + | 164 | 166 | -- | The name of an NStack type | 165 | 167 | newtype TyName = TyName Text | 166 | 168 | deriving (Eq, Ord, Typeable, Data, IsString, Pretty, Generic, ToJSON) | @@ -186,6 +188,10 @@ instance ToJSON a => ToJSON (Qualified a) where | 186 | 188 | type QFnName = Qualified FnName | 187 | 189 | type QTyName = Qualified TyName | 188 | 190 |
| | 191 | +instance SafeCopy QFnName where | | 192 | + putCopy (Qualified mod' fn) = contain $ safePut mod' >> safePut fn | | 193 | + getCopy = contain $ Qualified <$> safeGet <*> safeGet | | 194 | + | 189 | 195 | instance Show a => Show (Qualified a) where | 190 | 196 | show (Qualified modName methName) = pprS modName <> "." <> show methName | 191 | 197 |
| |
Collapse file Copy file name to clipboardExpand all lines: nstack/src/NStack/Settings.hs +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -18,6 +18,7 @@ module NStack.Settings (SettingsT, | 18 | 18 | frontendHost, | 19 | 19 | serviceLimits, | 20 | 20 | cliTimeout, | | 21 | + debug, | 21 | 22 | defaultFrontendHost, | 22 | 23 | runSettingsParser, | 23 | 24 | serverConn, | |
Collapse file Copy file name to clipboardExpand all lines: nstack/src/NStack/Settings/Parser.hs +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,6 +9,7 @@ import qualified Data.UUID as UUID | 9 | 9 | import Data.Yaml.Combinators | 10 | 10 |
| 11 | 11 | import NStack.Auth (readUserId, readKey) | | 12 | +import NStack.Module.Types (DebugOpt(..)) | 12 | 13 | import NStack.Settings.Types (AnalyticsSettings(..), HostName(..), ServerDetails(..), AuthSettings(..), Settings(..), InstallID(..)) | 13 | 14 |
| 14 | 15 | valueWhenMatching :: a -> Parser () -> Parser a | @@ -54,6 +55,12 @@ authSettingsParser = nstackAuthParser <> trustAuthParser | 54 | 55 | secretKeyParser = validate string $ | 55 | 56 | maybe (Left "the secret-key to be a lowercase hexstring with even length") Right . readKey | 56 | 57 |
| | 58 | +debugParser :: Parser DebugOpt | | 59 | +debugParser = trueToDebug <$> bool | | 60 | + where | | 61 | + trueToDebug True = Debug | | 62 | + trueToDebug False = NoDebug | | 63 | + | 57 | 64 | settingsParser :: Parser Settings | 58 | 65 | settingsParser = object $ Settings <$> | 59 | 66 | optFieldOrNull "install-id" (InstallID <$> uuidParser) <*> | @@ -63,7 +70,8 @@ settingsParser = object $ Settings <$> | 63 | 70 | optFieldOrNull "server" serverDetailsParser <*> | 64 | 71 | optFieldOrNull "frontend-host" frontendHostParser <*> | 65 | 72 | optFieldOrNull "service-limits" bool <*> | 66 | | - optFieldOrNull "cli-timeout" integer | | 73 | + optFieldOrNull "cli-timeout" integer <*> | | 74 | + optFieldOrNull "debug" debugParser | 67 | 75 | where | 68 | 76 | uuidParser = validate string $ | 69 | 77 | maybe (Left "install-id to be a valid UUID") Right . UUID.fromText | |
Collapse file Copy file name to clipboardExpand all lines: nstack/src/NStack/Settings/Types.hs +7-2Lines changed: 7 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,6 +12,7 @@ import Data.UUID (UUID) | 12 | 12 | import Data.Text (Text, toLower) -- from: text | 13 | 13 | import GHC.Generics | 14 | 14 |
| | 15 | +import NStack.Module.Types (DebugOpt(NoDebug)) | 15 | 16 | import NStack.Auth (SecretKey, UserId) | 16 | 17 |
| 17 | 18 | newtype InstallID = InstallID UUID deriving (Eq, Show, ToJSON, FromJSON) | @@ -47,7 +48,8 @@ data Settings = Settings { _installId :: Maybe InstallID, | 47 | 48 | _server :: Maybe ServerDetails, | 48 | 49 | _frontendHost :: Maybe HostName, | 49 | 50 | _serviceLimits :: Maybe Bool, | 50 | | - _cliTimeout :: Maybe Int | | 51 | + _cliTimeout :: Maybe Int, | | 52 | + _debug :: Maybe DebugOpt | 51 | 53 | } | 52 | 54 | deriving (Eq, Show) | 53 | 55 |
| @@ -75,7 +77,7 @@ instance ToJSON AuthSettings where | 75 | 77 | "secret-key" .= key] | 76 | 78 |
| 77 | 79 | defaultSettings :: Settings | 78 | | -defaultSettings = Settings { _installId = Nothing, _analytics = Nothing, _authSettings = Nothing, _authServer = Nothing, _server = Nothing, _frontendHost = Nothing, _serviceLimits = Nothing, _cliTimeout = Nothing } | | 80 | +defaultSettings = Settings { _installId = Nothing, _analytics = Nothing, _authSettings = Nothing, _authServer = Nothing, _server = Nothing, _frontendHost = Nothing, _serviceLimits = Nothing, _cliTimeout = Nothing, _debug = Nothing } | 79 | 81 |
| 80 | 82 | installId :: Lens' Settings (Maybe InstallID) | 81 | 83 | installId f s = (\r -> s { _installId = r }) <$> f (_installId s) | @@ -98,6 +100,9 @@ serviceLimits f s = (\r -> s { _serviceLimits = Just r }) <$> f (fromMaybe True | 98 | 100 | cliTimeout :: Lens' Settings Int | 99 | 101 | cliTimeout f s = (\r -> s { _cliTimeout = Just r }) <$> f (fromMaybe 15 $ _cliTimeout s) | 100 | 102 |
| | 103 | +debug :: Lens' Settings DebugOpt | | 104 | +debug f s = (\r -> s { _debug = Just r }) <$> f (fromMaybe NoDebug $ _debug s) | | 105 | + | 101 | 106 | authKey :: Lens' AuthSettings SecretKey | 102 | 107 | authKey f = \case | 103 | 108 | NStackHMAC u k -> NStackHMAC u <$> f k | |
Collapse file Copy file name to clipboardExpand all lines: nstack/test/TestSuite.hs +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,7 @@ main = defaultMainWithIngredients (antXMLRunner:defaultIngredients) $ testGroup | 19 | 19 | settingsParserTests :: TestTree | 20 | 20 | settingsParserTests = testGroup "Unit Tests" | 21 | 21 | [ testCase "Display a proper error message when invalid analytics settings" $ | 22 | | - checkErrorMessages "test/res/invalid-analytics-settings.conf" "Expected \"enabled\", \"disabled\" instead of", | | 22 | + checkErrorMessages "test/res/invalid-analytics-settings.conf" "Expected \"disabled\", \"enabled\" instead of", | 23 | 23 | testCase "Display a proper error message when invalid install-id" $ | 24 | 24 | checkErrorMessages "test/res/invalid-install-id.conf" "Expected install-id to be a valid UUID instead of", | 25 | 25 | testCase "Display a proper error message when invalid server" $ | @@ -29,7 +29,7 @@ settingsParserTests = testGroup "Unit Tests" | 29 | 29 | checkErrorMessages "test/res/invalid-authentication1.conf" "Unexpected \n\nuser-id: abc123", | 30 | 30 |
| 31 | 31 | testCase "Display a proper error message when more arguments for nstack scheme are needed" $ | 32 | | - checkErrorMessages "test/res/invalid-authentication2.conf" "Expected \"trust\" instead of:", | | 32 | + checkErrorMessages "test/res/invalid-authentication2.conf" "Expected field \"user-id\" as part of:", | 33 | 33 |
| 34 | 34 | testCase "Display a proper error message when invalid authentication scheme is used" $ | 35 | 35 | checkErrorMessages "test/res/invalid-authentication3.conf" "Expected \"nstack\", \"trust\" instead of:", | @@ -76,3 +76,4 @@ parseSettingsFileTest = do | 76 | 76 | (Just (HostName "http://localhost:8000")) | 77 | 77 | Nothing | 78 | 78 | Nothing | | 79 | + Nothing |
|