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 +4 -4
- data/README.md +5 -5
- data/Rakefile +1 -0
- data/lib/chef/automate.rb +1 -1
- data/lib/chef/knife/ec_backup.rb +2 -2
- data/lib/chef/knife/ec_base.rb +1 -1
- data/lib/chef/knife/ec_key_base.rb +1 -1
- data/lib/chef/knife/ec_restore.rb +7 -7
- data/lib/chef/server.rb +10 -1
- data/lib/knife_ec_backup/version.rb +1 -1
- data/spec/chef/knife/ec_error_handler_spec.rb +5 -5
- data/spec/chef/knife/ec_key_base_spec.rb +4 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b15fe8682fd2e275bc2d321c69be3082a145b3f90559dc90d9d26afbbb356d24
|
4
|
+
data.tar.gz: 8cd7ecb92d4de14b4ab740d8cb072f798ceff4b901da50d474b08f334705f3e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e19516b065248e9f1fd7dbefc48b4563a861821ad25ce05afab2c248a2eff8ce950aa5ee59c360fefcca98c0cbca91cba6d8ec1fb5b4e80ba653a2c3c2ae560e
|
7
|
+
data.tar.gz: 64d57fed9dc70dc9f8cc868842d68e64b2d3a7ee5adc06b0254e2c313a3c4e6d632d561785a7b18f3cb488f625b85c8d7d85280f73cd6e0017510477483d8a69
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Knife EC Backup
|
2
|
-
[](https://buildkite.com/chef-oss/chef-knife-ec-backup-main-verify)
|
3
3
|
[](https://badge.fury.io/rb/knife-ec-backup)
|
4
4
|
|
5
|
-
**Umbrella Project**: [Knife](https://github.com/chef/chef-oss-practices/blob/
|
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/
|
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/
|
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/
|
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
data/lib/chef/automate.rb
CHANGED
data/lib/chef/knife/ec_backup.rb
CHANGED
@@ -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::
|
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::
|
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
|
data/lib/chef/knife/ec_base.rb
CHANGED
@@ -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.
|
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::
|
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::
|
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::
|
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::
|
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::
|
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::
|
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::
|
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
|
-
|
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
|
@@ -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::
|
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::
|
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::
|
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::
|
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::
|
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
|
-
|
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.
|
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:
|
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: '
|
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: '
|
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: '
|
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.
|
135
|
+
rubygems_version: 3.3.27
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Backup and Restore of Enterprise Chef
|