Skip to content

Releases: ameily/cincoconfig

v0.9.0

23 Apr 18:55
Compare
Choose a tag to compare

Added

  • New support method, is_value_defined to check if a config field value is defined by the user,
    through either a loaded config file or the API.
  • New support method, reset_value to reset a configuration value back to the default.
  • New Config method, Config._set_default_value, to set a field default value. This was added so
    that __setdefault__ methods wouldn't need to access the _data dictionary directly.
  • New options to the DictField that control key and value validation.

Internal API Changes

  • Switched to GitHub Actions.
  • Switched to ruff, pyright, and black for linting and formatting.
  • Switched to poetry for dependency management.

v0.8.0

17 Jul 14:40
Compare
Choose a tag to compare

Added

  • Improved full reference path detection for both field and configuration objects.
  • New internal ConfigTypeField that allows a schema field to reference a ConfigType class, as
    returned by the cincoconfig.make_type function.
  • New method, asdict, to get a Config values as a dict.
  • New method, get_fields, to get all fields within a Schema or Config.

Deprecated

  • Work was done to reduce methods exposed by the Schema and Config classes by moving the
    functions out of the class. This methods are still available in the class but will be removed
    in v1.0.0.
    • Schema.instance_method: use cincoconfig.instance_method instead.
    • Schema.generate_argparse_parser: use cincoconfig.generate_argparse_parser instead.
    • Schema.make_type: use cincoconfig.make_type instead.
    • Schema.validator: use cincoconfig.validator instead.
    • Schema.get_all_fields: use cincoconfig.get_all_fields instead.
    • Schema.full_path and Config.full_path: use cincoconfig.item_ref_path instead.
    • Config.cmdline_args_override: use cincoconfig.cmdline_args_override instead.
  • BaseSchema and BaseConfig were removed and their functionality merged into their concrete
    classes, Schema and Config, respectively. cincoconfig will continues to provide BaseConfig
    and BaseSchema aliases but these will be removed in v1.0.0.
  • FormatRegistry functionality integrated into ConfigFormat.

Internal API Changes

  • Field subclasses were broken out into separate modules.
  • Field.key was renamed to Field._key to be consistent with Schema and Config.
  • Field.schema was renamed to Field._schema to be consistent with Schema and Config.
  • cincoconfig.abc and cincoconfig.config modules were integrated into a new cincoconfig.core
    module.

v0.7.0

10 Feb 01:04
42a2eb6
Compare
Choose a tag to compare

Added

  • Support for the ~ home directory symbol. All filenames are passed through the
    os.path.expanduser function.
  • IPv4NetworkField now support setting a minimum and maximum prefix length, in bits.
  • Field.help attribute to document the field, similar to a docstring. The help and
    autogenerated short_help attribute, can be used in UI to display information and
    documentation about the field.
  • BaseSchema.generate_argparse_parser method to autogenerate an argparse.ArgumentParser
    object to parse command line arguments.
  • Field.env and Schema.env to control automatically loading configuration values from
    environment variables.

Changed

  • Improved error reporting with the ValidationError exception that contains the offending
    field's full name and path.

v0.6.0

06 Nov 04:47
Compare
Choose a tag to compare

[v0.6.0] - 2020-11-05

Added

  • Field.sensitive property to mark a value as sensitive.
  • Config.to_tree() now supports masking sensitive values (sensitive_mask parameter) and
    including virtual fields in the tree (virtual parameter).

Changed

  • StringField now only accepts string values. Prior to this release, all input values were
    coerced to a string, via str(value). This was causing inconsistencies and non-intuitive
    behavior for fields that inherited from StringField.
  • Refactor ListProxy to inherit from list.

Fixed

  • ListField now handles empty or None values.

v0.5.0

02 Nov 23:09
f4bb229
Compare
Choose a tag to compare

[v0.5.0] - 2020-10-31

Added

  • StringField: Provide available choices in the raised exception when value is not valid.
  • Field.friendly_name() to retrieve the friendly name of the field, either the Field.name or
    the full path to the field in the configuration, Field.full_path()
  • Config.__contains__() to check if a configuration has a field value set.

Changed

  • All exceptions raised during validation are now wrapped in a ValidationError exception that
    contains the friendly name or full path to the field.
  • SecureField: Do not encrypt empty string or null values.

Fixed

  • Properly evaluate nested IncludeField.
  • FilenameField: Properly validate and handle required filename values.
  • ListField: Properly handle a list of complex or Schema objects.
  • ListField: Wrap the default ListField value in a ListProxy object.
  • SecureField: Properly load best encrypted values.
  • SecureField: Resolve best encryption method to a concrete method (aes or xor) during
    encryption.

v0.4.0

26 Jul 14:10
Compare
Choose a tag to compare

[0.4.0] - 2020-07-25

Added

  • Schema.__getitem__() implementation to get a schema field programmatically.
  • Schema.get_all_fields() to recursively get all the fields and nested fields from a schema.

Changed

  • The Schema fields are now stored in an OrderedDict so that the original order that the fields
    were added to the Schema is preserved when tterating over the Schema's fields, via iter() or
    the new get_all_fields().

v0.2.1

23 Aug 12:20
e352a37
Compare
Choose a tag to compare
  • Fix an issue with key generation if the key file doesn't exist (#12)
  • Properly expand user home paths, ~/.cincokey

v0.2.0

19 Aug 11:59
Compare
Choose a tag to compare
  • Improve usability of reusable schemas, such as when a configuration has a list of complex types. The new Schema.make_type method creates a new type that can be used like a traditional Python class.

    webhook_schema = Schema()
    webhook_schema.url = UrlField(required=True)
    webhook_schema.verify_ssl = BoolField(default=True)
    WebHook = webhook_schema.make_type('WebHook')  # WebHook is now a new type
    
    schema = Schema()
    schema.issue_webhooks = ListField(webhook_schema)
    schema.merge_request_webhooks = ListField(webhook_schema)
    
    config = schema()
    
    wh = WebHook(url='https://google.com')
    config.issue_webhooks.append(wh)
  • Simplify how custom config-level validations are performed using a decorator.

    schema = Schema()
    schema.x = IntField()
    schema.y = IntField()
    schema.db.username = StringField()
    schema.db.password = StringField()
    
    @schema.validator
    def validate_x_lt_y(cfg):
        # validates that x < y
        if cfg.x and cfg.y and cfg.x >= cfg.y:
            raise ValueError('x must be less-than y')
    
    @schema.db.validator
    def validate_db_creds(cfg):
        # validates that if the db username is specifed then the password must
        # also be specified.
        if cfg.username and not db.password:
            raise ValueError('db.password is required when username is specified')
    
    config = schema()
    config.load('mycfg.json', format='json')  # will call the above validators

v0.1.0

14 Aug 16:44
Compare
Choose a tag to compare
add release checklist