sbuild 0.0.1
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 +7 -0
- data/lib/sbuild.rb +72 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef183006d458d0bce38044aca73d8dd3d04edc0f
|
4
|
+
data.tar.gz: 402813f3625698fb884f4bc13da5fcce1a29bc37
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9b46124d107ef5ad8e16b94697b89ea39aa2dc881dfc9452afc01bee60d976526cadb330570676e9451de01ebbfa31d2a7b6e1285c835f7e18284a848433fe1
|
7
|
+
data.tar.gz: 74d40a89f4a96469e92bf682f62d80d695f661bf6acc4cf6bb01b66dc160c4f40b3f063d31c976c2b926ed0bc33bbbc5b24102630190e9e395b54e11c1dbb11a
|
data/lib/sbuild.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
def self.safe_retry(cmd, tries=3)
|
4
|
+
begin
|
5
|
+
status, output = system_safe(cmd)
|
6
|
+
rescue
|
7
|
+
if (tries -= 1) > 0
|
8
|
+
sleep 5
|
9
|
+
retry unless (tries).zero?
|
10
|
+
else
|
11
|
+
raise "Build failed"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
return status
|
16
|
+
|
17
|
+
end
|
18
|
+
def self.system_safe(cmd)
|
19
|
+
cmd_sanitized = get_sanitized_cmd(cmd)
|
20
|
+
puts "Executing command: #{cmd_sanitized}"
|
21
|
+
|
22
|
+
stdout, stderr, status = Open3.capture3(cmd)
|
23
|
+
|
24
|
+
puts "STDOUT:\n#{stdout}"
|
25
|
+
puts "STDERR:\n#{stderr}"
|
26
|
+
|
27
|
+
if not status.success?
|
28
|
+
raise "Build failed"
|
29
|
+
end
|
30
|
+
|
31
|
+
return [status.success?, stdout]
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.get_secret(key, subkey)
|
36
|
+
cmd = "vault read -field=#{subkey} #{key}"
|
37
|
+
status, secret = system_safe(cmd, log_identifier, "Get secret failed", true, "ERROR", false)
|
38
|
+
secret = secret.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.revoke_lease(lease_id)
|
42
|
+
cmd = "vault revoke #{lease_id}"
|
43
|
+
safe_retry(cmd)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.get_sanitized_cmd(cmd)
|
47
|
+
secret_fields = ["AWS_ACCESS_KEY_ID",
|
48
|
+
"AWS_SECRET_ACCESS_KEY",
|
49
|
+
"password",
|
50
|
+
"aws_access_key_id",
|
51
|
+
"aws_secret_access_key",
|
52
|
+
"aws_access_key",
|
53
|
+
"aws_secret_key",
|
54
|
+
"access_key",
|
55
|
+
"secret_key",
|
56
|
+
"account_access_key",
|
57
|
+
"account_secret_key",
|
58
|
+
"aws.accessKeyId",
|
59
|
+
"aws.secretKey",
|
60
|
+
"jwtsecret",
|
61
|
+
"master_access_key",
|
62
|
+
"master_secret_key",
|
63
|
+
"github_password"]
|
64
|
+
|
65
|
+
cmd = cmd.gsub(/\s+/m, ' ').strip.split(" ")
|
66
|
+
replace = cmd.grep(Regexp.union(secret_fields))
|
67
|
+
unless replace.empty?
|
68
|
+
replace = Set.new replace
|
69
|
+
cmd.collect! {|e| (replace.include? e) ? '<secret>': e}
|
70
|
+
end
|
71
|
+
cmd = cmd.join(' ')
|
72
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sbuild
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Antenesse
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Common functions for build
|
14
|
+
email: chrisantenesse@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/sbuild.rb
|
20
|
+
homepage: http://rubygems.org/gems/socotra
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.8
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Build library
|
44
|
+
test_files: []
|
45
|
+
has_rdoc:
|