From 2bfd787b3513b6845c0075a5c6e8ad67ce04c48d Mon Sep 17 00:00:00 2001 From: Luis Mayta Date: Sat, 14 May 2022 19:25:04 -0500 Subject: [PATCH] refactor: generator readme (#42) --- provision/generators/README.yaml | 36 ++++-------------- provision/generators/plop/generators/test.ts | 17 +++++++++ .../plop/templates/test/data.add.hbs | 0 .../plop/templates/test/versions.add.hbs | 2 +- provision/templates/README.tpl.md | 38 +++---------------- 5 files changed, 31 insertions(+), 62 deletions(-) create mode 100644 provision/generators/plop/templates/test/data.add.hbs diff --git a/provision/generators/README.yaml b/provision/generators/README.yaml index 7ff8d5c..a6ff4f7 100644 --- a/provision/generators/README.yaml +++ b/provision/generators/README.yaml @@ -19,10 +19,6 @@ categories: email: support: support@hadenlabs.com -confluence: - space: TerraformAwsOpenvpn - title: Project - # Logo for this project #logo: docs/logo.png @@ -53,14 +49,17 @@ badges: image: https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow url: https://conventionalcommits.org - name: KeepAChangelog - image: https://img.shields.io/badge/Keep%20A%20Changelog-1.0.0-%23E05735 + image: https://img.shields.io/badge/changelog-Keep%20a%20Changelog%20v1.0.0-orange url: https://keepachangelog.com + - name: Terraform Version + image: https://img.shields.io/badge/terraform-1.x%20|%200.15%20|%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform + url: https://github.com/hashicorp/terraform/releases requirements: |- This is a list of plugins that need to be installed previously to enjoy all the goodies of this configuration: - - [Pyenv](https://github.com/pyenv/pyenv) + - [gomplate](https://github.com/hairyhenderson/gomplate) - [Docker](https://www.docker.com) - [python](https://www.python.org) - [taskfile](https://github.com/go-task/task) @@ -69,29 +68,8 @@ requirements: |- description: |- Terraform module to provision an openvpn instance. -# How to use this project -usage: |- - - ```hcl - module "main" { - source = "hadenlabs/openvpn/aws" - version = "0.3.0" - - providers = { - aws = aws - template = template - local = local - } - - public_key = local.auth_public_key - private_key = local.auth_private_key - admin_user = "slovacus" - storage_path = "~/openvpn" - - } - ``` - - Full working examples can be found in [examples](./examples) folder. +usages: + - docs/usage.md examples: - 'docs/examples/common.md' diff --git a/provision/generators/plop/generators/test.ts b/provision/generators/plop/generators/test.ts index d825853..6e2faca 100644 --- a/provision/generators/plop/generators/test.ts +++ b/provision/generators/plop/generators/test.ts @@ -24,9 +24,12 @@ export const testGenerator: PlopGeneratorConfig = { actions: (data) => { const answers = data as Answers const containerPath = `${testPath}/openvpn-${slugify(answers.testName, '-')}` + const containerDocsPath = `${containerPath}/docs` if (!pathExists(containerPath)) { pathMake(containerPath) + pathMake(containerDocsPath) + pathMake(path.join(containerDocsPath, 'include')) } const actions: Actions = [] @@ -45,6 +48,13 @@ export const testGenerator: PlopGeneratorConfig = { abortOnFail: false }) + actions.push({ + type: 'add', + templateFile: `${baseTemplatesPath}/test/data.add.hbs`, + path: `${containerPath}/data.tf`, + abortOnFail: false + }) + actions.push({ type: 'add', templateFile: `${baseTemplatesPath}/test/outputs.add.hbs`, @@ -73,6 +83,13 @@ export const testGenerator: PlopGeneratorConfig = { abortOnFail: true }) + actions.push({ + type: 'add', + templateFile: `${baseTemplatesPath}/test/docs/include/terraform.md`, + path: `${containerDocsPath}/include/terraform.md`, + abortOnFail: true + }) + return actions } } diff --git a/provision/generators/plop/templates/test/data.add.hbs b/provision/generators/plop/templates/test/data.add.hbs new file mode 100644 index 0000000..e69de29 diff --git a/provision/generators/plop/templates/test/versions.add.hbs b/provision/generators/plop/templates/test/versions.add.hbs index a6df3e9..abff2ef 100644 --- a/provision/generators/plop/templates/test/versions.add.hbs +++ b/provision/generators/plop/templates/test/versions.add.hbs @@ -1,5 +1,5 @@ terraform { - required_version = ">=0.13" + required_version = ">= 0.12.20, < 2.0" required_providers { aws = { diff --git a/provision/templates/README.tpl.md b/provision/templates/README.tpl.md index c72193d..87178a0 100644 --- a/provision/templates/README.tpl.md +++ b/provision/templates/README.tpl.md @@ -78,12 +78,14 @@ {{- end }} {{- end }} -{{ if has (ds "config") "usage" }} +{{ if has (ds "config") "usages" }} ## Usage -{{ (ds "config").usage -}} {{ end }} - +{{ range $file := (datasource "config").usages -}} +{{ (include "includes" $file) }} +{{- end }} +{{ end }} {{ if has (ds "config") "quickstart" -}} @@ -136,35 +138,7 @@ File a GitLab [issue]({{ printf "https://gitlab.com/%s/-/issues" (ds "config").g ## Contributing -### Bug Reports & Feature Requests - -{{ if has (ds "config") "github_repo" }} -Please use the [issue tracker]({{ printf "https://github.com/%s/issues" (ds "config").github_repo}}) to report any bugs or file feature requests. -{{ else if has (ds "config") "gitlab_host" }} -Please use the [issue tracker]({{ printf "https://%s/%s/-/issues" (ds "config").gitlab_host (ds "config").gitlab_repo}}) to report any bugs or file feature requests. -{{ else if has (ds "config") "gitlab_repo" }} -Please use the [issue tracker]({{ printf "https://gitlab.com/%s/issues" (ds "config").gitlab_repo}}) to report any bugs or file feature requests. -{{ end }} - -### Development - -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 -{{ if has (ds "config") "github_repo" }} -5. Submit a **Pull Request** so that we can review your changes -{{ else if has (ds "config") "gitlab_repo" }} -5. Submit a **Merge Request** so that we can review your changes -{{ end }} - -{{ if has (ds "config") "github_repo" }} -**NOTE:** Be sure to rebase the latest changes from "upstream" before making a pull request! -{{ else if has (ds "config") "gitlab_repo" }} -**NOTE:** Be sure to rebase the latest changes from "upstream" before making a merge request! -{{ end }} +See [Contributing](./docs/contributing.md). ## Module Versioning