Class: Sambot::CLI

Inherits:
BaseCommand show all
Defined in:
lib/sambot/cli.rb

Instance Method Summary collapse

Methods inherited from Thor

command_help

Instance Method Details

#buildObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sambot/cli.rb', line 54

def build
  execute do
    cloud = nil
    cloud = 'local' if options[:local]
    cloud = 'google' if options[:google]
    cloud = 'rackspace' if options[:rackspace]
    unless cloud
      UI.error('Please select which environment this is building for using one of the following flags: --local, --rackspace or --google')
      exit
    end
    local_workflow = options[:docker] ? 'docker' : 'vagrant'
    Chef::Cookbook.build(Config.read, cloud, local_workflow)
  end
end

#bumpObject



45
46
47
# File 'lib/sambot/cli.rb', line 45

def bump
  execute { Chef::Cookbook.bump }
end

#cleanObject



9
10
11
# File 'lib/sambot/cli.rb', line 9

def clean
  execute { Chef::Cookbook.clean }
end

#createObject



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/sambot/cli.rb', line 70

def create
  execute do
    opts = {
      name: ask(' What is the name of this cookbook?'),
      type: ask(' What type of cookbook will this be?', limited_to: %w[wrapper role]),
      platforms: ask(' What operating system will this cookbook run on?', limited_to: %w[windows centos both]),
      description: ask(' What does this cookbook do?')
    }
    opts[:identifier] = ask(' What will be the unique machiner identifier for this role cookbook i.e. TCA (TeamCity Agent) or RMQ (RabbitMQ role)?') if opts[:type] == 'role'
    opts[:platforms] = opts[:platforms] == 'both' ? %w[centos windows] : [opts[:platforms]]
    Chef::Cookbook.create(Config.new(opts))
  end
end

#downObject



22
23
24
25
26
# File 'lib/sambot/cli.rb', line 22

def down
  execute do
    `docker-compose down`
  end
end

#populateObject



38
39
40
41
42
# File 'lib/sambot/cli.rb', line 38

def populate
  execute do
    populate_cmd
  end
end

#testObject



29
30
31
32
33
34
35
# File 'lib/sambot/cli.rb', line 29

def test
  execute do
    `docker-compose -p chef up -d`
    populate_cmd
    `docker-compose down`
  end
end

#upObject



14
15
16
17
18
19
# File 'lib/sambot/cli.rb', line 14

def up
  execute do
    `docker-compose -p chef up -d`
    populate_cmd
  end
end

#versionObject



85
86
87
# File 'lib/sambot/cli.rb', line 85

def version
  execute { puts "##teamcity[buildNumber '#{Config.read.version}']" }
end