Skip to content

Commit

Permalink
Merge branch 'main' into CHEF-2616-license-command
Browse files Browse the repository at this point in the history
  • Loading branch information
ashiqueps authored Sep 18, 2024
2 parents fa887af + 86243c3 commit d8cac96
Show file tree
Hide file tree
Showing 44 changed files with 219 additions and 148 deletions.
21 changes: 19 additions & 2 deletions .expeditor/verify.pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,33 @@ steps:
docker:
image: ruby:3.1

- label: run-specs-windows-ruby-3.1
- label: run-specs-ruby-3.3
command:
- .expeditor/run_linux_tests.sh rspec
expeditor:
executor:
docker:
image: ruby:3.3

- label: run-specs-windows-3.1
command:
- powershell .expeditor/run_windows_tests.ps1 rspec
expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.1

- label: run-specs-windows-ruby-3.3
command:
- powershell .expeditor/run_windows_tests.ps1 rspec
expeditor:
executor:
docker:
host_os: windows
shell: ["powershell", "-Command"]
image: rubydistros/windows-2019:3.3

- label: cookstyle-generator-cb-tests-ruby-3.1
command:
- .expeditor/run_linux_tests.sh "rake style:cookstyle"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ip-range-controlled
# needs: [build]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
Expand All @@ -30,4 +30,4 @@ jobs:
# - uses: sonarsource/sonarqube-quality-gate-action@master
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up ruby 3.1
uses: ruby/setup-ruby@v1
with:
Expand Down
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
---
require:
- chefstyle

AllCops:
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
- "vendor/**/*"
- "spec/**/*"
Style/StringLiterals:
Exclude:
- "spec/unit/fixtures/**/*"
Expand Down
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<!-- usage documentation: https://expeditor.chef.io/docs/reference/changelog/#common-changelog -->
<!-- latest_release -->
<!-- latest_release 5.6.15 -->
## [v5.6.15](https://github.com/chef/chef-cli/tree/v5.6.15) (2024-08-17)

#### Merged Pull Requests
- Update generator kitchen templates for modern platforms [#234](https://github.com/chef/chef-cli/pull/234) ([Stromweld](https://github.com/Stromweld))
<!-- latest_release -->

<!-- release_rollup -->
<!-- release_rollup since=5.6.14 -->
### Changes not yet released to rubygems.org

#### Merged Pull Requests
- Update generator kitchen templates for modern platforms [#234](https://github.com/chef/chef-cli/pull/234) ([Stromweld](https://github.com/Stromweld)) <!-- 5.6.15 -->
<!-- release_rollup -->

<!-- latest_stable_release -->
Expand Down
18 changes: 5 additions & 13 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,16 @@ source "https://rubygems.org"

gemspec

gem "logger", "< 1.6" # 1.6 causes errors with mixlib-log < 3.1.1

group :test do
gem "rake"
gem "rspec", "~> 3.8"
gem "rspec-expectations", "~> 3.8"
gem "rspec-mocks", "~> 3.8"
gem "cookstyle", "=7.7.2" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
gem "chefstyle", "=1.6.2"
gem "test-kitchen", "=3.5.1" # pinning test-kitchen to 3.5.1 which supports ruby < 3.1 . Need to update this to latest once we update the ruby to 3.1 and chef to 18.x in chef-cli

if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6")
gem "chef-zero", "~> 14"
gem "chef", "~> 15"
gem "chef-utils", "=16.6.14"
end
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")
gem "ohai", "~> 16"
end

gem "cookstyle"
gem "chefstyle"
gem "test-kitchen"
gem "simplecov", require: false
end

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.6.14
5.6.15
8 changes: 2 additions & 6 deletions chef-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
gem.license = "Apache-2.0"
gem.homepage = "https://www.chef.io/"

gem.required_ruby_version = ">= 2.7"
gem.required_ruby_version = ">= 3.1"

gem.files = %w{Rakefile LICENSE} +
Dir.glob("Gemfile*") + # Includes Gemfile and locks
Expand All @@ -43,11 +43,7 @@ Gem::Specification.new do |gem|
gem.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
gem.add_dependency "ffi-yajl", ">= 1.0", "< 3.0"
gem.add_dependency "minitar", "~> 0.6"
if RUBY_VERSION.match?(/3.1/)
gem.add_dependency "chef", "~> 18.0"
else
gem.add_dependency "chef", "~> 17.0"
end
gem.add_dependency "chef", "~> 18.0"
gem.add_dependency "solve", "< 5.0", "> 2.0"
gem.add_dependency "addressable", ">= 2.3.5", "< 2.9"
gem.add_dependency "cookbook-omnifetch", "~> 0.5"
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/clean_policy_cookbooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def run(params)

def clean_policy_cookbooks_service
@clean_policy_cookbooks_service ||=
PolicyfileServices::CleanPolicyCookbooks.new(config: chef_config, ui: ui)
PolicyfileServices::CleanPolicyCookbooks.new(config: chef_config, ui:)
end

def debug?
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/clean_policy_revisions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(params)

def clean_policies_service
@policy_list_service ||=
PolicyfileServices::CleanPolicies.new(config: chef_config, ui: ui)
PolicyfileServices::CleanPolicies.new(config: chef_config, ui:)
end

def debug?
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/command/delete_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def run(params)
def rm_policy_service
@rm_policy_service ||=
PolicyfileServices::RmPolicy.new(config: chef_config,
ui: ui,
policy_name: policy_name)
ui:,
policy_name:)
end

def debug?
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/command/delete_policy_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def run(params)
def rm_policy_group_service
@rm_policy_group_service ||=
PolicyfileServices::RmPolicyGroup.new(config: chef_config,
ui: ui,
policy_group: policy_group)
ui:,
policy_group:)
end

def debug?
Expand Down
6 changes: 3 additions & 3 deletions lib/chef-cli/command/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def print_diff

def differ(ui = self.ui)
Policyfile::Differ.new(old_name: old_base.name,
old_lock: old_lock,
old_lock:,
new_name: new_base.name,
new_lock: new_lock,
ui: ui)
new_lock:,
ui:)
end

def http_client
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def archive?
def export_service
@export_service ||= PolicyfileServices::ExportRepo.new(
policyfile: policyfile_relative_path,
export_dir: export_dir,
export_dir:,
root_dir: Dir.pwd,
archive: archive?,
force: config[:force],
Expand Down
2 changes: 1 addition & 1 deletion lib/chef-cli/command/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run(params = [])
end

def installer
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, config: chef_config)
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui:, root_dir: Dir.pwd, config: chef_config)
end

def debug?
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/command/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def debug?

def push
@push ||= PolicyfileServices::Push.new(policyfile: policyfile_relative_path,
ui: ui,
policy_group: policy_group,
ui:,
policy_group:,
config: chef_config,
root_dir: Dir.pwd)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/chef-cli/command/push_archive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def handle_error(error)
def push_archive_service
@push_archive_service ||=
ChefCLI::PolicyfileServices::PushArchive.new(
archive_file: archive_file,
policy_group: policy_group,
ui: ui,
archive_file:,
policy_group:,
ui:,
config: chef_config
)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/chef-cli/command/show_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ def run(params)
def show_policy_service
@policy_list_service ||=
PolicyfileServices::ShowPolicy.new(config: chef_config,
ui: ui,
policy_name: policy_name,
policy_group: policy_group,
ui:,
policy_name:,
policy_group:,
show_orphans: show_orphans?,
summary_diff: show_summary_diff?,
pager: enable_pager?)
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/command/undelete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def run(params)
def undelete_service
@undelete_service ||=
PolicyfileServices::Undelete.new(config: chef_config,
ui: ui,
undo_record_id: undo_record_id)
ui:,
undo_record_id:)
end

def debug?
Expand Down
4 changes: 2 additions & 2 deletions lib/chef-cli/command/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ def run(params = [])
end

def installer
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, config: chef_config, overwrite: true)
@installer ||= PolicyfileServices::Install.new(policyfile: policyfile_relative_path, ui:, root_dir: Dir.pwd, config: chef_config, overwrite: true)
end

def attributes_updater
@attributes_updater ||=
PolicyfileServices::UpdateAttributes.new(policyfile: policyfile_relative_path, ui: ui, root_dir: Dir.pwd, chef_config: chef_config)
PolicyfileServices::UpdateAttributes.new(policyfile: policyfile_relative_path, ui:, root_dir: Dir.pwd, chef_config:)
end

def debug?
Expand Down
14 changes: 6 additions & 8 deletions lib/chef-cli/policyfile/artifactory_cookbook_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ def preferred_source_for?(cookbook_name)
end

def universe_graph
@universe_graph ||= begin
full_community_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
deps_by_version[version] = metadata["dependencies"]
deps_by_version
end
normalized_graph
@universe_graph ||= full_community_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
deps_by_version[version] = metadata["dependencies"]
deps_by_version
end
normalized_graph
end
end

Expand Down Expand Up @@ -90,7 +88,7 @@ def artifactory_api_key

def http_connection_for(base_url)
headers = { "X-Jfrog-Art-API" => artifactory_api_key }
@http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url, headers: headers)
@http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url, headers:)
end

def full_community_graph
Expand Down
16 changes: 6 additions & 10 deletions lib/chef-cli/policyfile/chef_server_cookbook_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ def preferred_source_for?(cookbook_name)
end

def universe_graph
@universe_graph ||= begin
full_chef_server_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
deps_by_version[version] = metadata["dependencies"]
deps_by_version
end
normalized_graph
@universe_graph ||= full_chef_server_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
deps_by_version[version] = metadata["dependencies"]
deps_by_version
end
normalized_graph
end
end

Expand Down Expand Up @@ -90,9 +88,7 @@ def http_connection_for(base_url)

def full_chef_server_graph
@full_chef_server_graph ||=
begin
http_connection_for(uri.to_s).get("/universe")
end
http_connection_for(uri.to_s).get("/universe")
end
end
end
Expand Down
12 changes: 5 additions & 7 deletions lib/chef-cli/policyfile/community_cookbook_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ def ==(other)
end

def universe_graph
@universe_graph ||= begin
full_community_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
deps_by_version[version] = metadata["dependencies"]
deps_by_version
end
normalized_graph
@universe_graph ||= full_community_graph.inject({}) do |normalized_graph, (cookbook_name, metadata_by_version)|
normalized_graph[cookbook_name] = metadata_by_version.inject({}) do |deps_by_version, (version, metadata)|
deps_by_version[version] = metadata["dependencies"]
deps_by_version
end
normalized_graph
end
end

Expand Down
14 changes: 6 additions & 8 deletions lib/chef-cli/policyfile/delivery_supermarket_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,13 @@ def default_source_args
end

def universe_graph
@universe_graph ||= begin
@community_source.universe_graph.inject({}) do |truncated, (cookbook_name, version_and_deps_list)|
sorted_versions = version_and_deps_list.keys.sort_by do |version_string|
Semverse::Version.new(version_string)
end
greatest_version = sorted_versions.last
truncated[cookbook_name] = { greatest_version => version_and_deps_list[greatest_version] }
truncated
@universe_graph ||= @community_source.universe_graph.inject({}) do |truncated, (cookbook_name, version_and_deps_list)|
sorted_versions = version_and_deps_list.keys.sort_by do |version_string|
Semverse::Version.new(version_string)
end
greatest_version = sorted_versions.last
truncated[cookbook_name] = { greatest_version => version_and_deps_list[greatest_version] }
truncated
end
end

Expand Down
Loading

0 comments on commit d8cac96

Please sign in to comment.