diff --git a/src/Puppet/Interpreter/Resolve.hs b/src/Puppet/Interpreter/Resolve.hs index ed1d3502..07d9176e 100644 --- a/src/Puppet/Interpreter/Resolve.hs +++ b/src/Puppet/Interpreter/Resolve.hs @@ -661,6 +661,7 @@ resolveDataType ud UDTScalar -> pure DTScalar UDTData -> pure DTData UDTOptional dt -> DTOptional <$> resolveDataType dt + UDTSensitive dt -> DTSensitive <$> resolveDataType dt UNotUndef -> pure NotUndef UDTVariant vrs -> DTVariant <$> traverse resolveDataType vrs UDTPattern a -> pure (DTPattern a) @@ -785,6 +786,7 @@ datatypeMatch dt v = DTScalar -> datatypeMatch (DTVariant (DTInteger Nothing Nothing :| [DTString Nothing Nothing, DTBoolean])) v DTData -> datatypeMatch (DTVariant (DTScalar :| [DTArray DTData 0 Nothing, DTHash DTScalar DTData 0 Nothing])) v DTOptional sdt -> datatypeMatch (DTVariant (DTUndef :| [sdt])) v + DTSensitive sdt -> datatypeMatch (DTVariant (DTUndef :| [sdt])) v DTVariant sdts -> any (`datatypeMatch` v) sdts DTEnum lst -> maybe False (`elem` lst) (v ^? _PString) DTAny -> True diff --git a/src/Puppet/Language/Value.hs b/src/Puppet/Language/Value.hs index 16ed3bee..cca7d261 100644 --- a/src/Puppet/Language/Value.hs +++ b/src/Puppet/Language/Value.hs @@ -24,6 +24,7 @@ data DataType | DTScalar | DTData | DTOptional DataType + | DTSensitive DataType | NotUndef | DTVariant (NonEmpty DataType) | DTPattern (NonEmpty CompRegex) @@ -45,6 +46,7 @@ instance Pretty DataType where DTScalar -> "Scalar" DTData -> "Data" DTOptional o -> "Optional" <> brackets (pretty o) + DTSensitive o -> "Sensitive" <> brackets (pretty o) NotUndef -> "NotUndef" DTVariant vs -> "Variant" <> list (foldMap (pure . pretty) vs) DTPattern vs -> "Pattern" <> list (foldMap (pure . pretty) vs) diff --git a/src/Puppet/Parser.hs b/src/Puppet/Parser.hs index 76e349b6..712b429f 100644 --- a/src/Puppet/Parser.hs +++ b/src/Puppet/Parser.hs @@ -668,6 +668,7 @@ datatype = dtString <|> dtHash <|> (UDTUndef <$ reserved "Undef") <|> (reserved "Optional" *> (UDTOptional <$> brackets datatype)) + <|> (reserved "Sensitive" *> (UDTSensitive <$> brackets datatype)) <|> (UNotUndef <$ reserved "NotUndef") <|> (reserved "Variant" *> (UDTVariant . NE.fromList <$> brackets (datatype `sepBy1` symbolic ','))) -- while all the other cases are straightforward, it seems that the diff --git a/src/Puppet/Parser/PrettyPrinter.hs b/src/Puppet/Parser/PrettyPrinter.hs index 9bc18cec..6d352623 100644 --- a/src/Puppet/Parser/PrettyPrinter.hs +++ b/src/Puppet/Parser/PrettyPrinter.hs @@ -38,6 +38,7 @@ instance Pretty UDataType where UDTScalar -> "Scalar" UDTData -> "Data" UDTOptional o -> "Optional" <> brackets (pretty o) + UDTSensitive o -> "Sensitive" <> brackets (pretty o) UNotUndef -> "NotUndef" UDTVariant vs -> "Variant" <> list (foldMap (pure . pretty) vs) UDTPattern vs -> "Pattern" <> list (foldMap (pure . pretty) vs) diff --git a/src/Puppet/Parser/Types.hs b/src/Puppet/Parser/Types.hs index f3c17bb9..2bbf3794 100644 --- a/src/Puppet/Parser/Types.hs +++ b/src/Puppet/Parser/Types.hs @@ -173,6 +173,7 @@ data UDataType | UDTScalar | UDTData | UDTOptional UDataType + | UDTSensitive UDataType | UNotUndef | UDTVariant (NonEmpty UDataType) | UDTPattern (NonEmpty CompRegex) diff --git a/tests/DT/Parser.hs b/tests/DT/Parser.hs index 0326dd76..8f23da61 100644 --- a/tests/DT/Parser.hs +++ b/tests/DT/Parser.hs @@ -18,3 +18,5 @@ spec = do it "accepts variables" $ pendingWith "to be fixed" *> parse datatype "?" "String[$var]" `shouldParse` UDTString (Just 5) Nothing describe "Stdlib::" $ do "Stdlib::HTTPUrl" `parsed` UDTData + describe "Sensitive" $ do + "Sensitive[String]" `parsed` UDTSensitive (UDTString Nothing Nothing)