knife-ec-backup 3.0.1 → 3.0.5

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
  SHA256:
3
- metadata.gz: 2a0b8a9bc3f08aad497a8f1b7811b361dd8c0e9d7702154f11a3382cd81b90c4
4
- data.tar.gz: 36151413cfbda4f5c672df845f8105a8b9fd091cefa9fa9305e9476e502a0ddc
3
+ metadata.gz: b15fe8682fd2e275bc2d321c69be3082a145b3f90559dc90d9d26afbbb356d24
4
+ data.tar.gz: 8cd7ecb92d4de14b4ab740d8cb072f798ceff4b901da50d474b08f334705f3e8
5
5
  SHA512:
6
- metadata.gz: 20b36c896d4805fae633dcec1abcb9f056a4c03f18bc44c1df8b792f1b04a674705a7f5395c83f21ec81d2150811e4cd3c19e3a5aaa9c0105d546d04cd0c5a95
7
- data.tar.gz: 065177a92147ba8af0b514d6da93c602f5ab192c89c187ba91a090e0d1b2215ac2ab1e4c3bd7ef01c02a37235abc773ce795098fb8ff5f8b4e5f76879d87d00c
6
+ metadata.gz: e19516b065248e9f1fd7dbefc48b4563a861821ad25ce05afab2c248a2eff8ce950aa5ee59c360fefcca98c0cbca91cba6d8ec1fb5b4e80ba653a2c3c2ae560e
7
+ data.tar.gz: 64d57fed9dc70dc9f8cc868842d68e64b2d3a7ee5adc06b0254e2c313a3c4e6d632d561785a7b18f3cb488f625b85c8d7d85280f73cd6e0017510477483d8a69
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # Knife EC Backup
2
- [![Build status](https://badge.buildkite.com/4bc85427aab66accafbd7abb2932b9dd7f9208162c5be33488.svg?branch=master)](https://buildkite.com/chef-oss/chef-knife-ec-backup-master-verify)
2
+ [![Build status](https://badge.buildkite.com/4bc85427aab66accafbd7abb2932b9dd7f9208162c5be33488.svg?branch=main)](https://buildkite.com/chef-oss/chef-knife-ec-backup-main-verify)
3
3
  [![Gem Version](https://badge.fury.io/rb/knife-ec-backup.svg)](https://badge.fury.io/rb/knife-ec-backup)
4
4
 
5
- **Umbrella Project**: [Knife](https://github.com/chef/chef-oss-practices/blob/master/projects/knife.md)
5
+ **Umbrella Project**: [Knife](https://github.com/chef/chef-oss-practices/blob/main/projects/knife.md)
6
6
 
7
- **Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md#active)
7
+ **Project State**: [Active](https://github.com/chef/chef-oss-practices/blob/main/repo-management/repo-states.md#active)
8
8
 
9
- **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days
9
+ **Issues [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/main/repo-management/repo-states.md)**: 14 days
10
10
 
11
- **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/master/repo-management/repo-states.md)**: 14 days
11
+ **Pull Request [Response Time Maximum](https://github.com/chef/chef-oss-practices/blob/main/repo-management/repo-states.md)**: 14 days
12
12
 
13
13
  ## Description
14
14
 
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ task :default => :spec
11
11
  desc "Run specs"
12
12
  RSpec::Core::RakeTask.new(:spec) do |spec|
13
13
  spec.pattern = 'spec/**/*_spec.rb'
14
+ spec.rspec_opts = "--tag ~smoke"
14
15
  end
15
16
 
16
17
  gem_spec = eval(File.read("knife-ec-backup.gemspec"))
data/lib/chef/automate.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  class Automate
3
3
  def self.is_installed?
4
- File.exists?('/hab/svc/automate-cs-oc-erchef/')
4
+ File.exist?('/hab/svc/automate-cs-oc-erchef/')
5
5
  end
6
6
 
7
7
  def self.config
@@ -85,7 +85,7 @@ class Chef
85
85
  remote_users.each_pair do |name, url|
86
86
  yield name, url
87
87
  end
88
- rescue Net::HTTPServerException => ex
88
+ rescue Net::HTTPClientException => ex
89
89
  knife_ec_error_handler.add(ex)
90
90
  end
91
91
 
@@ -95,7 +95,7 @@ class Chef
95
95
  ui.msg "Downloading organization object for #{name} from #{url}"
96
96
  begin
97
97
  org = rest.get(url)
98
- rescue Net::HTTPServerException => ex
98
+ rescue Net::HTTPClientException => ex
99
99
  ui.error "Failed to find organization '#{name}'."
100
100
  knife_ec_error_handler.add(ex)
101
101
  next
@@ -142,7 +142,7 @@ class Chef
142
142
  else
143
143
  admin_users[0]
144
144
  end
145
- rescue Net::HTTPServerException => ex
145
+ rescue Net::HTTPClientException => ex
146
146
  knife_ec_error_handler.add(ex)
147
147
  end
148
148
  end
@@ -109,7 +109,7 @@ class Chef
109
109
  ui.msg "Automate detected"
110
110
  config.merge! Chef::Automate.config {|key, v1, v2| v1}
111
111
  else
112
- if ! File.exists?("/etc/opscode/chef-server-running.json")
112
+ if ! File.exist?("/etc/opscode/chef-server-running.json")
113
113
  ui.fatal "SQL User or Password not provided as option and running config cannot be found!"
114
114
  exit 1
115
115
  else
@@ -76,7 +76,7 @@ class Chef
76
76
  def create_organization(orgname)
77
77
  org = JSONCompat.from_json(File.read("#{dest_dir}/organizations/#{orgname}/org.json"))
78
78
  rest.post('organizations', org)
79
- rescue Net::HTTPServerException => ex
79
+ rescue Net::HTTPClientException => ex
80
80
  if ex.response.code == "409"
81
81
  rest.put("organizations/#{orgname}", org)
82
82
  else
@@ -89,7 +89,7 @@ class Chef
89
89
  invitations.each do |invitation|
90
90
  begin
91
91
  rest.post("organizations/#{orgname}/association_requests", { 'user' => invitation['username'] })
92
- rescue Net::HTTPServerException => ex
92
+ rescue Net::HTTPClientException => ex
93
93
  if ex.response.code != "409"
94
94
  ui.error("Cannot create invitation #{invitation['id']}")
95
95
  knife_ec_error_handler.add(ex)
@@ -106,7 +106,7 @@ class Chef
106
106
  response = rest.post("organizations/#{orgname}/association_requests", { 'user' => username })
107
107
  association_id = response["uri"].split("/").last
108
108
  rest.put("users/#{username}/association_requests/#{association_id}", { 'response' => 'accept' })
109
- rescue Net::HTTPServerException => ex
109
+ rescue Net::HTTPClientException => ex
110
110
  knife_ec_error_handler.add(ex) if ex.response.code != "409"
111
111
  end
112
112
  end
@@ -149,7 +149,7 @@ class Chef
149
149
  user_with_password = user.dup
150
150
  user_with_password['password'] = SecureRandom.hex
151
151
  rest.post('users', user_with_password)
152
- rescue Net::HTTPServerException => ex
152
+ rescue Net::HTTPClientException => ex
153
153
  if ex.response.code == "409"
154
154
  rest.put("users/#{name}", user)
155
155
  next
@@ -175,7 +175,7 @@ class Chef
175
175
  ui.msg "Deleting user #{user} from remote (purge is on)"
176
176
  begin
177
177
  rest.delete("/users/#{user}")
178
- rescue Net::HTTPServerException => e
178
+ rescue Net::HTTPClientException => e
179
179
  ui.warn "Failed deleting user #{user} from remote #{e}"
180
180
  end
181
181
  end
@@ -321,7 +321,7 @@ class Chef
321
321
  chef_fs_config.chef_fs, nil,
322
322
  config, ui,
323
323
  proc { |entry| chef_fs_config.format_path(entry) })
324
- rescue Net::HTTPServerException,
324
+ rescue Net::HTTPClientException,
325
325
  Chef::ChefFS::FileSystem::NotFoundError,
326
326
  Chef::ChefFS::FileSystem::OperationFailedError => ex
327
327
  knife_ec_error_handler.add(ex)
@@ -387,7 +387,7 @@ class Chef
387
387
  rest.put("#{url}/#{permission}", { permission => acls[permission] })
388
388
  end
389
389
  end
390
- rescue Net::HTTPServerException => ex
390
+ rescue Net::HTTPClientException => ex
391
391
  knife_ec_error_handler.add(ex)
392
392
  end
393
393
  end
data/lib/chef/server.rb CHANGED
@@ -18,7 +18,16 @@ class Chef
18
18
  def parse_server_version(line)
19
19
  # first line from the /version endpoint will either be this format "chef-server 12.17.5\n"
20
20
  # or, when habitat, this format "Package: chef-server/chef-server-nginx/12.17.42/20180413212943\n"
21
- Gem::Version.new(line.include?('/') ? line.split('/')[2] : line.split(' ').last.gsub(/\+.*$/, ''))
21
+ version_str = if line.include?('/')
22
+ line.split('/')[2]
23
+ else
24
+ # Strip everything after '+' using String#partition.
25
+ # We avoid regex here since Ruby < 3.2 is vulnerable to ReDoS,
26
+ # and we support Ruby 3.1 in pipelines.
27
+ line.split(' ').last.partition('+').first
28
+ end
29
+
30
+ Gem::Version.new(version_str)
22
31
  end
23
32
 
24
33
  def version
@@ -1,4 +1,4 @@
1
1
  # when you change this to double quotes, also update .expeditor/update_version.sh
2
2
  module KnifeECBackup
3
- VERSION = '3.0.1'
3
+ VERSION = '3.0.5'
4
4
  end
@@ -55,7 +55,7 @@ Error Summary Report
55
55
  "timestamp": "1988-04-17 00:00:00 \+0000",
56
56
  "message": "I'm not real!",
57
57
  "backtrace": null,
58
- "exception": "Net::HTTPServerException"
58
+ "exception": "Net::HTTPClientException"
59
59
  }
60
60
  /).to_stdout
61
61
  end
@@ -66,22 +66,22 @@ Error Summary Report
66
66
  "timestamp": "1988-04-17 00:00:00 +0000",
67
67
  "message": "I'm not real!",
68
68
  "backtrace": null,
69
- "exception": "Net::HTTPServerException"
69
+ "exception": "Net::HTTPClientException"
70
70
  }{
71
71
  "timestamp": "1988-04-17 00:00:00 +0000",
72
72
  "message": "I'm not real!",
73
73
  "backtrace": null,
74
- "exception": "Net::HTTPServerException"
74
+ "exception": "Net::HTTPClientException"
75
75
  }{
76
76
  "timestamp": "1988-04-17 00:00:00 +0000",
77
77
  "message": "I'm not real!",
78
78
  "backtrace": null,
79
- "exception": "Net::HTTPServerException"
79
+ "exception": "Net::HTTPClientException"
80
80
  }{
81
81
  "timestamp": "1988-04-17 00:00:00 +0000",
82
82
  "message": "I'm not real!",
83
83
  "backtrace": null,
84
- "exception": "Net::HTTPServerException"
84
+ "exception": "Net::HTTPClientException"
85
85
  }{
86
86
  "timestamp": "1988-04-17 00:00:00 +0000",
87
87
  "message": "The reason",
@@ -23,13 +23,15 @@ describe Chef::Knife::EcKeyBase do
23
23
  allow(File).to receive(:exists?).and_return(true)
24
24
  allow(File).to receive(:size).and_return(1)
25
25
  end
26
- it "correctly sets sql options when they live under postgresql settings" do
26
+ ## skipping status test because of the missing file in automate - /etc/opscode/chef-server-running.json
27
+ ## adding smoke tag or else all the test will be considered skipping only the status test
28
+ it "correctly sets sql options when they live under postgresql settings", :smoke do
27
29
  allow(IO).to receive(:read).and_return(running_server_postgresql_sql_config_json)
28
30
  knife.load_config_from_file!
29
31
  expect(knife.config[:sql_user]).to eq("jiminy")
30
32
  expect(knife.config[:sql_password]).to eq("secret")
31
33
  end
32
- it "correctly sets sql options when they live under opscode-erchef settings" do
34
+ it "correctly sets sql options when they live under opscode-erchef settings", :smoke do
33
35
  allow(IO).to receive(:read).and_return(running_server_erchef_config_json)
34
36
  knife.load_config_from_file!
35
37
  expect(knife.config[:sql_user]).to eq("cricket")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-29 00:00:00.000000000 Z
11
+ date: 2025-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: chef
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '11.8'
47
+ version: '18.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '11.8'
54
+ version: '18.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: veil
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -125,14 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: '2.6'
128
+ version: '3.1'
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.1.4
135
+ rubygems_version: 3.3.27
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Backup and Restore of Enterprise Chef