diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-16 14:14:41 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-16 14:14:41 -0500 |
| commit | 260b7b83b0ec396bb880038f4c93f977af0056c5 (patch) | |
| tree | fd6905ac74d0cb366758fd146887629a03c2cf12 /Omni/Deploy | |
| parent | bf64b25a2106ec04d91b3e8d7ee9e86fe9ff43ab (diff) | |
Fix hlint errors in Deploy modules
- Systemd: use list comprehension instead of if-then-else
- Manifest: use </> operator, replace case with maybe
- Deployer: use newtype, use flip removeService
- Caddy: use newtype for single-field types
Diffstat (limited to 'Omni/Deploy')
| -rw-r--r-- | Omni/Deploy/Caddy.hs | 4 | ||||
| -rw-r--r-- | Omni/Deploy/Deployer.hs | 4 | ||||
| -rw-r--r-- | Omni/Deploy/Manifest.hs | 18 | ||||
| -rw-r--r-- | Omni/Deploy/Systemd.hs | 4 |
4 files changed, 13 insertions, 17 deletions
diff --git a/Omni/Deploy/Caddy.hs b/Omni/Deploy/Caddy.hs index de73a35..6cedf92 100644 --- a/Omni/Deploy/Caddy.hs +++ b/Omni/Deploy/Caddy.hs @@ -53,7 +53,7 @@ instance Aeson.ToJSON Route where "terminal" .= routeTerminal ] -data RouteMatch = RouteMatch +newtype RouteMatch = RouteMatch { matchHost :: [Text] } deriving (Show, Eq, Generic) @@ -75,7 +75,7 @@ instance Aeson.ToJSON RouteHandler where "upstreams" .= handlerUpstreams ] -data Upstream = Upstream +newtype Upstream = Upstream { upstreamDial :: Text } deriving (Show, Eq, Generic) diff --git a/Omni/Deploy/Deployer.hs b/Omni/Deploy/Deployer.hs index fe03f74..ee06907 100644 --- a/Omni/Deploy/Deployer.hs +++ b/Omni/Deploy/Deployer.hs @@ -71,7 +71,7 @@ gcrootsDir = "/nix/var/nix/gcroots/biz" s3Url :: String s3Url = "s3://omni-nix-cache?profile=digitalocean&scheme=https&endpoint=nyc3.digitaloceanspaces.com" -data DeployerState = DeployerState +newtype DeployerState = DeployerState { stateServices :: Map Text Text } deriving (Show, Eq, Generic, Aeson.FromJSON, Aeson.ToJSON) @@ -196,7 +196,7 @@ reconcile manifest st = do localServices = Set.fromList <| Map.keys (stateServices st) toRemove = localServices Set.\\ mfstServices - st' <- foldM (\s name -> removeService name s) st (Set.toList toRemove) + st' <- foldM (flip removeService) st (Set.toList toRemove) foldM ( \s svc -> diff --git a/Omni/Deploy/Manifest.hs b/Omni/Deploy/Manifest.hs index bbbda95..13dd47a 100644 --- a/Omni/Deploy/Manifest.hs +++ b/Omni/Deploy/Manifest.hs @@ -71,7 +71,7 @@ instance Aeson.FromJSON Artifact where parseJSON = Aeson.withObject "Artifact" <| \o -> Artifact - <$> o + </ o .:? "type" .!= "nix-closure" <*> o @@ -95,7 +95,7 @@ instance Aeson.FromJSON Exec where parseJSON = Aeson.withObject "Exec" <| \o -> Exec - <$> o + </ o .:? "command" <*> o .:? "user" @@ -126,7 +126,7 @@ instance Aeson.FromJSON Http where parseJSON = Aeson.withObject "Http" <| \o -> Http - <$> o + </ o .: "domain" <*> o .:? "path" @@ -154,7 +154,7 @@ instance Aeson.FromJSON Systemd where parseJSON = Aeson.withObject "Systemd" <| \o -> Systemd - <$> o + </ o .:? "after" .!= ["network-online.target"] <*> o @@ -191,7 +191,7 @@ instance Aeson.FromJSON Hardening where parseJSON = Aeson.withObject "Hardening" <| \o -> Hardening - <$> o + </ o .:? "dynamicUser" .!= False <*> o @@ -234,7 +234,7 @@ instance Aeson.FromJSON Service where parseJSON = Aeson.withObject "Service" <| \o -> Service - <$> o + </ o .: "name" <*> o .: "artifact" @@ -286,7 +286,7 @@ instance Aeson.FromJSON Manifest where parseJSON = Aeson.withObject "Manifest" <| \o -> Manifest - <$> o + </ o .:? "version" .!= 1 <*> o @@ -515,9 +515,7 @@ move args Exit.exitWith (Exit.ExitFailure 1) Right svc -> do manifest <- loadManifestFromS3 - m <- case manifest of - Nothing -> createEmptyManifest - Just existing -> pure existing + m <- maybe createEmptyManifest pure manifest case findService (serviceName svc) m of Just _ -> do Log.fail ["manifest", "service already exists:", serviceName svc] diff --git a/Omni/Deploy/Systemd.hs b/Omni/Deploy/Systemd.hs index ba85295..d7af1cd 100644 --- a/Omni/Deploy/Systemd.hs +++ b/Omni/Deploy/Systemd.hs @@ -47,9 +47,7 @@ generateUnit Service {..} = ++ requiresLine requiresLine = - if null (systemdRequires serviceSystemd) - then [] - else ["Requires=" <> Text.intercalate " " (systemdRequires serviceSystemd)] + ["Requires=" <> Text.intercalate " " (systemdRequires serviceSystemd) | not (null (systemdRequires serviceSystemd))] serviceSection = [ "", |
