knife-cookbook-cleanup 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5634029cada3e8260d116e10293848022f59591a
4
- data.tar.gz: 95c5f74456429e1fc96ebe3692d8fdc1dff83376
2
+ SHA256:
3
+ metadata.gz: 7e7fd8d36ecd569973dcee2add6856f1d36f115727fd6be43d523cc3bc1d5b4a
4
+ data.tar.gz: 4bbe81a9c2b9cf49ea504c32b081518d8cf6ff5fb789725695ee37d64c3ccb4e
5
5
  SHA512:
6
- metadata.gz: b58938a53f84128ea50d4fc31402808d2036868b7ac12099deadcd45fc37fa15a8c9cf3e2a48d422caf2e601f9790a3848704f185bf7fa04205fcddc2fce4567
7
- data.tar.gz: 4b06f120e37cc4c65c433273ee5d9caafc01529ef7eb8842ea08320a5a11963675e8f04cc1f5c53e094375bbadf49055af9429e598179ac219c8f080702088c1
6
+ metadata.gz: d7cd709997f01efb69e0e2bf6fff94058b46adc510ea16e0337c375a3968f91812c4425d55434a2245adfe4f728ca21dfc360a5ab04f7f2f89c82da8807d4b61
7
+ data.tar.gz: 482270e2175288acb36f58eed7a42be9cedf61eee37c026a534f973285a7e130b3252cc9d109bb9947d1678d0649a9dae09f670ed8e18e81f28dc48c4ec401d0
data/.gitignore CHANGED
@@ -17,6 +17,7 @@ mkmf.log
17
17
  .DS_Store
18
18
  .idea/*
19
19
  *.gem
20
+ Gemfile.lock
20
21
 
21
22
 
22
23
  # test-kitchen
@@ -4,6 +4,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format located [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
5
5
 
6
6
  ## [Unreleased]
7
+
8
+
9
+ ## [1.1.0] - 2019-10-28
10
+ ### Security
11
+ - updated dependencies via dependabot (@dependabot)
12
+
13
+ ### Added
14
+ - allow targeting a single cookbook for cleanup, not specifying any cookbook will cleanup all cookbooks (@majormoses)
15
+
16
+ ### Changed
17
+ - locked `chef` dependencies to keep ruby `2.3` support (@majomoses)
18
+
19
+ ## [1.0.0] - 2018-03-06
7
20
  ### Added
8
21
  - option `--dry-run` to echo out what it would do (@majormoses)
9
22
  - option `--versions-to-keep` which allows you keep x versions, this is useful for cleaning up cookbooks but leaving the last few around for easy rollback and such (@majormoses)
@@ -19,5 +32,7 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin
19
32
  ### Added
20
33
  - functional version (@agoddard)
21
34
 
22
- [Unreleased]: https://github.com/majormoses/knife-cookbook-cleanup/compare/v0.1.1...HEAD
35
+ [Unreleased]: https://github.com/majormoses/knife-cookbook-cleanup/compare/1.1.0...HEAD
36
+ [1.1.0]: https://github.com/majormoses/knife-cookbook-cleanup/compare/1.0.0...1.1.0
37
+ [1.0.0]: https://github.com/majormoses/knife-cookbook-cleanup/compare/v0.1.1...1.0.0
23
38
  [0.1.1]: https://github.com/majormoses/knife-cookbook-cleanup/compare/df026a622e4962f0a1d88e93d866bf4daae02b0e...7822c8a3790c25ab2acb56b24507728c19efd7b4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  knife-cookbook-cleanup
2
2
  ========
3
- A knife plugin for removing old versions of cookbooks from your chef-server, the plugin will only leave the latest versions of cookbooks on the server.
3
+ A knife plugin for removing old versions of cookbooks from your chef-server, the plugin will by default only leave the latest versions of cookbooks on the server. You can control the number of versions that are left on the chef server.
4
4
 
5
5
 
6
6
  Installing knife-cookbook-cleanup
@@ -15,4 +15,31 @@ add `knife-cookbook-cleanup` to your Gemfile, or simply
15
15
  Usage
16
16
  ---------------
17
17
 
18
- knife cookbook cleanup
18
+ Both cookbook and options are not required:
19
+
20
+ $ knife cookbook cleanup --help
21
+ knife cookbook cleanup [COOKBOOK] (options)
22
+ -s, --server-url URL Chef Server URL
23
+ --chef-zero-host HOST Host to start chef-zero on
24
+ --chef-zero-port PORT Port (or port range) to start chef-zero on. Port ranges like 1000,1010 or 8889-9999 will try all given ports until one works.
25
+ -k, --key KEY API Client Key
26
+ --[no-]color Use colored output, defaults to enabled
27
+ -c, --config CONFIG The configuration file to use
28
+ --config-option OPTION=VALUE Override a single configuration option
29
+ --defaults Accept default values for all questions
30
+ -d, --disable-editing Do not open EDITOR, just accept the data as is
31
+ --dry-run Allows showing what would have been done without actually doing the deed
32
+ -e, --editor EDITOR Set the editor to use for interactive commands
33
+ -E, --environment ENVIRONMENT Set the Chef environment (except for in searches, where this will be flagrantly ignored)
34
+ --[no-]fips Enable fips mode
35
+ -F, --format FORMAT Which format to use for output
36
+ --[no-]listen Whether a local mode (-z) server binds to a port
37
+ -z, --local-mode Point knife commands at local repository instead of server
38
+ -u, --user USER API Client Username
39
+ --print-after Show the data after a destructive operation
40
+ --profile PROFILE The credentials profile to select
41
+ -V, --verbose More verbose output. Use twice for max verbosity
42
+ -v, --version Show chef version
43
+ --versions-to-keep VALUE Versions of cookbooks to keep (default 1)
44
+ -y, --yes Say yes to all prompts for confirmation
45
+ -h, --help Show this message
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.email = ['me@benabrams.it']
20
20
  s.homepage = 'https://github.com/majormoses/knife-cookbook-cleanup'
21
21
  s.summary = 'Chef Knife plugin to remove all cookbooks except the latest'
22
- s.description = 'Deletes all cookbooks from the chef server except for x versions'
22
+ s.description = 'Deletes a specific or all cookbooks from the chef server except for x versions'
23
23
 
24
24
  s.files = `git ls-files`.split("\n")
25
25
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.require_paths = ['lib']
28
28
  s.required_ruby_version = '>= 2.3.1'
29
29
 
30
- s.add_dependency 'chef', '> 12.0'
30
+ s.add_dependency 'chef', '> 12.0', '< 14.0'
31
31
 
32
32
  s.add_development_dependency 'bundler', '~> 1.6'
33
33
  s.add_development_dependency 'rake'
@@ -29,7 +29,7 @@ class Chef
29
29
  Chef::Knife::Bootstrap.load_deps
30
30
  end
31
31
 
32
- banner 'knife cookbook cleanup'
32
+ banner 'knife cookbook cleanup [COOKBOOK] (options)'
33
33
 
34
34
  option :versions_to_keep,
35
35
  long: '--versions-to-keep VALUE',
@@ -44,11 +44,13 @@ class Chef
44
44
  default: false
45
45
 
46
46
  def run
47
+ target_cookbook = name_args[0] if name_args.length.positive?
47
48
  all_cookbooks = rest.get_rest('/cookbooks?num_versions=all')
48
49
  drop_cookbooks = {}
49
50
  keep_cookbooks = {}
50
51
  all_cookbooks.each do |cb|
51
52
  cookbook_name = cb[0]
53
+ next if !target_cookbook.nil? && target_cookbook != cookbook_name
52
54
  sorted_versions = cb[1]['versions'].map { |v| v['version'] }.sort { |x, y| Gem::Version.new(x) <=> Gem::Version.new(y) }
53
55
  keep_versions = sorted_versions.pop(config[:versions_to_keep])
54
56
  dropped_versions = sorted_versions
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Knife
3
4
  module CookbookCleanup
4
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
5
6
  MAJOR, MINOR, TINY = VERSION.split('.')
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-cookbook-cleanup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Goddard
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-03-06 00:00:00.000000000 Z
14
+ date: 2019-10-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: chef
@@ -20,6 +20,9 @@ dependencies:
20
20
  - - ">"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '12.0'
23
+ - - "<"
24
+ - !ruby/object:Gem::Version
25
+ version: '14.0'
23
26
  type: :runtime
24
27
  prerelease: false
25
28
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,6 +30,9 @@ dependencies:
27
30
  - - ">"
28
31
  - !ruby/object:Gem::Version
29
32
  version: '12.0'
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '14.0'
30
36
  - !ruby/object:Gem::Dependency
31
37
  name: bundler
32
38
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +75,8 @@ dependencies:
69
75
  - - "~>"
70
76
  - !ruby/object:Gem::Version
71
77
  version: 0.51.0
72
- description: Deletes all cookbooks from the chef server except for x versions
78
+ description: Deletes a specific or all cookbooks from the chef server except for x
79
+ versions
73
80
  email:
74
81
  - me@benabrams.it
75
82
  executables: []
@@ -83,7 +90,6 @@ files:
83
90
  - ".travis.yml"
84
91
  - CHANGELOG.md
85
92
  - Gemfile
86
- - Gemfile.lock
87
93
  - LICENSE
88
94
  - LICENSE.md
89
95
  - README.md
@@ -109,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
115
  - !ruby/object:Gem::Version
110
116
  version: '0'
111
117
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.5.2.1
118
+ rubygems_version: 3.0.3
114
119
  signing_key:
115
120
  specification_version: 4
116
121
  summary: Chef Knife plugin to remove all cookbooks except the latest