Skip to content

Commit

Permalink
refactor: generator readme (hadenlabs#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed May 15, 2022
1 parent 1d58201 commit 2bfd787
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 62 deletions.
36 changes: 7 additions & 29 deletions provision/generators/README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ categories:
email:
support: support@hadenlabs.com

confluence:
space: TerraformAwsOpenvpn
title: Project

# Logo for this project
#logo: docs/logo.png

Expand Down Expand Up @@ -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)
Expand All @@ -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'
Expand Down
17 changes: 17 additions & 0 deletions provision/generators/plop/generators/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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`,
Expand Down Expand Up @@ -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
}
}
Empty file.
2 changes: 1 addition & 1 deletion provision/generators/plop/templates/test/versions.add.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = ">=0.13"
required_version = ">= 0.12.20, < 2.0"
required_providers {

aws = {
Expand Down
38 changes: 6 additions & 32 deletions provision/templates/README.tpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" -}}

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2bfd787

Please sign in to comment.