lambda-version-manager 0.0.14 → 0.0.15

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: 8b74f08aa1f3d28d495ce5ed45725e11fdd99233
4
- data.tar.gz: 81d3e4031ea100cd5713242ca6273a6c93a9d35c
3
+ metadata.gz: 756e8755c8b012593bfc0dc95610d4fc5df98959
4
+ data.tar.gz: 3a31a6b225ae135b922d680da79e0137fbbb0ee5
5
5
  SHA512:
6
- metadata.gz: 2e7d3aabd312942d9edd74d22247abcb104c0bf7e8a6c20c5efdb8fc7836f4b0c8714759e267714d50b1ed9bbce383585e0e1f7e17ac417f2cfb46ec56396186
7
- data.tar.gz: b7744d9a396c49c9c17fc0ea77c203bfd3b4df9c452d48ed714243014403be1172cd8ec2eaf0b523ef738cefeebe3b8f7b3407272af676ef1c8269e34e4f19fe
6
+ metadata.gz: f726a836018b87d78158fb12e10db831f7069d358865ba939e9071c1053315f80cabff400d645d306fd1b5721a31dd59642c9e9938851c4ea289326a8396774f
7
+ data.tar.gz: 8b56d369eb0bce581ec606b519e2ed2339600fda105c653497452ecd45de0c627410909e4aae5d168fa750d5344ad495f916c5dc0bee3654b715160bb70d1d2c
@@ -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
- if opts['version_map_file']
22
- #for each x=y pair we need to call
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['version_map_file'] || (options['version'] && (options['lambda'] || options['artifact']))
75
- raise 'Either a file must be specified or a version and lambda or artifact.'
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['version_map_file'] || options['environments'] || options['lambda'] || options['artifact']
82
- raise 'Either a file must be specified or a environment or lambda or artifact.'
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
@@ -111,7 +111,11 @@ 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].eql?(configs)
114
+ if new_project[environment][lambda].has_key?('sha1')
115
+ unless configs.has_key?('sha1') && (configs['sha1'] == new_project[environment][lambda]['sha1'])
116
+ new_project[environment].delete(lambda)
117
+ end
118
+ elsif new_project[environment][lambda].eql?(configs)
115
119
  new_project[environment].delete(lambda)
116
120
  end
117
121
  end
data/lib/project.rb CHANGED
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lambda-version-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Call