Skip to content

Commit

Permalink
refactor: generate readme of yaml template (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Jan 22, 2021
1 parent 55d921b commit 34ead3d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ What types of changes does your code introduce to Project? _Put an `x` in the bo

_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._

- [ ] I have read the [CONTRIBUTING](/CONTRIBUTING.rst) doc
- [ ] I have read the [CONTRIBUTING](/docs/contributing.md) doc
- [ ] Lint and unit tests pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation (if appropriate)
Expand Down
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ repos:
rev: v1.45.0
hooks:
- id: terraform_docs
- id: terraform_docs_replace
args: ['--sort-by-required', '--dest=docs/include/terraform.md']
- id: terraform_tflint
args:
- '--args=--deep'
- '--args=--config=__GIT_WORKING_DIR__/.github/linters/.tflint.hcl'
- id: terragrunt_fmt
- id: terraform_fmt
- id: terraform_tfsec
- id: checkov
- repo: git://github.com/dnephin/pre-commit-golang
rev: v0.3.5
hooks:
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# See ./CONTRIBUTING.rst
# See ./docs/contributing.md
#

OS := $(shell uname)
Expand Down Expand Up @@ -44,17 +44,17 @@ SHELL ?=/bin/bash
ROOT_DIR=$(shell pwd)
MESSAGE:=🍺️
MESSAGE_HAPPY:="Done! ${MESSAGE}, Now Happy Hacking"
SOURCE_DIR=$(ROOT_DIR)/
README_TEMPLATE:=$(ROOT_DIR)/templates/README.md

TERRAFORM_README_FILE := $(ROOT_DIR)/docs/include/terraform.md
SOURCE_DIR=$(ROOT_DIR)
PROVISION_DIR:=$(ROOT_DIR)/provision
DOCS_DIR:=$(ROOT_DIR)/docs
README_TEMPLATE:=$(PROVISION_DIR)/templates/README.md.gotmpl
TERRAFORM_README_FILE := $(DOCS_DIR)/include/terraform.md

export README_FILE ?= README.md
export README_YAML ?= README.yaml
export README_INCLUDES ?= $(file://$(shell pwd)/?type=text/plain)

PROVISION_DIR:=$(ROOT_DIR)/provision
FILE_README:=$(ROOT_DIR)/README.rst
FILE_README:=$(ROOT_DIR)/README.md

PATH_DOCKER_COMPOSE:=docker-compose.yml -f provision/docker-compose

Expand Down
17 changes: 16 additions & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ tags:
categories:
- terraform-modules/vpn

company:
name: hadenlabs
description: |-
company labs
url: https://hadenlabs.com
github: https://github.com/hadenlabs
email: support@hadenlbas.com

copyright:
name: Hadenlabs
url: https://hadenlabs.com

email:
support: support@hadenlabs.com

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

Expand Down Expand Up @@ -46,7 +61,7 @@ usage: |-
version = "0.1.0"
providers = {
aws = aws.main
aws = aws
}
public_key = local.auth_public_key
Expand Down
58 changes: 48 additions & 10 deletions templates/README.md → provision/templates/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<!--


** DO NOT EDIT THIS FILE
**
** 1) Make all changes to `README.yaml`
** 2) Run`make readme` to rebuild this file.
**
** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.)
**


-->

{{ defineDatasource "config" .Env.README_YAML | regexp.Replace ".*" "" }} {{ defineDatasource "includes" .Env.README_INCLUDES | regexp.Replace ".*" "" }}

# {{(ds "config").name}}{{ if gt (len (ds "config").name) 34 }}{{ print "\n\n" }}{{ end }}{{ if has (ds "config") "badges" }}{{- range $badge := (ds "config").badges -}}{{ printf " [![%s](%s)](%s)" $badge.name $badge.image $badge.url }}{{ end }}{{ end }}
Expand All @@ -8,7 +22,9 @@

---

This project is part of our comprehensive ["Hadenlabs"](https://hadenlabs.com) modules of terraform.
{{ if has (ds "config") "company" }}
This project is part of our comprehensive [{{ printf (ds "config").company.name}}]({{ printf (ds "config").company.url}}) modules of terraform.
{{end}}

{{ if eq (ds "config").license "APACHE2" }} It's 100% Open Source and licensed under the [APACHE2](LICENSE). {{ end }} {{ if eq (ds "config").license "CC-BY-NC-SA-4.0" }} It's 100% Open Source and licensed under the [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](LICENSE).

Expand All @@ -18,7 +34,12 @@ This project is part of our comprehensive ["Hadenlabs"](https://hadenlabs.com) m

## Screenshots

{{ range $screenshot := (ds "config").screenshots }} {{ printf "![%s](%s)\n*%s*" $screenshot.name $screenshot.url $screenshot.description }}{{ end }} {{ end }} {{ if has (ds "config") "introduction" }}
{{ range $screenshot := (ds "config").screenshots }}
{{ printf "![%s](%s)\n*%s*" $screenshot.name $screenshot.url $screenshot.description }}
{{ end }}
{{ end }}

{{ if has (ds "config") "introduction" }}

## Introduction

Expand Down Expand Up @@ -68,7 +89,8 @@ Please use the [issue tracker]({{ printf "https://github.com/%s/issues" (ds "con

### Developing

If you are interested in being a contributor and want to get involved in developing this project or [help out](https://github.com/hadenlabs) with our other projects, we would love to hear from you! Shoot us an [email](mailto:hola@hadenlabs.com).
If you are interested in being a contributor and want to get involved in developing this project or [help out]({{ printf (ds "config").company.url}})
with our other projects, we would love to hear from you! Shoot us an [email](mailto:{{ printf (ds "config").email.support}}).

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

Expand All @@ -78,17 +100,19 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
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 changes from "upstream" before making a pull request!
**NOTE:** Be sure to rebase the latest changes from "upstream" before making a pull request!

{{ if has (ds "config") "copyrights" }}

## Copyrights

{{ range $copyright := (ds "config").copyrights -}} {{ printf "Copyright © %s-%d [%s](%s)\n" $copyright.year time.Now.Year $copyright.name $copyright.url }} {{ end }} {{ else }}
{{ range $copyright := (ds "config").copyrights -}} {{ printf "Copyright © %s-%d [%s](%s)\n" $copyright.year time.Now.Year $copyright.name $copyright.url }} {{ end }}
{{ else }}

## Copyright

Copyright © 2018-{{ time.Now.Year }} [Hadenlabs, LLC](https://hadenlabs.com) {{ end}}
Copyright © 2018-{{ time.Now.Year }} [Hadenlabs](https://hadenlabs.com)
{{ end}}

{{ if eq (ds "config").license "APACHE2" }}

Expand Down Expand Up @@ -187,12 +211,26 @@ All other trademarks referenced herein are the property of their respective owne

## About

This project is maintained and funded by [Hadenlabs, LLC][website]. Like it? Please let us know at <hola@hadenlabs.com>
This project is maintained and funded by [{{ printf (ds "config").copyright.name }}][{{ printf (ds "config").copyright.url }}]. Like it? Please let us know at <{{ printf (ds "config").email.support }}>

{{ if has (datasource "config") "contributors" }}

### Contributors

| {{ range $contributor := (ds "config").contributors }}{{ printf " [![%s][%s_avatar]][%s_homepage]<br/>[%s][%s_homepage] |" $contributor.name $contributor.github $contributor.github $contributor.name $contributor.github}}{{ end }} |{{- range $contributor := (ds "config").contributors -}}---|{{ end }}

{{ range $contributor := (ds "config").contributors -}} {{- if has $contributor "homepage" }} {{ printf " [%s_homepage]: %s" $contributor.github $contributor.homepage }} {{ else -}} {{ printf " [%s_homepage]: https://github.com/%s" $contributor.github $contributor.github }} {{ end -}} {{ if has $contributor "avatar" }}{{ printf " [%s_avatar]: %s" $contributor.github $contributor.avatar }} {{ else -}} {{ printf " [%s_avatar]: https://github.com/%s.png?size=150" $contributor.github $contributor.github }} {{- end }} {{ end }} {{ end }}
| {{ range $contributor := (ds "config").contributors }}{{ printf " [![%s][%s_avatar]][%s_homepage]<br/>[%s][%s_homepage] |" $contributor.name $contributor.github $contributor.github $contributor.name $contributor.github}}{{ end }}
|{{- range $contributor := (ds "config").contributors -}}---|{{ end }}

{{ range $contributor := (ds "config").contributors -}}
{{- if has $contributor "homepage" }}
{{ printf " [%s_homepage]: %s" $contributor.github $contributor.homepage }}
{{ else -}}
{{ printf " [%s_homepage]: https://github.com/%s" $contributor.github $contributor.github }}
{{ end -}}
{{ if has $contributor "avatar" }}
{{ printf " [%s_avatar]: %s" $contributor.github $contributor.avatar }}
{{ else -}}
{{ printf " [%s_avatar]: https://github.com/%s.png?size=150" $contributor.github $contributor.github }}
{{- end }}
{{ end }}

{{ end }}

0 comments on commit 34ead3d

Please sign in to comment.