Skip to content

Commit

Permalink
Merge branch 'master' into update-to-latest-kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
f-f authored Jul 28, 2019
2 parents 95c1fda + f3d7590 commit 7e8458a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dhall-kubernetes-generator/src/Dhall/Kubernetes/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ toDefault definitions types modelName = go
(Dhall.App Dhall.List _) -> Nothing
-- Simple types should not have a default
(Dhall.Text) -> Nothing
-- Set lists to empty
(Dhall.App Dhall.List typ) -> Just $ Dhall.ListLit (Just $ adjustImport typ) mempty
-- But most of the times we are dealing with a record.
-- Here we transform the record type in a value, transforming the keys in this way:
-- * take the BaseData from definition and populate it
Expand Down Expand Up @@ -228,6 +230,13 @@ toDefault definitions types modelName = go
= Dhall.Embed $ mkImport ["types", ".."] (file <> ".dhall")
adjustImport other = other

-- | The imports that we get from the types are referring to the local folder,
-- but if we want to refer them from the defaults we need to adjust the path
adjustImport :: Expr -> Expr
adjustImport (Dhall.Embed imp) | Just file <- namespacedObjectFromImport imp
= Dhall.Embed $ mkImport ["types", ".."] (file <> ".dhall")
adjustImport other = other


-- | Get a Dhall.Map filled with imports, for creating giant Records or Unions of types or defaults
getImportsMap
Expand Down

0 comments on commit 7e8458a

Please sign in to comment.