Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

validation (11) Versions 0.2.3

Perform validation on your node's attributes from a Cookbook's attribute metadata definitions.

Policyfile
Berkshelf
Knife
cookbook 'validation', '~> 0.2.3', :supermarket
cookbook 'validation', '~> 0.2.3'
knife supermarket install validation
knife supermarket download validation
README
Dependencies
Changelog
Quality 17%

chef-validation

Perform validation on your node's attributes from a Cookbook's attribute metadata definitions.

Supported Platforms

  • Ubuntu 12.04 / 14.04
  • CentOS

Usage

Add the validation cookbook to your cookbook's metadata and define your attribute rules:

name             "my_app"
maintainer       "Jamie Winsor"
maintainer_email "jamie@vialstudios.com"
license          "MIT"
description      "Installs/Configures my_app"
long_description "Installs/Configures my_app"
version          "0.1.0"

depends "validation"

grouping "my_app",
  title: "My Application"
attribute "my_app/log_level",
  required: "required",
  default: "debug",
  choices: [
    "debug",
    "fatal",
    "warn",
    "info"
  ]
attribute "my_app/cookie",
  required: "required",
  default: "",
  type: "string"

Attribute rules are already part of Chef metadata. However, they are not used at all by the Chef client application itself. You'll need to ensure that you still initialize attributes to their supposedly default value in an attributes file or a recipe.

Since Chef client doesn't do anything with these attribute definitions we need to leverage the validate_attributes definition provided by this cookbook. Place a line like this in one of your cookbook's recipes.

validate_attributes "my_app"

I recommend placing this in the top of your "default" recipe for each cookbook that you maintain.

Compile time validation

By default, attribute validation will occur at convergence time but this can be switched to compile time by setting an attribute on the validate_attributes definition.

validate_attributes "my_app" do
  mode :compile
end

Convergence time validation

You can also explicitly validate at convergence

validate_attributes "my_app" do
  mode :converge
end

However, this is not necessary since :converge is the default mode.

Filtering validation

The name parameter of the validate_attributes definition is also the cookbook parameter. Setting this to the name of a cookbook will cause attribute validations to only be run for the metadata of that cookbook for the resource the definition creates. You can have multiple validate_attributes definitions within your resource chain or you can validate against all of your run context's loaded cookbooks.

validate_attributes "all"

Note: I swear to fucking god - if one of you makes a cookbook called "all" and puts that shit on the community site I will drink myself into the grave faster than I already am.

License and Authors

Author:: Jamie Winsor (jamie@vialstudios.com)

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

elixir Applicable Versions
instrumental Applicable Versions

0.2.3

  • Enhancements
    • Use Chef Gem compile_time option when available

0.2.2

  • Bug Fixes
    • Allow optional and recommended to be passed in for required attribute rule
    • Display name of cookbook in error when cookbook not in run list

0.2.1

  • Bug Fixes
    • Don't treat 'false' as a missing required attribute

0.2.0

  • Enhancements
    • Validations will not be run for attributes who are dependent upon recipes when those recipes are not in the expanded run list of the node.

0.1.6

  • Bug Fixes
    • Required attribute validations will once again pass if they have values present

0.1.5

  • Bug Fixes
    • Fix issue with running boolean type validations on Ruby 1.9 series

0.1.4

  • Bug Fixes
    • Fix issue with validating non-string required attributes

0.1.3

  • Bug Fixes
    • Fix issue on some versions of Chef where metadata would not be properly loaded at different points of the Chef run
    • Fix crash when a value is nil and checking for it's presence

0.1.2

  • Enhancements
    • Loosen constraint on Chef to allow for any version of Chef from the 11 & 12 series.

0.1.1

  • Bug Fixes
    • 0.1.0 cookbook package was uploaded incorrectly, sigh.

0.1.0

Initial release of validation

Collaborator Number Metric
            

0.2.3 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

0.2.3 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

0.2.3 failed this metric

FC064: Ensure issues_url is set in metadata: validation/metadata.rb:1
FC065: Ensure source_url is set in metadata: validation/metadata.rb:1
FC066: Ensure chef_version is set in metadata: validation/metadata.rb:1
Run with Foodcritic Version 16.3.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

No Binaries Metric
            

0.2.3 passed this metric

Testing File Metric
            

0.2.3 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

0.2.3 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number