iapi-idlc-sdk-core 1.0.16 → 1.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +13 -0
- data/.yardopts +1 -0
- data/Gemfile +6 -0
- data/Jenkinsfile +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/iapi-idlc-sdk-core.gemspec +38 -0
- data/lib/iapi-idlc-sdk-core/helpers.rb +36 -0
- data/lib/iapi-idlc-sdk-core/restclient.rb +185 -0
- data/lib/iapi-idlc-sdk-core/utility.rb +44 -0
- data/lib/iapi-idlc-sdk-core/version.rb +4 -0
- data/lib/iapi-idlc-sdk-core/workspace.rb +46 -0
- data/lib/iapi-idlc-sdk-core/zip.rb +40 -0
- data/lib/iapi-idlc-sdk-core.rb +62 -0
- metadata +30 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e71e2f2d5dcb7376ec5628743a55a90482f0f9e72ba94b04ac5a20e5859f951
|
4
|
+
data.tar.gz: 7850178711a194be76746cbf5e488663a2e53eca4c083d474a43ae77981d092a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d11c1a53678682ee7ef6e93d69e4ea4b7b7e074905d0e853b64692c6171a910e683ac87e2da5bb32ccf0bde7a86c62426ab3aa44c2c9dec647b08702a566bd
|
7
|
+
data.tar.gz: 01b70e400551a37b36471f98ad2428caec807a03fa813d7ff543d5879e28e5a22b6d45f1b126969feacd54878b8649fb5535cbdfefa70cd8d0789565a1517371
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.1
|
5
|
+
before_install: gem install bundler -v 1.15.4
|
6
|
+
deploy:
|
7
|
+
provider: rubygems
|
8
|
+
api_key:
|
9
|
+
secure: IGztrc71SZ6X3uMHT+RkrqRaHGihyq8Ikt80FfQEfC7CEsIJQtScOr8+Edqs0GRJfDBhV2WikUdUvMVvq9hZeiO0bJf4QMVTbh5cUIq5A+IP2T6nDwQZvlTO03vxMGunnCaF9MDqSTtA39VtIQJUlV5S3J2pv8oShBGB9CMffaB+LdzTw49fdKBc1TfBo6du8X1ELJPxx2ZmT0+0XAqxD0+lJ1x08T2XOfb2/iLmD/Yhg5+EPOuDY2ePO+PqSTJuiyKsFLxxKgjI1eVRwfvqKeSuFeFMxrj+CqA2+9aF8M28J4FIXac3U5obJYgPxmZznmqlPlh8fLamBZ2yZ/AVRfJIwSeYgAzTbo8te+bOpwwAk/+lMOzxkz82yK3bf2R9cnKY09lH2Uht3hkBWE5IUijfl4j34mvQl7JJJP6ZQHGg1v2pcAgXRlRQw60M2v4v8XFxOhdO39lMymyRXol1Raq3N4eY8AcxPa/GVPfR2/H4u9JDA1dUqsYxTO3LcfIZjs68q801Z3ddxLhOECOH0b8VfvCTibnVUOj8XpP/E0VUoXyjQ8mPancblfsy5BL9c8HB9Vim1ZcdmZ3FKbJ2Ud/dVxQmbMRW9doVL7dZMDbfxIuPEVfqTsssGucJByNeSXJzc+fMej5HCrCTpuOztOIgsT/JbxJQ6/e0IVL5F18=
|
10
|
+
gem: idlc-sdk-core
|
11
|
+
on:
|
12
|
+
tags: true
|
13
|
+
repo: NathanTCz/idlc-sdk-core
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-m markdown
|
data/Gemfile
ADDED
data/Jenkinsfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
pipeline {
|
2
|
+
agent any
|
3
|
+
options {
|
4
|
+
buildDiscarder logRotator(daysToKeepStr: '5', numToKeepStr: '10')
|
5
|
+
}
|
6
|
+
stages {
|
7
|
+
stage('Ruby Gem Push') {
|
8
|
+
environment {
|
9
|
+
GEM_HOST_API_KEY = credentials('rubygems-apikey')
|
10
|
+
}
|
11
|
+
steps {
|
12
|
+
sh '''
|
13
|
+
DOCKER_CMD="docker run --rm -v $PWD:/opt -w /opt -e GEM_HOST_API_KEY -e BUILD_NUMBER -u 999 ruby:3.0"
|
14
|
+
$DOCKER_CMD gem build iapi-idlc-sdk-core.gemspec -o iapi-idlc-sdk-core.gem
|
15
|
+
$DOCKER_CMD gem push iapi-idlc-sdk-core.gem
|
16
|
+
'''
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nathan Cazell
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Idlc::Sdk::Core
|
2
|
+
|
3
|
+
Provides core libraries for idlc-sdk. This gem is part of the IDLC SDK
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'iapi-idlc-sdk-core'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install iapi-idlc-sdk-core
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
require 'iapi-idlc-sdk-core'
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "idlc-sdk-core"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'iapi-idlc-sdk-core/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'iapi-idlc-sdk-core'
|
9
|
+
spec.version = Idlc::VERSION
|
10
|
+
spec.authors = ["Nathan Cazell", "Michael McHolm"]
|
11
|
+
spec.email = ["techsupport@imageapi.com"]
|
12
|
+
|
13
|
+
spec.summary = 'IDLC SDK for AWS resources - Core'
|
14
|
+
spec.description = 'Provides core libraries for idlc-sdk. This gem is part of the IDLC SDK'
|
15
|
+
spec.homepage = 'https://bitbucket.org/imageapi/iapi-idlc-sdk-core'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.metadata = {
|
19
|
+
'source_code_uri' => 'https://bitbucket.org/imageapi/iapi-idlc-sdk-core'
|
20
|
+
}
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
f.match(%r{^(test|spec|features)/})
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 2'
|
29
|
+
spec.add_development_dependency 'pry'
|
30
|
+
spec.add_development_dependency 'rake', '>= 12.3.3'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
32
|
+
spec.add_development_dependency 'rubocop', '0.48.1'
|
33
|
+
spec.add_development_dependency 'yard'
|
34
|
+
|
35
|
+
spec.add_runtime_dependency 'aws-sdk-lambda', '1.111.0'
|
36
|
+
spec.add_runtime_dependency 'aws-sigv4', '1.6.1'
|
37
|
+
spec.add_runtime_dependency 'rubyzip', '1.3.0'
|
38
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Idlc
|
2
|
+
module Helpers
|
3
|
+
module_function
|
4
|
+
|
5
|
+
#
|
6
|
+
# Runs given commands using mixlib-shellout
|
7
|
+
#
|
8
|
+
def system_command(*command_args)
|
9
|
+
cmd = Mixlib::ShellOut.new(*command_args)
|
10
|
+
cmd.run_command
|
11
|
+
cmd
|
12
|
+
end
|
13
|
+
|
14
|
+
def err(message)
|
15
|
+
stderr.print("#{message}\n")
|
16
|
+
end
|
17
|
+
|
18
|
+
def msg(message)
|
19
|
+
stdout.print("#{message}\n")
|
20
|
+
stdout.flush
|
21
|
+
end
|
22
|
+
|
23
|
+
def debug(message)
|
24
|
+
stdout.print("#{message}\n") if ENV['DEBUG']
|
25
|
+
stdout.flush
|
26
|
+
end
|
27
|
+
|
28
|
+
def stdout
|
29
|
+
$stdout
|
30
|
+
end
|
31
|
+
|
32
|
+
def stderr
|
33
|
+
$stderr
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'aws-sigv4'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
require 'aws-sdk-lambda'
|
5
|
+
|
6
|
+
# Idlc::SERVICES object is loaded from core lib
|
7
|
+
|
8
|
+
# default region
|
9
|
+
ENV['AWS_REGION'] = 'us-east-1' unless ENV['AWS_REGION']
|
10
|
+
|
11
|
+
module Idlc
|
12
|
+
class AWSLambdaProxy
|
13
|
+
include Helpers
|
14
|
+
|
15
|
+
def fetch(request)
|
16
|
+
client = Aws::Lambda::Client.new()
|
17
|
+
region = ENV['AWS_REGION']
|
18
|
+
backend_services = Idlc::SERVICES[region]
|
19
|
+
|
20
|
+
request[:function] = "#{request[:service]}-" + backend_services[request[:service]]['stage'] + "-#{request[:lambda]}"
|
21
|
+
request[:httpMethod] = request[:method]
|
22
|
+
|
23
|
+
retries = 0
|
24
|
+
max_retries = 5
|
25
|
+
sleep_time = 5
|
26
|
+
exp_backoff = 2
|
27
|
+
result = nil
|
28
|
+
|
29
|
+
loop do
|
30
|
+
begin
|
31
|
+
resp = client.invoke({
|
32
|
+
function_name: "service-lambda-proxy",
|
33
|
+
invocation_type: "RequestResponse",
|
34
|
+
log_type: "None",
|
35
|
+
payload: request.to_json,
|
36
|
+
})
|
37
|
+
|
38
|
+
result = JSON.parse(JSON.parse(JSON.parse(resp.payload.string)['Payload'])['body'])
|
39
|
+
break
|
40
|
+
rescue Exception => e
|
41
|
+
break if retries >= max_retries
|
42
|
+
retries += 1
|
43
|
+
msg("RequestFailed: #{e} - Waiting #{sleep_time}s then retrying... (#{retries} of #{max_retries})")
|
44
|
+
|
45
|
+
|
46
|
+
sleep sleep_time
|
47
|
+
sleep_time *= exp_backoff # use an exponential backoff when retrying requests
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
result
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class AWSRestClient
|
56
|
+
include Helpers
|
57
|
+
|
58
|
+
def initialize(credentials= {
|
59
|
+
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
60
|
+
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
|
61
|
+
session_token: ENV['AWS_SESSION_TOKEN']
|
62
|
+
},
|
63
|
+
region=ENV['AWS_REGION']
|
64
|
+
)
|
65
|
+
@service_name = 'execute-api'
|
66
|
+
@credentials = credentials
|
67
|
+
@region = region
|
68
|
+
@backend_services = Idlc::SERVICES[region]
|
69
|
+
end
|
70
|
+
|
71
|
+
def fetch(request)
|
72
|
+
request = JSON.parse(request)
|
73
|
+
|
74
|
+
endpoint = 'https://' + @backend_services[request['service']]['endpoint'] + '/' + @backend_services[request['service']]['stage']
|
75
|
+
|
76
|
+
body = ''
|
77
|
+
body = request['body'].to_json if request['body']
|
78
|
+
|
79
|
+
retries = 0
|
80
|
+
max_retries = 5
|
81
|
+
sleep_time = 5
|
82
|
+
exp_backoff = 2
|
83
|
+
result = nil
|
84
|
+
|
85
|
+
loop do
|
86
|
+
begin
|
87
|
+
resp = send_signed_request(
|
88
|
+
request['method'],
|
89
|
+
"#{endpoint.strip}#{request['path']}",
|
90
|
+
body
|
91
|
+
)
|
92
|
+
|
93
|
+
result = JSON.parse(resp.body)
|
94
|
+
message = "status: #{resp.code}, response: #{result}"
|
95
|
+
raise message unless resp.code == '200'
|
96
|
+
break
|
97
|
+
rescue Exception => e
|
98
|
+
break if retries >= max_retries
|
99
|
+
retries += 1
|
100
|
+
msg("RequestFailed: #{e} - Waiting #{sleep_time}s then retrying... (#{retries} of #{max_retries})")
|
101
|
+
|
102
|
+
|
103
|
+
sleep sleep_time
|
104
|
+
sleep_time *= exp_backoff # use an exponential backoff when retrying requests
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# if request has 'outfile' param, write response body to file
|
109
|
+
to_file(result, request['outfile']) if request['outfile']
|
110
|
+
|
111
|
+
# return response body obj
|
112
|
+
result
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_file(obj, filename)
|
116
|
+
File.open(filename, 'w') do |f|
|
117
|
+
f.write(obj.to_json)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def send_signed_request(method, url, payload)
|
124
|
+
uri = URI.parse(url)
|
125
|
+
https = Net::HTTP.new(uri.host, uri.port)
|
126
|
+
https.use_ssl = true
|
127
|
+
signature = sigv4_signature(method, url, payload)
|
128
|
+
path = uri.path
|
129
|
+
path = path + '?' + uri.query if uri.query
|
130
|
+
request = http_request(method, path, signature, payload)
|
131
|
+
|
132
|
+
response = https.request(request)
|
133
|
+
end
|
134
|
+
|
135
|
+
def set_headers(request, signature)
|
136
|
+
request.add_field 'content-type', 'application/json'
|
137
|
+
request.add_field 'host', signature.headers['host']
|
138
|
+
request.add_field 'x-amz-date', signature.headers['x-amz-date']
|
139
|
+
request.add_field 'x-amz-security-token', signature.headers['x-amz-security-token'] unless (signature.headers['x-amz-security-token'].nil?)
|
140
|
+
request.add_field 'x-amz-content-sha256', signature.headers['x-amz-content-sha256']
|
141
|
+
request.add_field 'authorization', signature.headers['authorization']
|
142
|
+
end
|
143
|
+
|
144
|
+
def http_request(method, path, signature, payload)
|
145
|
+
case method.downcase
|
146
|
+
when 'put'
|
147
|
+
request = Net::HTTP::Put.new(path)
|
148
|
+
when 'post'
|
149
|
+
request = Net::HTTP::Post.new(path)
|
150
|
+
when 'get'
|
151
|
+
request = Net::HTTP::Get.new(path)
|
152
|
+
when 'delete'
|
153
|
+
request = Net::HTTP::Delete.new(path)
|
154
|
+
else
|
155
|
+
request = Net::HTTP::Put.new(path)
|
156
|
+
end
|
157
|
+
|
158
|
+
set_headers(request, signature)
|
159
|
+
request.body = payload
|
160
|
+
|
161
|
+
request
|
162
|
+
end
|
163
|
+
|
164
|
+
def signer
|
165
|
+
Aws::Sigv4::Signer.new(
|
166
|
+
service: @service_name,
|
167
|
+
region: @region,
|
168
|
+
access_key_id: @credentials[:access_key_id],
|
169
|
+
secret_access_key: @credentials[:secret_access_key],
|
170
|
+
session_token: @credentials[:session_token]
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
def sigv4_signature(method, url, payload)
|
175
|
+
signer.sign_request(
|
176
|
+
http_method: method,
|
177
|
+
url: url,
|
178
|
+
headers: {
|
179
|
+
'content-type' => 'application/json'
|
180
|
+
},
|
181
|
+
body: payload
|
182
|
+
)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Idlc
|
2
|
+
module Utility
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
class MissingCredentials < StandardError; end
|
6
|
+
class MissingVersionFile < StandardError; end
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def check_for_creds
|
10
|
+
creds_fmt = {
|
11
|
+
'AWS_ACCESS_ID' => 'AWS_ACCESS_KEY_ID',
|
12
|
+
'AWS_SECRET_KEY' => 'AWS_SECRET_ACCESS_KEY'
|
13
|
+
}
|
14
|
+
creds_fmt.each do |old_fmt, new_fmt|
|
15
|
+
if ENV.include? new_fmt
|
16
|
+
next
|
17
|
+
elsif ENV.include?(old_fmt) && !ENV.include?(new_fmt)
|
18
|
+
ENV[new_fmt] = ENV[old_fmt]
|
19
|
+
elsif !ENV.include?(old_fmt) || !ENV.include?(new_fmt)
|
20
|
+
raise MissingCredentials, "#{new_fmt} is not set."
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_global_version(filename)
|
26
|
+
filename = ENV['VERSION_FILE'] if ENV.include? 'VERSION_FILE'
|
27
|
+
Idlc::Helpers.debug('WARNING: Not using a global version file') unless File.exist? filename
|
28
|
+
YAML.load_file(filename)['version'] if File.exist? filename
|
29
|
+
end
|
30
|
+
|
31
|
+
def major_minor_patch(version)
|
32
|
+
# Strip build number from version number. The migration scripts only include
|
33
|
+
# major.minor.patch
|
34
|
+
version.split('.')[0..2].join('.')
|
35
|
+
end
|
36
|
+
|
37
|
+
def major_minor(version)
|
38
|
+
# Strip build number from version number. The migration scripts only include
|
39
|
+
# major.minor.patch
|
40
|
+
version.split('.')[0..1].join('.')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Idlc
|
2
|
+
class Workspace
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def zip_folder(src, out)
|
7
|
+
zf = ZipFileGenerator.new(src, out)
|
8
|
+
zf.write
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :tmp_dir
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@tmp_dir = Dir.mktmpdir('ws-temp')
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty?
|
19
|
+
!Dir.exist? @tmp_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
def cleanup
|
23
|
+
debug("keeping directory: #{@tmp_dir} for dubugging")
|
24
|
+
return if ENV['DEBUG']
|
25
|
+
|
26
|
+
FileUtils.rm_rf(@tmp_dir)
|
27
|
+
end
|
28
|
+
|
29
|
+
def flatten(base_path, file_ext)
|
30
|
+
Dir["#{base_path}/**/*.#{file_ext}"].each do |file|
|
31
|
+
# get the filename and parent dir
|
32
|
+
filename = file.tr('/', '-')
|
33
|
+
|
34
|
+
# copy the files to a single temp directory.
|
35
|
+
debug("copying #{file} to #{@tmp_dir}/#{filename} ...")
|
36
|
+
FileUtils.cp(file, "#{@tmp_dir}/#{filename}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def add(path)
|
41
|
+
parent_dir = path.split('/')[0..-2].join('/')
|
42
|
+
FileUtils.mkdir_p("#{@tmp_dir}/#{parent_dir}")
|
43
|
+
FileUtils.cp_r(path, "#{@tmp_dir}/#{path}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Idlc
|
2
|
+
class ZipFileGenerator
|
3
|
+
include Helpers
|
4
|
+
|
5
|
+
# Initialize with the directory to zip and the location of the output archive.
|
6
|
+
def initialize(inputDir, outputFile)
|
7
|
+
@inputDir = inputDir
|
8
|
+
@outputFile = outputFile
|
9
|
+
end
|
10
|
+
|
11
|
+
# Zip the input directory.
|
12
|
+
def write()
|
13
|
+
entries = Dir.entries(@inputDir); entries.delete("."); entries.delete("..")
|
14
|
+
io = Zip::File.open(@outputFile, Zip::File::CREATE);
|
15
|
+
|
16
|
+
writeEntries(entries, "", io)
|
17
|
+
io.close();
|
18
|
+
end
|
19
|
+
|
20
|
+
# A helper method to make the recursion work.
|
21
|
+
private
|
22
|
+
def writeEntries(entries, path, io)
|
23
|
+
|
24
|
+
entries.each { |e|
|
25
|
+
zipFilePath = path == "" ? e : File.join(path, e)
|
26
|
+
diskFilePath = File.join(@inputDir, zipFilePath)
|
27
|
+
|
28
|
+
debug("Deflating " + diskFilePath)
|
29
|
+
|
30
|
+
if File.directory?(diskFilePath)
|
31
|
+
io.mkdir(zipFilePath)
|
32
|
+
subdir =Dir.entries(diskFilePath); subdir.delete("."); subdir.delete("..")
|
33
|
+
writeEntries(subdir, zipFilePath, io)
|
34
|
+
else
|
35
|
+
io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read())}
|
36
|
+
end
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'zip'
|
3
|
+
|
4
|
+
require 'iapi-idlc-sdk-core/version'
|
5
|
+
require 'iapi-idlc-sdk-core/helpers'
|
6
|
+
require 'iapi-idlc-sdk-core/utility'
|
7
|
+
require 'iapi-idlc-sdk-core/workspace'
|
8
|
+
require 'iapi-idlc-sdk-core/zip'
|
9
|
+
require 'iapi-idlc-sdk-core/restclient'
|
10
|
+
|
11
|
+
module Idlc
|
12
|
+
stage = ENV.fetch('IDLC_STAGE', 'prod')
|
13
|
+
# Service Definitions
|
14
|
+
SERVICES = {
|
15
|
+
'us-east-1' => {
|
16
|
+
'build' => {
|
17
|
+
'endpoint' => 'build.orchestrate.imageapi.com',
|
18
|
+
'stage' => stage,
|
19
|
+
'publish_bucket' => "service-build-#{stage}-build-artifacts"
|
20
|
+
},
|
21
|
+
'config' => {
|
22
|
+
'endpoint' => 'config.orchestrate.imageapi.com',
|
23
|
+
'stage' => stage
|
24
|
+
},
|
25
|
+
'deploy' => {
|
26
|
+
'endpoint' => 'deploy.orchestrate.imageapi.com',
|
27
|
+
'stage' => stage
|
28
|
+
},
|
29
|
+
'status' => {
|
30
|
+
'endpoint' => 'status.orchestrate.imageapi.com',
|
31
|
+
'stage' => stage
|
32
|
+
},
|
33
|
+
'auth' => {
|
34
|
+
'endpoint' => 'auth.orchestrate.imageapi.com',
|
35
|
+
'stage' => stage
|
36
|
+
}
|
37
|
+
},
|
38
|
+
'us-gov-west-1' => {
|
39
|
+
'build' => {
|
40
|
+
'endpoint' => 'build.orchestrate-us-gov.imageapi.com',
|
41
|
+
'stage' => 'govcloud',
|
42
|
+
'publish_bucket' => 'service-build-govcloud-build-artifacts'
|
43
|
+
},
|
44
|
+
'config' => {
|
45
|
+
'endpoint' => 'config.orchestrate-us-gov.imageapi.com',
|
46
|
+
'stage' => 'govcloud'
|
47
|
+
},
|
48
|
+
'deploy' => {
|
49
|
+
'endpoint' => 'deploy.orchestrate-us-gov.imageapi.com',
|
50
|
+
'stage' => 'govcloud'
|
51
|
+
},
|
52
|
+
'status' => {
|
53
|
+
'endpoint' => 'status.orchestrate-us-gov.imageapi.com',
|
54
|
+
'stage' => 'govcloud'
|
55
|
+
},
|
56
|
+
'auth' => {
|
57
|
+
'endpoint' => 'auth.orchestrate-us-gov.imageapi.com',
|
58
|
+
'stage' => 'govcloud'
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}.freeze
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iapi-idlc-sdk-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Cazell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-11-
|
12
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -99,30 +99,30 @@ dependencies:
|
|
99
99
|
name: aws-sdk-lambda
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - '='
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
104
|
+
version: 1.111.0
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - '='
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
111
|
+
version: 1.111.0
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: aws-sigv4
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - '='
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
118
|
+
version: 1.6.1
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - '='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 1.6.1
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: rubyzip
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,7 +143,26 @@ email:
|
|
143
143
|
executables: []
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
|
-
files:
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".travis.yml"
|
150
|
+
- ".yardopts"
|
151
|
+
- Gemfile
|
152
|
+
- Jenkinsfile
|
153
|
+
- LICENSE.txt
|
154
|
+
- README.md
|
155
|
+
- Rakefile
|
156
|
+
- bin/console
|
157
|
+
- bin/setup
|
158
|
+
- iapi-idlc-sdk-core.gemspec
|
159
|
+
- lib/iapi-idlc-sdk-core.rb
|
160
|
+
- lib/iapi-idlc-sdk-core/helpers.rb
|
161
|
+
- lib/iapi-idlc-sdk-core/restclient.rb
|
162
|
+
- lib/iapi-idlc-sdk-core/utility.rb
|
163
|
+
- lib/iapi-idlc-sdk-core/version.rb
|
164
|
+
- lib/iapi-idlc-sdk-core/workspace.rb
|
165
|
+
- lib/iapi-idlc-sdk-core/zip.rb
|
147
166
|
homepage: https://bitbucket.org/imageapi/iapi-idlc-sdk-core
|
148
167
|
licenses:
|
149
168
|
- MIT
|