diff --git a/README.md b/README.md index e72ac058..bcc6d641 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,13 @@ The pipeline verifies that: - The generated tile passes all acceptance tests in `ci/acceptance-tests` - The generated tile successfully deploys to a current version of PCF - The deployed tile passes all deployment tests in `ci/deployment-tests` + +## Contributing to the Tile Generator + +We welcome comments, questions, and contributions from community members. Please consider +the following ways to contribute: + +- File Github issues for questions, bugs and new features and comment and vote on the ones that you are interested in. +- If you want to contribute code, please make your code changes on a fork of this repository and submit a +pull request to the master branch of tile-generator. We strongly suggest that you first file an issue to +let us know of your intent, or comment on the issue you are planning to address. diff --git a/sample/missing-properties.yml b/sample/missing-properties.yml index 05289701..eb3ca1e4 100644 --- a/sample/missing-properties.yml +++ b/sample/missing-properties.yml @@ -3,6 +3,8 @@ customer_name: Jimmy's Johnnys street_address: Cartaway Alley city: New Jersey country: country_us +username: SpongeBob +password: { 'secret': SquarePants } app2: persistence_store_type: none # p-mysql # Works, but turned off because this is not deployed in our PCF environments dynamic_service_plans: diff --git a/sample/tile.yml b/sample/tile.yml index 024a48d1..d5cb80cb 100644 --- a/sample/tile.yml +++ b/sample/tile.yml @@ -45,6 +45,19 @@ forms: default: true - name: country_elsewhere label: Elsewhere +- name: account-info-1 + label: Account Info + description: Example Account Information Form + properties: + - name: username + type: string + label: Username + constraints: + - must_match_regex: '^[^!@#$%^&*()]*$' + error_message: 'This name cannot contain capital digits.' + - name: password + type: secret + label: Password service_plan_forms: - name: custom_dynamic_service_plan_1 @@ -63,6 +76,10 @@ service_plan_forms: type: integer configurable: true description: The number of available seats for this license + default: 1 + constraints: + min: 1 + max: 500 - name: custom_dynamic_service_plan_2 label: Custom Dynamic Service Plan 2 description: Custom Dynamic service plan 2 for Test Tile @@ -79,7 +96,10 @@ service_plan_forms: type: integer configurable: true description: The number of licenses + default: 1 +# Deprecated but still supported for backward compatibility. +# Use service_plan_forms instead. dynamic_service_plans: - name: description type: string @@ -93,6 +113,7 @@ dynamic_service_plans: type: integer configurable: true description: The number of available seats for this license + default: 1 packages: diff --git a/tile_generator/build.py b/tile_generator/build.py index e1ab1cf9..4d018a7d 100644 --- a/tile_generator/build.py +++ b/tile_generator/build.py @@ -108,10 +108,15 @@ def add_defaults(context): properties = form.get('properties', []) for property in properties: if 'configurable' not in property: - property['configurable'] = 'true' + property['configurable'] = True context['all_properties'] += properties for property in context['all_properties']: property['name'] = property['name'].lower().replace('-','_') + default = property.get('default', property.pop('value', None)) # NOTE this intentionally removes property['value'] + if default is not None: + property['default'] = default + property['configurable'] = property.get('configurable', False) + property['optional'] = property.get('optional', False) def default_stemcell(context): stemcell_criteria = context.get('stemcell_criteria', {}) diff --git a/tile_generator/templates/jobs/deploy-all.sh.erb b/tile_generator/templates/jobs/deploy-all.sh.erb index cb0f04c7..1cef9815 100644 --- a/tile_generator/templates/jobs/deploy-all.sh.erb +++ b/tile_generator/templates/jobs/deploy-all.sh.erb @@ -46,7 +46,7 @@ function import_opsmgr_variables() { end end %> - export DYNAMIC_PLANS='<%= Shellwords.escape JSON.dump(plans) %>' + export DYNAMIC_PLANS=<%= Shellwords.escape JSON.dump(plans) %> {% endif %} {% for service_plan_form in context.service_plan_forms %} <% @@ -58,7 +58,7 @@ function import_opsmgr_variables() { end end %> - export {{ service_plan_form.name | upper }}='<%= Shellwords.escape JSON.dump(plans) %>' + export {{ service_plan_form.name | upper }}=<%= Shellwords.escape JSON.dump(plans) %> {% endfor %} {% for property in context.all_properties %} diff --git a/tile_generator/templates/tile/metadata.yml b/tile_generator/templates/tile/metadata.yml index 12ee4dfc..8b756491 100644 --- a/tile_generator/templates/tile/metadata.yml +++ b/tile_generator/templates/tile/metadata.yml @@ -72,17 +72,7 @@ property_blueprints: type: string configurable: true {% for field in dynamic_service_plans %} - - name: {{ field.name }} - type: {{ field.type }} - configurable: {{ field.configurable }} - decription: {{ field.description }} - {% if field.options is defined %} - options: - {% for option in field.options %} - - name: {{ option.name }} - label: {{ option.label }} - {% endfor %} - {% endif %} + - {{ field | yaml | indent }} {% endfor %} {% endif %} {% for service_plan_form in service_plan_forms %} @@ -102,17 +92,7 @@ property_blueprints: type: string configurable: true {% for field in service_plan_form.properties %} - - name: {{ field.name }} - type: {{ field.type }} - configurable: {{ field.configurable }} - decription: {{ field.description }} - {% if field.options is defined %} - options: - {% for option in field.options %} - - name: {{ option.name }} - label: {{ option.label }} - {% endfor %} - {% endif %} + - {{ field | yaml | indent }} {% endfor %} {% endfor %} @@ -162,32 +142,7 @@ property_blueprints: # Custom properties from the tile.yml file # {% for property in all_properties %} -- name: {{ property.name }} # Refer to this elsewhere as (( .properties.{{ property.name }} )) - type: {{ property.type }} - {% if property.value is defined %} - default: {{ property.value }} - {% elif property.default is defined %} - default: {{ property.default }} - {% endif %} - configurable: {{ property.configurable or 'false' }} - optional: {{ property.optional or 'false' }} - {% if property.constraints is defined %} - constraints: - {{ property.constraints | yaml | indent }} - {% endif %} - {% if property.options is defined %} - options: - {% for option in property.options %} - - name: {{ option.name }} - label: {{ option.label }} - {% if option.default is defined %} - default: {{ option.default }} - {% endif %} - {% if option.slug is defined %} - slug: {{ option.slug }} - {% endif %} - {% endfor %} - {% endif %} +- {{ property | yaml | indent(2) }} {% endfor %} form_types: @@ -212,7 +167,7 @@ form_types: {% for service_plan_form in service_plan_forms %} # -# Custom Service Plan form {{ service_plan_form.name}} from the tile.yml file +# Custom Service Plan form {{service_plan_form.name}} from the tile.yml file # - name: {{ service_plan_form.name }} label: {{ service_plan_form.label }}