Class: LinchpinCLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/linchpin/cli.rb

Instance Method Summary collapse

Instance Method Details

#buildObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/linchpin/cli.rb', line 12

def build
  app_type = discover_type(Dir.pwd)
  app_name = discover_appname
  case app_type
  when 'dotnet'
    puts "Building dotnet app #{app_name}"
    build_dotnet(app_name, get_version_hash)
  else
    raise "Error: Could not build app type #{app_type}."
  end
end

#deployObject



35
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
# File 'lib/linchpin/cli.rb', line 35

def deploy
  app_name = discover_appname
  short_app_name = discover_short_appname
  app_type = discover_type(Dir.pwd)
  version = get_version_hash

  temp_dir = Dir.mktmpdir
  command_output = false
  begin
    deploy_templates = Dir[File.join(File.join(File.join(File.dirname(File.expand_path(__FILE__)), 'k8s'), app_type),"*.erb")]
    deploy_templates.each do |filename|
      "LOL #{filename}"
      FileUtils.cp(filename, "#{temp_dir}")
    end
    FileUtils.cp(File.join(File.join(File.join(Dir.pwd, 'config'), "deploy"), "secrets.ejson"), "#{temp_dir}")

    expose = configs.fetch('expose', '')
    escaped_command = Shellwords.escape("KUBECONFIG=~/.kube/config REVISION=#{version} kubernetes-deploy #{short_app_name} cicd-example --template-dir=#{temp_dir} --bindings=full_name=#{app_name},app_name=#{short_app_name},expose=#{expose}")
    command_output = system({}, "bash -c #{escaped_command}")

  ensure
    # remove the directory.
    FileUtils.remove_entry temp_dir
  end

  exit(1) unless command_output
end

#pushObject



25
26
27
28
29
30
31
# File 'lib/linchpin/cli.rb', line 25

def push
  app_name = discover_appname
  version = get_version_hash
  escaped_command = Shellwords.escape("docker push dataconstruct/#{app_name}:#{version}")
  command_output = system({}, "bash -c #{escaped_command}")
  exit(1) unless command_output
end