Class: ChefApply::Config

Inherits:
Object
  • Object
show all
Extended by:
Mixlib::Config
Defined in:
lib/chef_apply/config.rb

Constant Summary collapse

WS_BASE_PATH =
File.join(Dir.home, ".chef-workstation/")
SUPPORTED_PROTOCOLS =
%w{ssh winrm}.freeze

Class Method Summary collapse

Class Method Details

.base_log_directoryObject



61
62
63
# File 'lib/chef_apply/config.rb', line 61

def base_log_directory
  File.dirname(log.location)
end

.custom_location(path) ⇒ Object



40
41
42
43
# File 'lib/chef_apply/config.rb', line 40

def custom_location(path)
  @custom_location = path
  raise "No config file located at #{path}" unless exist?
end

.default_locationObject



45
46
47
# File 'lib/chef_apply/config.rb', line 45

def default_location
  File.join(WS_BASE_PATH, "config.toml")
end

.error_output_pathObject

These paths are relative to the log output path, which is user-configurable.



66
67
68
# File 'lib/chef_apply/config.rb', line 66

def error_output_path
  File.join(base_log_directory, "errors.txt")
end

.exist?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/chef_apply/config.rb', line 88

def exist?
  File.exist? location
end

.initialize_mixlib_configObject

Ensure when we extend Mixlib::Config that we load up the workstation config since we will need that to converge later



36
37
38
# File 'lib/chef_apply/config.rb', line 36

def initialize_mixlib_config
  super
end

.loadObject



82
83
84
85
86
# File 'lib/chef_apply/config.rb', line 82

def load
  if exist?
    from_file(location)
  end
end

.locationObject



78
79
80
# File 'lib/chef_apply/config.rb', line 78

def location
  using_default_location? ? default_location : @custom_location
end

.resetObject



92
93
94
95
# File 'lib/chef_apply/config.rb', line 92

def reset
  @custom_location = nil
  super
end

.stack_trace_pathObject



70
71
72
# File 'lib/chef_apply/config.rb', line 70

def stack_trace_path
  File.join(base_log_directory, "stack-trace.log")
end

.telemetry_installation_identifier_fileObject



57
58
59
# File 'lib/chef_apply/config.rb', line 57

def telemetry_installation_identifier_file
  File.join(WS_BASE_PATH, "installation_id")
end

.telemetry_pathObject



49
50
51
# File 'lib/chef_apply/config.rb', line 49

def telemetry_path
  File.join(WS_BASE_PATH, "telemetry")
end

.telemetry_session_fileObject



53
54
55
# File 'lib/chef_apply/config.rb', line 53

def telemetry_session_file
  File.join(telemetry_path, "TELEMETRY_SESSION_ID")
end

.using_default_location?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/chef_apply/config.rb', line 74

def using_default_location?
  @custom_location.nil?
end