Safe Haskell | None |
---|---|
Language | Haskell2010 |
ConfCrypt.Commands
Synopsis
- class Monad m => Command a m
- evaluate :: Command a m => a -> m [Text]
- data ReadConfCrypt = ReadConfCrypt {}
- data GetConfCrypt = GetConfCrypt {}
- data AddConfCrypt = AddConfCrypt {}
- data EditConfCrypt = EditConfCrypt {}
- data DeleteConfCrypt = DeleteConfCrypt {}
- data ValidateConfCrypt = ValidateConfCrypt
- data NewConfCrypt = NewConfCrypt
- data FileAction
- genNewFileState :: (Monad m, MonadError ConfCryptError m) => Map ConfCryptElement LineNumber -> [(ConfCryptElement, FileAction)] -> m (Map ConfCryptElement LineNumber)
- writeFullContentsToBuffer :: Monad m => Bool -> Map ConfCryptElement LineNumber -> m [Text]
Commands
class Monad m => Command a m Source #
All confcrypt commands can be generalized into an evaluate
call. In reality, instances likely
need to provide some environment, although that's not required as everything could be contained
as record fields of the command argument itself.
Minimal complete definition
Instances
Supported Commands
data ReadConfCrypt Source #
Read and return the full contents of an encrypted file. Provides support for using a local RSA key or an externl KMS service
Constructors
ReadConfCrypt | |
Instances
data GetConfCrypt Source #
Used to get the decrypted value of a single encrypted config parameter
Constructors
GetConfCrypt | |
Instances
data AddConfCrypt Source #
Used to add a new config parameter to the file
Constructors
AddConfCrypt | |
Instances
data EditConfCrypt Source #
Modify the value or type of a parameter in-place. This should result in a diff touching only the impacted lines. Very important that this property holds to make reviews easier.
Constructors
EditConfCrypt | |
Instances
data DeleteConfCrypt Source #
Removes a particular parameter and schema from the config file. This does not require an encryption key because the lines may simply be deleted based on the parameter name.
Constructors
DeleteConfCrypt | |
Instances
data ValidateConfCrypt Source #
Run all of the rules in Validation
on this file.
Constructors
ValidateConfCrypt |
Instances
(Monad m, MonadDecrypt (ConfCryptM m key) key) => Command ValidateConfCrypt (ConfCryptM m key) Source # | |
Defined in ConfCrypt.Commands Methods evaluate :: ValidateConfCrypt -> ConfCryptM m key [Text] Source # |
data NewConfCrypt Source #
Dumps the contents of defaultLines
to the output buffer. This is the same example config used
in the readme.
Constructors
NewConfCrypt |
Instances
Monad m => Command NewConfCrypt (ConfCryptM m ()) Source # | |
Defined in ConfCrypt.Commands Methods evaluate :: NewConfCrypt -> ConfCryptM m () [Text] Source # |
Utilities
data FileAction Source #
Commands may perform one of the following operations to a line of a confcrypt file
Exported for testing
Arguments
:: (Monad m, MonadError ConfCryptError m) | |
=> Map ConfCryptElement LineNumber | initial file state |
-> [(ConfCryptElement, FileAction)] | edits |
-> m (Map ConfCryptElement LineNumber) | new file, with edits applied in-place |
Given a known file state and some edits, apply the edits and produce the new file contents
writeFullContentsToBuffer :: Monad m => Bool -> Map ConfCryptElement LineNumber -> m [Text] Source #
Writes the provided ConfCryptFile
(provided as a Map) to the output buffer in line-number order. This
allows for producing an easily diffable output and makes in-place edits easy to spot in source control diffs.