Module: Gitchefsync::Configuration

Included in:
Gitchefsync
Defined in:
lib/gitchefsync/config.rb

Constant Summary collapse

REL_BRANCH =
'master'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.logObject



91
92
93
94
# File 'lib/gitchefsync/config.rb', line 91

def self.log 
  Gitchefsync.logger()
  
end

Instance Method Details

#configurationObject



96
97
98
# File 'lib/gitchefsync/config.rb', line 96

def configuration
  @config
end

#configure(options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gitchefsync/config.rb', line 36

def configure(options)
  
  @options = options
  config = options[:config]
  @git_bin = config['git']
  @berks = config['berks']
  @knife = config['knife']
  @git_local = options[:git_local]
  @token =  options[:private_token]
  @stage_dir = config['stage_dir']
  @audit_dir = config['stage_dir'] + "/audit"
  config['audit_dir'] = @audit_dir
  @rel_branch = config['release_branch']
  @rel_branch ||= 'master'
  @stage_cb_dir = options[:stage_cookbook_dir]
  @stage_cb_dir ||= '/tmp/cookbooks'
  @berks_upload = false
  @audit_keep_trim = config['audit_keep_trim'] 
  @audit_keep_trim ||= 20
    
  #backward compatibility for "sync_local" attribute
  if config['sync_local'].is_a? String 
    if config['sync_local'] == "true"
      config['sync_local'] = true
      config[:sync_local] = true
    else
      config['sync_local'] = false
      config[:sync_local] = false
    end
  end
  options[:syslog] ?
    @log = Gitchefsync::Log::SysLogger.new('gitchefsync') :
    @log = Logger.new(STDOUT)
  #json based configuration
  @config = config
 
end

#initialize(opts) ⇒ Object



31
32
33
34
# File 'lib/gitchefsync/config.rb', line 31

def initialize(opts)
  @git_bin = 'git'

end

#loggerObject



87
88
89
# File 'lib/gitchefsync/config.rb', line 87

def logger
  @log
end

#optionsObject



100
101
102
# File 'lib/gitchefsync/config.rb', line 100

def options
  @options
end

#parseAndConfigure(args) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/gitchefsync/config.rb', line 74

def parseAndConfigure(args)
  include Parser

  $args = args.clone
  $opts = Parser.parseOpts args
  configure $opts
  
  #instantiate audit
  #@audit = Audit.new(@config['stage_dir'] )
     
  return $opts
end