lambda-version-manager 0.0.14 → 0.0.19
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 +4 -4
- data/bin/lambda-version-manager +8 -28
- data/lib/deployer.rb +7 -2
- data/lib/project.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fd802fb143d6d2fe85fe2e5964ccce86f796300c
|
|
4
|
+
data.tar.gz: 84aee5400d772dc1945a208a0cf8405f478b7883
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e02245ccddaf83685e8bf01d2964c6e5147bcf4a5a8334e7118ebc8714ae2614ee0f9d10fdc504f76bd4ad477ec58546cfe4e36c93eb3449719d96f3492da40f
|
|
7
|
+
data.tar.gz: 62eb53f6b482acf97fa591bfe73f67c0f8815b1618dcbb6ac1fd166260ef7215429482e247d172c72416d93d15b35d5059561579a51abbbc361d402b28057841
|
data/bin/lambda-version-manager
CHANGED
|
@@ -13,30 +13,20 @@ class GeneratorCLI < ::Thor
|
|
|
13
13
|
option 'artifact', banner: 'ARTIFACT', type: :string, desc: 'Deploy lambdas that use this artifact'
|
|
14
14
|
option 'lambda', banner: 'LAMBDA', type: :string, desc: 'Deploy lambdas with this name'
|
|
15
15
|
option 'account', banner: 'ACCOUNT', type: :string, desc: 'Account to deploy to', :required => true
|
|
16
|
-
option 'version_map_file', banner: 'VERSION_MAP_FILE', type: :string, desc: 'A java properties file mapping artifacts to update to version'
|
|
17
16
|
option 'deploy_all', banner: 'DEPLOY_ALL', type: :boolean, desc: 'Ignore the history therefore deploy everything included in the filter', default: false
|
|
18
17
|
|
|
19
18
|
def deploy
|
|
20
19
|
opts = validate_deploy(options)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
File.readlines(options['version_map_file']).each do |line|
|
|
24
|
-
array = line.split("=")
|
|
25
|
-
deployer = Deployer.new(opts['deploy_all'], opts['project_path'], opts['account'], array[0].strip)
|
|
26
|
-
deployer.deploy(opts['environments'])
|
|
27
|
-
end
|
|
28
|
-
else
|
|
29
|
-
deployer = Deployer.new(opts['deploy_all'], opts['project_path'], opts['account'], opts['artifact'], opts['lambda'])
|
|
30
|
-
deployer.deploy(opts['environments'])
|
|
31
|
-
end
|
|
20
|
+
deployer = Deployer.new(opts['deploy_all'], opts['project_path'], opts['account'], opts['artifact'], opts['lambda'])
|
|
21
|
+
deployer.deploy(opts['environments'])
|
|
32
22
|
end
|
|
33
23
|
|
|
34
24
|
desc 'update_project', 'Update the versions'
|
|
35
25
|
option 'project_path', banner: 'PROJECT_PATH', type: :string, desc: 'Path to the lambda version mappings project'
|
|
36
26
|
option 'artifact', banner: 'ARTIFACT', type: :string, desc: 'Deploy lambdas that use this artifact'
|
|
37
27
|
option 'version', banner: 'VERSION', type: :string, desc: 'Version of the new artifact'
|
|
38
|
-
option 'version_map_file', banner: 'VERSION_MAP_FILE', type: :string, desc: 'A java properties file mapping artifacts to update to version'
|
|
39
28
|
option 'accounts', banner: 'ACCOUNT', type: :array, desc: 'Account to deploy to', :required => true
|
|
29
|
+
option 'sha1', banner: 'SHA1', type: :string, desc: 'SHA1 of the artifact'
|
|
40
30
|
|
|
41
31
|
def update_project
|
|
42
32
|
opts = validate_project_update(options)
|
|
@@ -55,31 +45,21 @@ class GeneratorCLI < ::Thor
|
|
|
55
45
|
end
|
|
56
46
|
end
|
|
57
47
|
|
|
58
|
-
|
|
59
|
-
if opts['version_map_file']
|
|
60
|
-
#for each artifact=version pair we need to call
|
|
61
|
-
File.readlines(opts['version_map_file']).each do |line|
|
|
62
|
-
array = line.split("=")
|
|
63
|
-
updated_files = project.update_by_artifact(lambda_env_map, array[0].strip, array[1].strip)
|
|
64
|
-
lambda_env_map = updated_files
|
|
65
|
-
end
|
|
66
|
-
else
|
|
67
|
-
lambda_env_map = project.update_by_artifact(lambda_env_map, opts['artifact'], opts['version'])
|
|
68
|
-
end
|
|
48
|
+
lambda_env_map = project.update_by_artifact(lambda_env_map, opts['artifact'], opts['version'], opts['sha1'])
|
|
69
49
|
project.write_new_files(lambda_env_map)
|
|
70
50
|
end
|
|
71
51
|
|
|
72
52
|
no_commands do
|
|
73
53
|
def validate_project_update(options)
|
|
74
|
-
unless options['
|
|
75
|
-
raise 'Either a
|
|
54
|
+
unless options['version'] && (options['lambda'] || options['artifact'])
|
|
55
|
+
raise 'Either a version and lambda or artifact must be specified.'
|
|
76
56
|
end
|
|
77
57
|
options.dup
|
|
78
58
|
end
|
|
79
59
|
|
|
80
60
|
def validate_deploy(options)
|
|
81
|
-
unless options['
|
|
82
|
-
raise 'Either a
|
|
61
|
+
unless options['environments'] || options['lambda'] || options['artifact']
|
|
62
|
+
raise 'Either a environment or lambda or artifact must be specified.'
|
|
83
63
|
end
|
|
84
64
|
options.dup
|
|
85
65
|
end
|
data/lib/deployer.rb
CHANGED
|
@@ -61,7 +61,7 @@ class Deployer
|
|
|
61
61
|
environments ||= project.environments
|
|
62
62
|
account_env_map.each do |env|
|
|
63
63
|
#IF users has specified environments, skip if the environment is not a user specified one
|
|
64
|
-
next unless !environments.nil? && environments.include?(env)
|
|
64
|
+
next unless !environments.nil? && environments.include?(env) && !lambda_env_map[env].nil?
|
|
65
65
|
lambda_env_map[env].each do |lambda_name, properties|
|
|
66
66
|
client = Client.new(env_region_map[env])
|
|
67
67
|
|
|
@@ -111,7 +111,12 @@ class Deployer
|
|
|
111
111
|
historic = parse_archive
|
|
112
112
|
historic.each do |environment, lambdas|
|
|
113
113
|
lambdas.each do |lambda, configs|
|
|
114
|
-
if new_project[environment][lambda].
|
|
114
|
+
next if new_project[environment][lambda].nil?
|
|
115
|
+
if new_project[environment][lambda].has_key?('sha1')
|
|
116
|
+
if configs.has_key?('sha1') && (configs['sha1'] == new_project[environment][lambda]['sha1'])
|
|
117
|
+
new_project[environment].delete(lambda)
|
|
118
|
+
end
|
|
119
|
+
elsif new_project[environment][lambda].eql?(configs)
|
|
115
120
|
new_project[environment].delete(lambda)
|
|
116
121
|
end
|
|
117
122
|
end
|
data/lib/project.rb
CHANGED
|
@@ -14,7 +14,7 @@ class Project
|
|
|
14
14
|
def get_lambdas
|
|
15
15
|
lambdas = {}
|
|
16
16
|
environments.keys.each do |env|
|
|
17
|
-
lambdas[env] = YAML.load_file("#{project_path}/environments/#{env}.yaml")
|
|
17
|
+
lambdas[env] = YAML.load_file("#{project_path}/environments/#{env}.yaml") if File.exist?("#{project_path}/environments/#{env}.yaml")
|
|
18
18
|
end
|
|
19
19
|
lambdas
|
|
20
20
|
end
|
|
@@ -45,13 +45,14 @@ class Project
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
|
|
48
49
|
def write_new_files(lambda_env_map)
|
|
49
50
|
lambda_env_map.each do |env, contents|
|
|
50
51
|
File.write("#{project_path}/environments/#{env}.yaml", contents.to_yaml)
|
|
51
52
|
end
|
|
52
53
|
end
|
|
53
54
|
|
|
54
|
-
def update_by_artifact(lambda_env_map, artifact, version)
|
|
55
|
+
def update_by_artifact(lambda_env_map, artifact, version, sha1=nil)
|
|
55
56
|
#iterate through all lambdas and update the ones with version changes
|
|
56
57
|
lambda_env_map.each do |env, lambda|
|
|
57
58
|
pp env
|
|
@@ -59,6 +60,7 @@ class Project
|
|
|
59
60
|
lambda.each do |lambda_name, properties|
|
|
60
61
|
if properties['artifact_name'] == artifact
|
|
61
62
|
properties['version'] = version
|
|
63
|
+
properties['sha1'] = sha1 unless sha1.nil?
|
|
62
64
|
end
|
|
63
65
|
end
|
|
64
66
|
end
|