lono 7.5.2 → 8.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/README.md +5 -15
- data/.cody/acceptance/bin/build.sh +52 -0
- data/.cody/acceptance/buildspec.yml +10 -0
- data/.cody/acceptance/project.rb +6 -0
- data/.cody/{role.rb → acceptance/role.rb} +0 -0
- data/.cody/shared/script/install/lono.sh +40 -0
- data/.cody/shared/script/install.sh +5 -0
- data/CHANGELOG.md +21 -4
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +5 -1
- data/LICENSE.txt +201 -1
- data/README.md +4 -4
- data/lib/lono/api/client.rb +3 -2
- data/lib/lono/app/inits.rb +13 -0
- data/lib/lono/app.rb +71 -0
- data/lib/lono/app_file/base.rb +1 -1
- data/lib/lono/app_file/build/lambda_layer/ruby_packager.rb +9 -9
- data/lib/lono/app_file/build/lambda_layer.rb +3 -3
- data/lib/lono/app_file/build.rb +9 -14
- data/lib/lono/app_file/registry/item.rb +4 -4
- data/lib/lono/app_file/upload.rb +1 -1
- data/lib/lono/autoloader.rb +2 -2
- data/lib/lono/aws_services/helper.rb +43 -6
- data/lib/lono/aws_services.rb +37 -6
- data/lib/lono/blueprint.rb +18 -9
- data/lib/lono/booter.rb +28 -0
- data/lib/lono/{template → builder}/context/helpers.rb +1 -1
- data/lib/lono/{template → builder}/context/loader/load_files.rb +5 -6
- data/lib/lono/builder/context/loader.rb +35 -0
- data/lib/lono/builder/context/params.rb +7 -0
- data/lib/lono/{template → builder}/context/ssm_fetcher.rb +1 -1
- data/lib/lono/{template → builder}/context.rb +5 -9
- data/lib/lono/{param/generator.rb → builder/param.rb} +21 -22
- data/lib/lono/builder/template/aws_service.rb +15 -0
- data/lib/lono/builder/template/bashify.rb +43 -0
- data/lib/lono/{template → builder/template}/configset_injector.rb +4 -4
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/fn.rb +2 -2
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/core_helper.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/ec2_helper.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/file_helper.rb +8 -12
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/s3_helper.rb +2 -2
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/stack_helper.rb +11 -8
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers/tags_helper.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/helpers.rb +2 -2
- data/lib/lono/builder/template/dsl/evaluator/section/base.rb +23 -0
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/condition.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/mapping.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/methods.rb +7 -7
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/output.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/parameter.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/resource/property_mover.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/resource.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/section/section.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/squeezer.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/stringify.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax/extend_with.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax/parameter_group.rb +1 -1
- data/lib/lono/{template/strategy/dsl/builder → builder/template/dsl/evaluator}/syntax.rb +3 -3
- data/lib/lono/builder/template/dsl/evaluator.rb +45 -0
- data/lib/lono/{template/strategy → builder/template}/dsl/finalizer/parameter_groups.rb +2 -2
- data/lib/lono/{template/strategy → builder/template}/dsl/finalizer.rb +1 -1
- data/lib/lono/builder/template/dsl.rb +14 -0
- data/lib/lono/{template → builder/template}/evaluate.rb +18 -6
- data/lib/lono/builder/template/helpers.rb +149 -0
- data/lib/lono/{output/template.rb → builder/template/output.rb} +14 -7
- data/lib/lono/{template → builder/template}/post_processor.rb +4 -4
- data/lib/lono/{template → builder/template}/upload.rb +3 -5
- data/lib/lono/builder/template.rb +55 -0
- data/lib/lono/bundler/cli/base.rb +10 -0
- data/lib/lono/bundler/cli/bundle.rb +44 -0
- data/lib/lono/bundler/cli/clean.rb +27 -0
- data/lib/lono/bundler/cli/help/bundle.md +3 -0
- data/lib/lono/bundler/cli/help.rb +11 -0
- data/lib/lono/bundler/cli.rb +7 -0
- data/lib/lono/bundler/component/concerns/local_concern.rb +10 -0
- data/lib/lono/bundler/component/concerns/notation_concern.rb +59 -0
- data/lib/lono/bundler/component/concerns/path_concern.rb +68 -0
- data/lib/lono/bundler/component/concerns/stack_concern.rb +60 -0
- data/lib/lono/bundler/component/fetcher/base.rb +27 -0
- data/lib/lono/bundler/component/fetcher/gcs.rb +69 -0
- data/lib/lono/bundler/component/fetcher/git.rb +69 -0
- data/lib/lono/bundler/component/fetcher/local.rb +15 -0
- data/lib/lono/bundler/component/fetcher/s3.rb +66 -0
- data/lib/lono/bundler/component/fetcher.rb +18 -0
- data/lib/lono/bundler/component/http/concern.rb +45 -0
- data/lib/lono/bundler/component/http/source.rb +19 -0
- data/lib/lono/bundler/component/org_repo.rb +65 -0
- data/lib/lono/bundler/component/props/extension.rb +19 -0
- data/lib/lono/bundler/component/props/typer.rb +41 -0
- data/lib/lono/bundler/component/props.rb +122 -0
- data/lib/lono/bundler/component/registry.rb +136 -0
- data/lib/lono/bundler/component.rb +52 -0
- data/lib/lono/bundler/config.rb +18 -0
- data/lib/lono/bundler/dsl/syntax.rb +46 -0
- data/lib/lono/bundler/dsl.rb +21 -0
- data/lib/lono/bundler/exporter/base.rb +6 -0
- data/lib/lono/bundler/exporter/copy.rb +22 -0
- data/lib/lono/bundler/exporter.rb +50 -0
- data/lib/lono/bundler/extract/tar.rb +34 -0
- data/lib/lono/bundler/extract/zip.rb +16 -0
- data/lib/lono/bundler/info.rb +39 -0
- data/lib/lono/bundler/list.rb +26 -0
- data/lib/lono/bundler/lockfile/version_comparer.rb +56 -0
- data/lib/lono/bundler/lockfile/yamler.rb +36 -0
- data/lib/lono/bundler/lockfile.rb +66 -0
- data/lib/lono/bundler/lonofile.rb +32 -0
- data/lib/lono/bundler/runner.rb +27 -0
- data/lib/lono/bundler/syncer.rb +70 -0
- data/lib/lono/bundler/util/git.rb +37 -0
- data/lib/lono/bundler/util/logging.rb +7 -0
- data/lib/lono/bundler/util/sure.rb +5 -0
- data/lib/lono/{bundle.rb → bundler.rb} +38 -4
- data/lib/lono/cfn/base.rb +9 -195
- data/lib/lono/cfn/cancel.rb +9 -26
- data/lib/lono/cfn/concerns/build.rb +10 -0
- data/lib/lono/cfn/concerns/template_output.rb +10 -0
- data/lib/lono/cfn/concerns.rb +43 -0
- data/lib/lono/cfn/delete.rb +8 -32
- data/lib/lono/cfn/deploy/base.rb +4 -0
- data/lib/lono/cfn/deploy/iam.rb +49 -0
- data/lib/lono/cfn/deploy/notification.rb +8 -0
- data/lib/lono/cfn/deploy/operable.rb +18 -0
- data/lib/lono/cfn/deploy/opts.rb +49 -0
- data/lib/lono/cfn/deploy/rollback.rb +46 -0
- data/lib/lono/cfn/deploy/tags.rb +18 -0
- data/lib/lono/cfn/deploy.rb +71 -5
- data/lib/lono/cfn/download.rb +5 -7
- data/lib/lono/cfn/output.rb +49 -0
- data/lib/lono/cfn/plan/base.rb +19 -0
- data/lib/lono/cfn/plan/changeset/base.rb +19 -0
- data/lib/lono/cfn/plan/changeset/notifications.rb +24 -0
- data/lib/lono/cfn/plan/changeset/outputs.rb +25 -0
- data/lib/lono/cfn/plan/changeset/resources.rb +48 -0
- data/lib/lono/cfn/plan/changeset/tags.rb +16 -0
- data/lib/lono/cfn/plan/changeset.rb +136 -0
- data/lib/lono/cfn/plan/concerns.rb +10 -0
- data/lib/lono/cfn/plan/delete.rb +16 -0
- data/lib/lono/cfn/plan/diff/base.rb +10 -0
- data/lib/lono/cfn/plan/diff/data.rb +52 -0
- data/lib/lono/cfn/plan/diff/file.rb +56 -0
- data/lib/lono/cfn/plan/new.rb +26 -0
- data/lib/lono/cfn/{preview → plan}/param.rb +26 -34
- data/lib/lono/cfn/plan/summary.rb +16 -0
- data/lib/lono/cfn/plan/template.rb +28 -0
- data/lib/lono/cfn/plan.rb +33 -0
- data/lib/lono/cfn/show.rb +30 -0
- data/lib/lono/cfn/status.rb +1 -1
- data/lib/lono/cli/abstract.rb +17 -0
- data/lib/lono/cli/base.rb +9 -0
- data/lib/lono/cli/build.rb +101 -0
- data/lib/lono/cli/bundle.rb +21 -0
- data/lib/lono/cli/cfn/opts.rb +59 -0
- data/lib/lono/cli/cfn.rb +19 -0
- data/lib/lono/cli/clean.rb +22 -0
- data/lib/lono/{code.rb → cli/code.rb} +2 -2
- data/lib/lono/{completion.rb → cli/completion.rb} +2 -2
- data/lib/lono/{help → cli/help}/blueprint/new.md +4 -4
- data/lib/lono/{help/generate.md → cli/help/build.md} +6 -6
- data/lib/lono/{help → cli/help}/cfn/cancel.md +0 -0
- data/lib/lono/cli/help/cfn/download.md +3 -0
- data/lib/lono/{help → cli/help}/cfn/preview.md +9 -8
- data/lib/lono/{help → cli/help}/cfn/status.md +0 -0
- data/lib/lono/cli/help/cfn.md +4 -0
- data/lib/lono/{help → cli/help}/code/convert.md +0 -0
- data/lib/lono/{help → cli/help}/code/import.md +2 -2
- data/lib/lono/{help → cli/help}/completion.md +3 -3
- data/lib/lono/{help → cli/help}/completion_script.md +0 -0
- data/lib/lono/{help → cli/help}/configsets.md +0 -0
- data/lib/lono/cli/help/down.md +13 -0
- data/lib/lono/cli/help/new/project.md +34 -0
- data/lib/lono/{help → cli/help}/param/generate.md +0 -0
- data/lib/lono/cli/help/param.md +6 -0
- data/lib/lono/{help → cli/help}/pro/blueprints.md +0 -0
- data/lib/lono/{help → cli/help}/pro/configsets.md +0 -0
- data/lib/lono/{help → cli/help}/script/build.md +0 -0
- data/lib/lono/{help → cli/help}/script/upload.md +0 -0
- data/lib/lono/{help → cli/help}/seed.md +2 -2
- data/lib/lono/cli/help/summary.md +33 -0
- data/lib/lono/{help → cli/help}/template/bashify.md +0 -0
- data/lib/lono/cli/help/template/generate.md +7 -0
- data/lib/lono/{help → cli/help}/template.md +0 -0
- data/lib/lono/cli/help/up.md +30 -0
- data/lib/lono/{help → cli/help}/user_data.md +3 -3
- data/lib/lono/cli/help.rb +56 -0
- data/lib/lono/cli/list.rb +28 -0
- data/lib/lono/cli/new/blueprint.rb +33 -0
- data/lib/lono/cli/new/concerns.rb +16 -0
- data/lib/lono/{configset/new.rb → cli/new/configset.rb} +2 -9
- data/lib/lono/{extension/new.rb → cli/new/extension.rb} +2 -10
- data/lib/lono/cli/new/helper.rb +32 -0
- data/lib/lono/cli/new/project.rb +77 -0
- data/lib/lono/cli/new/sequence.rb +51 -0
- data/lib/lono/cli/new/shim.rb +59 -0
- data/lib/lono/cli/new/test/blueprint.rb +23 -0
- data/lib/lono/cli/new/test/sequence.rb +10 -0
- data/lib/lono/cli/new/test.rb +8 -0
- data/lib/lono/cli/new.rb +31 -0
- data/lib/lono/{opts.rb → cli/opts.rb} +9 -12
- data/lib/lono/{s3.rb → cli/s3.rb} +9 -7
- data/lib/lono/cli/script/base.rb +5 -0
- data/lib/lono/cli/script/build.rb +72 -0
- data/lib/lono/cli/script/upload.rb +49 -0
- data/lib/lono/{script.rb → cli/script.rb} +2 -2
- data/lib/lono/cli/seed.rb +9 -0
- data/lib/lono/cli/test.rb +35 -0
- data/lib/lono/cli.rb +80 -109
- data/lib/lono/command.rb +27 -0
- data/lib/lono/configset/{generator.rb → builder.rb} +9 -7
- data/lib/lono/configset/combiner.rb +8 -6
- data/lib/lono/configset/evaluate_file.rb +1 -1
- data/lib/lono/configset/meta.rb +1 -1
- data/lib/lono/configset/s3_file/build.rb +5 -4
- data/lib/lono/configset/s3_file/item.rb +1 -1
- data/lib/lono/configset/s3_file/upload.rb +2 -2
- data/lib/lono/configset/strategy/base.rb +6 -6
- data/lib/lono/configset/strategy/helpers/dsl/core.rb +1 -1
- data/lib/lono/core.rb +25 -54
- data/lib/lono/extensions/dsl.rb +2 -5
- data/lib/lono/extensions/loader.rb +1 -12
- data/lib/lono/extensions.rb +2 -2
- data/lib/lono/importer/base.rb +5 -5
- data/lib/lono/importer/download.rb +7 -7
- data/lib/lono/importer/dsl.rb +3 -3
- data/lib/lono/importer/service/coder.rb +10 -10
- data/lib/lono/importer.rb +1 -10
- data/lib/lono/inspector/base.rb +7 -7
- data/lib/lono/inspector/summary.rb +19 -17
- data/lib/lono/layering/layer.rb +126 -0
- data/lib/lono/layering.rb +13 -55
- data/lib/lono/logger/formatter.rb +13 -0
- data/lib/lono/logger.rb +33 -0
- data/lib/lono/lookup.rb +12 -0
- data/lib/lono/names.rb +50 -0
- data/lib/lono/plugin/meta.rb +30 -0
- data/lib/lono/plugin/tester.rb +13 -0
- data/lib/lono/plugin.rb +10 -0
- data/lib/lono/s3/aws_setup.rb +4 -3
- data/lib/lono/s3/bucket.rb +19 -19
- data/lib/lono/s3/uploader.rb +10 -12
- data/lib/lono/script/base.rb +3 -3
- data/lib/lono/script/build.rb +11 -12
- data/lib/lono/script/upload.rb +7 -7
- data/lib/lono/{seed → seeder}/service_role.rb +1 -1
- data/lib/lono/{seed/base.rb → seeder.rb} +21 -36
- data/lib/lono/user_data.rb +8 -13
- data/lib/lono/utils/context.rb +15 -0
- data/lib/lono/utils/item/zip.rb +5 -5
- data/lib/lono/utils/logging.rb +7 -0
- data/lib/lono/utils/{pretty_time.rb → pretty.rb} +6 -2
- data/lib/lono/utils/quit.rb +7 -0
- data/lib/lono/utils/rsync.rb +4 -2
- data/lib/lono/utils/sure.rb +4 -4
- data/lib/lono/version.rb +1 -1
- data/lib/lono.rb +7 -12
- data/lib/templates/blueprint/template.rb +2 -0
- data/lib/templates/configset/{lib/configset.rb → configset.rb} +0 -0
- data/lib/templates/examples/blueprint/template.rb +9 -0
- data/lib/templates/helper/%underscore_name%_helper.rb.tt +6 -0
- data/lib/templates/{skeleton → project}/.gitignore +1 -2
- data/lib/templates/project/Gemfile.tt +11 -0
- data/lib/templates/project/README.md +9 -0
- data/lib/templates/project/config/app.rb +3 -0
- data/lib/templates/shim/lono +7 -0
- data/lono.gemspec +51 -44
- metadata +246 -269
- data/.circleci/README.md +0 -3
- data/.circleci/config.yml +0 -58
- data/.cody/acceptance.sh +0 -49
- data/.cody/buildspec.yml +0 -9
- data/.cody/demo.rb +0 -38
- data/.cody/project.rb +0 -6
- data/.gitmodules +0 -3
- data/lib/lono/abstract_base.rb +0 -25
- data/lib/lono/aws_services/stack.rb +0 -41
- data/lib/lono/aws_services/stack_set.rb +0 -41
- data/lib/lono/blueprint/configset/loader.rb +0 -7
- data/lib/lono/blueprint/helper.rb +0 -24
- data/lib/lono/blueprint/meta.rb +0 -30
- data/lib/lono/blueprint/new.rb +0 -127
- data/lib/lono/blueprint/root.rb +0 -25
- data/lib/lono/cfn/create.rb +0 -41
- data/lib/lono/cfn/opts.rb +0 -88
- data/lib/lono/cfn/preview/changeset.rb +0 -168
- data/lib/lono/cfn/preview/codediff.rb +0 -41
- data/lib/lono/cfn/preview/diff_viewer.rb +0 -23
- data/lib/lono/cfn/rollback.rb +0 -26
- data/lib/lono/cfn/update.rb +0 -71
- data/lib/lono/cfn.rb +0 -75
- data/lib/lono/clean.rb +0 -14
- data/lib/lono/configset/list.rb +0 -67
- data/lib/lono/configset/preparer.rb +0 -44
- data/lib/lono/configset/register/base.rb +0 -122
- data/lib/lono/configset/register/blueprint.rb +0 -16
- data/lib/lono/configset/register/dsl.rb +0 -14
- data/lib/lono/configset/register/project.rb +0 -13
- data/lib/lono/configset/resolver.rb +0 -47
- data/lib/lono/configset.rb +0 -16
- data/lib/lono/conventions.rb +0 -23
- data/lib/lono/core/config.rb +0 -22
- data/lib/lono/default/settings.yml +0 -21
- data/lib/lono/ext/bundler.rb +0 -7
- data/lib/lono/extension/helper.rb +0 -13
- data/lib/lono/extension/list.rb +0 -40
- data/lib/lono/extension.rb +0 -9
- data/lib/lono/extensions/preparer.rb +0 -26
- data/lib/lono/extensions/register.rb +0 -15
- data/lib/lono/file_uploader.rb +0 -21
- data/lib/lono/finder/base.rb +0 -152
- data/lib/lono/finder/blueprint/configset.rb +0 -17
- data/lib/lono/finder/blueprint.rb +0 -11
- data/lib/lono/finder/configset.rb +0 -11
- data/lib/lono/finder/extension.rb +0 -11
- data/lib/lono/generate.rb +0 -111
- data/lib/lono/help/cfn/create.md +0 -26
- data/lib/lono/help/cfn/delete.md +0 -13
- data/lib/lono/help/cfn/deploy.md +0 -21
- data/lib/lono/help/cfn/download.md +0 -3
- data/lib/lono/help/cfn/update.md +0 -49
- data/lib/lono/help/cfn.md +0 -7
- data/lib/lono/help/new.md +0 -57
- data/lib/lono/help/param.md +0 -6
- data/lib/lono/help/set_instances/delete.md +0 -21
- data/lib/lono/help/set_instances/deploy.md +0 -31
- data/lib/lono/help/set_instances/list.md +0 -14
- data/lib/lono/help/set_instances/status.md +0 -15
- data/lib/lono/help/set_instances/sync.md +0 -92
- data/lib/lono/help/sets/delete.md +0 -8
- data/lib/lono/help/sets/deploy.md +0 -76
- data/lib/lono/help/sets/status.md +0 -23
- data/lib/lono/help/summary.md +0 -33
- data/lib/lono/help/template/generate.md +0 -7
- data/lib/lono/help/upgrade.md +0 -1
- data/lib/lono/help/xgraph.md +0 -16
- data/lib/lono/help.rb +0 -15
- data/lib/lono/importer/erb.rb +0 -31
- data/lib/lono/inspector/graph.rb +0 -125
- data/lib/lono/jade/circular.rb +0 -26
- data/lib/lono/jade/materializer/final.rb +0 -10
- data/lib/lono/jade/materializer/gems_builder.rb +0 -81
- data/lib/lono/jade/materializer/source.rb +0 -54
- data/lib/lono/jade/materializer.rb +0 -15
- data/lib/lono/jade/registry.rb +0 -64
- data/lib/lono/jade.rb +0 -110
- data/lib/lono/jadespec.rb +0 -68
- data/lib/lono/new/helper.rb +0 -15
- data/lib/lono/new.rb +0 -95
- data/lib/lono/param.rb +0 -14
- data/lib/lono/pro/base.rb +0 -16
- data/lib/lono/pro/repo.rb +0 -28
- data/lib/lono/pro.rb +0 -15
- data/lib/lono/project_checker.rb +0 -35
- data/lib/lono/registration/base.rb +0 -37
- data/lib/lono/registration/check.rb +0 -15
- data/lib/lono/registration/temp.rb +0 -53
- data/lib/lono/registration/user.rb +0 -60
- data/lib/lono/seed.rb +0 -39
- data/lib/lono/sequence.rb +0 -35
- data/lib/lono/set_instances/base.rb +0 -30
- data/lib/lono/set_instances/changeable.rb +0 -53
- data/lib/lono/set_instances/create.rb +0 -7
- data/lib/lono/set_instances/delete.rb +0 -47
- data/lib/lono/set_instances/deploy.rb +0 -52
- data/lib/lono/set_instances/list.rb +0 -13
- data/lib/lono/set_instances/opts.rb +0 -37
- data/lib/lono/set_instances/status.rb +0 -12
- data/lib/lono/set_instances/sync.rb +0 -181
- data/lib/lono/set_instances/update.rb +0 -15
- data/lib/lono/set_instances.rb +0 -54
- data/lib/lono/sets/base.rb +0 -50
- data/lib/lono/sets/create.rb +0 -27
- data/lib/lono/sets/delete.rb +0 -43
- data/lib/lono/sets/deploy.rb +0 -11
- data/lib/lono/sets/list.rb +0 -35
- data/lib/lono/sets/opts.rb +0 -18
- data/lib/lono/sets/preview/codediff.rb +0 -35
- data/lib/lono/sets/preview/param.rb +0 -32
- data/lib/lono/sets/status/instance/base.rb +0 -120
- data/lib/lono/sets/status/instance/completed.rb +0 -35
- data/lib/lono/sets/status/instance/deleted.rb +0 -32
- data/lib/lono/sets/status/instance/show.rb +0 -7
- data/lib/lono/sets/status/instance.rb +0 -20
- data/lib/lono/sets/status/instances.rb +0 -136
- data/lib/lono/sets/status.rb +0 -128
- data/lib/lono/sets/summarize.rb +0 -22
- data/lib/lono/sets/time_spent.rb +0 -11
- data/lib/lono/sets/update.rb +0 -74
- data/lib/lono/sets/waiter.rb +0 -23
- data/lib/lono/sets.rb +0 -34
- data/lib/lono/setting.rb +0 -75
- data/lib/lono/template/aws_service.rb +0 -20
- data/lib/lono/template/bashify.rb +0 -39
- data/lib/lono/template/context/loader.rb +0 -52
- data/lib/lono/template/generator.rb +0 -23
- data/lib/lono/template/helper.rb +0 -152
- data/lib/lono/template/strategy/base.rb +0 -4
- data/lib/lono/template/strategy/common/helpers.rb +0 -44
- data/lib/lono/template/strategy/dsl/builder/section/base.rb +0 -30
- data/lib/lono/template/strategy/dsl/builder.rb +0 -59
- data/lib/lono/template/strategy/dsl.rb +0 -14
- data/lib/lono/template/strategy/erb.rb +0 -82
- data/lib/lono/template/strategy/source.rb +0 -8
- data/lib/lono/template/template.rb +0 -54
- data/lib/lono/template/util.rb +0 -8
- data/lib/lono/template.rb +0 -24
- data/lib/lono/upgrade.rb +0 -20
- data/lib/lono/utils/generators/tree.rb +0 -18
- data/lib/templates/blueprint/%blueprint_name%.gemspec.tt +0 -45
- data/lib/templates/blueprint/.gitignore +0 -11
- data/lib/templates/blueprint/CHANGELOG.md +0 -7
- data/lib/templates/blueprint/Gemfile +0 -4
- data/lib/templates/blueprint/README.md.tt +0 -33
- data/lib/templates/blueprint/Rakefile.tt +0 -9
- data/lib/templates/blueprint/seed/configs.rb +0 -28
- data/lib/templates/blueprint_types/dsl/app/templates/%blueprint_name%.rb +0 -36
- data/lib/templates/blueprint_types/dsl/app/user_data/bootstrap.sh +0 -2
- data/lib/templates/blueprint_types/erb/app/definitions/base.rb.tt +0 -1
- data/lib/templates/blueprint_types/erb/app/templates/%blueprint_name%.yml +0 -67
- data/lib/templates/configset/%configset_name%.gemspec.tt +0 -42
- data/lib/templates/configset/.gitignore +0 -10
- data/lib/templates/configset/CHANGELOG.md +0 -7
- data/lib/templates/configset/Gemfile +0 -4
- data/lib/templates/configset/README.md.tt +0 -3
- data/lib/templates/configset/Rakefile.tt +0 -9
- data/lib/templates/extension/%extension_name%.gemspec.tt +0 -46
- data/lib/templates/extension/.gitignore +0 -11
- data/lib/templates/extension/.rspec +0 -3
- data/lib/templates/extension/CHANGELOG.md +0 -7
- data/lib/templates/extension/Gemfile.tt +0 -4
- data/lib/templates/extension/Rakefile.tt +0 -9
- data/lib/templates/extension/spec/spec_helper.rb.tt +0 -29
- data/lib/templates/skeleton/Gemfile +0 -3
- data/lib/templates/skeleton/README.md +0 -58
- data/lib/templates/skeleton/configs/settings.yml +0 -13
- data/vendor/cfn-status/CHANGELOG.md +0 -14
- data/vendor/cfn-status/Gemfile +0 -4
- data/vendor/cfn-status/Gemfile.lock +0 -49
- data/vendor/cfn-status/LICENSE.txt +0 -21
- data/vendor/cfn-status/README.md +0 -58
- data/vendor/cfn-status/Rakefile +0 -6
- data/vendor/cfn-status/bin/console +0 -14
- data/vendor/cfn-status/bin/setup +0 -8
- data/vendor/cfn-status/cfn-status.gemspec +0 -30
- data/vendor/cfn-status/lib/cfn-status.rb +0 -1
- data/vendor/cfn-status/lib/cfn_status/aws_service.rb +0 -51
- data/vendor/cfn-status/lib/cfn_status/version.rb +0 -3
- data/vendor/cfn-status/lib/cfn_status.rb +0 -245
- data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-1.json +0 -1103
- data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-2.json +0 -1104
- data/vendor/cfn-status/spec/fixtures/cfn/pages/fresh/describe_stack_events-3.json +0 -1103
- data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-1.json +0 -1103
- data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-2.json +0 -1104
- data/vendor/cfn-status/spec/fixtures/cfn/pages/updating/describe_stack_events-3.json +0 -1103
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-complete.json +0 -1080
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-in-progress.json +0 -1080
- data/vendor/cfn-status/spec/fixtures/cfn/stack-events-update-rollback-complete.json +0 -1086
- data/vendor/cfn-status/spec/lib/cfn_status_spec.rb +0 -153
- data/vendor/cfn-status/spec/spec_helper.rb +0 -14
@@ -0,0 +1,49 @@
|
|
1
|
+
module Lono::Cfn
|
2
|
+
class Output < Base
|
3
|
+
def run
|
4
|
+
stack = find_stack(@stack)
|
5
|
+
unless stack
|
6
|
+
logger.info "ERROR: stack #{@stack} not found".color(:red)
|
7
|
+
quit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
outputs = stack.outputs.map(&:to_h)
|
11
|
+
logger.info <<~EOL
|
12
|
+
#{"Outputs:".color(:green)}
|
13
|
+
|
14
|
+
EOL
|
15
|
+
if outputs.empty?
|
16
|
+
logger.stdout outputs.inspect
|
17
|
+
else
|
18
|
+
logger.stdout pretty(outputs)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
# Input:
|
24
|
+
#
|
25
|
+
# [{
|
26
|
+
# output_key: "SecurityGroup",
|
27
|
+
# output_value: "demo-dev-SecurityGroup-142DZFIEG3G9L"
|
28
|
+
# }]
|
29
|
+
#
|
30
|
+
# Output:
|
31
|
+
#
|
32
|
+
# { "SecurityGroup" => "demo-dev-SecurityGroup-142DZFIEG3G9L" }
|
33
|
+
#
|
34
|
+
def pretty(outputs)
|
35
|
+
outs = outputs.inject({}) do |result,h|
|
36
|
+
result.merge!(h[:output_key] => h[:output_value])
|
37
|
+
end
|
38
|
+
default = {format: "equal"}
|
39
|
+
options = default.merge(@options.symbolize_keys)
|
40
|
+
presenter = CliFormat::Presenter.new(options)
|
41
|
+
presenter.header = ["Key", "Value"] unless presenter.format == "equal"
|
42
|
+
outs.keys.sort.each do |k|
|
43
|
+
row = [k,outs[k]]
|
44
|
+
presenter.rows << row
|
45
|
+
end
|
46
|
+
presenter.show
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class Base < Lono::Cfn::Base
|
3
|
+
def initialize(options={})
|
4
|
+
super
|
5
|
+
# Allow build and iam to be passed from Cfn::Deploy. Reasons:
|
6
|
+
#
|
7
|
+
# 1. build.all only needs to be called once.
|
8
|
+
# 2. iam.capabilities can be adjusted with retry
|
9
|
+
# 3. objects are passed in a clear single direction.
|
10
|
+
#
|
11
|
+
# However, for CLI commands like `lono plan`, no objects are passed.
|
12
|
+
# In this case, new instances are created. In both cases the same options
|
13
|
+
# to the build and iam instances are used.
|
14
|
+
#
|
15
|
+
@build = options[:build] || build
|
16
|
+
@iam = options[:iam] || iam
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Lono::Cfn::Plan::Changeset
|
2
|
+
class Base
|
3
|
+
extend Memoist
|
4
|
+
include Lono::AwsServices
|
5
|
+
include Lono::Utils::Logging
|
6
|
+
include Lono::Cfn::Concerns::TemplateOutput
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
@blueprint = options[:blueprint]
|
10
|
+
@change_set = options[:change_set]
|
11
|
+
@stack = options[:stack]
|
12
|
+
end
|
13
|
+
|
14
|
+
def stack
|
15
|
+
find_stack(@stack)
|
16
|
+
end
|
17
|
+
memoize :stack
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Lono::Cfn::Plan::Changeset
|
2
|
+
class Notifications < Base
|
3
|
+
def changes
|
4
|
+
old = stack.notification_arns
|
5
|
+
new = @change_set.notification_arns
|
6
|
+
added = new - old
|
7
|
+
removed = old - new
|
8
|
+
return if added.empty? && removed.empty?
|
9
|
+
|
10
|
+
logger.info "Changes to notifications"
|
11
|
+
log = Proc.new do |k|
|
12
|
+
logger.info " #{k}"
|
13
|
+
end
|
14
|
+
unless added.empty?
|
15
|
+
logger.info "Added:"
|
16
|
+
added.each(&log)
|
17
|
+
end
|
18
|
+
unless removed.empty?
|
19
|
+
logger.info "Removed:"
|
20
|
+
removed.each(&log)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Lono::Cfn::Plan::Changeset
|
2
|
+
class Outputs < Base
|
3
|
+
# Not enough info to show value changes. Show whats possible: Added and Removed keys
|
4
|
+
def changes
|
5
|
+
old_keys = stack.outputs.map { |output| output[:output_key] }
|
6
|
+
new_keys = template_output.outputs.map { |k,_| k }
|
7
|
+
added_keys = new_keys - old_keys
|
8
|
+
removed_keys = old_keys - new_keys
|
9
|
+
return if added_keys.empty? && removed_keys.empty?
|
10
|
+
|
11
|
+
logger.info "Changes to outputs"
|
12
|
+
log = Proc.new do |k|
|
13
|
+
logger.info " #{k}"
|
14
|
+
end
|
15
|
+
unless added_keys.empty?
|
16
|
+
logger.info "Added:"
|
17
|
+
added_keys.each(&log)
|
18
|
+
end
|
19
|
+
unless removed_keys.empty?
|
20
|
+
logger.info "Removed:"
|
21
|
+
removed_keys.each(&log)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Lono::Cfn::Plan::Changeset
|
2
|
+
class Resources < Base
|
3
|
+
def changes
|
4
|
+
return if @change_set.changes.empty?
|
5
|
+
logger.info "Resource Changes"
|
6
|
+
changes = @change_set.changes.sort_by do |change|
|
7
|
+
change["resource_change"]["action"]
|
8
|
+
end
|
9
|
+
changes.each do |change|
|
10
|
+
display_change(change)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Private: formats a Aws::CloudFormation::Types::Change in pretty human readable form
|
15
|
+
#
|
16
|
+
# change - Aws::CloudFormation::Types::Change
|
17
|
+
#
|
18
|
+
# Examples
|
19
|
+
#
|
20
|
+
# display_change(change)
|
21
|
+
# => Remove AWS::Route53::RecordSet: DnsRecord testsubdomain.sub.tongueroo.com
|
22
|
+
#
|
23
|
+
# Returns nil
|
24
|
+
#
|
25
|
+
# change.to_h
|
26
|
+
# {:type=>"Resource",
|
27
|
+
# :resource_change=>
|
28
|
+
# {:action=>"Remove",
|
29
|
+
# :logical_resource_id=>"DnsRecord",
|
30
|
+
# :physical_resource_id=>"testsubdomain.sub.tongueroo.com",
|
31
|
+
# :resource_type=>"AWS::Route53::RecordSet",
|
32
|
+
# :scope=>[],
|
33
|
+
# :details=>[]}}
|
34
|
+
def display_change(change)
|
35
|
+
message = if change.type == "Resource"
|
36
|
+
c = change.resource_change
|
37
|
+
" #{c.action} #{c.resource_type}: #{c.logical_resource_id} #{c.physical_resource_id}"
|
38
|
+
else
|
39
|
+
change.to_h
|
40
|
+
end
|
41
|
+
|
42
|
+
colors = { Remove: :red, Add: :green, Modify: :yellow }
|
43
|
+
action = change.resource_change.action.to_sym
|
44
|
+
message = message.color(colors[action]) if colors.has_key?(action)
|
45
|
+
logger.info message
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Lono::Cfn::Plan::Changeset
|
2
|
+
class Tags < Base
|
3
|
+
def changes
|
4
|
+
old = simplify(stack.tags)
|
5
|
+
new = simplify(@change_set.tags)
|
6
|
+
diff = Lono::Cfn::Plan::Diff::Data.new(old, new)
|
7
|
+
diff.show("Tag Changes:")
|
8
|
+
end
|
9
|
+
|
10
|
+
def simplify(tags)
|
11
|
+
tags.inject({}) do |result, i|
|
12
|
+
result.merge(i.key => i.value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class Changeset < Base
|
3
|
+
# used by deploy to see whether or not to continue and bypass sure prompt
|
4
|
+
attr_reader :changed
|
5
|
+
alias_method :changed?, :changed
|
6
|
+
|
7
|
+
# Override run from Base superclass, the run method is different enough with Preview
|
8
|
+
def create
|
9
|
+
@build.all
|
10
|
+
@changed = false
|
11
|
+
logger.info "Change Set Changes:".color(:green) if Lono.config.diff.changeset
|
12
|
+
preview_change_set
|
13
|
+
logger.info "" # newline
|
14
|
+
end
|
15
|
+
|
16
|
+
def display_changes(change_set)
|
17
|
+
options = {change_set: change_set, blueprint: @blueprint, stack: @stack}
|
18
|
+
Tags.new(options).changes
|
19
|
+
Outputs.new(options).changes
|
20
|
+
Resources.new(options).changes
|
21
|
+
Notifications.new(options).changes
|
22
|
+
end
|
23
|
+
|
24
|
+
def preview_change_set
|
25
|
+
create_change_set
|
26
|
+
change_set = wait_for_change_set
|
27
|
+
@changed = change_set.status == "CREATE_COMPLETE"
|
28
|
+
handle_out(change_set)
|
29
|
+
display(change_set)
|
30
|
+
end
|
31
|
+
|
32
|
+
def wait_for_change_set
|
33
|
+
change_set = describe_change_set
|
34
|
+
newline_needed = false
|
35
|
+
until change_set_finished?(change_set) do
|
36
|
+
change_set = describe_change_set
|
37
|
+
sleep 1
|
38
|
+
unless newline_needed
|
39
|
+
logger.print "Determining Change Set"
|
40
|
+
end
|
41
|
+
newline_needed = true
|
42
|
+
logger.print '.'
|
43
|
+
end
|
44
|
+
logger.print "\n" if newline_needed
|
45
|
+
change_set
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_change_set
|
49
|
+
unless stack_exists?(@stack)
|
50
|
+
logger.info "WARN: Cannot create a change set for the stack because the #{@stack} does not exists.".color(:yellow)
|
51
|
+
return false
|
52
|
+
end
|
53
|
+
operable.check!
|
54
|
+
|
55
|
+
options = {
|
56
|
+
change_set_name: change_set_name,
|
57
|
+
stack_name: @stack,
|
58
|
+
parameters: @build.parameters,
|
59
|
+
}
|
60
|
+
|
61
|
+
opts = Lono::Cfn::Deploy::Opts.new(@blueprint, "create_change_set", @iam, options)
|
62
|
+
opts.show
|
63
|
+
options = opts.values
|
64
|
+
|
65
|
+
begin
|
66
|
+
# Tricky for preview need to set capabilities so that it gets updated. For Base#run save within the begin block already.
|
67
|
+
options[:capabilities] = iam.capabilities # ["CAPABILITY_IAM", "CAPABILITY_NAMED_IAM"]
|
68
|
+
resp = cfn.create_change_set(options)
|
69
|
+
rescue Aws::CloudFormation::Errors::InsufficientCapabilitiesException => e
|
70
|
+
# If coming from cfn_preview_command automatically add iam capabilities
|
71
|
+
cfn_preview_command = ARGV.join(" ").include?("cfn preview")
|
72
|
+
if cfn_preview_command
|
73
|
+
# e.message is "Requires capabilities : [CAPABILITY_IAM]"
|
74
|
+
# grab CAPABILITY_IAM with regexp
|
75
|
+
capabilities = e.message.match(/\[(.*)\]/)[1]
|
76
|
+
@options.merge!(capabilities: [capabilities])
|
77
|
+
retry
|
78
|
+
end
|
79
|
+
yes = iam.rerun?(e)
|
80
|
+
@options = iam.options
|
81
|
+
retry if yes
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def display(change_set)
|
86
|
+
return unless Lono.config.diff.changeset
|
87
|
+
case change_set.status
|
88
|
+
when "CREATE_COMPLETE"
|
89
|
+
display_changes(change_set)
|
90
|
+
when "FAILED"
|
91
|
+
logger.info "No changes"
|
92
|
+
logger.debug change_set.status_reason # The submitted information didn't contain changes. Submit different information to create a change set.
|
93
|
+
else
|
94
|
+
raise "hell: never come here"
|
95
|
+
end
|
96
|
+
change_set
|
97
|
+
end
|
98
|
+
|
99
|
+
def execute_change_set
|
100
|
+
return unless @changed
|
101
|
+
cfn.execute_change_set(
|
102
|
+
change_set_name: change_set_name,
|
103
|
+
stack_name: @stack
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
# generates a change set name
|
108
|
+
def change_set_name
|
109
|
+
@change_set_name ||= "changeset-#{Time.now.strftime("%Y%d%m%H%M%S")}"
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
def change_set_finished?(change_set)
|
114
|
+
change_set.status =~ /_COMPLETE/ || change_set.status == "FAILED"
|
115
|
+
end
|
116
|
+
|
117
|
+
def describe_change_set
|
118
|
+
cfn.describe_change_set(
|
119
|
+
change_set_name: change_set_name,
|
120
|
+
stack_name: @stack
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def handle_out(change_set)
|
125
|
+
out = @options[:out]
|
126
|
+
return unless out
|
127
|
+
logger.info "Change Set ARN: #{change_set.change_set_id}"
|
128
|
+
if change_set.status == "FAILED"
|
129
|
+
logger.info "Note: #{change_set.status_reason}"
|
130
|
+
end
|
131
|
+
logger.info "Change Set info saved to #{out}"
|
132
|
+
FileUtils.mkdir_p(File.dirname(out))
|
133
|
+
IO.write(out, JSON.pretty_generate(change_set.to_h))
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class Delete < Lono::Cfn::Base
|
3
|
+
include Concerns
|
4
|
+
|
5
|
+
def run
|
6
|
+
stack = find_stack(@stack)
|
7
|
+
unless stack
|
8
|
+
logger.info "ERROR: stack #{@stack} not found".color(:red)
|
9
|
+
quit 1
|
10
|
+
end
|
11
|
+
|
12
|
+
logger.info "Will delete".color(:green)
|
13
|
+
Lono::Cfn::Show.new(@options).print
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Lono::Cfn::Plan::Diff
|
2
|
+
class Data < Base
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
def initialize(old, new)
|
6
|
+
@old = old
|
7
|
+
@new = new
|
8
|
+
end
|
9
|
+
|
10
|
+
def show(header_message=nil)
|
11
|
+
changes = calculate
|
12
|
+
if !changes && header_message
|
13
|
+
return
|
14
|
+
end
|
15
|
+
logger.info header_message if header_message
|
16
|
+
|
17
|
+
unless @added_keys.empty?
|
18
|
+
logger.info "Added:"
|
19
|
+
@added_keys.each do |k|
|
20
|
+
logger.info " #{k}: #{@new[k]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
unless @removed_keys.empty?
|
24
|
+
logger.info "Removed:"
|
25
|
+
@removed_keys.each do |k|
|
26
|
+
logger.info " #{k}: #{@old[k]}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
unless @modified_keys.empty?
|
30
|
+
logger.info "Modified:"
|
31
|
+
@modified_keys.each do |k|
|
32
|
+
logger.info " #{k}: #{@old[k]} -> #{@new[k]}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
unless changes
|
37
|
+
logger.info "No changes"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def calculate
|
42
|
+
@added_keys = @new.keys - @old.keys
|
43
|
+
@removed_keys = @old.keys - @new.keys
|
44
|
+
all_keys = (@old.keys + @new.keys).uniq
|
45
|
+
kept_keys = all_keys - @added_keys - @removed_keys
|
46
|
+
@modified_keys = kept_keys.select { |k| @old[k] != @new[k] }
|
47
|
+
no_changes = @added_keys.empty? && @removed_keys.empty? && @modified_keys.empty?
|
48
|
+
!no_changes
|
49
|
+
end
|
50
|
+
memoize :calculate
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Lono::Cfn::Plan::Diff
|
2
|
+
class File < Base
|
3
|
+
def show(existing_path, new_path)
|
4
|
+
if @options[:mode] == true || @options[:mode] == "summary"
|
5
|
+
summary(existing_path, new_path)
|
6
|
+
else # full
|
7
|
+
full(existing_path, new_path)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def summary(existing_path, new_path)
|
12
|
+
command = "diff #{existing_path} #{new_path} -u -s"
|
13
|
+
pretty_command = "diff #{pretty_path(existing_path)} #{pretty_path(new_path)}"
|
14
|
+
logger.info "=> #{pretty_command}"
|
15
|
+
out = `#{command}`
|
16
|
+
lines = out.split("\n")
|
17
|
+
lines.reject! { |l| l =~ /^\+\+\+ / || l =~ /^--- / } # remove header lines
|
18
|
+
stats = lines.inject(Hash.new(0)) do |stats,line|
|
19
|
+
char = line[0] # first char will be - +
|
20
|
+
case char
|
21
|
+
when '+'
|
22
|
+
stats[:insertions] += 1
|
23
|
+
when '-'
|
24
|
+
stats[:deletions] += 1
|
25
|
+
end
|
26
|
+
stats
|
27
|
+
end
|
28
|
+
if stats.all? { |_,count| count == 0 }
|
29
|
+
logger.info "No changes"
|
30
|
+
else
|
31
|
+
logger.info " #{stats[:insertions]} insertions(+), #{stats[:deletions]} deletions(-)"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def full(existing_path, new_path)
|
36
|
+
command = "#{diff_viewer} #{existing_path} #{new_path}"
|
37
|
+
pretty_command = "#{diff_viewer} #{pretty_path(existing_path)} #{pretty_path(new_path)}"
|
38
|
+
logger.info "=> #{pretty_command}"
|
39
|
+
out = `#{command}`
|
40
|
+
if out.strip == ''
|
41
|
+
logger.info "No changes"
|
42
|
+
else
|
43
|
+
logger.info out
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def diff_viewer
|
48
|
+
return ENV['LONO_DIFF'] if ENV['LONO_DIFF']
|
49
|
+
colordiff_installed = system("type colordiff > /dev/null 2>&1")
|
50
|
+
unless colordiff_installed
|
51
|
+
logger.info "INFO: colordiff it not available. Recommend installing it."
|
52
|
+
end
|
53
|
+
colordiff_installed ? "colordiff" : "diff"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class New < Lono::Cfn::Base
|
3
|
+
include Concerns
|
4
|
+
|
5
|
+
def run
|
6
|
+
if resource_types.empty?
|
7
|
+
logger.info "ERROR: At least one Resource member must be defined in the template".color(:red)
|
8
|
+
quit 1
|
9
|
+
end
|
10
|
+
|
11
|
+
logger.info "Will create".color(:green)
|
12
|
+
summary.print(resource_types)
|
13
|
+
end
|
14
|
+
|
15
|
+
def resource_types
|
16
|
+
resources = template_output.resources
|
17
|
+
return {} unless resources
|
18
|
+
|
19
|
+
types = Hash.new(0)
|
20
|
+
resources.each do |logical_id, resource|
|
21
|
+
types[resource["Type"]] += 1
|
22
|
+
end
|
23
|
+
types
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,25 +1,14 @@
|
|
1
|
-
|
2
|
-
class Param <
|
3
|
-
delegate :required_parameters, :optional_parameters, :parameters, :data,
|
4
|
-
to: :output_template
|
5
|
-
|
6
|
-
include DiffViewer
|
7
|
-
include Lono::AwsServices
|
8
|
-
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class Param < Base
|
9
3
|
def run
|
10
|
-
return unless stack_exists?(@stack)
|
11
|
-
|
12
|
-
generated_parameters # eager call generated_parameters so its output is above Parameter Diff Preview
|
13
|
-
puts "Parameter Diff Preview:".color(:green)
|
14
|
-
if @options[:noop]
|
15
|
-
puts "NOOP CloudFormation parameters preview for #{@stack} update"
|
16
|
-
return
|
17
|
-
end
|
18
|
-
|
4
|
+
return unless Lono.config.diff.params && stack_exists?(@stack)
|
5
|
+
logger.info "Parameter Changes:".color(:green)
|
19
6
|
write_to_tmp(existing_path, existing_params)
|
20
7
|
write_to_tmp(new_path, new_params)
|
21
|
-
|
22
|
-
|
8
|
+
logger.debug "=> diff #{pretty_path(existing_path)} #{pretty_path(new_path)}"
|
9
|
+
diff = Diff::Data.new(json_load(existing_path), json_load(new_path))
|
10
|
+
diff.show
|
11
|
+
logger.info "" # newline
|
23
12
|
end
|
24
13
|
|
25
14
|
def existing_params
|
@@ -30,11 +19,21 @@ module Lono::Cfn::Preview
|
|
30
19
|
memoize :existing_params
|
31
20
|
|
32
21
|
def new_params
|
33
|
-
|
22
|
+
parameters = @build.parameters
|
23
|
+
params = normalize(parameters)
|
24
|
+
params = optional_params.merge(params)
|
25
|
+
params = replace_noecho_values!(params)
|
34
26
|
subtract(params, noecho_params)
|
35
27
|
end
|
36
28
|
|
37
|
-
|
29
|
+
def replace_noecho_values!(params)
|
30
|
+
template_output.parameters.each do |key, data|
|
31
|
+
params[key] = '**** (NoEcho)' if data['NoEcho'] # mimic noecho
|
32
|
+
end
|
33
|
+
params
|
34
|
+
end
|
35
|
+
|
36
|
+
# Remove existing items with the same key. The value can be different. This removes the noecho params.
|
38
37
|
def subtract(h1,h2)
|
39
38
|
hash = h1.reject do |k,v|
|
40
39
|
h2.keys.include?(k)
|
@@ -42,15 +41,9 @@ module Lono::Cfn::Preview
|
|
42
41
|
Hash[hash.sort_by {|k,v| k}]
|
43
42
|
end
|
44
43
|
|
45
|
-
def generated_parameters
|
46
|
-
parameters = generate_all
|
47
|
-
normalize(parameters)
|
48
|
-
end
|
49
|
-
memoize :generated_parameters
|
50
|
-
|
51
44
|
def optional_params
|
52
45
|
# normalizing to simple Hash
|
53
|
-
optional_parameters.inject({}) do |result,(k,v)|
|
46
|
+
template_output.optional_parameters.inject({}) do |result,(k,v)|
|
54
47
|
result.merge(k => v["Default"].to_s)
|
55
48
|
end
|
56
49
|
end
|
@@ -69,11 +62,6 @@ module Lono::Cfn::Preview
|
|
69
62
|
memoize :stack_parameters
|
70
63
|
|
71
64
|
private
|
72
|
-
def output_template
|
73
|
-
Lono::Output::Template.new(@blueprint, @template)
|
74
|
-
end
|
75
|
-
memoize :output_template
|
76
|
-
|
77
65
|
def write_to_tmp(path, hash)
|
78
66
|
text = JSON.pretty_generate(hash)
|
79
67
|
FileUtils.mkdir_p(File.dirname(path))
|
@@ -104,7 +92,11 @@ module Lono::Cfn::Preview
|
|
104
92
|
end
|
105
93
|
|
106
94
|
def tmp_base
|
107
|
-
"/tmp/lono/params
|
95
|
+
"/tmp/lono/diff/params"
|
96
|
+
end
|
97
|
+
|
98
|
+
def json_load(path)
|
99
|
+
JSON.load(IO.read(path))
|
108
100
|
end
|
109
101
|
end
|
110
102
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class Summary
|
3
|
+
include Lono::Utils::Logging
|
4
|
+
|
5
|
+
def print(resource_types)
|
6
|
+
types = resource_types.sort_by {|r| r[0]} # Hash -> 2D Array
|
7
|
+
types.each do |a|
|
8
|
+
type, count = a
|
9
|
+
logger.info "%3s %s" % [count, type]
|
10
|
+
end
|
11
|
+
total = types.inject(0) { |sum,(type,count)| sum += count }
|
12
|
+
logger.info "%3s %s" % [total, "Total"]
|
13
|
+
logger.info "" # newline
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Lono::Cfn::Plan
|
2
|
+
class Template < Base
|
3
|
+
def run
|
4
|
+
return unless Lono.config.diff.template
|
5
|
+
@build.all
|
6
|
+
logger.info "Template Changes:".color(:green)
|
7
|
+
download_existing_cfn_template
|
8
|
+
diff = Diff::File.new(mode: Lono.config.diff.template)
|
9
|
+
diff.show(existing_template_path, new_cfn_template)
|
10
|
+
logger.info "" # newline
|
11
|
+
end
|
12
|
+
|
13
|
+
def download_existing_cfn_template
|
14
|
+
resp = cfn.get_template(stack_name: @stack, template_stage: "Original")
|
15
|
+
FileUtils.mkdir_p(File.dirname(existing_template_path))
|
16
|
+
IO.write(existing_template_path, resp.template_body)
|
17
|
+
end
|
18
|
+
|
19
|
+
# for clarity
|
20
|
+
def new_cfn_template
|
21
|
+
@blueprint.output_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def existing_template_path
|
25
|
+
"/tmp/lono/diff/template/existing.yml"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|