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.1.2

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

Policyfile
Berkshelf
Knife
cookbook 'validation', '= 0.1.2', :supermarket
cookbook 'validation', '= 0.1.2'
knife supermarket install validation
knife supermarket download validation
README
Dependencies
Changelog
Quality 0%

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.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

Foodcritic Metric
            

0.1.2 failed this metric

FC015: Consider converting definition to a LWRP: /tmp/cook/ca28c8e75e3c6d6e842bf706/validation/definitions/validate_attributes.rb:1