From a70238d42ee3a7263911844534c3ed6414f1d203 Mon Sep 17 00:00:00 2001 From: Michael Bloch Date: Fri, 28 Jul 2023 11:46:20 +1000 Subject: [PATCH] [RS-160] Add Orchestrator Preview app props --- .gitignore | 1 + CHANGELOG.md | 2 + Gemfile | 15 +- Gemfile.lock | 235 +++++++++++--------- manifests/application_properties.pp | 37 ++- requirements.txt | 1 + spec/classes/application_properties_spec.rb | 32 +++ templates/application_properties.erb | 24 ++ tools/parse_application_properties | 181 +++++++-------- 9 files changed, 313 insertions(+), 215 deletions(-) diff --git a/.gitignore b/.gitignore index 8a8b4a3..2934c7c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ junit/ *.iml .*.sw .yardoc +core diff --git a/CHANGELOG.md b/CHANGELOG.md index 69eded2..926cdd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added new application property parameter `aem_client_api_verifyssl` +- Added new application property parameters for AEM Preview components ### Changed - Replace Maven Central base URL from http://central.maven.org to https://repo.maven.apache.org +- Migrated python tool to Python3 ## [1.4.1] - 2019-05-19 ### Changed diff --git a/Gemfile b/Gemfile index 8d47a9e..aa85991 100644 --- a/Gemfile +++ b/Gemfile @@ -11,11 +11,12 @@ def location_for(place, fake_version = nil) end group :test do - gem 'puppetlabs_spec_helper', :require => false + gem 'puppet', '~> 7.18', :require => false + gem 'puppetlabs_spec_helper', '4.0.1', :require => false # gem 'rspec-puppet', :require => false, :git => 'https://github.com/rodjek/rspec-puppet.git' # gem 'rspec-puppet-facts', :require => false # gem 'rspec-puppet-utils', :require => false - gem 'puppet-lint', :require => false + gem 'puppet-lint', '2.5.2', :require => false gem 'puppet-lint-param-docs', :require => false gem 'puppet-lint-strict_indent-check', :require => false gem 'puppet-lint-absolute_classname-check', :require => false @@ -30,16 +31,16 @@ group :test do gem 'puppet-lint-duplicate_class_parameters-check', :require => false gem 'metadata-json-lint', :require => false gem 'puppet-blacksmith', :require => false - gem 'voxpupuli-release', :require => false, :git => 'https://github.com/voxpupuli/voxpupuli-release-gem.git' + gem 'voxpupuli-release', '2.0.0', :require => false gem 'json_pure', '<= 2.0.1', :require => false if RUBY_VERSION < '2.0.0' gem 'semantic_puppet', :require => false end group :development do - gem 'travis', :require => false - gem 'travis-lint', :require => false - gem 'guard-rake', :require => false - gem 'puppet-strings', :require => false + gem 'travis', :require => false + gem 'travis-lint', :require => false + gem 'guard-rake', :require => false + gem 'puppet-strings', :require => false end # # group :system_tests do diff --git a/Gemfile.lock b/Gemfile.lock index f72ad35..17e97a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,38 +1,50 @@ -GIT - remote: https://github.com/voxpupuli/voxpupuli-release-gem.git - revision: aa12bdde4cc033152233ad818ef90afb812ef377 - specs: - voxpupuli-release (1.0.1) - puppet-blacksmith (>= 4.0.0) - rake - GEM remote: https://rubygems.org/ specs: - activesupport (5.2.4.4) + activesupport (5.2.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.7.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.4) + public_suffix (>= 2.0.2, < 6.0) coderay (1.1.3) - concurrent-ruby (1.1.7) - deep_merge (1.2.1) - diff-lcs (1.4.4) + concurrent-ruby (1.2.2) + deep_merge (1.2.2) + diff-lcs (1.5.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - facter (4.0.46) + facter (4.4.1) hocon (~> 1.3) thor (>= 1.0.1, < 2.0) - faraday (1.1.0) - multipart-post (>= 1.2, < 3) - ruby2_keywords - faraday_middleware (1.0.0) + faraday (1.10.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.2.0) faraday (~> 1.0) - fast_gettext (1.8.0) - ffi (1.13.1) - formatador (0.2.5) + fast_gettext (2.3.0) + ffi (1.15.5) + formatador (1.1.0) gh (0.18.0) activesupport (~> 5.0) addressable (~> 2.4) @@ -41,50 +53,49 @@ GEM multi_json (~> 1.0) net-http-persistent (~> 2.9) net-http-pipeline - guard (2.16.2) + guard (2.18.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) - pry (>= 0.9.12) + pry (>= 0.13.0) shellany (~> 0.0) thor (>= 0.18.1) guard-rake (1.0.0) guard rake - hiera (3.6.0) - highline (2.0.3) - hocon (1.3.1) + hiera (3.12.0) + highline (2.1.0) + hocon (1.4.0) http-accept (1.7.0) - http-cookie (1.0.3) + http-cookie (1.0.5) domain_name (~> 0.5) - httpclient (2.8.3) - i18n (1.8.5) + i18n (1.14.1) concurrent-ruby (~> 1.0) - json (2.3.1) - json-schema (2.8.1) - addressable (>= 2.4) - json_pure (2.3.1) + json (2.6.3) + json-schema (4.0.0) + addressable (>= 2.8) + json_pure (2.6.3) launchy (2.4.3) addressable (~> 2.3) - listen (3.3.3) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.3) lumberjack (1.2.8) - metadata-json-lint (3.0.0) - json-schema (~> 2.8) + metadata-json-lint (3.0.3) + json-schema (>= 2.8, < 5.0) spdx-licenses (~> 1.0) method_source (1.0.0) - mime-types (3.3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2020.1104) + mime-types-data (3.2023.0218.1) minitar (0.9) - minitest (5.14.2) - mocha (1.11.2) + minitest (5.18.1) + mocha (1.16.1) multi_json (1.15.0) - multipart-post (2.1.1) + multipart-post (2.3.0) nenv (0.3.0) net-http-persistent (2.9.4) net-http-pipeline (1.0.1) @@ -92,72 +103,72 @@ GEM notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - pathspec (0.2.1) - pry (0.13.1) + pathspec (1.0.0) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (4.0.6) - puppet (6.19.1) + public_suffix (5.0.3) + puppet (7.25.0) concurrent-ruby (~> 1.0) deep_merge (~> 1.0) facter (> 2.0.1, < 5) - fast_gettext (~> 1.1) + fast_gettext (>= 1.1, < 3) hiera (>= 3.2.1, < 4) - httpclient (~> 2.8) locale (~> 2.1) multi_json (~> 1.10) puppet-resource_api (~> 1.5) + scanf (~> 1.0) semantic_puppet (~> 1.0) - puppet-blacksmith (6.1.0) - puppet-modulebuilder (~> 0.2) + puppet-blacksmith (7.0.0) + puppet-modulebuilder (~> 1.0) rest-client (~> 2.0) - puppet-lint (2.4.2) - puppet-lint-absolute_classname-check (3.0.0) - puppet-lint (>= 1.0, < 3.0) - puppet-lint-classes_and_types_beginning_with_digits-check (0.1.2) + puppet-lint (2.5.2) + puppet-lint-absolute_classname-check (3.1.0) + puppet-lint (>= 1.0, < 4) + puppet-lint-classes_and_types_beginning_with_digits-check (1.0.0) puppet-lint (>= 1.0, < 3.0) puppet-lint-duplicate_class_parameters-check (1.0.5) puppet-lint (>= 1.1, < 3.0) - puppet-lint-leading_zero-check (0.1.1) - puppet-lint (>= 1.0, < 3.0) + puppet-lint-leading_zero-check (1.1.0) + puppet-lint (>= 1.0, < 4.0) puppet-lint-legacy_facts-check (1.0.4) puppet-lint (~> 2.4) - puppet-lint-param-docs (1.6.0) - puppet-lint (>= 1.1, < 3.0) - puppet-lint-resource_reference_syntax (1.1.0) - puppet-lint (>= 1.0, < 3.0) - puppet-lint-strict_indent-check (2.0.7) - puppet-lint (> 1.0) - puppet-lint-trailing_comma-check (0.4.2) - puppet-lint (>= 1.0, < 3.0) - puppet-lint-unquoted_string-check (2.0.0) - puppet-lint (>= 2.1, < 3.0) - puppet-lint-variable_contains_upcase (1.2.0) - puppet-lint (>= 1.0, < 3.0) - puppet-lint-version_comparison-check (0.2.1) - puppet-lint (>= 1.0, < 3.0) - puppet-modulebuilder (0.2.1) - minitar (~> 0.6) - pathspec (~> 0.2.1) - puppet-resource_api (1.8.13) + puppet-lint-param-docs (1.7.6) + puppet-lint (>= 1.1, < 4.0) + puppet-lint-resource_reference_syntax (1.2.0) + puppet-lint (>= 1.0, < 4) + puppet-lint-strict_indent-check (2.1.0) + puppet-lint (>= 1.0, < 4) + puppet-lint-trailing_comma-check (1.0.0) + puppet-lint (>= 1.0, < 4) + puppet-lint-unquoted_string-check (2.2.0) + puppet-lint (>= 2.1, < 4) + puppet-lint-variable_contains_upcase (1.4.0) + puppet-lint (>= 1.0, < 5) + puppet-lint-version_comparison-check (1.1.0) + puppet-lint (>= 1.0, < 4) + puppet-modulebuilder (1.0.0) + minitar (~> 0.9) + pathspec (>= 0.2.1, < 2.0.0) + puppet-resource_api (1.8.14) hocon (>= 1.0) - puppet-strings (2.5.0) - rgen - yard (~> 0.9.5) - puppet-syntax (3.1.0) + puppet-strings (4.1.0) + rgen (~> 0.9) + yard (~> 0.9) + puppet-syntax (3.3.0) puppet (>= 5) rake - puppetlabs_spec_helper (2.15.0) + puppetlabs_spec_helper (4.0.1) mocha (~> 1.0) - pathspec (~> 0.2.1) + pathspec (>= 0.2.1, < 1.1.0) puppet-lint (~> 2.0) puppet-syntax (>= 2.0, < 4) rspec-puppet (~> 2.0) pusher-client (0.6.2) json websocket (~> 1.0) - rake (13.0.1) - rb-fsevent (0.10.4) + rake (13.0.6) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rest-client (2.1.0) @@ -165,29 +176,30 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rgen (0.8.2) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.0) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.0) + rgen (0.9.1) + rspec (3.12.0) + rspec-core (~> 3.12.0) + rspec-expectations (~> 3.12.0) + rspec-mocks (~> 3.12.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.0) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-puppet (2.8.0) + rspec-support (~> 3.12.0) + rspec-puppet (2.12.0) rspec - rspec-support (3.10.0) - ruby2_keywords (0.0.2) - semantic_puppet (1.0.2) + rspec-support (3.12.1) + ruby2_keywords (0.0.5) + scanf (1.0.0) + semantic_puppet (1.1.0) shellany (0.0.1) - spdx-licenses (1.2.0) - thor (1.0.1) + spdx-licenses (1.3.0) + thor (1.2.2) thread_safe (0.3.6) - travis (1.10.0) + travis (1.11.1) faraday (~> 1.0) faraday_middleware (~> 1.0) gh (~> 0.13) @@ -197,22 +209,27 @@ GEM pusher-client (~> 0.4) travis-lint (2.0.0) json - tzinfo (1.2.8) + tzinfo (1.2.11) thread_safe (~> 0.1) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) - websocket (1.2.8) - yard (0.9.25) + unf_ext (0.0.8.2) + voxpupuli-release (2.0.0) + puppet-blacksmith (>= 4.0.0) + puppet-strings (>= 2.9.0) + rake + websocket (1.2.9) + yard (0.9.34) PLATFORMS - ruby + x86_64-linux DEPENDENCIES guard-rake metadata-json-lint + puppet (~> 7.18) puppet-blacksmith - puppet-lint + puppet-lint (= 2.5.2) puppet-lint-absolute_classname-check puppet-lint-classes_and_types_beginning_with_digits-check puppet-lint-duplicate_class_parameters-check @@ -226,11 +243,11 @@ DEPENDENCIES puppet-lint-variable_contains_upcase puppet-lint-version_comparison-check puppet-strings - puppetlabs_spec_helper + puppetlabs_spec_helper (= 4.0.1) semantic_puppet travis travis-lint - voxpupuli-release! + voxpupuli-release (= 2.0.0) BUNDLED WITH - 1.17.3 + 2.3.21 diff --git a/manifests/application_properties.pp b/manifests/application_properties.pp index 987cdd8..37ac198 100644 --- a/manifests/application_properties.pp +++ b/manifests/application_properties.pp @@ -7,7 +7,7 @@ # `application.properties` from which it is generated. (see below) # # _Note:_ This is an internal class that shouldn't be used directly. It is -# included by the `aem_orchestrator` class. You can change values for it's +# included by the `aem_orchestrator` class. You can change values for its # parameters using Hiera. # # @see https://github.com/shinesolutions/aem-orchestrator/blob/master/src/main/resources/application.properties @@ -63,6 +63,12 @@ # @param aem_port_author_dispatcher # Java property `aem.port.authorDispatcher` # +# @param aem_port_preview_publish +# Java property `aem.port.previewPublish` +# +# @param aem_port_preview_publish_dispatcher +# Java property `aem.port.previewPublishDispatcher` +# # @param aem_port_publish # Java property `aem.port.publish` # @@ -75,6 +81,12 @@ # @param aem_protocol_author_dispatcher # Java property `aem.protocol.authorDispatcher` # +# @param aem_protocol_preview_publish +# Java property `aem.protocol.previewPublish` +# +# @param aem_protocol_preview_publish_dispatcher +# Java property `aem.protocol.previewPublishDispatcher` +# # @param aem_protocol_publish # Java property `aem.protocol.publish` # @@ -120,6 +132,12 @@ # @param aws_cloudformation_auto_scale_group_logical_id_author_dispatcher # Java property `aws.cloudformation.autoScaleGroup.logicalId.authorDispatcher` # +# @param aws_cloudformation_auto_scale_group_logical_id_preview_publish +# Java property `aws.cloudformation.autoScaleGroup.logicalId.previewPublish` +# +# @param aws_cloudformation_auto_scale_group_logical_id_preview_publish_dispatcher +# Java property `aws.cloudformation.autoScaleGroup.logicalId.previewPublishDispatcher` +# # @param aws_cloudformation_auto_scale_group_logical_id_publish # Java property `aws.cloudformation.autoScaleGroup.logicalId.publish` # @@ -141,6 +159,12 @@ # @param aws_cloudformation_stack_name_messaging # Java property `aws.cloudformation.stackName.messaging` # +# @param aws_cloudformation_stack_name_preview_publish +# Java property `aws.cloudformation.stackName.previewPublish` +# +# @param aws_cloudformation_stack_name_preview_publish_dispatcher +# Java property `aws.cloudformation.stackName.previewPublishDispatcher` +# # @param aws_cloudformation_stack_name_publish # Java property `aws.cloudformation.stackName.publish` # @@ -204,10 +228,14 @@ Variant[String, Undef] $aem_flush_log_level = undef, Variant[String, Undef] $aem_port_author = undef, Variant[String, Undef] $aem_port_author_dispatcher = undef, + Variant[String, Undef] $aem_port_preview_publish = undef, + Variant[String, Undef] $aem_port_preview_publish_dispatcher = undef, Variant[String, Undef] $aem_port_publish = undef, Variant[String, Undef] $aem_port_publish_dispatcher = undef, Variant[String, Undef] $aem_protocol_author = undef, Variant[String, Undef] $aem_protocol_author_dispatcher = undef, + Variant[String, Undef] $aem_protocol_preview_publish = undef, + Variant[String, Undef] $aem_protocol_preview_publish_dispatcher = undef, Variant[String, Undef] $aem_protocol_publish = undef, Variant[String, Undef] $aem_protocol_publish_dispatcher = undef, Variant[String, Undef] $aem_relaxed_ssl_enable = undef, @@ -223,6 +251,8 @@ Variant[String, Undef] $aws_client_proxy_port = undef, Variant[String, Undef] $aws_client_use_proxy = undef, Variant[String, Undef] $aws_cloudformation_auto_scale_group_logical_id_author_dispatcher = undef, + Variant[String, Undef] $aws_cloudformation_auto_scale_group_logical_id_preview_publish = undef, + Variant[String, Undef] $aws_cloudformation_auto_scale_group_logical_id_preview_publish_dispatcher = undef, Variant[String, Undef] $aws_cloudformation_auto_scale_group_logical_id_publish = undef, Variant[String, Undef] $aws_cloudformation_auto_scale_group_logical_id_publish_dispatcher = undef, Variant[String, Undef] $aws_cloudformation_load_balancer_logical_id_author = undef, @@ -230,6 +260,8 @@ Variant[String, Undef] $aws_cloudformation_stack_name_author = undef, Variant[String, Undef] $aws_cloudformation_stack_name_author_dispatcher = undef, Variant[String, Undef] $aws_cloudformation_stack_name_messaging = undef, + Variant[String, Undef] $aws_cloudformation_stack_name_preview_publish = undef, + Variant[String, Undef] $aws_cloudformation_stack_name_preview_publish_dispatcher = undef, Variant[String, Undef] $aws_cloudformation_stack_name_publish = undef, Variant[String, Undef] $aws_cloudformation_stack_name_publish_dispatcher = undef, Variant[String, Undef] $aws_device_name = undef, @@ -244,7 +276,6 @@ Variant[String, Undef] $startup_wait_for_author_elb_back_off_period_multiplier = undef, Variant[String, Undef] $startup_wait_for_author_elb_max_attempts = undef, Variant[String, Undef] $startup_wait_for_author_elb_max_back_off_period = undef, - ) { file { $path: ensure => file, @@ -253,4 +284,4 @@ mode => $mode, content => template('aem_orchestrator/application_properties.erb'), } -} +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 757158f..ed0d1fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ case_conversion==2.1.0 javaproperties==0.5.2 jinja2==2.10.1 +more-itertools==8.14.0 diff --git a/spec/classes/application_properties_spec.rb b/spec/classes/application_properties_spec.rb index c3278c7..57d0374 100644 --- a/spec/classes/application_properties_spec.rb +++ b/spec/classes/application_properties_spec.rb @@ -51,6 +51,14 @@ let(:params) { {:aem_port_author_dispatcher => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.port.authorDispatcher = foo/) } end + context 'with aem_port_preview_publish => foo' do + let(:params) { {:aem_port_preview_publish => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.port.previewPublish = foo/) } + end + context 'with aem_port_preview_publish_dispatcher => foo' do + let(:params) { {:aem_port_preview_publish_dispatcher => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.port.previewPublishDispatcher = foo/) } + end context 'with aem_port_publish => foo' do let(:params) { {:aem_port_publish => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.port.publish = foo/) } @@ -67,6 +75,14 @@ let(:params) { {:aem_protocol_author_dispatcher => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.protocol.authorDispatcher = foo/) } end + context 'with aem_protocol_preview_publish => foo' do + let(:params) { {:aem_protocol_preview_publish => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.protocol.previewPublish = foo/) } + end + context 'with aem_protocol_preview_publish_dispatcher => foo' do + let(:params) { {:aem_protocol_preview_publish_dispatcher => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.protocol.previewPublishDispatcher = foo/) } + end context 'with aem_protocol_publish => foo' do let(:params) { {:aem_protocol_publish => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aem.protocol.publish = foo/) } @@ -127,6 +143,14 @@ let(:params) { {:aws_cloudformation_auto_scale_group_logical_id_author_dispatcher => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.autoScaleGroup.logicalId.authorDispatcher = foo/) } end + context 'with aws_cloudformation_auto_scale_group_logical_id_preview_publish => foo' do + let(:params) { {:aws_cloudformation_auto_scale_group_logical_id_preview_publish => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.autoScaleGroup.logicalId.previewPublish = foo/) } + end + context 'with aws_cloudformation_auto_scale_group_logical_id_preview_publish_dispatcher => foo' do + let(:params) { {:aws_cloudformation_auto_scale_group_logical_id_preview_publish_dispatcher => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.autoScaleGroup.logicalId.previewPublishDispatcher = foo/) } + end context 'with aws_cloudformation_auto_scale_group_logical_id_publish => foo' do let(:params) { {:aws_cloudformation_auto_scale_group_logical_id_publish => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.autoScaleGroup.logicalId.publish = foo/) } @@ -155,6 +179,14 @@ let(:params) { {:aws_cloudformation_stack_name_messaging => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.stackName.messaging = foo/) } end + context 'with aws_cloudformation_stack_name_preview_publish => foo' do + let(:params) { {:aws_cloudformation_stack_name_preview_publish => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.stackName.previewPublish = foo/) } + end + context 'with aws_cloudformation_stack_name_preview_publish_dispatcher => foo' do + let(:params) { {:aws_cloudformation_stack_name_preview_publish_dispatcher => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.stackName.previewPublishDispatcher = foo/) } + end context 'with aws_cloudformation_stack_name_publish => foo' do let(:params) { {:aws_cloudformation_stack_name_publish => 'foo', :path => '/tmp/foo', } } it { is_expected.to contain_file('/tmp/foo').with_content(/^aws.cloudformation.stackName.publish = foo/) } diff --git a/templates/application_properties.erb b/templates/application_properties.erb index 413891d..268a1f7 100644 --- a/templates/application_properties.erb +++ b/templates/application_properties.erb @@ -35,6 +35,12 @@ <%- if scope[pfx + 'aem_port_author_dispatcher'] != nil -%> <%--%>aem.port.authorDispatcher = <%= scope[pfx + 'aem_port_author_dispatcher'] %> <%- end -%> +<%- if scope[pfx + 'aem_port_preview_publish'] != nil -%> + <%--%>aem.port.previewPublish = <%= scope[pfx + 'aem_port_preview_publish'] %> +<%- end -%> +<%- if scope[pfx + 'aem_port_preview_publish_dispatcher'] != nil -%> + <%--%>aem.port.previewPublishDispatcher = <%= scope[pfx + 'aem_port_preview_publish_dispatcher'] %> +<%- end -%> <%- if scope[pfx + 'aem_port_publish'] != nil -%> <%--%>aem.port.publish = <%= scope[pfx + 'aem_port_publish'] %> <%- end -%> @@ -47,6 +53,12 @@ <%- if scope[pfx + 'aem_protocol_author_dispatcher'] != nil -%> <%--%>aem.protocol.authorDispatcher = <%= scope[pfx + 'aem_protocol_author_dispatcher'] %> <%- end -%> +<%- if scope[pfx + 'aem_protocol_preview_publish'] != nil -%> + <%--%>aem.protocol.previewPublish = <%= scope[pfx + 'aem_protocol_preview_publish'] %> +<%- end -%> +<%- if scope[pfx + 'aem_protocol_preview_publish_dispatcher'] != nil -%> + <%--%>aem.protocol.previewPublishDispatcher = <%= scope[pfx + 'aem_protocol_preview_publish_dispatcher'] %> +<%- end -%> <%- if scope[pfx + 'aem_protocol_publish'] != nil -%> <%--%>aem.protocol.publish = <%= scope[pfx + 'aem_protocol_publish'] %> <%- end -%> @@ -92,6 +104,12 @@ <%- if scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_author_dispatcher'] != nil -%> <%--%>aws.cloudformation.autoScaleGroup.logicalId.authorDispatcher = <%= scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_author_dispatcher'] %> <%- end -%> +<%- if scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_preview_publish'] != nil -%> + <%--%>aws.cloudformation.autoScaleGroup.logicalId.previewPublish = <%= scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_preview_publish'] %> +<%- end -%> +<%- if scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_preview_publish_dispatcher'] != nil -%> + <%--%>aws.cloudformation.autoScaleGroup.logicalId.previewPublishDispatcher = <%= scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_preview_publish_dispatcher'] %> +<%- end -%> <%- if scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_publish'] != nil -%> <%--%>aws.cloudformation.autoScaleGroup.logicalId.publish = <%= scope[pfx + 'aws_cloudformation_auto_scale_group_logical_id_publish'] %> <%- end -%> @@ -113,6 +131,12 @@ <%- if scope[pfx + 'aws_cloudformation_stack_name_messaging'] != nil -%> <%--%>aws.cloudformation.stackName.messaging = <%= scope[pfx + 'aws_cloudformation_stack_name_messaging'] %> <%- end -%> +<%- if scope[pfx + 'aws_cloudformation_stack_name_preview_publish'] != nil -%> + <%--%>aws.cloudformation.stackName.previewPublish = <%= scope[pfx + 'aws_cloudformation_stack_name_preview_publish'] %> +<%- end -%> +<%- if scope[pfx + 'aws_cloudformation_stack_name_preview_publish_dispatcher'] != nil -%> + <%--%>aws.cloudformation.stackName.previewPublishDispatcher = <%= scope[pfx + 'aws_cloudformation_stack_name_preview_publish_dispatcher'] %> +<%- end -%> <%- if scope[pfx + 'aws_cloudformation_stack_name_publish'] != nil -%> <%--%>aws.cloudformation.stackName.publish = <%= scope[pfx + 'aws_cloudformation_stack_name_publish'] %> <%- end -%> diff --git a/tools/parse_application_properties b/tools/parse_application_properties index 53f3359..ca3538c 100755 --- a/tools/parse_application_properties +++ b/tools/parse_application_properties @@ -1,8 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys, os, argparse, javaproperties, textwrap, case_conversion from jinja2 import Template -from itertools import imap, chain +from itertools import chain +imap=map __version__='0.1' @@ -120,105 +121,93 @@ def parse_example_file(file): keys.append(property_key(key, full_class_name, acronyms = args.acronym)) return keys - template_tmpl = Template( - textwrap.dedent(u"""\ - <% pfx = '{{ class_prefix }}::' -%> - {% for property in properties -%} - <%- if scope[pfx + '{{ property.snake_case }}'] != nil -%> - <%--%>{{ property.key }} = <%= scope[pfx + '{{ property.snake_case }}'] %> - <%- end -%> - {% endfor -%} - """ - ), - trim_blocks = True, - lstrip_blocks = True, + """<% pfx = '{{ class_prefix }}::' -%> +{% for property in properties %} +<%- if scope[pfx + '{{ property.snake_case }}'] != nil -%> + <%--%>{{ property.key }} = <%= scope[pfx + '{{ property.snake_case }}'] %> +<%- end -%> +{% endfor %}""", + trim_blocks=True, + lstrip_blocks=True, ) -class_tmpl = Template( - textwrap.dedent(u"""\ - # @summary - # Write the `application.properties` file. - # - # This class writes the `application.properties` file for the AEM - # Orchestrator. It is auto-generated and should not be modified by hand. - # Documentation for each of the properties can be found in the example - # `application.properties` from which it is generated. (see below) - # - # _Note:_ This is an internal class that shouldn't be used directly. It is - # included by the `aem_orchestrator` class. You can change values for it's - # parameters using Hiera. - # - # @see https://github.com/shinesolutions/aem-orchestrator/blob/master/src/main/resources/application.properties - # The example AEM Orchestrator file. - # - # @param path - # The path to the application.properties file on disk. Required. - # - # @param owner - # The user that should own the application.properties file. This user is *not* - # created by this module and should be managed elsewhere. Required. - # - # @param group - # The group that should own the application.properties file. This group is - # *not* created by this module and should be managed elsewhere. Required. - # - # @param mode - # The mode of the application.properties file. Passed to the `file` resource. - # - {% for property in properties -%} - # @param {{ property.snake_case }} - # {{ property.doco }} - # - {% endfor -%} - # - # Copyright © 2017-2021 Shine Solutions Group Group, unless otherwise noted. - # - class {{ full_class_name }} ( - String $path, - String $owner, - String $group, - String $mode, - - {% for property in properties %} - Variant[String, Undef] ${{ property.snake_case }} = undef, - {% endfor %} - - ) { - file { $path: - ensure => file, - owner => $owner, - group => $group, - mode => $mode, - content => template('{{ template_path }}'), - } - } - """ - ), +class_tmpl = Template( + """# @summary +# Write the `application.properties` file. +# +# This class writes the `application.properties` file for the AEM +# Orchestrator. It is auto-generated and should not be modified by hand. +# Documentation for each of the properties can be found in the example +# `application.properties` from which it is generated. (see below) +# +# _Note:_ This is an internal class that shouldn't be used directly. It is +# included by the `aem_orchestrator` class. You can change values for its +# parameters using Hiera. +# +# @see https://github.com/shinesolutions/aem-orchestrator/blob/master/src/main/resources/application.properties +# The example AEM Orchestrator file. +# +# @param path +# The path to the application.properties file on disk. Required. +# +# @param owner +# The user that should own the application.properties file. This user is *not* +# created by this module and should be managed elsewhere. Required. +# +# @param group +# The group that should own the application.properties file. This group is +# *not* created by this module and should be managed elsewhere. Required. +# +# @param mode +# The mode of the application.properties file. Passed to the `file` resource. +# +{% for property in properties %} +# @param {{ property.snake_case }} +# {{ property.doco }} +# +{% endfor %} +# +# Copyright © 2017-2019 Shine Solutions Group, unless otherwise noted. +# +class {{ full_class_name }} ( + String $path, + String $owner, + String $group, + String $mode, + +{% for property in properties %} + Variant[String, Undef] ${{ property.snake_case }} = undef, +{% endfor %} +) { + file { $path: + ensure => file, + owner => $owner, + group => $group, + mode => $mode, + content => template('{{ template_path }}'), + } +}""", trim_blocks = True, lstrip_blocks = True, ) spec_tmpl = Template( - textwrap.dedent(u"""\ - require 'spec_helper' - describe '{{ full_class_name }}' do - context 'with defaults for all parameters' do - it { is_expected.to contain_class('{{ full_class_name }}') } - end - {% for property in properties %} - context 'with {{ property.snake_case }} => foo' do - let(:params) { {:{{ property.snake_case }} => 'foo', :path => '/tmp/foo', } } - it { is_expected.to contain_file('/tmp/foo').with_content(/^{{ property.key }} = foo/) } - end - {% endfor %} - end - """ - ), - trim_blocks = True, - lstrip_blocks = True, -) + """require 'spec_helper' +describe '{{ full_class_name }}' do + context 'with defaults for all parameters' do + it { is_expected.to contain_class('{{ full_class_name }}') } + end + {% for property in properties %} + context 'with {{ property.snake_case }} => foo' do + let(:params) { {:{{ property.snake_case }} => 'foo', :path => '/tmp/foo', } } + it { is_expected.to contain_file('/tmp/foo').with_content(/^{{ property.key }} = foo/) } + end + {% endfor %} +end""", + trim_blocks=True, + lstrip_blocks=True) if __name__ == '__main__': args = parse_args() @@ -239,7 +228,8 @@ if __name__ == '__main__': template_file.write(template_tmpl.render( class_prefix = full_class_name, properties = keys, - ).encode('utf-8')) + scope=keys, + )) with open(args.class_file, 'w') as class_file: template_path = os.path.basename(args.template_file) @@ -249,11 +239,10 @@ if __name__ == '__main__': full_class_name = full_class_name, template_path = template_path, properties = keys, - ).encode('utf-8')) + )) with open(args.spec_file, 'w') as spec_file: spec_file.write(spec_tmpl.render( full_class_name = full_class_name, properties = keys, - ).encode('utf-8')) - + ))