bbaugher / confluent

A Chef cookbook to install the Confluent Platform
MIT License
15 stars 7 forks source link

Bad practices in attributes/default.rb #17

Closed BDeus closed 3 years ago

BDeus commented 7 years ago

It's a bad practices to derived attributes in default.rb because it's not recompute when you run the chef-client.

It will be a better place to put this code in recipes/_install.rb

version_numbers = node["confluent"]["version"].split(".")
archive_version = "#{version_numbers[0]}.#{version_numbers[1]}"

default["confluent"]["artifact_url"] = File.join("http://packages.confluent.io/archive", archive_version, "confluent-#{node["confluent"]["version"]}-#{node["confluent"]["scala_version"]}.zip")

See Avoid derived attributes in attribute files in https://github.com/pulseenergy/chef-style-guide#attributes