Class: Minfra::Cli::Project

Inherits:
Command show all
Defined in:
lib/minfra/cli/commands/project.rb,
lib/minfra/cli/commands/project/tag.rb,
lib/minfra/cli/commands/project/branch.rb

Defined Under Namespace

Classes: Branch, ProjectInfo, TagCli

Instance Method Summary collapse

Methods included from Logging

#debug, #deprecated, #error, #exit_error, #info, #warn

Methods included from Common

#run_cmd

Instance Method Details

#buildObject



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/minfra/cli/commands/project.rb', line 61

def build
  p = ProjectInfo.load(Pathname.pwd)
  target = options[:target]
  res=docker_build(target)
  exit(1) if res.error?

  return if options[:noload]

  debug("loading image into KIND's registry")
  Runner.run(%(kind load docker-image #{p.repo_name}:latest --name #{minfra_config.name}))
end

#exec(cmd = '/bin/bash') ⇒ Object



74
75
76
77
78
# File 'lib/minfra/cli/commands/project.rb', line 74

def exec(cmd = '/bin/bash')
  p = ProjectInfo.load(Pathname.pwd)
  run_pre_repo
  Kernel.exec(%(docker run -ti --rm  #{p.exec_params} -v #{p.app_dir}:/code #{p.repo_name}:latest #{cmd}))
end

#pushObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/minfra/cli/commands/project.rb', line 84

def push
  tag = options[:tag] || `date +%Y%m%d%H%M`
  p = ProjectInfo.load(Pathname.pwd)
  
  repo_name = if options[:registry]
                "#{options[:registry]}/#{p.repo_name}"
              else
                p.repo_name
              end

  docker_build(nil) if options[:build]
  #        Runner.run(%{docker push #{p.repo_name}})
  Runner.run(%(docker tag #{p.repo_name}:latest #{repo_name}:#{tag}))
  Runner.run(%(docker push #{repo_name}:#{tag}))
end

#testObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/minfra/cli/commands/project.rb', line 45

def test
  ARGV.delete('project') # ARGV is passed along to `rspec` call
  ARGV.delete('test')

  if File.exist?('./bin/run_tests')
    project = ProjectInfo.load(Pathname.pwd)
    debug "Using project specific ./bin/run_tests in #{project.name}"
    system('./bin/run_tests', out: $stdout, err: :out)
  else
    require_relative '../../generic/bin/run_tests'
  end
end