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

updatable-attributes (8) Versions 1.1.1

Allow definition of attribute based on other attributes and recomputed on update.

Policyfile
Berkshelf
Knife
cookbook 'updatable-attributes', '= 1.1.1', :supermarket
cookbook 'updatable-attributes', '= 1.1.1'
knife supermarket install updatable-attributes
knife supermarket download updatable-attributes
README
Dependencies
Quality 20%

Cookbook updatable-attributes

Cookbook Version
License
CI

Allow to declare attributes computed each time other ones are updated.

Requirements

This cookbook supports and requires Chef 12.16.23+.

Platforms

This cookbook leverage built-in Chef features and supports all Platforms.

Usage

To compute attributes based on a single attribute path:

on_attribute_update('foo', 'bar') do
  default['blah'] = node['foo']['bar']
end
# equivalent to
on_attribute_update(%w[foo bar]) do
  default['blah'] = node['foo']['bar']
end

To compute attributes based on multiple attribute paths:

on_attributes_update(%w[foo bar], 'blah') do
  default['all'] = node['foo']['bar'] + node['blah']
end
# equivalent to
on_attributes_update(%w[foo bar], %w[blah]) do
  default['all'] = node['foo']['bar'] + node['blah']
end

Options

Option Default Description
init_on_registration true Evaluate the block on registration.
observe_parents true Also observe parent attribute updates.
recursion 0 Configure allowed level of recursion.

To debug attributes update

Sometimes it is tricky to understand why an attribute ended-up with its final value.
Chef provides the node.debug_value method, which is already great, but it only prints the state when you call it.

If you need to debug the "lifecycle" of your attributes, you can enable a temporary debug feature simply using the environment variable: DEBUG_ATTRIBUTES_KEYS

The debug feature will evaluate this environment variable as a comma-separated list of attribute's key to watch.
For instance if you want to debug all changes on attributes named "dangerous" and "important" you can do this:

  DEBUG_ATTRIBUTES_KEYS=dangerous,important sudo -E chef-client

As the attributes matching is trivial any attribute key equal to the given values will be logged.
For instance the following attributes changes will be logged:

default['dangerous'] = true
default['a']['dangerous']['setting'] = 42
override['not']['important']['at'] = 'all'

However the matching is case sensitive on the whole string, so these changes won't be logged:

default['almost_dangerous'] = 41
override['very']['Interesting'] = '!'

Finally, please note that the default log level used here is debug, if you want to change that you should use another environement variable: DEBUG_ATTRIBUTES_LOG_LEVEL

For instance to log as warning the use of a dangerous attribute you can do:

DEBUG_ATTRIBUTES_LOG_LEVEL=warn DEBUG_ATTRIBUTES_KEYS=dangerous sudo -E chef-client

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Authors

Copyright 2017 Baptiste Courtois

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Collaborator Number Metric
            

1.1.1 failed this metric

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

Cookstyle Metric
            

1.1.1 failed this metric

Chef/Deprecations/FoodcriticTesting: The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_foodcritictesting): updatable-attributes/Gemfile: 6
Chef/Deprecations/FoodcriticTesting: The Foodcritic cookbook linter has been deprecated and should no longer be used for validating cookbooks. (https://docs.chef.io/workstation/cookstyle/chef_deprecations_foodcritictesting): updatable-attributes/Rakefile: 2
Chef/Modernize/RespondToInMetadata: It is no longer necessary to use respond_to? or defined? in metadata.rb in Chef Infra Client 12.15 and later (https://docs.chef.io/workstation/cookstyle/chef_modernize_respondtoinmetadata): updatable-attributes/metadata.rb: 13
Chef/Modernize/RespondToInMetadata: It is no longer necessary to use respond_to? or defined? in metadata.rb in Chef Infra Client 12.15 and later (https://docs.chef.io/workstation/cookstyle/chef_modernize_respondtoinmetadata): updatable-attributes/metadata.rb: 14
Chef/Modernize/RespondToInMetadata: It is no longer necessary to use respond_to? or defined? in metadata.rb in Chef Infra Client 12.15 and later (https://docs.chef.io/workstation/cookstyle/chef_modernize_respondtoinmetadata): updatable-attributes/metadata.rb: 15
Chef/RedundantCode/LongDescriptionMetadata: The long_description metadata.rb method is not used and is unnecessary in cookbooks. (https://docs.chef.io/workstation/cookstyle/chef_redundantcode_longdescriptionmetadata): updatable-attributes/metadata.rb: 6

Run with Cookstyle Version 7.32.1 with cops Chef/Deprecations,Chef/Correctness,Chef/Sharing,Chef/RedundantCode,Chef/Modernize,Chef/Security,InSpec/Deprecations

No Binaries Metric
            

1.1.1 passed this metric

Testing File Metric
            

1.1.1 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
            

1.1.1 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