cide 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eef0027f8b949b1a7a4ee2e7983c2369c49cf10b
4
- data.tar.gz: 3de799bf632c0bce40f2241398a9657adde1c4b1
3
+ metadata.gz: 30a2f95075fe4906e536539c360fddaffdf271ba
4
+ data.tar.gz: f0f615e78197b0a54391b3812b74aff2c26e8a32
5
5
  SHA512:
6
- metadata.gz: 50e1f087ea456126e4016d12b8eef77f7b038d3bc7dba071767169ed30c2ff6f4253947f2ba9c0c98e01c7d60ec417d513136bcf95b81fb03a11494c16eea184
7
- data.tar.gz: 47ccc6598cfe4b13070c9850529f6e40d8c3108d2ac140726f06466cde2e8c83bbb08efd39fb6ddac55b84485dec377d99e0496e1dd1efa160254e5e006f6083
6
+ metadata.gz: ee97b84d524086f7a8b7adc129811696f95ab1401c1b06940d6f5aef3bb1d475ac4219203ddc96caa5df7b5d325838fc1f1be1b019d3a31c311d14cdfd8b14e7
7
+ data.tar.gz: c487bcdd7b5650ca4c31f2fdc3876156adb82af50fa01473b0954216b8788cc07a9a4e44d94805b8bdf88ebbd55203f3d629b65c6245cda37277df1cae474b61
data/.rubocop.yml CHANGED
@@ -24,3 +24,10 @@ Style/SpecialGlobalVars:
24
24
  # Prefering the short style
25
25
  Style/PerlBackrefs:
26
26
  Enabled: false
27
+
28
+ # Offense count: 28
29
+ Metrics/CyclomaticComplexity:
30
+ Max: 15
31
+
32
+ Metrics/PerceivedComplexity:
33
+ Max: 20
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 0.0.8 / 2014-12-18
3
+ ==================
4
+
5
+ * Allow to import SSH keys into the container
6
+
2
7
  0.0.7 / 2014-12-04
3
8
  ==================
4
9
 
data/cide.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'cide'
5
- s.version = '0.0.7'
5
+ s.version = '0.0.8'
6
6
  s.authors = ['zimbatm']
7
7
  s.email = ['zimbatm@zimbatm.com']
8
8
  s.summary = 'CI docker runner'
data/lib/cide.rb CHANGED
@@ -12,11 +12,17 @@ require 'thor'
12
12
  # The juicy bits are defined in CIDE::CLI
13
13
  module CIDE
14
14
  DOCKERFILE = 'Dockerfile'
15
- TEMPLATE = File.read(File.expand_path('../cide_template.erb', __FILE__))
15
+ SSH_CONFIG_FILE = 'ssh_config'
16
+ TEMP_SSH_KEY = 'id_rsa.tmp'
17
+ DOCKERFILE_TEMPLATE = File.read(
18
+ File.expand_path('../cide_template.erb', __FILE__),
19
+ )
20
+ SSH_CONFIG_CONTENTS = File.read(File.expand_path('../ssh_config', __FILE__))
16
21
  CONFIG_FILE = '.cide.yml'
17
22
 
18
23
  CIDE_DIR = '/cide'
19
24
  CIDE_SRC_DIR = File.join(CIDE_DIR, '/src')
25
+ CIDE_SSH_DIR = File.join(CIDE_DIR, '/.ssh')
20
26
 
21
27
  module_function
22
28
 
@@ -39,6 +45,7 @@ module CIDE
39
45
  export_dir: './artifacts',
40
46
  host_export_dir: nil,
41
47
  run: 'script/ci',
48
+ ssh_key: nil,
42
49
  ) do
43
50
 
44
51
  alias_method :image=, :from=
@@ -49,7 +56,7 @@ module CIDE
49
56
  end
50
57
 
51
58
  def to_dockerfile
52
- ERB.new(TEMPLATE, nil, '<>-').result(binding)
59
+ ERB.new(DOCKERFILE_TEMPLATE, nil, '<>-').result(binding)
53
60
  end
54
61
 
55
62
  def merge!(opts = {})
@@ -98,6 +105,11 @@ module CIDE
98
105
  aliases: ['r'],
99
106
  default: nil
100
107
 
108
+ method_option 'ssh_key',
109
+ desc: 'The ssh key to put into the docker image',
110
+ aliases: ['s'],
111
+ default: nil
112
+
101
113
  def build
102
114
  setup_docker
103
115
 
@@ -110,6 +122,18 @@ module CIDE
110
122
 
111
123
  tag = "cide/#{config.name}"
112
124
 
125
+ if config.ssh_key && File.exist?(config.ssh_key)
126
+ say_status :SSHkey, 'Creating temp ssh key file within directory'
127
+ ssh_key_contents = File.read(config.ssh_key)
128
+ File.write(TEMP_SSH_KEY, ssh_key_contents)
129
+ config.ssh_key = TEMP_SSH_KEY
130
+ at_exit do
131
+ File.unlink(TEMP_SSH_KEY)
132
+ end
133
+ else
134
+ say_status :SSHKey, 'No SSH key specified'
135
+ end
136
+
113
137
  say_status :config, config.to_h
114
138
 
115
139
  # FIXME: Move Dockerfile out of the way if it exists
@@ -123,6 +147,16 @@ module CIDE
123
147
  say_status :Dockerfile, 'Using existing Dockerfile'
124
148
  end
125
149
 
150
+ if !File.exist?(SSH_CONFIG_FILE)
151
+ say_status :ssh_config, 'Creating temporary ssh config'
152
+ File.write(SSH_CONFIG_FILE, SSH_CONFIG_CONTENTS)
153
+ at_exit do
154
+ File.unlink(SSH_CONFIG_FILE)
155
+ end
156
+ else
157
+ say_status :ssh_config, 'Using existing ssh config'
158
+ end
159
+
126
160
  docker :build, '-t', tag, '.'
127
161
 
128
162
  return unless config.export
@@ -13,6 +13,17 @@ RUN <%= cmd %>
13
13
  ENV HOME <%= CIDE_DIR %>
14
14
  WORKDIR <%= CIDE_SRC_DIR %>
15
15
 
16
+ # SSH config
17
+ <% if ssh_key -%>
18
+ ADD ssh_config <%= File.expand_path('config', CIDE_SSH_DIR) %>
19
+ RUN chmod 400 <%= File.expand_path('config', CIDE_SSH_DIR) %>
20
+
21
+ ADD <%= ssh_key %> <%= File.expand_path('id_rsa', CIDE_SSH_DIR) %>
22
+ RUN chmod 400 <%= File.expand_path('id_rsa', CIDE_SSH_DIR) %>
23
+ RUN chmod 755 <%= CIDE_SSH_DIR %>
24
+ RUN chown -R cide:cide <%= CIDE_DIR %>
25
+ <% end %>
26
+
16
27
  # Before
17
28
 
18
29
  <% if before['run'] -%>
data/lib/ssh_config ADDED
@@ -0,0 +1,3 @@
1
+
2
+ StrictHostKeyChecking no
3
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - zimbatm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -76,6 +76,7 @@ files:
76
76
  - cide.gemspec
77
77
  - lib/cide.rb
78
78
  - lib/cide_template.erb
79
+ - lib/ssh_config
79
80
  homepage: https://github.com/zimbatm/cide
80
81
  licenses:
81
82
  - MIT