chef-config 13.8.5 → 13.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,27 @@
1
- #
2
- # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "chef-config/windows"
19
- require "chef-config/logger"
20
-
21
- module ChefConfig
22
-
23
- class ConfigurationError < ArgumentError; end
24
- class InvalidPath < StandardError; end
25
- class UnparsableConfigOption < StandardError; end
26
-
27
- end
1
+ #
2
+ # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "chef-config/windows"
19
+ require "chef-config/logger"
20
+
21
+ module ChefConfig
22
+
23
+ class ConfigurationError < ArgumentError; end
24
+ class InvalidPath < StandardError; end
25
+ class UnparsableConfigOption < StandardError; end
26
+
27
+ end
@@ -1,51 +1,51 @@
1
- #
2
- # Author:: Matt Wrock (<matt@mattwrock.com>)
3
- # Copyright:: Copyright (c) 2016 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- module ChefConfig
20
-
21
- def self.fips?
22
- if ChefConfig.windows?
23
- begin
24
- require "win32/registry"
25
- rescue LoadError
26
- return false
27
- end
28
-
29
- # from http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
30
- reg_type =
31
- case ::RbConfig::CONFIG["target_cpu"]
32
- when "i386"
33
- Win32::Registry::KEY_READ | 0x100
34
- when "x86_64"
35
- Win32::Registry::KEY_READ | 0x200
36
- else
37
- Win32::Registry::KEY_READ
38
- end
39
- begin
40
- Win32::Registry::HKEY_LOCAL_MACHINE.open('System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy', reg_type) do |policy|
41
- policy["Enabled"] != 0
42
- end
43
- rescue Win32::Registry::Error
44
- false
45
- end
46
- else
47
- fips_path = "/proc/sys/crypto/fips_enabled"
48
- File.exist?(fips_path) && File.read(fips_path).chomp != "0"
49
- end
50
- end
51
- end
1
+ #
2
+ # Author:: Matt Wrock (<matt@mattwrock.com>)
3
+ # Copyright:: Copyright (c) 2016 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ module ChefConfig
20
+
21
+ def self.fips?
22
+ if ChefConfig.windows?
23
+ begin
24
+ require "win32/registry"
25
+ rescue LoadError
26
+ return false
27
+ end
28
+
29
+ # from http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
30
+ reg_type =
31
+ case ::RbConfig::CONFIG["target_cpu"]
32
+ when "i386"
33
+ Win32::Registry::KEY_READ | 0x100
34
+ when "x86_64"
35
+ Win32::Registry::KEY_READ | 0x200
36
+ else
37
+ Win32::Registry::KEY_READ
38
+ end
39
+ begin
40
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy', reg_type) do |policy|
41
+ policy["Enabled"] != 0
42
+ end
43
+ rescue Win32::Registry::Error
44
+ false
45
+ end
46
+ else
47
+ fips_path = "/proc/sys/crypto/fips_enabled"
48
+ File.exist?(fips_path) && File.read(fips_path).chomp != "0"
49
+ end
50
+ end
51
+ end
@@ -1,59 +1,59 @@
1
- #
2
- # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- module ChefConfig
19
-
20
- # Implements enough of Logger's API that we can use it in place of a real
21
- # logger for `ChefConfig.logger`
22
- class NullLogger
23
-
24
- def <<(_msg)
25
- end
26
-
27
- def add(_severity, _message = nil, _progname = nil)
28
- end
29
-
30
- def debug(_progname = nil, &block)
31
- end
32
-
33
- def info(_progname = nil, &block)
34
- end
35
-
36
- def warn(_progname = nil, &block)
37
- end
38
-
39
- def deprecation(_progname = nil, &block)
40
- end
41
-
42
- def error(_progname = nil, &block)
43
- end
44
-
45
- def fatal(_progname = nil, &block)
46
- end
47
-
48
- end
49
-
50
- @logger = NullLogger.new
51
-
52
- def self.logger=(new_logger)
53
- @logger = new_logger
54
- end
55
-
56
- def self.logger
57
- @logger
58
- end
59
- end
1
+ #
2
+ # Copyright:: Copyright 2015-2016, Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ module ChefConfig
19
+
20
+ # Implements enough of Logger's API that we can use it in place of a real
21
+ # logger for `ChefConfig.logger`
22
+ class NullLogger
23
+
24
+ def <<(_msg)
25
+ end
26
+
27
+ def add(_severity, _message = nil, _progname = nil)
28
+ end
29
+
30
+ def debug(_progname = nil, &block)
31
+ end
32
+
33
+ def info(_progname = nil, &block)
34
+ end
35
+
36
+ def warn(_progname = nil, &block)
37
+ end
38
+
39
+ def deprecation(_progname = nil, &block)
40
+ end
41
+
42
+ def error(_progname = nil, &block)
43
+ end
44
+
45
+ def fatal(_progname = nil, &block)
46
+ end
47
+
48
+ end
49
+
50
+ @logger = NullLogger.new
51
+
52
+ def self.logger=(new_logger)
53
+ @logger = new_logger
54
+ end
55
+
56
+ def self.logger
57
+ @logger
58
+ end
59
+ end
@@ -1,57 +1,57 @@
1
- #
2
- # Copyright:: Copyright 2017, Chef Software, Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "tomlrb"
19
- require "chef-config/path_helper"
20
-
21
- module ChefConfig
22
- module Mixin
23
- module Credentials
24
-
25
- def load_credentials(profile = nil)
26
- credentials_file = PathHelper.home(".chef", "credentials").freeze
27
- context_file = PathHelper.home(".chef", "context").freeze
28
-
29
- return unless File.file?(credentials_file)
30
-
31
- context = File.read(context_file) if File.file?(context_file)
32
-
33
- environment = ENV.fetch("CHEF_PROFILE", nil)
34
-
35
- profile = if !profile.nil?
36
- profile
37
- elsif !environment.nil?
38
- environment
39
- elsif !context.nil?
40
- context
41
- else
42
- "default"
43
- end
44
-
45
- config = Tomlrb.load_file(credentials_file)
46
- apply_credentials(config[profile], profile)
47
- rescue ChefConfig::ConfigurationError
48
- raise
49
- rescue => e
50
- # TOML's error messages are mostly rubbish, so we'll just give a generic one
51
- message = "Unable to parse Credentials file: #{credentials_file}\n"
52
- message << e.message
53
- raise ChefConfig::ConfigurationError, message
54
- end
55
- end
56
- end
57
- end
1
+ #
2
+ # Copyright:: Copyright 2017, Chef Software, Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "tomlrb"
19
+ require "chef-config/path_helper"
20
+
21
+ module ChefConfig
22
+ module Mixin
23
+ module Credentials
24
+
25
+ def load_credentials(profile = nil)
26
+ credentials_file = PathHelper.home(".chef", "credentials").freeze
27
+ context_file = PathHelper.home(".chef", "context").freeze
28
+
29
+ return unless File.file?(credentials_file)
30
+
31
+ context = File.read(context_file) if File.file?(context_file)
32
+
33
+ environment = ENV.fetch("CHEF_PROFILE", nil)
34
+
35
+ profile = if !profile.nil?
36
+ profile
37
+ elsif !environment.nil?
38
+ environment
39
+ elsif !context.nil?
40
+ context
41
+ else
42
+ "default"
43
+ end
44
+
45
+ config = Tomlrb.load_file(credentials_file)
46
+ apply_credentials(config[profile], profile)
47
+ rescue ChefConfig::ConfigurationError
48
+ raise
49
+ rescue => e
50
+ # TOML's error messages are mostly rubbish, so we'll just give a generic one
51
+ message = "Unable to parse Credentials file: #{credentials_file}\n"
52
+ message << e.message
53
+ raise ChefConfig::ConfigurationError, message
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,38 +1,38 @@
1
- #
2
- # Copyright:: Copyright 2016, Chef Software Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- require "chef-config/path_helper"
18
-
19
- module ChefConfig
20
- module Mixin
21
- module DotD
22
- def load_dot_d(path)
23
- dot_d_files =
24
- begin
25
- entries = Array.new
26
- entries << Dir.glob(File.join(
27
- ChefConfig::PathHelper.escape_glob_dir(path), "*.rb"))
28
- entries.flatten.select do |entry|
29
- File.file?(entry)
30
- end
31
- end
32
- dot_d_files.sort.map do |conf|
33
- apply_config(IO.read(conf), conf)
34
- end
35
- end
36
- end
37
- end
38
- end
1
+ #
2
+ # Copyright:: Copyright 2016, Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require "chef-config/path_helper"
18
+
19
+ module ChefConfig
20
+ module Mixin
21
+ module DotD
22
+ def load_dot_d(path)
23
+ dot_d_files =
24
+ begin
25
+ entries = Array.new
26
+ entries << Dir.glob(File.join(
27
+ ChefConfig::PathHelper.escape_glob_dir(path), "*.rb"))
28
+ entries.flatten.select do |entry|
29
+ File.file?(entry)
30
+ end
31
+ end
32
+ dot_d_files.sort.map do |conf|
33
+ apply_config(IO.read(conf), conf)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end