diff --git a/bin/template_generate.sh b/bin/template_generate.sh deleted file mode 100755 index b7deb8ce..00000000 --- a/bin/template_generate.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash - -IN=${IN:-".README.md"} -OUT=${OUT:-"README.md"} - -TIMESTAMP=$(date +"%s") -TMP=/tmp/$TIMESTAMP - -mkdir -p $TMP - -declare -A DATASOURCES - -INCLUDED_MODULES=() - -# Merge 2 lists (in format words separated be space in string) -function array-merge { - # Declare an associative array - declare -A tmp - # Store the values of arr3 in arr4 as keys - for k in $@; do tmp["$k"]=1; done - # Extract the keys - echo "${!tmp[@]}" -} - -## Get template modules from $IN file -## Example of usage -## module ./.README.md -function modules { - grep -Eo '\(datasource ".*?"\)' "$1" |cut -d'"' -f2 | sort -u | paste -sd " " - -} - -## Fire event $1 for all modules passed as args -## Example of usage -## fire_event "test" "git" "make" -## Will call functions "git-test" and "make-test" if exists -function fire_event { - local event=$1 - local modules=${@:2} - - for module in $modules - do - func="$module-$event" - if [ "$(type -t $func)" = 'function' ]; then - $func - fi - done -} - -## Provide datasource options for modules passed as args -## Example of usage -## datasources "git" "make" -function datasources { - for k in $@; do - echo "--datasource $k=${DATASOURCES[$k]}" - done -} - -## Register modules -for file in $BUILD_HARNESS_PATH/modules/*/template/*.sh ; do - if [ -f "$file" ] ; then - . "$file" - fi -done - -## Find used modules in $IN file -MODULES=$(modules $IN) - -until [ -z "$MODULES" ] -do - ## Merge module list with modules from previous iteration - INCLUDED_MODULES=$( array-merge $INCLUDED_MODULES $MODULES) - ## Prepare data for just found modules - fire_event "template-prepare-data" $MODULES - ## Replace template - $GOMPLATE --file $IN --out $OUT $(datasources $INCLUDED_MODULES) - - ## For all iterations (except first) use $OUT file as $IN template to replace recursive placeholders - IN=$OUT - ## Find modules in $IN file for the next iteration - MODULES=$(modules $IN) -done - -## Cleanup prepared data for all used modules -fire_event "template-cleanup-data" $INCLUDED_MODULES - -rm -rf $TMP - -echo "$OUT generated" diff --git a/modules/git/template/module.sh b/modules/git/template/module.sh deleted file mode 100644 index da8431ce..00000000 --- a/modules/git/template/module.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -GIT_FILE=$TMP/git.yml - -DATASOURCES[git]=file://$GIT_FILE - -function git-template-prepare-data { -cat << EOF > $GIT_FILE ---- - url: $(git ls-remote --get-url) - name: $(basename `git ls-remote --get-url` .git) - commit: ${GIT_COMMIT} - commit_short: ${GIT_COMMIT_SHORT} - branch: ${GIT_BRANCH} - tag: ${GIT_TAG} - is_tag: ${GIT_IS_TAG} - is_branch: ${GIT_IS_BRANCH} -EOF -} - -function git-template-cleanup-data { - rm -f $GIT_FILE -} diff --git a/modules/make/template/module.sh b/modules/make/template/module.sh deleted file mode 100644 index 8d4dcd64..00000000 --- a/modules/make/template/module.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -MAKE_DATA_FILE=$TMP/make_data.yml - -DATASOURCES[make]=file://$BUILD_HARNESS_PATH/modules/make/template/templates/make.yml -DATASOURCES[make_data]=file://$MAKE_DATA_FILE - -function make_data-template-prepare-data { -cat << EOF > $MAKE_DATA_FILE ---- -help: |- - $(make -s help | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | sed -e 's/^/ /') -EOF -} - -function make_data-template-cleanup-data { - rm -f $MAKE_DATA_FILE -} diff --git a/modules/make/template/templates/make.yml b/modules/make/template/templates/make.yml deleted file mode 100644 index cd904396..00000000 --- a/modules/make/template/templates/make.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- - help: |- - ## Makefile Targets - - ```bash - $ make help - - {{ (datasource "make_data").help }} - ``` \ No newline at end of file diff --git a/modules/semver/template/module.sh b/modules/semver/template/module.sh deleted file mode 100644 index d9270002..00000000 --- a/modules/semver/template/module.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -SEMVER_FILE=$TMP/semver.yml - -DATASOURCES[semver]=file://$SEMVER_FILE - -function semver-template-prepare-data { -cat << EOF > $SEMVER_FILE ---- -version: $SEMVERSION -EOF -} - -function semver-template-cleanup-data { - rm -f $SEMVER_FILE -} diff --git a/modules/template/template/contributor.yml b/modules/template/template/contributor.yml deleted file mode 100644 index 51f48a10..00000000 --- a/modules/template/template/contributor.yml +++ /dev/null @@ -1,55 +0,0 @@ ---- - andriy: |- - [![Andriy Knysh][andriy_img]][andriy_web]
[Andriy Knysh][andriy_web] - - erik: |- - [![Erik Osterman][erik_img]][erik_web]
[Erik Osterman][erik_web] - - igor: |- - [![Igor Rodionov][igor_img]][igor_web]
[Igor Rodionov][igor_img] - - konstantin: |- - [![Konstantin B][konstantin_img]][konstantin_web]
[Konstantin B][konstantin_web] - - sergey: |- - [![Sergey Vasilyev][sergey_img]][sergey_web]
[Sergey Vasilyev][sergey_web] - - valeriy: |- - [![Valeriy][valeriy_img]][valeriy_web]
[Valeriy][valeriy_web] - - vladimir: |- - [![Vladimir][vladimir_img]][vladimir_web]
[Vladimir][vladimir_web] - - _links: |- - [andriy_img]: https://avatars0.githubusercontent.com/u/7356997?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 - [andriy_web]: https://github.com/aknysh/ - - [erik_img]: http://s.gravatar.com/avatar/88c480d4f73b813904e00a5695a454cb?s=144 - [erik_web]: https://github.com/osterman/ - - [igor_img]: http://s.gravatar.com/avatar/bc70834d32ed4517568a1feb0b9be7e2?s=144 - [igor_web]: https://github.com/goruha/ - - [konstantin_img]: https://avatars1.githubusercontent.com/u/11299538?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 - [konstantin_web]: https://github.com/comeanother/ - - [sergey_img]: https://avatars1.githubusercontent.com/u/1134449?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 - [sergey_web]: https://github.com/s2504s/ - - [valeriy_img]: https://avatars1.githubusercontent.com/u/10601658?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 - [valeriy_web]: https://github.com/drama17/ - - [vladimir_img]: https://avatars1.githubusercontent.com/u/26582191?v=4&u=ed9ce1c9151d552d985bdf5546772e14ef7ab617&s=144 - [vladimir_web]: https://github.com/SweetOps/ - - _1: "|---|" - _2: "|---|---|" - _3: "|---|---|---|" - _4: "|---|---|---|---|" - _5: "|---|---|---|---|---|" - _6: "|---|---|---|---|---|---|" - _7: "|---|---|---|---|---|---|---|" - _8: "|---|---|---|---|---|---|---|---|" - _9: "|---|---|---|---|---|---|---|---|---|" - _10: "|---|---|---|---|---|---|---|---|---|---|" - diff --git a/modules/template/template/license.yml b/modules/template/template/license.yml deleted file mode 100644 index 9b3d8552..00000000 --- a/modules/template/template/license.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - apache2: |- - ## License - - [APACHE 2.0](LICENSE) © 2017 [Cloud Posse, LLC](https://cloudposse.com) - - See [LICENSE](LICENSE) for full details. - - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. diff --git a/modules/template/template/module.sh b/modules/template/template/module.sh deleted file mode 100644 index 05b56277..00000000 --- a/modules/template/template/module.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -DATASOURCES[contributor]=file://$BUILD_HARNESS_PATH/modules/template/template/contributor.yml -DATASOURCES[license]=file://$BUILD_HARNESS_PATH/modules/template/template/license.yml -DATASOURCES[section]=file://$BUILD_HARNESS_PATH/modules/template/template/section.yml - diff --git a/modules/template/template/section.yml b/modules/template/template/section.yml deleted file mode 100644 index 91feaab6..00000000 --- a/modules/template/template/section.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -warning: |- - -about: |- - ## About - - This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know at - - We love [Open Source Software](https://github.com/cloudposse/)! - - See [our other projects][community] - or [hire us][hire] to help build your next cloud-platform. - - [website]: http://cloudposse.com/ - [community]: https://github.com/cloudposse/ - [hire]: http://cloudposse.com/contact/ -help: |- - ## Help - - **Got a question?** - - File a GitHub [issue](https://github.com/cloudposse/{{ (datasource "git").name }}/issues), send us an [email](mailto:hello@cloudposse.com) or reach out to us on [Gitter](https://gitter.im/cloudposse/). - -contributing: |- - ## Contributing - - ### Bug Reports & Feature Requests - - Please use the [issue tracker](https://github.com/cloudposse/{{ (datasource "git").name }}/issues) to report any bugs or file feature requests. - - ### Developing - - If you are interested in being a contributor and want to get involved in developing `{{ (datasource "git").name }}`, we would love to hear from you! Shoot us an [email](mailto:hello@cloudposse.com). - - In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow. - - 1. **Fork** the repo on GitHub - 2. **Clone** the project to your own machine - 3. **Commit** changes to your own branch - 4. **Push** your work back up to your fork - 5. Submit a **Pull request** so that we can review your changes - - **NOTE:** Be sure to merge the latest from "upstream" before making a pull request! diff --git a/modules/terraform/template/module.sh b/modules/terraform/template/module.sh deleted file mode 100644 index d7a60430..00000000 --- a/modules/terraform/template/module.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -TERRAFORM_DOCS_REPO=segmentio/terraform-docs -TERRAFORM_DOCS_VERSION=v0.3.0 -TERRAFORM_DOCS=${BUILD_HARNESS_PATH}/vendor/terraform-docs - -TERRAFORM_DATA_FILE=$TMP/terraform_data.yml - -DATASOURCES[terraform]=file://$BUILD_HARNESS_PATH/modules/terraform/template/terraform.yml -DATASOURCES[terraform_data]=file://$TERRAFORM_DATA_FILE - -function terraform-template-prepare-data { - if [ ! -s $TERRAFORM_DOCS ]; then - make github/download-public-release \ - REPO=$TERRAFORM_DOCS_REPO \ - FILE=terraform-docs_${OS}_amd64 \ - VERSION=$TERRAFORM_DOCS_VERSION \ - OUTPUT=$TERRAFORM_DOCS - - chmod +x $TERRAFORM_DOCS - fi; -} - -function terraform_data-template-prepare-data { - $TERRAFORM_DOCS json . > $TERRAFORM_DATA_FILE -} -function terraform-template-cleanup-data { - rm -f $TERRAFORM_DATA_FILE -} - diff --git a/modules/terraform/template/terraform.yml b/modules/terraform/template/terraform.yml deleted file mode 100644 index 46928123..00000000 --- a/modules/terraform/template/terraform.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- - input: |- - ## Input - - - | Name | Default | Description | - |:------|:---------:|:--------------:| - {{- range $index, $element := (datasource "terraform_data").Inputs }} - | {{ $element.Name }} | - {{- if $element.Default }} - {{- if eq $element.Default.Type "map" }} - {{- "{}" }} - {{- else }} - {{- if eq $element.Default.Type "list" -}} - [] - {{- else -}} - "{{ $element.Default.Literal }}" - {{- end }} - {{- end }} - {{- else -}} - __REQUIRED__ - {{- end }} | - {{- $element.Description | strings.ReplaceAll "\n" " " }}| - {{- end }} - - output: |- - ## Output - - - | Name | Description | - |:------|:------------:| - {{- range $index, $element := (datasource "terraform_data").Outputs }} - | {{ $element.Name }} | {{ $element.Description | strings.ReplaceAll "\n" " " }} | - {{- end }}