chef-cli 5.1.0 → 5.2.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
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f07d3f568a94bf70e402ec732f96521233dafdf566b60bdc0ef9fad586e29af
|
4
|
+
data.tar.gz: 6b060133bceeb79fde35c38a41b7c4b6e4a71520f1f631cf37d4f0942838c0ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c429fdd87a900cd5c9178e44edc2eccf48a517a96aa0dd58de2adf5d1d9cdb0ddac522efeacb5676b9a12284bda262030fe8f5e65909ed40e21b5d3fb23845aa
|
7
|
+
data.tar.gz: db8f7b5d1a073a314489315aa35db2554575bba13e37f1ac28c99f0795eb57233d0ae0beb1989f7aa98d0970ed0826cd96849367b1161ecf144d76fc224e9167
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -67,6 +67,11 @@ module ChefCLI
|
|
67
67
|
description: "Enable stacktraces and other debug output",
|
68
68
|
default: false
|
69
69
|
|
70
|
+
option :policy_group,
|
71
|
+
long: "--policy-group POLICY_GROUP",
|
72
|
+
description: "The policy_group to include in the export (default: 'local')",
|
73
|
+
default: nil
|
74
|
+
|
70
75
|
attr_reader :policyfile_relative_path
|
71
76
|
attr_reader :export_dir
|
72
77
|
|
@@ -120,11 +125,14 @@ module ChefCLI
|
|
120
125
|
end
|
121
126
|
|
122
127
|
def export_service
|
123
|
-
@export_service ||= PolicyfileServices::ExportRepo.new(
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
+
@export_service ||= PolicyfileServices::ExportRepo.new(
|
129
|
+
policyfile: policyfile_relative_path,
|
130
|
+
export_dir: export_dir,
|
131
|
+
root_dir: Dir.pwd,
|
132
|
+
archive: archive?,
|
133
|
+
force: config[:force],
|
134
|
+
policy_group: config[:policy_group]
|
135
|
+
)
|
128
136
|
end
|
129
137
|
|
130
138
|
def handle_error(error)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -33,20 +33,15 @@ module ChefCLI
|
|
33
33
|
|
34
34
|
class ExportRepo
|
35
35
|
|
36
|
-
# Policy groups provide namespaces for policies so that a Chef Infra Server can
|
37
|
-
# have multiple active iterations of a policy at once, but we don't need
|
38
|
-
# this when serving a single exported policy via Chef Zero, so hardcode
|
39
|
-
# it to a "well known" value:
|
40
|
-
POLICY_GROUP = "local".freeze
|
41
|
-
|
42
36
|
include Policyfile::StorageConfigDelegation
|
43
37
|
|
44
38
|
attr_reader :storage_config
|
45
39
|
attr_reader :root_dir
|
46
40
|
attr_reader :export_dir
|
47
41
|
attr_reader :ui
|
42
|
+
attr_reader :policy_group
|
48
43
|
|
49
|
-
def initialize(policyfile: nil, export_dir: nil, root_dir: nil, archive: false, force: false)
|
44
|
+
def initialize(policyfile: nil, export_dir: nil, root_dir: nil, archive: false, force: false, policy_group: nil)
|
50
45
|
@root_dir = root_dir
|
51
46
|
@export_dir = File.expand_path(export_dir)
|
52
47
|
@archive = archive
|
@@ -55,6 +50,8 @@ module ChefCLI
|
|
55
50
|
|
56
51
|
@policy_data = nil
|
57
52
|
@policyfile_lock = nil
|
53
|
+
@policy_group = policy_group
|
54
|
+
@policy_group ||= "local".freeze
|
58
55
|
|
59
56
|
policyfile_rel_path = policyfile || "Policyfile.rb"
|
60
57
|
policyfile_full_path = File.expand_path(policyfile_rel_path, root_dir)
|
@@ -243,7 +240,7 @@ module ChefCLI
|
|
243
240
|
#
|
244
241
|
|
245
242
|
policy_name '#{policy_name}'
|
246
|
-
policy_group '
|
243
|
+
policy_group '#{policy_group}'
|
247
244
|
|
248
245
|
use_policyfile true
|
249
246
|
policy_document_native_api true
|
@@ -301,9 +298,8 @@ module ChefCLI
|
|
301
298
|
### policy_groups/
|
302
299
|
|
303
300
|
Policy groups are used by Chef Infra Server to manage multiple revisions of the same
|
304
|
-
policy.
|
305
|
-
|
306
|
-
|
301
|
+
policy. The default "local" policy is recommended for export use since there can be
|
302
|
+
no different revisions when not utilizing a server.
|
307
303
|
README
|
308
304
|
end
|
309
305
|
end
|
@@ -389,7 +385,7 @@ module ChefCLI
|
|
389
385
|
end
|
390
386
|
|
391
387
|
def policy_group_repo_item_path
|
392
|
-
File.join(staging_dir, "policy_groups", "
|
388
|
+
File.join(staging_dir, "policy_groups", "#{policy_group}.json")
|
393
389
|
end
|
394
390
|
|
395
391
|
def dot_chef_staging_dir
|
data/lib/chef-cli/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -84,6 +84,10 @@ describe ChefCLI::Command::Export do
|
|
84
84
|
expect(command.export_service.policyfile_filename).to eq(File.expand_path("Policyfile.rb"))
|
85
85
|
end
|
86
86
|
|
87
|
+
it "uses the default policy_group name" do
|
88
|
+
expect(command.export_service.policy_group).to eq("local")
|
89
|
+
end
|
90
|
+
|
87
91
|
end
|
88
92
|
|
89
93
|
context "when a Policyfile relative path and export path are given" do
|
@@ -98,6 +102,19 @@ describe ChefCLI::Command::Export do
|
|
98
102
|
expect(command.export_service.policyfile_filename).to eq(File.expand_path("CustomNamedPolicy.rb"))
|
99
103
|
end
|
100
104
|
end
|
105
|
+
|
106
|
+
context "when a policy_group is given" do
|
107
|
+
|
108
|
+
let(:params) { [ "path/to/export", "--policy_group", "production" ] }
|
109
|
+
|
110
|
+
it "configures the export service with the export path" do
|
111
|
+
expect(command.export_service.export_dir).to eq(File.expand_path("path/to/export"))
|
112
|
+
end
|
113
|
+
|
114
|
+
it "configures the export service with the policyfile relative path" do
|
115
|
+
expect(command.export_service.policy_group).to eq("production")
|
116
|
+
end
|
117
|
+
end
|
101
118
|
end
|
102
119
|
|
103
120
|
describe "running the export" do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -42,12 +42,15 @@ describe ChefCLI::PolicyfileServices::ExportRepo do
|
|
42
42
|
|
43
43
|
let(:archive) { false }
|
44
44
|
|
45
|
+
let(:policy_group) { nil }
|
46
|
+
|
45
47
|
subject(:export_service) do
|
46
48
|
described_class.new(policyfile: policyfile_rb_explicit_name,
|
47
49
|
root_dir: working_dir,
|
48
50
|
export_dir: export_dir,
|
49
51
|
archive: archive,
|
50
|
-
force: force_export
|
52
|
+
force: force_export,
|
53
|
+
policy_group: policy_group)
|
51
54
|
end
|
52
55
|
|
53
56
|
it "uses Policyfile.rb as the default Policyfile name" do
|
@@ -306,6 +309,52 @@ describe ChefCLI::PolicyfileServices::ExportRepo do
|
|
306
309
|
expect(File).to exist(readme_path)
|
307
310
|
end
|
308
311
|
|
312
|
+
context "when the policy_group is changed" do
|
313
|
+
let(:policy_group) { "production" }
|
314
|
+
it "creates a policy_group file for a specified policy group with the revision id of the exported policy" do
|
315
|
+
exported_policy_group_path = File.join(export_dir, "policy_groups", "production.json")
|
316
|
+
exported_policy_group_data = FFI_Yajl::Parser.parse(IO.read(exported_policy_group_path))
|
317
|
+
|
318
|
+
expected_data = { "policies" => { "install-example" => { "revision_id" => revision_id } } }
|
319
|
+
|
320
|
+
expect(exported_policy_group_data).to eq(expected_data)
|
321
|
+
end
|
322
|
+
|
323
|
+
it "creates a working local mode configuration file with the changed policy_group" do
|
324
|
+
expected_config_text = <<~CONFIG
|
325
|
+
### Chef Infra Client Configuration ###
|
326
|
+
# The settings in this file will configure chef to apply the exported policy in
|
327
|
+
# this directory. To use it, run:
|
328
|
+
#
|
329
|
+
# chef-client -z
|
330
|
+
#
|
331
|
+
|
332
|
+
policy_name 'install-example'
|
333
|
+
policy_group 'production'
|
334
|
+
|
335
|
+
use_policyfile true
|
336
|
+
policy_document_native_api true
|
337
|
+
|
338
|
+
# In order to use this repo, you need a version of Chef Infra Client and Chef Zero
|
339
|
+
# that supports policyfile "native mode" APIs:
|
340
|
+
current_version = Gem::Version.new(Chef::VERSION)
|
341
|
+
unless Gem::Requirement.new(">= 12.7").satisfied_by?(current_version)
|
342
|
+
puts("!" * 80)
|
343
|
+
puts(<<-MESSAGE)
|
344
|
+
This Chef Repo requires features introduced in Chef Infra Client 12.7, but you are using
|
345
|
+
Chef \#{Chef::VERSION}. Please upgrade to Chef Infra Client 12.7 or later.
|
346
|
+
MESSAGE
|
347
|
+
puts("!" * 80)
|
348
|
+
exit!(1)
|
349
|
+
end
|
350
|
+
|
351
|
+
CONFIG
|
352
|
+
config_path = File.join(export_dir, ".chef", "config.rb")
|
353
|
+
expect(File).to exist(config_path)
|
354
|
+
expect(IO.read(config_path)).to eq(expected_config_text)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
309
358
|
end
|
310
359
|
|
311
360
|
context "when the export dir is empty" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|