stackctl 1.5.0.0 → 1.5.0.1
raw patch · 5 files changed
+69/−9 lines, 5 filesdep +text-metricsPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependencies added: text-metrics
API changes (from Hackage documentation)
+ Stackctl.StackSpec: stackSpecDepends :: StackSpec -> [StackName]
Files
- CHANGELOG.md +7/−1
- src/Stackctl/Config.hs +2/−1
- src/Stackctl/Spec/Discover.hs +57/−6
- src/Stackctl/StackSpec.hs +1/−0
- stackctl.cabal +2/−1
CHANGELOG.md view
@@ -1,4 +1,10 @@-## [_Unreleased_](https://github.com/freckle/stackctl/compare/v1.5.0.0...main)+## [_Unreleased_](https://github.com/freckle/stackctl/compare/v1.5.0.1...main)++## [v1.5.0.1](https://github.com/freckle/stackctl/compare/v1.5.0.0...v1.5.0.1)++- Handle missing-or-empty specs directory more explicitly+- Add warning for `Depends` pointing to non-existent spec+- Fix formatting of required version in warning message ## [v1.5.0.0](https://github.com/freckle/stackctl/compare/v1.4.4.0...v1.5.0.0)
src/Stackctl/Config.hs view
@@ -63,7 +63,8 @@ :# ["error" .= Yaml.prettyPrintParseException ex] ConfigInvalid errs -> "Invalid configuration" :# ["errors" .= errs] ConfigVersionNotSatisfied rv v ->- "Incompatible Stackctl version" :# ["current" .= v, "required" .= show rv]+ "Incompatible Stackctl version"+ :# ["current" .= v, "required" .= show (requiredVersionToText rv)] loadConfigOrExit :: (MonadIO m, MonadLogger m) => m Config loadConfigOrExit = either die pure =<< loadConfig
src/Stackctl/Spec/Discover.hs view
@@ -8,6 +8,8 @@ import Data.List.Extra (dropPrefix) import qualified Data.List.NonEmpty as NE+import qualified Data.List.NonEmpty.Extra as NE+import Data.Text.Metrics (levenshtein) import Stackctl.AWS import Stackctl.AWS.Scope import Stackctl.Config (HasConfig)@@ -64,14 +66,29 @@ withThreadContext context $ do checkForDuplicateStackNames specPaths - specs <-- sortStackSpecs- . filterStackSpecs filterOption- <$> traverse (readStackSpec dir) specPaths+ mAllSpecs <- NE.nonEmpty <$> traverse (readStackSpec dir) specPaths - when (null specs) $ logWarn "No specs found"- specs <$ logDebug ("Discovered specs" :# ["matched" .= length specs])+ case mAllSpecs of+ Nothing -> do+ []+ <$ logWarn+ ( "Missing or empty specification directory"+ :# [ "directory" .= dir+ , "hint" .= ("Is this the correct directory?" :: Text)+ ]+ )+ Just allSpecs -> do+ let+ known = stackSpecStackName <$> allSpecs+ specs =+ sortStackSpecs+ $ filterStackSpecs filterOption+ $ NE.toList allSpecs + traverse_ (checkForUnknownDepends known) specs+ when (null specs) $ logWarn "No specs matched filters"+ specs <$ logDebug ("Discovered specs" :# ["matched" .= length specs])+ checkForDuplicateStackNames :: (MonadIO m, MonadLogger m) => [StackSpecPath] -> m () checkForDuplicateStackNames =@@ -93,6 +110,40 @@ ] exitFailure++-- | Warn if a 'StackSpec' depends on a name not in the given 'StackName's+--+-- The 'StackName's are built from all specs, but we only run this with specs+-- that are filtered in.+--+-- NB. This function is written so it can easily be made into a fatal error+-- (like 'checkForDuplicateStackNames'), but we only warn for now.+checkForUnknownDepends+ :: MonadLogger m => NonEmpty StackName -> StackSpec -> m ()+checkForUnknownDepends known spec =+ traverse_ reportUnknownDepends+ $ NE.nonEmpty+ $ filter (`notElem` known)+ $ stackSpecDepends spec+ where+ reportUnknownDepends depends = do+ for_ depends $ \depend -> do+ let (nearest, _distance) =+ NE.minimumBy1 (comparing snd)+ $ (id &&& getDistance depend)+ <$> known++ logWarn+ $ "Stack lists dependency that does not exist"+ :# [ "dependency"+ .= ( unStackName (stackSpecStackName spec)+ <> " -> "+ <> unStackName depend+ )+ , "hint" .= ("Did you mean " <> unStackName nearest <> "?")+ ]++ getDistance = levenshtein `on` unStackName buildSpecPath :: (MonadReader env m, HasAwsScope env)
src/Stackctl/StackSpec.hs view
@@ -5,6 +5,7 @@ , stackSpecSpecBody , stackSpecStackName , stackSpecStackDescription+ , stackSpecDepends , stackSpecActions , stackSpecParameters , stackSpecCapabilities
stackctl.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: stackctl-version: 1.5.0.0+version: 1.5.0.1 license: MIT license-file: LICENSE copyright: 2022 Renaissance Learning Inc@@ -115,6 +115,7 @@ rio, semigroups, text,+ text-metrics, time, transformers, typed-process,