assemblyline-cli 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9dcfbbae517caaf76970b495b5ab797e7ce5babd
4
- data.tar.gz: fe34a5ea95213917751f9c8b82bcfd2fb71db8f6
3
+ metadata.gz: 39d8bced5c840f80dbc46c7cf0ab8ad3f1722ca1
4
+ data.tar.gz: 1a5bc80a82ba80108afbcc56ceda4b401cadca55
5
5
  SHA512:
6
- metadata.gz: a78f1bd13c15e254f361c1fcc0916cefe520e24723b22982c0852dd2aed17e951cc80131db342fd404604fc4ec0a382f17394f60411bd04ea34bc3668925aa78
7
- data.tar.gz: 3a102fdc46358298e28819cbcbe5ff9541224069a57ae3d68b783e3615807e8fde543e5ac99cc804a9df2c23cb909ddbed6540fdb99c1349a9d69617a87c48b9
6
+ metadata.gz: 6722385c85447f9ad28ffa4859d34f67c4648e1b547d25350dcdeccf569e2a97b755db044194b5043f769f15840c4bce22e4edd854fb10c20126a7380b15ae30
7
+ data.tar.gz: 7c335b259f7cf1a005cf7cf358f8d8337f95732a943bc0d8a88f9cd53ba9ee8243138946fa62230c00a3c7681c8f332ac7c23a6e503362872450ea3889f63ce5
@@ -1,3 +1,3 @@
1
1
  module Assemblyline
2
- CLI_VERSION = "0.0.13"
2
+ CLI_VERSION = "0.0.14"
3
3
  end
@@ -65,32 +65,6 @@ module Assemblyline
65
65
  "-v #{File.expand_path(options[:dev], Dir.pwd)}:/usr/src"
66
66
  end
67
67
 
68
- def env_flags
69
- env.map { |var, val| "-e #{var}=#{val}" }.join(" ")
70
- end
71
-
72
- def env
73
- {
74
- "SSH_KEY" => ssh_key,
75
- "DOCKERCFG" => dockercfg,
76
- "JSPM_GITHUB_TOKEN" => ENV["JSPM_GITHUB_TOKEN"],
77
- "CI" => ci?,
78
- "CI_MASTER" => ci_master?,
79
- }.reject { |_, v| v.nil? }
80
- end
81
-
82
- def ci?
83
- %w(CI CONTINUOUS_INTEGRATION TDDIUM TRAVIS BUILD_ID JENKINS_URL CIRCLECI).each do |var|
84
- return true if ENV[var]
85
- end
86
- nil
87
- end
88
-
89
- def ci_master?
90
- return true if ENV["GIT_BRANCH"] == "origin/master"
91
- return true if ENV["CI_MASTER"]
92
- end
93
-
94
68
  def bind_mounts
95
69
  "-v /tmp:/tmp -v /var/run/docker.sock:/var/run/docker.sock"
96
70
  end
@@ -99,24 +73,74 @@ module Assemblyline
99
73
  "quay.io/assemblyline/builder:latest"
100
74
  end
101
75
 
102
- def ssh_key
103
- key = File.read(key_path)
104
- fail "SSH private key not found" unless key
105
- key.dump
76
+ def env_flags
77
+ Env.new.to_flags
106
78
  end
107
79
 
108
- def dockercfg
109
- cfg = ENV["DOCKERCFG"]
110
- cfg ||= File.read(File.join(Dir.home, ".dockercfg"))
111
- cfg.gsub("\n", "").gsub("\t", "").dump
112
- end
80
+ class Env
81
+ def to_flags
82
+ to_hash.map { |var, val| "-e #{var}=#{val}" }.join(" ")
83
+ end
113
84
 
114
- def key_path
115
- %w(id_rsa id_dsa).map { |private_key| ssh_key_path(private_key) }.detect { |path| File.exist? path }
116
- end
85
+ def to_hash
86
+ {
87
+ "SSH_KEY" => ssh_key,
88
+ "DOCKERCFG" => dockercfg,
89
+ "JSPM_GITHUB_TOKEN" => ENV["JSPM_GITHUB_TOKEN"],
90
+ "CI" => ci?,
91
+ "CI_MASTER" => ci_master?,
92
+ "BUILD_URL" => build_url,
93
+ "GIT_URL" => git_url,
94
+ "GITHUB_ACCESS_TOKEN" => ENV["GITHUB_ACCESS_TOKEN"],
95
+ }.reject { |_, v| v.nil? }
96
+ end
97
+
98
+ private
117
99
 
118
- def ssh_key_path(key)
119
- File.join(ENV["HOME"], ".ssh/#{key}")
100
+ def ssh_key
101
+ key = File.read(key_path)
102
+ fail "SSH private key not found" unless key
103
+ key.dump
104
+ end
105
+
106
+ def key_path
107
+ %w(id_rsa id_dsa).map { |private_key| ssh_key_path(private_key) }.detect { |path| File.exist? path }
108
+ end
109
+
110
+ def ssh_key_path(key)
111
+ File.join(ENV["HOME"], ".ssh/#{key}")
112
+ end
113
+
114
+ def dockercfg
115
+ cfg = ENV["DOCKERCFG"]
116
+ [".dockercfg", ".docker/config.json"].each do |cfg_path|
117
+ path = File.join(Dir.home, cfg_path)
118
+ next unless File.exist? path
119
+ cfg ||= File.read(path)
120
+ end
121
+ cfg.gsub("\n", "").gsub("\t", "").dump
122
+ end
123
+
124
+ def ci?
125
+ %w(CI CONTINUOUS_INTEGRATION TDDIUM TRAVIS BUILD_ID JENKINS_URL CIRCLECI).each do |var|
126
+ return true if ENV[var]
127
+ end
128
+ nil
129
+ end
130
+
131
+ def ci_master?
132
+ return true if ENV["GIT_BRANCH"] == "origin/master"
133
+ return true if ENV["CI_MASTER"]
134
+ end
135
+
136
+ def build_url
137
+ ENV["BUILD_URL"]
138
+ end
139
+
140
+ def git_url
141
+ u = `git remote get-url origin`.chomp
142
+ u.empty? ? nil : u
143
+ end
120
144
  end
121
145
  end
122
146
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assemblyline-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-08 00:00:00.000000000 Z
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.4.5.1
106
+ rubygems_version: 2.2.5
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: A super-lightweight wrapper to start assemblyline tasks