knife-chef-retention 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ff54c639881e87fffe4a593253d850625f5e642
4
- data.tar.gz: aaee45b42f3fa620baaa97e2577e612a9fc8f283
3
+ metadata.gz: 64496365e38ac8c73e6a775439371e644273661f
4
+ data.tar.gz: 6543809858bd5146a1fdc557b88c290517ae3a4d
5
5
  SHA512:
6
- metadata.gz: a57915b45f7229c37813a8d63425f844354f2421da19db823889885e171369f66d72405501c732b89363d8e38b41fff90c87002a6425f6cb6cab0c37f294ec70
7
- data.tar.gz: 07ffeaddb0a8396269e83ecc9120ea4f1b35b930bfad2c491e67dacc3e60cd12e114203fdcaed0c01fa7909e6b8a80a4c6a24b07d693ce594cc66be3da61c37c
6
+ metadata.gz: aa655b05de308773949ccae21c5ef3a869d179c2159c3c3415dd859dbd789cadd8bd117520cec25ab846bbcfde844114adcda4455bd60837abe88f5716a092c7
7
+ data.tar.gz: 18ecb4ee72db2a82c322b00add0dd7406420160dba99af227846313ae96fe86de5b413ade5f3c344f90eef0f80abcd4b08a87473b4e9e18e5ea430af8bcf49e8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.3.0](https://github.com/cvent/knife-chef-retention/tree/v0.3.0) (2019-04-10)
4
+ [Full Changelog](https://github.com/cvent/knife-chef-retention/compare/v0.2.0...v0.3.0)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Fix cookbook version sorting [\#7](https://github.com/cvent/knife-chef-retention/pull/7) ([majormoses](https://github.com/majormoses))
9
+
3
10
  ## [v0.2.0](https://github.com/cvent/knife-chef-retention/tree/v0.2.0) (2016-10-03)
4
11
  [Full Changelog](https://github.com/cvent/knife-chef-retention/compare/v0.0.1...v0.2.0)
5
12
 
data/Gemfile CHANGED
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  source "https://rubygems.org"
3
4
 
4
5
  gemspec
5
6
 
6
7
  group :development do
7
8
  gem "bundler", "~> 1.6"
9
+ gem "github_changelog_generator", "~> 1.13"
8
10
  gem "rake", "~> 11.1"
9
11
  gem "rubocop", "~> 0.38"
10
- gem "github_changelog_generator", "~> 1.13"
11
12
  end
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Import other external rake tasks
3
4
  Dir.glob("tasks/*.rake").each { |r| import r }
4
5
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.push File.expand_path("../lib", __FILE__)
2
+
3
+ $LOAD_PATH.push File.expand_path("lib", __dir__)
3
4
  require "knife-chef-retention/version"
4
5
 
5
6
  Gem::Specification.new do |s|
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "chef/knife"
3
4
 
4
5
  class Chef
@@ -24,6 +25,13 @@ class Chef
24
25
  description: "The number of extra versions to keep (Default: 1)",
25
26
  default: 1
26
27
 
28
+ option :ignore_used,
29
+ short: "-i",
30
+ long: "--ignore-used",
31
+ description: "Ignore used cookbooks, useful where stale inventory is a thing",
32
+ boolean: true,
33
+ default: false
34
+
27
35
  def run
28
36
  cookbook_name = name_args[0] if name_args.length.positive?
29
37
  clobber = config[:clobber]
@@ -89,9 +97,8 @@ class Chef
89
97
  unused_versions = cookbook_versions(cookbook).take_while do |version|
90
98
  # These are package that are not used and are considered old as they
91
99
  # are after the first used version still
92
- version unless version[:used]
100
+ version unless version[:used] && !config[:ignore_used]
93
101
  end
94
-
95
102
  save_some_versions(unused_versions, extra_versions)
96
103
  end
97
104
 
@@ -110,8 +117,7 @@ class Chef
110
117
  used: used_by_node
111
118
  }
112
119
  end
113
-
114
- versions.sort_by { |v| v[:version] }
120
+ versions.sort { |x, y| Gem::Version.new(x[:version]) <=> Gem::Version.new(y[:version]) }
115
121
  end
116
122
 
117
123
  def search_nodes(query)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Knife
3
4
  module ChefRetention
4
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
5
6
  end
6
7
  end
data/tasks/changelog.rake CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  begin
3
4
  require "knife-chef-retention/version"
4
5
  require "github_changelog_generator/task"
@@ -6,9 +7,9 @@ begin
6
7
  GitHubChangelogGenerator::RakeTask.new :changelog do |config|
7
8
  config.future_release = "v#{Knife::ChefRetention::VERSION}"
8
9
  config.issues = false
9
- config.enhancement_labels = %w(enhancement)
10
- config.bug_labels = %w(bug)
11
- config.exclude_labels = %w(no_changelog)
10
+ config.enhancement_labels = %w[enhancement]
11
+ config.bug_labels = %w[bug]
12
+ config.exclude_labels = %w[no_changelog]
12
13
  end
13
14
  rescue LoadError
14
15
  puts "Problem loading gems please install chef and github_changelog_generator"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-chef-retention
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Montague
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2019-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef