lono 3.5.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +15 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +15 -1
- data/Gemfile +3 -3
- data/Guardfile +17 -8
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +20 -12
- data/Rakefile +1 -2
- data/{bin → exe}/lono +1 -0
- data/lib/lono.rb +12 -9
- data/lib/lono/cfn.rb +7 -9
- data/lib/lono/cfn/{aws_services.rb → aws_service.rb} +1 -1
- data/lib/lono/cfn/base.rb +41 -38
- data/lib/lono/cfn/create.rb +6 -2
- data/lib/lono/cfn/delete.rb +2 -2
- data/lib/lono/cfn/diff.rb +1 -1
- data/lib/lono/cfn/preview.rb +26 -15
- data/lib/lono/cfn/update.rb +11 -9
- data/lib/lono/cfn/util.rb +3 -3
- data/lib/lono/clean.rb +1 -1
- data/lib/lono/cli.rb +71 -39
- data/lib/lono/command.rb +42 -18
- data/lib/lono/completer.rb +162 -0
- data/lib/lono/completer/script.rb +6 -0
- data/lib/lono/completer/script.sh +10 -0
- data/lib/lono/completion.rb +15 -0
- data/lib/lono/core.rb +23 -9
- data/lib/lono/core/config.rb +20 -0
- data/lib/lono/default/settings.yml +33 -13
- data/lib/lono/help.rb +6 -79
- data/lib/lono/help/cfn.md +6 -0
- data/lib/lono/help/cfn/create.md +22 -0
- data/lib/lono/help/cfn/delete.md +5 -0
- data/lib/lono/help/cfn/diff.md +5 -0
- data/lib/lono/help/cfn/download.md +5 -0
- data/lib/lono/help/cfn/preview.md +11 -0
- data/lib/lono/help/cfn/update.md +21 -0
- data/lib/lono/help/completion.md +22 -0
- data/lib/lono/help/completion_script.md +3 -0
- data/lib/lono/help/generate.md +7 -0
- data/lib/lono/help/hello.md +5 -0
- data/lib/lono/help/import.md +7 -0
- data/lib/lono/help/inspect.md +4 -0
- data/lib/lono/help/inspect/depends.md +3 -0
- data/lib/lono/help/inspect/summary.md +3 -0
- data/lib/lono/help/new.md +8 -0
- data/lib/lono/help/param.md +3 -0
- data/lib/lono/{param/help.rb → help/param/generate.md} +1 -9
- data/lib/lono/help/script/build.md +5 -0
- data/lib/lono/help/script/upload.md +8 -0
- data/lib/lono/help/template.md +4 -0
- data/lib/lono/help/template/bashify.md +4 -0
- data/lib/lono/help/template/generate.md +7 -0
- data/lib/lono/help/user_data.md +3 -0
- data/lib/lono/importer.rb +43 -20
- data/lib/lono/inspector.rb +2 -19
- data/lib/lono/inspector/base.rb +2 -2
- data/lib/lono/inspector/{depends.rb → graph.rb} +3 -3
- data/lib/lono/inspector/summary.rb +1 -1
- data/lib/lono/new.rb +79 -26
- data/lib/lono/new/helper.rb +16 -0
- data/lib/lono/new/message.rb +35 -0
- data/lib/lono/param.rb +1 -2
- data/lib/lono/param/generator.rb +34 -86
- data/lib/lono/project_checker.rb +35 -40
- data/lib/lono/script.rb +19 -0
- data/lib/lono/script/base.rb +9 -0
- data/lib/lono/script/build.rb +73 -0
- data/lib/lono/script/upload.rb +81 -0
- data/lib/lono/sequence.rb +33 -0
- data/lib/lono/setting.rb +83 -0
- data/lib/lono/template.rb +8 -9
- data/lib/lono/template/{aws_services.rb → aws_service.rb} +1 -1
- data/lib/lono/template/context.rb +73 -0
- data/lib/lono/template/dsl.rb +63 -64
- data/lib/lono/template/helper.rb +201 -0
- data/lib/lono/template/template.rb +29 -221
- data/lib/lono/template/upload.rb +41 -33
- data/lib/lono/upgrade4.rb +175 -0
- data/lib/lono/user_data.rb +31 -0
- data/lib/lono/version.rb +1 -1
- data/lib/starter_projects/autoscaling/.gitignore +1 -0
- data/lib/starter_projects/{json_project → autoscaling}/Gemfile +0 -0
- data/lib/starter_projects/{yaml_project → autoscaling}/Guardfile +0 -0
- data/lib/starter_projects/autoscaling/README.md +118 -0
- data/lib/starter_projects/autoscaling/app/definitions/base.rb +2 -0
- data/lib/starter_projects/autoscaling/app/templates/autoscaling.yml +682 -0
- data/lib/starter_projects/autoscaling/config/params/base/autoscaling.txt +6 -0
- data/lib/starter_projects/autoscaling/config/settings.yml +33 -0
- data/lib/starter_projects/ec2/.gitignore +1 -0
- data/lib/starter_projects/{yaml_project → ec2}/Gemfile +0 -0
- data/lib/starter_projects/{json_project → ec2}/Guardfile +1 -1
- data/lib/starter_projects/ec2/README.md +86 -0
- data/lib/starter_projects/ec2/app/definitions/base.rb +2 -0
- data/lib/starter_projects/ec2/app/definitions/development.rb +1 -0
- data/lib/starter_projects/ec2/app/definitions/production.rb +1 -0
- data/lib/starter_projects/{yaml_project → ec2/app}/helpers/my_custom_helper.rb +0 -0
- data/lib/starter_projects/{json_project/templates/user_data/app.sh → ec2/app/partials/user_data/bootstrap.sh} +1 -2
- data/lib/starter_projects/{yaml_project → ec2/app}/templates/example.yml +0 -0
- data/lib/starter_projects/{json_project/params/base/api-web.txt → ec2/config/params/base/example.txt} +0 -0
- data/lib/starter_projects/ec2/config/params/development/example.txt +3 -0
- data/lib/starter_projects/ec2/config/params/production/example.txt +2 -0
- data/lib/starter_projects/ec2/config/settings.yml +33 -0
- data/lib/starter_projects/ec2/config/variables/base.rb +3 -0
- data/lib/starter_projects/ec2/config/variables/development.rb +2 -0
- data/lib/starter_projects/ec2/config/variables/production.rb +2 -0
- data/lib/starter_projects/ec2/welcome.txt +8 -0
- data/lib/starter_projects/skeleton/.gitignore +1 -0
- data/lib/starter_projects/skeleton/Gemfile +3 -0
- data/lib/starter_projects/skeleton/Guardfile +12 -0
- data/lib/starter_projects/skeleton/README.md +53 -0
- data/{spec/fixtures/my_project/templates/.gitkeep → lib/starter_projects/skeleton/app/definitions/base.rb} +0 -0
- data/lib/starter_projects/skeleton/config/settings.yml +33 -0
- data/lib/starter_projects/skeleton/welcome.txt +7 -0
- data/lono.gemspec +12 -10
- data/spec/fixtures/lono_project/.gitignore +1 -0
- data/spec/fixtures/lono_project/Gemfile +3 -0
- data/spec/fixtures/lono_project/Guardfile +12 -0
- data/spec/fixtures/lono_project/app/definitions/base.rb +10 -0
- data/spec/fixtures/lono_project/app/definitions/base/more.rb +7 -0
- data/spec/fixtures/lono_project/app/definitions/development.rb +1 -0
- data/spec/fixtures/lono_project/app/definitions/production.rb +1 -0
- data/spec/fixtures/lono_project/app/helpers/custom_helper.rb +5 -0
- data/spec/fixtures/lono_project/app/partials/security_group.yml +10 -0
- data/{lib/starter_projects/yaml_project/templates/partial → spec/fixtures/lono_project/app/partials}/user_data/bootstrap.sh +8 -2
- data/spec/fixtures/lono_project/app/templates/example.yml +50 -0
- data/{lib/starter_projects/yaml_project/params/base/api-web-prod.txt → spec/fixtures/lono_project/config/params/base/example.txt} +1 -0
- data/spec/fixtures/lono_project/config/params/development/example.txt +1 -0
- data/spec/fixtures/lono_project/config/params/production/example.txt +1 -0
- data/spec/fixtures/lono_project/config/settings.yml +31 -0
- data/spec/fixtures/lono_project/config/variables/base.rb +3 -0
- data/spec/fixtures/lono_project/config/variables/development.rb +1 -0
- data/spec/fixtures/lono_project/config/variables/production.rb +1 -0
- data/spec/fixtures/params/envonly/params/{prod → development}/network.txt +0 -0
- data/spec/fixtures/params/overlay/params/{prod → development}/network.txt +0 -0
- data/spec/fixtures/raw_templates/aws-waf-security-automations.template +2 -2
- data/spec/lib/lono/cfn_spec.rb +6 -9
- data/spec/lib/lono/cli_spec.rb +44 -0
- data/spec/lib/lono/completion_spec.rb +17 -0
- data/spec/lib/lono/inspect_spec.rb +6 -15
- data/spec/lib/lono/param/generator_spec.rb +45 -26
- data/spec/lib/lono/param_spec.rb +1 -3
- data/spec/lib/lono/setting_spec.rb +47 -0
- data/spec/lib/lono/template/dsl_spec.rb +33 -157
- data/spec/lib/lono/template_spec.rb +4 -16
- data/spec/spec_helper.rb +45 -14
- metadata +168 -82
- data/.coveralls.yml +0 -1
- data/lib/lono/cfn/help.rb +0 -103
- data/lib/lono/current_region.rb +0 -42
- data/lib/lono/inspector/help.rb +0 -21
- data/lib/lono/settings.rb +0 -45
- data/lib/lono/template/help.rb +0 -25
- data/lib/lono/template/helpers.rb +0 -136
- data/lib/starter_projects/json_project/.gitignore +0 -1
- data/lib/starter_projects/json_project/config/templates/base/blog.rb +0 -20
- data/lib/starter_projects/json_project/config/templates/base/stacks.rb +0 -58
- data/lib/starter_projects/json_project/templates/db.json +0 -212
- data/lib/starter_projects/json_project/templates/partial/host_record.json +0 -28
- data/lib/starter_projects/json_project/templates/partial/server.json +0 -45
- data/lib/starter_projects/json_project/templates/user_data/db.sh +0 -39
- data/lib/starter_projects/json_project/templates/user_data/db2.sh +0 -2
- data/lib/starter_projects/json_project/templates/user_data/ruby_script.rb +0 -5
- data/lib/starter_projects/json_project/templates/web.json +0 -386
- data/lib/starter_projects/yaml_project/.gitignore +0 -1
- data/lib/starter_projects/yaml_project/config/templates/base/blog.rb +0 -20
- data/lib/starter_projects/yaml_project/config/templates/base/stacks.rb +0 -56
- data/lib/starter_projects/yaml_project/config/templates/prod/stacks.rb +0 -1
- data/lib/starter_projects/yaml_project/config/templates/stag/stacks.rb +0 -1
- data/lib/starter_projects/yaml_project/config/variables/base/variables.rb +0 -4
- data/lib/starter_projects/yaml_project/config/variables/prod/variables.rb +0 -1
- data/lib/starter_projects/yaml_project/config/variables/stag/variables.rb +0 -1
- data/lib/starter_projects/yaml_project/params/base/example.txt +0 -2
- data/lib/starter_projects/yaml_project/params/prod/example.txt +0 -1
- data/lib/starter_projects/yaml_project/params/stag/example.txt +0 -1
- data/lib/starter_projects/yaml_project/templates/db.yml +0 -148
- data/lib/starter_projects/yaml_project/templates/partial/host_record.yml +0 -14
- data/lib/starter_projects/yaml_project/templates/partial/server.yml +0 -59
- data/lib/starter_projects/yaml_project/templates/web.yml +0 -206
- data/spec/fixtures/my_project/config/templates/base/stacks.rb +0 -3
- data/spec/fixtures/my_project/params/my-stack.txt +0 -3
- data/spec/fixtures/my_project/templates/my-stack.yml +0 -0
- data/spec/lib/lono/new_spec.rb +0 -59
- data/spec/lib/lono/template/template_spec.rb +0 -104
- data/spec/lib/lono_spec.rb +0 -27
@@ -0,0 +1 @@
|
|
1
|
+
# resources that only exist in the development environment
|
@@ -0,0 +1 @@
|
|
1
|
+
# resources that only exist in the production environment
|
@@ -1,5 +1,11 @@
|
|
1
1
|
#!/bin/bash -lexv
|
2
|
-
|
2
|
+
|
3
3
|
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
|
4
|
-
|
4
|
+
|
5
|
+
# Lono.env=<%= Lono.env %>
|
6
|
+
# override_test=<%= @override_test %>
|
7
|
+
# self=<%= self.inspect %>
|
8
|
+
|
5
9
|
cat /proc/uptime | cut -f1 -d'.' > /tmp/time-to-boot
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
3
|
+
Description: 'AWS CloudFormation Sample Template. A fixture for testing only. @_name: <%= @_name %>'
|
4
|
+
Parameters:
|
5
|
+
KeyName:
|
6
|
+
Description: Name of an existing EC2 KeyPair for SSH. <%= custom_helper %>
|
7
|
+
Type: AWS::EC2::KeyPair::KeyName
|
8
|
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
9
|
+
<% if @route53 %>
|
10
|
+
HostedZoneName:
|
11
|
+
Description: The route53 HostedZoneName. For example, "mydomain.com." Don't forget the period at the end.
|
12
|
+
Type: String
|
13
|
+
Subdomain:
|
14
|
+
Description: The subdomain of the dns entry. For example, hello -> hello.mydomain.com, hello is the subdomain.
|
15
|
+
Type: String
|
16
|
+
<% end %>
|
17
|
+
Resources:
|
18
|
+
EC2Instance:
|
19
|
+
Type: AWS::EC2::Instance
|
20
|
+
Properties:
|
21
|
+
InstanceType:
|
22
|
+
Ref: InstanceType
|
23
|
+
SecurityGroups:
|
24
|
+
- Ref: InstanceSecurityGroup
|
25
|
+
KeyName:
|
26
|
+
Ref: KeyName
|
27
|
+
UserData:
|
28
|
+
Fn::Base64: !Sub |
|
29
|
+
<%= partial("user_data/bootstrap.sh", {}, indent: 10) %>
|
30
|
+
ImageId:
|
31
|
+
Fn::FindInMap:
|
32
|
+
- AWSRegionArch2AMI
|
33
|
+
- Ref: AWS::Region
|
34
|
+
- Fn::FindInMap:
|
35
|
+
- AWSInstanceType2Arch
|
36
|
+
- Ref: InstanceType
|
37
|
+
- Arch
|
38
|
+
<%= partial("security_group", desc: "Enable SSH access via port 22", port: "22") %>
|
39
|
+
<% if @route53 %>
|
40
|
+
DnsRecord:
|
41
|
+
Type: AWS::Route53::RecordSet
|
42
|
+
Properties:
|
43
|
+
HostedZoneName: !Ref 'HostedZoneName'
|
44
|
+
Comment: DNS name for my instance.
|
45
|
+
Name: !Join ['', [!Ref 'Subdomain', ., !Ref 'HostedZoneName']]
|
46
|
+
Type: CNAME
|
47
|
+
TTL: '900'
|
48
|
+
ResourceRecords:
|
49
|
+
- !GetAtt EC2Instance.PublicIp
|
50
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
InstanceType=t2.small
|
@@ -0,0 +1 @@
|
|
1
|
+
InstanceType=t2.large
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# More info: http://lono.cloud/docs/settings/
|
2
|
+
# The base config is specially treated. It gets included the other environments automatically.
|
3
|
+
# Yaml also directly supports merging with & and <<* syntax but doing it automatically
|
4
|
+
# for a cleaner syntax.
|
5
|
+
base:
|
6
|
+
# If s3_folder is set then the generated templates and app/scripts will automatically
|
7
|
+
# be uploaded to s3.
|
8
|
+
# There are 2 formats for s3_folder:
|
9
|
+
# Format 1:
|
10
|
+
# s3_folder: mybucket/path/to/folder # simple string
|
11
|
+
# Format 2:
|
12
|
+
# s3_folder: # Hash options in order to support different AWS_PROFILEs
|
13
|
+
# default: mybucket/folder
|
14
|
+
# aws_profile1: mybucket/folder
|
15
|
+
# aws_profile2: another-bucket/storage/folder
|
16
|
+
# randomize_stack_name: true # tack on a 3 char random string at the end of the stack name
|
17
|
+
# for lono cfn create
|
18
|
+
|
19
|
+
development:
|
20
|
+
# cluster: dev
|
21
|
+
# When you have AWS_PROFILE set to one of these values, ufo will switch to the desired
|
22
|
+
# environment. This prevents you from switching AWS_PROFILE, forgetting to
|
23
|
+
# also switch UFO_ENV, and accidentally deploying to production vs development.
|
24
|
+
# aws_profiles:
|
25
|
+
# - dev_profile1
|
26
|
+
# - dev_profile2
|
27
|
+
|
28
|
+
production:
|
29
|
+
# cluster: prod
|
30
|
+
# aws_profiles:
|
31
|
+
# - prod_profile
|
@@ -0,0 +1 @@
|
|
1
|
+
@override_test = "overridden-by-development"
|
@@ -0,0 +1 @@
|
|
1
|
+
@override_test = "overridden-by-production"
|
File without changes
|
File without changes
|
@@ -10,12 +10,12 @@
|
|
10
10
|
"Parameters": ["SqlInjectionProtectionParam", "CrossSiteScriptingProtectionParam", "ActivateHttpFloodProtectionParam", "ActivateScansProbesProtectionParam", "ActivateReputationListsProtectionParam", "ActivateBadBotProtectionParam"]
|
11
11
|
}, {
|
12
12
|
"Label": {
|
13
|
-
"default": "
|
13
|
+
"default": "Setting"
|
14
14
|
},
|
15
15
|
"Parameters": ["CloudFrontAccessLogBucket"]
|
16
16
|
}, {
|
17
17
|
"Label": {
|
18
|
-
"default": "Advanced
|
18
|
+
"default": "Advanced Setting"
|
19
19
|
},
|
20
20
|
"Parameters": ["RequestThreshold", "ErrorThreshold", "WAFBlockPeriod"]
|
21
21
|
}, {
|
data/spec/lib/lono/cfn_spec.rb
CHANGED
@@ -1,39 +1,36 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
1
|
describe Lono::Cfn do
|
4
2
|
before(:all) do
|
5
|
-
@env = "LONO_ROOT=#{ENV['LONO_ROOT']}"
|
6
3
|
@args = "--noop"
|
7
4
|
end
|
8
5
|
|
9
6
|
describe "lono cfn" do
|
10
7
|
it "create stack" do
|
11
|
-
out = execute("#{@env}
|
8
|
+
out = execute("#{@env} exe/lono cfn create example #{@args}")
|
12
9
|
expect(out).to include("Creating")
|
13
10
|
end
|
14
11
|
|
15
12
|
it "update stack" do
|
16
|
-
out = execute("#{@env}
|
13
|
+
out = execute("#{@env} exe/lono cfn update example #{@args}")
|
17
14
|
expect(out).to include("Updating")
|
18
15
|
end
|
19
16
|
|
20
17
|
it "delete stack" do
|
21
|
-
out = execute("#{@env}
|
18
|
+
out = execute("#{@env} exe/lono cfn delete example #{@args}")
|
22
19
|
expect(out).to include("Deleted")
|
23
20
|
end
|
24
21
|
|
25
22
|
it "preview stack" do
|
26
|
-
out = execute("#{@env}
|
23
|
+
out = execute("#{@env} exe/lono cfn preview example #{@args}")
|
27
24
|
expect(out).to include("CloudFormation preview")
|
28
25
|
end
|
29
26
|
|
30
27
|
it "diff stack" do
|
31
|
-
out = execute("#{@env}
|
28
|
+
out = execute("#{@env} exe/lono cfn diff example #{@args}")
|
32
29
|
expect(out).to include("diff")
|
33
30
|
end
|
34
31
|
|
35
32
|
it "download stack" do
|
36
|
-
out = execute("#{@env}
|
33
|
+
out = execute("#{@env} exe/lono cfn download example #{@args}")
|
37
34
|
expect(out).to include("Download")
|
38
35
|
end
|
39
36
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
describe Lono::CLI do
|
2
|
+
context "general" do
|
3
|
+
it "new generate new project" do
|
4
|
+
# using another name for the lono project because we call
|
5
|
+
# exe/lono new lono_project for all specs via the RSpec.config already
|
6
|
+
# NOTE: LONO_ROOT modified in the spec_helper.rb
|
7
|
+
execute("exe/lono new test_project --no-bundle")
|
8
|
+
exist = File.exist?("tmp/test_project/config/settings.yml")
|
9
|
+
expect(exist).to be true
|
10
|
+
FileUtils.rm_rf("tmp/test_project")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "import should download template" do
|
14
|
+
out = execute("exe/lono import spec/fixtures/raw_templates/aws-waf-security-automations.template --name waf")
|
15
|
+
expect(out).to match(/=> Imported CloudFormation template/)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Ensure the example starter project is always able to produce output/templates.
|
20
|
+
context "project generated from lono new command" do
|
21
|
+
before(:all) do
|
22
|
+
# hack to so we don't have to change LONO_ROOT
|
23
|
+
@project = ENV['LONO_ROOT']
|
24
|
+
FileUtils.mv(@project, "#{@project}.temp") if File.exist?(@project)
|
25
|
+
end
|
26
|
+
after(:all) do
|
27
|
+
FileUtils.rm_rf(@project)
|
28
|
+
# move temp back for the rest of the tests
|
29
|
+
FileUtils.mv("#{@project}.temp", @project) if File.exist?("#{@project}.temp")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "generate should build templates" do
|
33
|
+
# NOTE: LONO_ROOT modified in the spec_helper.rb
|
34
|
+
execute("exe/lono new lono_project --no-bundle")
|
35
|
+
execute("exe/lono generate")
|
36
|
+
success = $?.exitstatus == 0
|
37
|
+
expect(success).to be true
|
38
|
+
|
39
|
+
exist = File.exist?("#{Lono.root}/config/settings.yml")
|
40
|
+
expect(exist).to be true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe Lono::CLI do
|
2
|
+
describe "lono completion" do
|
3
|
+
commands = {
|
4
|
+
# "new" => "name", # options is the completion because it's a Thor::Group
|
5
|
+
"generate" => "--clean",
|
6
|
+
"cfn" => "create",
|
7
|
+
"cfn create" => "name",
|
8
|
+
"param" => "generate",
|
9
|
+
}
|
10
|
+
commands.each do |command, expected_word|
|
11
|
+
it "#{command}" do
|
12
|
+
out = execute("exe/lono completion #{command}")
|
13
|
+
expect(out).to include(expected_word) # only checking for one word for simplicity
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,20 +1,11 @@
|
|
1
|
-
require_relative "../../spec_helper"
|
2
|
-
|
3
1
|
describe Lono::Inspector do
|
4
|
-
|
5
|
-
|
2
|
+
it "lono xgraph" do
|
3
|
+
out = execute("exe/lono xgraph example --noop")
|
4
|
+
expect(out).to include("Generating dependencies tree")
|
6
5
|
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
expect(out).to include("Generating dependencies tree")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "summary" do
|
15
|
-
out = execute("bin/lono inspect summary my-stack #{@args}")
|
16
|
-
expect(out).to include("Summary")
|
17
|
-
end
|
7
|
+
it "lono summary" do
|
8
|
+
out = execute("exe/lono summary example")
|
9
|
+
expect(out).to include("Summary")
|
18
10
|
end
|
19
11
|
end
|
20
|
-
|
@@ -1,37 +1,56 @@
|
|
1
|
-
require_relative "../../../spec_helper"
|
2
|
-
|
3
1
|
describe Lono::Param::Generator do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
context "layering" do
|
3
|
+
def generate(context)
|
4
|
+
path = "spec/fixtures/params/#{context}/params/development/network.txt"
|
5
|
+
param = Lono::Param::Generator.new("network",
|
6
|
+
path: path,
|
7
|
+
mute: true,
|
8
|
+
)
|
9
|
+
json = param.generate
|
10
|
+
data = JSON.load(json)
|
11
|
+
param_value = data.first["ParameterValue"]
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
context "overlay params" do
|
15
|
+
it "should combine params" do
|
16
|
+
param_value = generate("overlay")
|
17
|
+
expect(param_value).to eq "2"
|
18
|
+
end
|
19
|
+
end
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
context "only base param" do
|
22
|
+
it "should generate prod param from base param" do
|
23
|
+
param_value = generate("baseonly")
|
24
|
+
expect(param_value).to eq "foo"
|
25
|
+
end
|
21
26
|
end
|
22
|
-
end
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
context "only env param" do
|
29
|
+
it "should generate prod param from env param" do
|
30
|
+
param_value = generate("envonly")
|
31
|
+
expect(param_value).to eq "bar"
|
32
|
+
end
|
28
33
|
end
|
29
34
|
end
|
30
35
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
# Load the variables defined in config/variables/* to make available the params/*.txt files
|
37
|
+
#
|
38
|
+
# Example:
|
39
|
+
#
|
40
|
+
# config/variables/base/variables.rb:
|
41
|
+
# @ami = "ami-base-main"
|
42
|
+
#
|
43
|
+
# params/base/example.txt:
|
44
|
+
# Ami=<%= @ami %>
|
45
|
+
#
|
46
|
+
context "shared variables access" do
|
47
|
+
it "should have access to shared variables" do
|
48
|
+
# quickest to write test by shelling out
|
49
|
+
out = execute("exe/lono generate")
|
50
|
+
text = IO.read("#{Lono.root}/output/params/example.json")
|
51
|
+
data = JSON.load(text)
|
52
|
+
param = data.select { |i| i["ParameterKey"] == "Ami" }.first
|
53
|
+
expect(param["ParameterValue"]).to eq "ami-base-main"
|
35
54
|
end
|
36
55
|
end
|
37
56
|
end
|
data/spec/lib/lono/param_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative "../../spec_helper"
|
2
|
-
|
3
1
|
describe Lono::Param do
|
4
2
|
before(:all) do
|
5
3
|
@args = ""
|
@@ -7,7 +5,7 @@ describe Lono::Param do
|
|
7
5
|
|
8
6
|
describe "lono param" do
|
9
7
|
it "generate" do
|
10
|
-
out = execute("
|
8
|
+
out = execute("exe/lono param generate #{@args}")
|
11
9
|
expect(out).to include("Generating")
|
12
10
|
end
|
13
11
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe Lono::Param::Generator do
|
2
|
+
let(:setting) do
|
3
|
+
setting = Lono::Setting.new(check_lono_project=false)
|
4
|
+
allow(setting).to receive(:data).and_return(data)
|
5
|
+
setting
|
6
|
+
end
|
7
|
+
context "simple string" do
|
8
|
+
let(:data) do
|
9
|
+
{
|
10
|
+
"s3_folder" => "s3-bucket/simple/string/example"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
it "should return simple string value" do
|
14
|
+
value = setting.s3_folder
|
15
|
+
expect(value).to eq "s3-bucket/simple/string/example"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "options hash" do
|
20
|
+
let(:data) do
|
21
|
+
{
|
22
|
+
"s3_folder" => {
|
23
|
+
"default" => "s3-bucket/default/path",
|
24
|
+
"aws_profile1" => "s3-bucket/aws_profile1/path",
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
it "should return default value when AWS_PROFILE not set" do
|
29
|
+
saved = ENV['AWS_PROFILE']
|
30
|
+
|
31
|
+
value = setting.s3_folder
|
32
|
+
expect(value).to eq "s3-bucket/default/path"
|
33
|
+
|
34
|
+
ENV['AWS_PROFILE'] = saved
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return AWS_PROFILE value when AWS_PROFILE set" do
|
38
|
+
saved = ENV['AWS_PROFILE']
|
39
|
+
ENV['AWS_PROFILE'] = "aws_profile1"
|
40
|
+
|
41
|
+
value = setting.s3_folder
|
42
|
+
expect(value).to eq "s3-bucket/aws_profile1/path"
|
43
|
+
|
44
|
+
ENV['AWS_PROFILE'] = saved
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|