Sha256: 8eaf5cb019b2744690e66a5365642ac6f83368d61ed804f7904f5acabbef5469
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
require 'yaml' module Shell class Runner def error message UI.error message exit 1 end def launch command = ARGV.empty? ? "sh" : ARGV.join(" ") file = "docker-compose.dev.yml" if !File.exist? file error "Could not find file '#{file}'." end manifest = YAML.load File.read file services = manifest["services"].to_a if services.length != 1 error "Currently sct only supports a single service declaration in '#{file}'. Contact the infra guild if you consider this a limitation." end service, service_spec = services.first container = service_spec["container_name"] project = `docker container inspect --format '{{index .Config.Labels "com.docker.compose.project"}}' #{container}`.chomp if project == "spend-cloud" print "This container was not started with 'sct dev'. Are you sure you want to continue? [y/N] ".red answer = $stdin.readline.chomp.downcase if answer != "y" exit end end system "docker exec -it --user $(id -u):$(id -g) #{container} #{command}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sct-1.0.4 | shell/lib/shell/runner.rb |
sct-1.0.2 | shell/lib/shell/runner.rb |
sct-1.0.1 | shell/lib/shell/runner.rb |