diff --git a/dhall-kubernetes-generator/src/Dhall/Kubernetes/Convert.hs b/dhall-kubernetes-generator/src/Dhall/Kubernetes/Convert.hs index daae9d73..afd3d768 100644 --- a/dhall-kubernetes-generator/src/Dhall/Kubernetes/Convert.hs +++ b/dhall-kubernetes-generator/src/Dhall/Kubernetes/Convert.hs @@ -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 @@ -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