fig2coreos 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/fig2coreos +9 -5
  3. data/lib/fig2coreos.rb +19 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 884412e8eca038c81d5834eacea5ea641290d30d
4
- data.tar.gz: 6b2d8839f718e9827343290acd61683c8037812f
3
+ metadata.gz: 944247b3ed3f3f5e0dd8792cdb5e3f944b610dd9
4
+ data.tar.gz: dff72cbe3a9ced91a1e81d5c4f8dd8afad59afb9
5
5
  SHA512:
6
- metadata.gz: a483f79d273b744a4d880933c5e0d4fb8fd3167165e14f8b402a59a8ee364951765a38abeb53292f7a1a1448ad901ffc36b9f5b81810939966f9ce257a412d30
7
- data.tar.gz: 586350f3c608138d5fa4abe763f8d0abf9d490c27ae3ea30f22e49e89ab33e50c944dec55e1c80ebbcdd49189ca141fe36e1281ae3eb868aff37a4e3d9c59338
6
+ metadata.gz: b510c97c08d9b97fc925df10b1e31d64d3f39100ae7e98170fbd9fd21cfb8108c4f73c351a7e9917825b80e7060882796b775a85dc4c192ac1c5d930c71ea350
7
+ data.tar.gz: bd08a816eac64b32db8fb087dc7b9921dc4f74985a90801ef6c16c2f9fccd59bcb9e294a38fc075556d9e76039767c95005625d1c12ab7a7c81c1009bb6f2aba
data/bin/fig2coreos CHANGED
@@ -4,15 +4,21 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "fig2cor
4
4
 
5
5
  FIG2COREOS_BANNER = "Usage: fig2coreos [options] APP_NAME FIG_YAML OUTPUT_DIRECTORY"
6
6
 
7
- options = {type: "vagrant"}
7
+ options = {type: "fleet"}
8
+
8
9
  OptionParser.new do |opts|
9
10
  opts.banner = FIG2COREOS_BANNER
10
11
 
11
- opts.on("-t", "--type TYPE", "Output type: vagrant (default), systemd (just the systemd service files)") do |type|
12
+ opts.on("-t", "--type TYPE", "Output type: fllet (default) or vagrant (generate a Vagrantfile)") do |type|
12
13
  options[:type] = type
13
14
  end
14
15
  end.parse!
15
16
 
17
+ if ARGV[0].to_s.include?("-t")
18
+ ARGV.shift
19
+ ARGV.shift
20
+ end
21
+
16
22
  if ARGV[0].nil?
17
23
  puts "[ERROR] APP_NAME required"
18
24
  puts FIG2COREOS_BANNER
@@ -33,9 +39,7 @@ if !ARGV[2] || !File.directory?(File.expand_path(ARGV[2].to_s))
33
39
  end
34
40
  end
35
41
 
36
- vagrant_version = `vagrant --version`.split.last
37
-
38
- if options[:type] == "vagrant" && Gem::Version.new(vagrant_version) < Gem::Version.new("1.4.3")
42
+ if options[:type] == "vagrant" && Gem::Version.new(`vagrant --version`.split.last) < Gem::Version.new("1.4.3")
39
43
  puts "[ERROR] Your version of vagrant (#{vagrant_version}) is out of date, please upgrade to at least 1.4.3 at http://www.vagrantup.com/downloads.html or change the --type"
40
44
  exit -1
41
45
  end
data/lib/fig2coreos.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
1
4
  require 'yaml'
2
5
  require 'fileutils'
3
6
 
@@ -10,17 +13,20 @@ class Fig2CoreOS
10
13
  @app_name = app_name
11
14
  @fig = YAML.load_file(fig_file.to_s)
12
15
  @output_dir = File.expand_path(output_dir.to_s)
16
+ @vagrant = (options[:type] == "vagrant")
13
17
 
14
18
  # clean and setup directory structure
19
+ FileUtils.rm_rf(Dir[File.join(@output_dir, "*.service")])
15
20
  FileUtils.rm_rf(File.join(@output_dir, "media"))
16
21
  FileUtils.rm_rf(File.join(@output_dir, "setup-coreos.sh"))
17
22
  FileUtils.rm_rf(File.join(@output_dir, "Vagrantfile"))
18
- FileUtils.mkdir_p(File.join(@output_dir, "media", "state", "units"))
19
-
23
+
24
+ if @vagrant
25
+ FileUtils.mkdir_p(File.join(@output_dir, "media", "state", "units"))
26
+ create_vagrant_file
27
+ end
28
+
20
29
  create_service_files
21
-
22
- create_vagrant_file if options[:type] == "vagrant"
23
-
24
30
  exit 0
25
31
  end
26
32
 
@@ -40,7 +46,13 @@ class Fig2CoreOS
40
46
  "docker"
41
47
  end
42
48
 
43
- File.open(File.join(@output_dir, "media", "state", "units", "#{service_name}.1.service"), "w") do |file|
49
+ if @vagrant
50
+ base_path = File.join(@output_dir, "media", "state", "units")
51
+ else
52
+ base_path = @output_dir
53
+ end
54
+
55
+ File.open(File.join(base_path, "#{service_name}.1.service") , "w") do |file|
44
56
  file << <<-eof
45
57
  [Unit]
46
58
  Description=Run #{service_name}_1
@@ -61,7 +73,7 @@ WantedBy=local.target
61
73
  eof
62
74
  end
63
75
 
64
- File.open(File.join(@output_dir, "media", "state", "units", "#{service_name}-discovery.1.service"), "w") do |file|
76
+ File.open(File.join(base_path, "#{service_name}-discovery.1.service"), "w") do |file|
65
77
  file << <<-eof
66
78
  [Unit]
67
79
  Description=Announce #{service_name}_1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig2coreos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson