├── .github
├── labeler.yml
└── workflows
│ ├── build.yml
│ ├── label.yml
│ ├── linter.yml.disabled
│ └── release.yml
├── .gitignore
├── .vscode
├── launch.json
└── tasks.json
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── COMMANDS.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── NOTICE
├── README.md
├── VERSIONING.md
├── box
├── .gitignore
├── box.go
├── gen.go
└── resources
│ ├── VERSION
│ ├── init
│ ├── .gitignore
│ ├── clencli
│ │ ├── aws-well-architected.tmpl
│ │ ├── aws-well-architected.yaml
│ │ ├── hld.tmpl
│ │ ├── hld.yaml
│ │ ├── readme.tmpl
│ │ └── readme.yaml
│ └── project
│ │ └── type
│ │ ├── clouformation
│ │ ├── skeleton.json
│ │ └── skeleton.yaml
│ │ └── terraform
│ │ ├── LICENSE
│ │ ├── Makefile
│ │ ├── environments
│ │ ├── dev.tf
│ │ └── prod.tf
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ └── manual
│ ├── configure.yaml
│ ├── gitignore.yaml
│ ├── init.yaml
│ ├── render.yaml
│ ├── root.yaml
│ ├── unsplash.yaml
│ └── version.yaml
├── clencli
├── logo.jpeg
├── readme.tmpl
├── readme.yaml
└── unsplash.yaml
├── cobra
├── README.md
├── aid
│ ├── configure.go
│ ├── gitignore.go
│ ├── init.go
│ ├── render.go
│ ├── root.go
│ └── unsplash.go
├── cmd
│ ├── configure.go
│ ├── gitignore.go
│ ├── init.go
│ ├── render.go
│ ├── root.go
│ ├── unsplash.go
│ └── version.go
├── controller
│ ├── configure.go
│ ├── gitignore.go
│ ├── init.go
│ ├── render.go
│ ├── root.go
│ ├── unsplash.go
│ └── version.go
├── dao
│ └── configure.go
├── model
│ ├── configure.go
│ ├── init.go
│ ├── root.go
│ └── unsplash.go
└── view
│ └── configure.go
├── go.mod
├── go.sum
├── helper
├── cobra.go
├── directories.go
├── files.go
├── manual.go
└── strings.go
├── lib
└── make
│ ├── cobra
│ └── Makefile
│ ├── docker
│ └── Makefile
│ ├── github
│ └── Makefile
│ └── go
│ └── Makefile
├── main.go
├── tests
├── cmd_gitignore_test.go
├── cmd_init_test.go
├── cmd_render_test.go
├── cmd_root_test.go
├── cmd_unsplash_test.go
├── cmd_version_test.go
└── pkg_test.go
└── unsplash.yaml
/.github/labeler.yml:
--------------------------------------------------------------------------------
1 | documentation:
2 | - docs/**/*
3 | - docs-src/**/*
4 |
5 | dependencies:
6 | - go.mod
7 | - go.sum
8 | - vendor/**/*
9 |
10 | build:
11 | - .github/workflows/*
12 | - Makefile
13 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 | on: [push]
3 | jobs:
4 | linux-build:
5 | runs-on: ubuntu-latest
6 | steps:
7 | - uses: actions/checkout@v2
8 | - uses: actions/setup-go@v2
9 | with:
10 | go-version: '^1.16.4'
11 | - run: sudo apt-get install -y git
12 | - run: go version
13 | - run: go env
14 | - run: go get ./...
15 | - run: go generate ./...
16 | - name: go test
17 | run: cd tests && go test pkg_test.go cmd_root_test.go cmd_init_test.go cmd_render_test.go cmd_version_test.go
18 | - name: go build
19 | run: mkdir bin && go build -o bin/clencli
20 | windows-build:
21 | runs-on: windows-latest
22 | steps:
23 | - uses: actions/checkout@v2
24 | - uses: actions/setup-go@v2
25 | with:
26 | go-version: '^1.16.4'
27 | - run: go version
28 | - run: go env
29 | - run: go get ./...
30 | - run: go generate ./...
31 | - name: go test
32 | run: cd tests && go test pkg_test.go cmd_root_test.go cmd_init_test.go cmd_render_test.go cmd_version_test.go
33 | - name: go build
34 | run: New-Item -Path "." -Name "bin" -ItemType "directory" && go build -o bin/clencli
--------------------------------------------------------------------------------
/.github/workflows/label.yml:
--------------------------------------------------------------------------------
1 | name: Labeler
2 | on: [pull_request]
3 |
4 | jobs:
5 | label:
6 | runs-on: ubuntu-latest
7 | steps:
8 | - uses: actions/labeler@v2
9 | with:
10 | repo-token: "${{ secrets.GITHUB_TOKEN }}"
--------------------------------------------------------------------------------
/.github/workflows/linter.yml.disabled:
--------------------------------------------------------------------------------
1 | name: Lint
2 |
3 | # Run this workflow every time a new commit pushed to the repository
4 | on: [pull_request]
5 |
6 | jobs:
7 | # Set the job key. The key is displayed as the job name when a job name is not provided
8 | super-lint:
9 | # Name the Job
10 | name: Lint Code Base
11 | # Set the type of machine to run on
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | # Checks out a copy of your repository on the ubuntu-latest machine
16 | - name: Checkout code
17 | uses: actions/checkout@v2
18 |
19 | # Runs the Super-Linter action
20 | - name: Lint Code Base
21 | uses: github/super-linter@v3
22 | env:
23 | DEFAULT_BRANCH: main
24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 |
26 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 | on:
3 | push:
4 | # Sequence of patterns matched against refs/tags
5 | tags:
6 | - '*' # Push events to matching v*, i.e. v1.0, v20.15.10
7 | jobs:
8 | release:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v2
12 | - uses: actions/setup-go@v2
13 | with:
14 | go-version: '^1.15.2' # The Go version to download (if necessary) and use.
15 | - run: go version
16 | - run: go env
17 | - run: go get ./...
18 | - run: go generate ./...
19 | - run: make clencli/compile
20 | - name: Create Release
21 | id: create_release
22 | uses: actions/create-release@v1
23 | env:
24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
25 | with:
26 | tag_name: ${{ github.ref }}
27 | release_name: Release ${{ github.ref }}
28 | body_path: CHANGELOG.md
29 | draft: false # true to create a draft (unpublished) release, false to create a published one. Default: false
30 | prerelease: false # true to identify the release as a prerelease. false to identify the release as a full release. Default: false
31 | - name: Upload Release Asset (clencli-darwin-amd64)
32 | id: upload-release-asset-clencli-darwin-amd64
33 | uses: actions/upload-release-asset@v1
34 | env:
35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 | with:
37 | upload_url: ${{ steps.create_release.outputs.upload_url }}
38 | asset_path: ./dist/clencli-darwin-amd64
39 | asset_name: clencli-darwin-amd64
40 | asset_content_type: application/x-clencli
41 | - name: Upload Release Asset (clencli-solaris-amd64)
42 | id: upload-release-asset-clencli-solaris-amd64
43 | uses: actions/upload-release-asset@v1
44 | env:
45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 | with:
47 | upload_url: ${{ steps.create_release.outputs.upload_url }}
48 | asset_path: ./dist/clencli-solaris-amd64
49 | asset_name: clencli-solaris-amd64
50 | asset_content_type: application/x-clencli
51 | - name: Upload Release Asset (clencli-freebsd-386)
52 | id: upload-release-asset-clencli-freebsd-386
53 | uses: actions/upload-release-asset@v1
54 | env:
55 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56 | with:
57 | upload_url: ${{ steps.create_release.outputs.upload_url }}
58 | asset_path: ./dist/clencli-freebsd-386
59 | asset_name: clencli-freebsd-386
60 | asset_content_type: application/x-clencli
61 | - name: Upload Release Asset (clencli-freebsd-amd64)
62 | id: upload-release-asset-clencli-freebsd-amd64
63 | uses: actions/upload-release-asset@v1
64 | env:
65 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66 | with:
67 | upload_url: ${{ steps.create_release.outputs.upload_url }}
68 | asset_path: ./dist/clencli-freebsd-amd64
69 | asset_name: clencli-freebsd-amd64
70 | asset_content_type: application/x-clencli
71 | - name: Upload Release Asset (clencli-freebsd-arm)
72 | id: upload-release-asset-clencli-freebsd-arm
73 | uses: actions/upload-release-asset@v1
74 | env:
75 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76 | with:
77 | upload_url: ${{ steps.create_release.outputs.upload_url }}
78 | asset_path: ./dist/clencli-freebsd-arm
79 | asset_name: clencli-freebsd-arm
80 | asset_content_type: application/x-clencli
81 | - name: Upload Release Asset (clencli-openbsd-386)
82 | id: upload-release-asset-clencli-openbsd-386
83 | uses: actions/upload-release-asset@v1
84 | env:
85 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86 | with:
87 | upload_url: ${{ steps.create_release.outputs.upload_url }}
88 | asset_path: ./dist/clencli-openbsd-386
89 | asset_name: clencli-openbsd-386
90 | asset_content_type: application/x-clencli
91 | - name: Upload Release Asset (clencli-openbsd-amd64)
92 | id: upload-release-asset-clencli-openbsd-amd64
93 | uses: actions/upload-release-asset@v1
94 | env:
95 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 | with:
97 | upload_url: ${{ steps.create_release.outputs.upload_url }}
98 | asset_path: ./dist/clencli-openbsd-amd64
99 | asset_name: clencli-openbsd-amd64
100 | asset_content_type: application/x-clencli
101 | - name: Upload Release Asset (clencli-openbsd-arm)
102 | id: upload-release-asset-clencli-openbsd-arm
103 | uses: actions/upload-release-asset@v1
104 | env:
105 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106 | with:
107 | upload_url: ${{ steps.create_release.outputs.upload_url }}
108 | asset_path: ./dist/clencli-openbsd-arm
109 | asset_name: clencli-openbsd-arm
110 | asset_content_type: application/x-clencli
111 | - name: Upload Release Asset (clencli-linux-386)
112 | id: upload-release-asset-clencli-linux-386
113 | uses: actions/upload-release-asset@v1
114 | env:
115 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116 | with:
117 | upload_url: ${{ steps.create_release.outputs.upload_url }}
118 | asset_path: ./dist/clencli-linux-386
119 | asset_name: clencli-linux-386
120 | asset_content_type: application/x-clencli
121 | - name: Upload Release Asset (clencli-linux-amd64)
122 | id: upload-release-asset-clencli-linux-amd64
123 | uses: actions/upload-release-asset@v1
124 | env:
125 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126 | with:
127 | upload_url: ${{ steps.create_release.outputs.upload_url }}
128 | asset_path: ./dist/clencli-linux-amd64
129 | asset_name: clencli-linux-amd64
130 | asset_content_type: application/x-clencli
131 | - name: Upload Release Asset (clencli-linux-arm)
132 | id: upload-release-asset-clencli-linux-arm
133 | uses: actions/upload-release-asset@v1
134 | env:
135 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
136 | with:
137 | upload_url: ${{ steps.create_release.outputs.upload_url }}
138 | asset_path: ./dist/clencli-linux-arm
139 | asset_name: clencli-linux-arm
140 | asset_content_type: application/x-clencli
141 | - name: Upload Release Asset (clencli-windows-386)
142 | id: upload-release-asset-clencli-windows-386
143 | uses: actions/upload-release-asset@v1
144 | env:
145 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146 | with:
147 | upload_url: ${{ steps.create_release.outputs.upload_url }}
148 | asset_path: ./dist/clencli-windows-386.exe
149 | asset_name: clencli-windows-386.exe
150 | asset_content_type: application/x-clencli
151 | - name: Upload Release Asset (clencli-windows-amd64)
152 | id: upload-release-asset-clencli-windows-amd64
153 | uses: actions/upload-release-asset@v1
154 | env:
155 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156 | with:
157 | upload_url: ${{ steps.create_release.outputs.upload_url }}
158 | asset_path: ./dist/clencli-windows-amd64.exe
159 | asset_name: clencli-windows-amd64.exe
160 | asset_content_type: application/x-clencli
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/go,java,linux,macos,python,windows,virtualenv,visualstudiocode
3 | # Edit at https://www.gitignore.io/?templates=go,java,linux,macos,python,windows,virtualenv,visualstudiocode
4 |
5 | ### Go ###
6 | # Binaries for programs and plugins
7 | *.exe
8 | *.exe~
9 | *.dll
10 | *.so
11 | *.dylib
12 |
13 | # Test binary, built with `go test -c`
14 | *.test
15 |
16 | # Output of the go coverage tool, specifically when used with LiteIDE
17 | *.out
18 |
19 | # Dependency directories (remove the comment below to include it)
20 | # vendor/
21 |
22 | ### Go Patch ###
23 | /vendor/
24 | /Godeps/
25 |
26 | ### Java ###
27 | # Compiled class file
28 | *.class
29 |
30 | # Log file
31 | *.log
32 |
33 | # BlueJ files
34 | *.ctxt
35 |
36 | # Mobile Tools for Java (J2ME)
37 | .mtj.tmp/
38 |
39 | # Package Files #
40 | *.jar
41 | *.war
42 | *.nar
43 | *.ear
44 | *.zip
45 | *.tar.gz
46 | *.rar
47 |
48 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
49 | hs_err_pid*
50 |
51 | ### Linux ###
52 | *~
53 |
54 | # temporary files which can be created if a process still has a handle open of a deleted file
55 | .fuse_hidden*
56 |
57 | # KDE directory preferences
58 | .directory
59 |
60 | # Linux trash folder which might appear on any partition or disk
61 | .Trash-*
62 |
63 | # .nfs files are created when an open file is removed but is still being accessed
64 | .nfs*
65 |
66 | ### macOS ###
67 | # General
68 | .DS_Store
69 | .AppleDouble
70 | .LSOverride
71 |
72 | # Icon must end with two \r
73 | Icon
74 |
75 | # Thumbnails
76 | ._*
77 |
78 | # Files that might appear in the root of a volume
79 | .DocumentRevisions-V100
80 | .fseventsd
81 | .Spotlight-V100
82 | .TemporaryItems
83 | .Trashes
84 | .VolumeIcon.icns
85 | .com.apple.timemachine.donotpresent
86 |
87 | # Directories potentially created on remote AFP share
88 | .AppleDB
89 | .AppleDesktop
90 | Network Trash Folder
91 | Temporary Items
92 | .apdisk
93 |
94 | ### Python ###
95 | # Byte-compiled / optimized / DLL files
96 | __pycache__/
97 | *.py[cod]
98 | *$py.class
99 |
100 | # C extensions
101 |
102 | # Distribution / packaging
103 | .Python
104 | build/
105 | develop-eggs/
106 | dist/
107 | downloads/
108 | eggs/
109 | .eggs/
110 | lib64/
111 | parts/
112 | sdist/
113 | var/
114 | wheels/
115 | pip-wheel-metadata/
116 | share/python-wheels/
117 | *.egg-info/
118 | .installed.cfg
119 | *.egg
120 | MANIFEST
121 |
122 | # PyInstaller
123 | # Usually these files are written by a python script from a template
124 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
125 | *.manifest
126 | *.spec
127 |
128 | # Installer logs
129 | pip-log.txt
130 | pip-delete-this-directory.txt
131 |
132 | # Unit test / coverage reports
133 | htmlcov/
134 | .tox/
135 | .nox/
136 | .coverage
137 | .coverage.*
138 | .cache
139 | nosetests.xml
140 | coverage.xml
141 | *.cover
142 | .hypothesis/
143 | .pytest_cache/
144 |
145 | # Translations
146 | *.mo
147 | *.pot
148 |
149 | # Scrapy stuff:
150 | .scrapy
151 |
152 | # Sphinx documentation
153 | docs/_build/
154 |
155 | # PyBuilder
156 | target/
157 |
158 | # pyenv
159 | .python-version
160 |
161 | # pipenv
162 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
163 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
164 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
165 | # install all needed dependencies.
166 | #Pipfile.lock
167 |
168 | # celery beat schedule file
169 | celerybeat-schedule
170 |
171 | # SageMath parsed files
172 | *.sage.py
173 |
174 | # Spyder project settings
175 | .spyderproject
176 | .spyproject
177 |
178 | # Rope project settings
179 | .ropeproject
180 |
181 | # Mr Developer
182 | .mr.developer.cfg
183 | .project
184 | .pydevproject
185 |
186 | # mkdocs documentation
187 | /site
188 |
189 | # mypy
190 | .mypy_cache/
191 | .dmypy.json
192 | dmypy.json
193 |
194 | # Pyre type checker
195 | .pyre/
196 |
197 | ### VirtualEnv ###
198 | # Virtualenv
199 | # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
200 | pyvenv.cfg
201 | .env
202 | .venv
203 | env/
204 | venv/
205 | ENV/
206 | env.bak/
207 | venv.bak/
208 | pip-selfcheck.json
209 |
210 | ### VisualStudioCode ###
211 | .vscode/*
212 | !.vscode/settings.json
213 | !.vscode/tasks.json
214 | !.vscode/launch.json
215 | !.vscode/extensions.json
216 |
217 | ### VisualStudioCode Patch ###
218 | # Ignore all local history of files
219 | .history
220 |
221 | ### Windows ###
222 | # Windows thumbnail cache files
223 | Thumbs.db
224 | Thumbs.db:encryptable
225 | ehthumbs.db
226 | ehthumbs_vista.db
227 |
228 | # Dump file
229 | *.stackdump
230 |
231 | # Folder config file
232 | [Dd]esktop.ini
233 |
234 | # Recycle Bin used on file shares
235 | $RECYCLE.BIN/
236 |
237 | # Windows Installer files
238 | *.cab
239 | *.msi
240 | *.msix
241 | *.msm
242 | *.msp
243 |
244 | # Windows shortcuts
245 | *.lnk
246 |
247 | # End of https://www.gitignore.io/api/go,java,linux,macos,python,windows,virtualenv,visualstudiocode
248 |
249 | # Custom rules
250 | downloads/
251 | generated-*/
252 | bin/*
253 | dist/*
254 | # Ignore the examples folder (also used as a branch)
255 | examples/*
256 | test/*
257 | *debug_bin*
258 | clencli/log.json
259 | *.tmp*
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "d-configure",
9 | "type": "go",
10 | "request": "launch",
11 | "mode": "debug",
12 | "program": "${workspaceFolder}/main.go",
13 | "args": ["configure"]
14 | },
15 | {
16 | "name": "d-configure-delete-profile",
17 | "type": "go",
18 | "request": "launch",
19 | "mode": "debug",
20 | "program": "${workspaceFolder}/main.go",
21 | "args": ["configure", "delete", "--profile", "dylan"]
22 | },
23 | {
24 | "name": "d-init-help",
25 | "type": "go",
26 | "request": "launch",
27 | "mode": "debug",
28 | "program": "${workspaceFolder}/main.go",
29 | "args": ["init", "--help"]
30 | },
31 | {
32 | "name": "d-init-project-basic",
33 | "type": "go",
34 | "request": "launch",
35 | "mode": "debug",
36 | "program": "${workspaceFolder}/main.go",
37 | "args": ["init", "project", "--name", "generated-basic-project"]
38 | },
39 | {
40 | "name": "d-init-project-terraform",
41 | "type": "go",
42 | "request": "launch",
43 | "mode": "debug",
44 | "program": "${workspaceFolder}/main.go",
45 | "args": ["init", "project", "--name", "generated-terraform-project", "--type", "terraform"],
46 | },
47 | {
48 | "name": "d-init-project-terraform-with-only-customized-structure",
49 | "type": "go",
50 | "request": "launch",
51 | "mode": "debug",
52 | "program": "${workspaceFolder}/main.go",
53 | "args": ["init", "project", "--name", "generated-terraform-project-only-customized-structure", "--type", "terraform", "-o"],
54 | },
55 | {
56 | "name": "d-render-template",
57 | "type": "go",
58 | "request": "launch",
59 | "mode": "debug",
60 | "program": "${workspaceFolder}/main.go",
61 | "args": ["render", "template"],
62 | }
63 | ]
64 | }
--------------------------------------------------------------------------------
/.vscode/tasks.json:
--------------------------------------------------------------------------------
1 | {
2 | // See https://go.microsoft.com/fwlink/?LinkId=733558
3 | // for the documentation about the tasks.json format
4 | "version": "2.0.0",
5 | "tasks": [
6 | {
7 | "label": "build",
8 | "type": "shell",
9 | "command": "make clencli/build",
10 | "problemMatcher": [],
11 | "group": {
12 | "kind": "build",
13 | "isDefault": true
14 | }
15 | },
16 | {
17 | "label": "render-template",
18 | "type": "shell",
19 | "command": [
20 | "go",
21 | "run",
22 | "${workspaceFolder}/main.go",
23 | "render",
24 | "template"
25 | ],
26 | "problemMatcher": [],
27 | "group": "build"
28 | }
29 | ]
30 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | ## v0.3.6
4 |
5 | * Fixed render template command on Windows
6 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
2 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
3 | opensource-codeofconduct@amazon.com with any additional questions or comments.
4 |
--------------------------------------------------------------------------------
/COMMANDS.md:
--------------------------------------------------------------------------------
1 | ## Commands
2 | ```
3 | The Cloud Engineer CLI
4 |
5 | Usage:
6 | clencli [command]
7 |
8 | Available Commands:
9 | configure Configures CLENCLI global settings
10 | gitignore Download .gitignore based on the given input
11 | help Help about any command
12 | init Initialize a project
13 | render Render a template
14 | unsplash Downloads random photos from Unsplash.com
15 | version Displays the version of CLENCLI and all installed plugins
16 |
17 | Flags:
18 | -h, --help help for clencli
19 | --log Enable or disable logs (can be found at ./clencli/log.json). Log outputs will be redirected default output if disabled. (default true)
20 | --log-file-path string Log file path. Requires log=true, ignored otherwise. (default "clencli/log.json")
21 | -p, --profile string Use a specific profile from your credentials and configurations file. (default "default")
22 | -v, --verbosity string Valid log level:panic,fatal,error,warn,info,debug,trace). (default "error")
23 |
24 | Use "clencli [command] --help" for more information about a command.
25 | ```
26 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ### Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ### Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ### Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *master* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ### Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45 |
46 |
47 | ### Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ### Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ### Licensing
58 |
59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60 |
61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes.
62 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 |
3 | include lib/make/*/Makefile
4 |
5 | .PHONY: clencli/test
6 | clencli/test: clencli/build go/test
7 |
8 | .PHONY: clencli/build
9 | clencli/build: clencli/clean go/mod/tidy go/version go/fmt go/generate go/install clencli/update-readme ## Builds the app
10 |
11 | .PHONY: clencli/install
12 | clencli/install: go/get go/fmt go/generate go/install ## Builds the app and install all dependencies
13 |
14 | .PHONY: clencli/run
15 | clencli/run: go/fmt ## Run a command
16 | ifdef command
17 | make go/run command='$(command)'
18 | else
19 | make go/run
20 | endif
21 |
22 | .PHONY: clencli/compile
23 | clencli/compile: ## Compile to multiple architectures
24 | @mkdir -p dist
25 | @echo "Compiling for every OS and Platform"
26 | GOOS=darwin GOARCH=amd64 go build -o dist/clencli-darwin-amd64 main.go
27 | GOOS=solaris GOARCH=amd64 go build -o dist/clencli-solaris-amd64 main.go
28 |
29 | GOOS=freebsd GOARCH=386 go build -o dist/clencli-freebsd-386 main.go
30 | GOOS=freebsd GOARCH=amd64 go build -o dist/clencli-freebsd-amd64 main.go
31 | GOOS=freebsd GOARCH=arm go build -o dist/clencli-freebsd-arm main.go
32 |
33 | GOOS=openbsd GOARCH=386 go build -o dist/clencli-openbsd-386 main.go
34 | GOOS=openbsd GOARCH=amd64 go build -o dist/clencli-openbsd-amd64 main.go
35 | GOOS=openbsd GOARCH=arm go build -o dist/clencli-openbsd-arm main.go
36 |
37 | GOOS=linux GOARCH=386 go build -o dist/clencli-linux-386 main.go
38 | GOOS=linux GOARCH=amd64 go build -o dist/clencli-linux-amd64 main.go
39 | GOOS=linux GOARCH=arm go build -o dist/clencli-linux-arm main.go
40 |
41 | GOOS=windows GOARCH=386 go build -o dist/clencli-windows-386.exe main.go
42 | GOOS=windows GOARCH=amd64 go build -o dist/clencli-windows-amd64.exe main.go
43 |
44 | .PHONY: clencli/clean
45 | clencli/clean: ## Removes unnecessary files and directories
46 | rm -rf downloads/
47 | rm -rf generated-*/
48 | rm -rf dist/
49 | rm -rf build/
50 | rm -f box/blob.go
51 |
52 | #rm -f $$GOPATH/bin/clencli
53 |
54 | .PHONY: clencli/update-readme
55 | clencli/update-readme: ## Renders template readme.tmpl with additional documents
56 | @echo "Updating README.tmpl to the latest version"
57 | @cp box/resources/init/clencli/readme.tmpl clencli/readme.tmpl
58 | @echo "Generate COMMANDS.md"
59 | @echo "## Commands" > COMMANDS.md
60 | @echo '```' >> COMMANDS.md
61 | @clencli --help >> COMMANDS.md
62 | @echo '```' >> COMMANDS.md
63 | @echo "COMMANDS.md generated successfully"
64 | @clencli render template --name readme
65 |
66 | # .PHONY: clencli/test
67 | # clencli/test: go/test
68 |
69 | .DEFAULT_GOAL := help
70 |
71 | .PHONY: help
72 | help: ## This HELP message
73 | @fgrep -h ": ##" $(MAKEFILE_LIST) | sed -e 's/\(\:.*\#\#\)/\:\ /' | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
74 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |  on [Unsplash](https://unsplash.com)](clencli/logo.jpeg)
16 |
17 | > Photo by [Felipe Dias](https://unsplash.com/fdiascreator) on [Unsplash](https://unsplash.com)
18 |
19 |
20 | [](https://github.com/awslabs/clencli/issues)[](https://github.com/awslabs/clencli/network)[](https://github.com/awslabs/clencli/stargazers)[](https://github.com/awslabs/clencli/blob/master/LICENSE)[](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fawslabs%2Fclencli)
21 |
22 | # Cloud Engineer CLI ( clencli )
23 |
24 | A CLI built to assist Cloud Engineers.
25 |
26 | ## Table of Contents
27 | ---
28 |
29 |
30 |
31 |
32 | - [Usage](#usage)
33 |
34 | - [Installing](#installing)
35 |
36 |
37 | - [Acknowledgments](#acknowledgments)
38 | - [Contributors](#contributors)
39 | - [References](#references)
40 | - [License](#license)
41 | - [Copyright](#copyright)
42 |
43 |
44 |
45 |
46 | ## Usage
47 | ---
48 |
49 | Expand
50 |
51 | In a polyglot world where a team can choose it's programming language, often this flexibility can spill into chaos as every repo looks different.
52 | CLENCLI solves this issue by giving developers a quick and easy way to create a standardised repo structure and easily rendering documentation via a YAML file.
53 |
54 | ### Create a new project
55 | ```
56 | $ clencli init project --project-name foo
57 | $ tree -a moon/
58 | foo/
59 | ├── clencli
60 | │ ├── readme.tmpl
61 | │ └── readme.yaml
62 | └── .gitignore
63 | ```
64 |
65 | ### Create a new CloudFormation project
66 | ```
67 | $ clencli init project --project-name foo --project-type cloudformation
68 | $ tree -a sun/
69 | foo/
70 | ├── clencli
71 | │ ├── hld.tmpl
72 | │ ├── hld.yaml
73 | │ ├── readme.tmpl
74 | │ └── readme.yaml
75 | ├── environments
76 | │ ├── dev
77 | │ └── prod
78 | ├── .gitignore
79 | ├── skeleton.json
80 | └── skeleton.yaml
81 | ```
82 |
83 | ### Create a new Terraform project
84 | ```
85 | $ clencli init project --project-name foo --project-type terraform
86 | $ tree -a foo/
87 | foo/
88 | ├── clencli
89 | │ ├── hld.tmpl
90 | │ ├── hld.yaml
91 | │ ├── readme.tmpl
92 | │ └── readme.yaml
93 | ├── environments
94 | │ ├── dev.tf
95 | │ └── prod.tf
96 | ├── .gitignore
97 | ├── LICENSE
98 | ├── main.tf
99 | ├── Makefile
100 | ├── outputs.tf
101 | └── variables.tf
102 | ```
103 |
104 | ## Render a template
105 | ```
106 | $ clencli init project --project-name foo
107 | foo was successfully initialized as a basic project
108 | $ cd foo/
109 | $ clencli render template
110 | Template readme.tmpl rendered as README.md
111 | ```
112 |
113 | The `README.md` you are reading right now was generated and it's maintained by `CLENCLI` itself.
114 | Please check [readme.yaml](clencli/readme.yaml) for more details.
115 |
116 | ## Download a .gitignore for your project
117 | ```
118 | $ clencli gitignore --input="terraform,visualstudiocode"
119 | .gitignore created successfully
120 | $ less .gitignore
121 |
122 | # Created by https://www.toptal.com/developers/gitignore/api/terraform,visualstudiocode
123 | # Edit at https://www.toptal.com/developers/gitignore?templates=terraform,visualstudiocode
124 |
125 | ### Terraform ###
126 | # Local .terraform directories
127 | **/.terraform/*
128 |
129 | # .tfstate files
130 | *.tfstate
131 | *.tfstate.*
132 |
133 | # Crash log files
134 | crash.log
135 |
136 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most
137 | # .tfvars files are managed as part of configuration and so should be included in
138 | # version control.
139 | #
140 | # example.tfvars
141 |
142 | # Ignore override files as they are usually used to override resources locally and so
143 | # are not checked in
144 | override.tf
145 | override.tf.json
146 | *_override.tf
147 | *_override.tf.json
148 |
149 | # Include override files you do wish to add to version control using negated pattern
150 | # !example_override.tf
151 |
152 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
153 | # example: *tfplan*
154 |
155 | ### VisualStudioCode ###
156 | .vscode/*
157 | !.vscode/settings.json
158 | !.vscode/tasks.json
159 | !.vscode/launch.json
160 | !.vscode/extensions.json
161 | *.code-workspace
162 |
163 | ### VisualStudioCode Patch ###
164 | # Ignore all local history of files
165 | .history
166 | .ionide
167 |
168 | # End of https://www.toptal.com/developers/gitignore/api/terraform,visualstudiocode
169 |
170 | ```
171 | Additionally, you can also *customize the initialization* of your projects (scaffolding) and download photos for your projects from [unsplash](https://unsplash.com), please read more [here](https://github.com/awslabs/clencli/wiki/Configuration).
172 |
173 |
174 |
175 |
176 |
177 |
178 | ## Installing
179 | ---
180 |
181 | Expand
182 |
183 | Download the latest version [released](https://github.com/awslabs/clencli/releases) according to your platform and execute it directly. I recommend placing the binary into your `$PATH`, so it's easily accessible.
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 | ## Commands
195 | ```
196 | The Cloud Engineer CLI
197 |
198 | Usage:
199 | clencli [command]
200 |
201 | Available Commands:
202 | configure Configures CLENCLI global settings
203 | gitignore Download .gitignore based on the given input
204 | help Help about any command
205 | init Initialize a project
206 | render Render a template
207 | unsplash Downloads random photos from Unsplash.com
208 | version Displays the version of CLENCLI and all installed plugins
209 |
210 | Flags:
211 | -h, --help help for clencli
212 | --log Enable or disable logs (can be found at ./clencli/log.json). Log outputs will be redirected default output if disabled. (default true)
213 | --log-file-path string Log file path. Requires log=true, ignored otherwise. (default "clencli/log.json")
214 | -p, --profile string Use a specific profile from your credentials and configurations file. (default "default")
215 | -v, --verbosity string Valid log level:panic,fatal,error,warn,info,debug,trace). (default "error")
216 |
217 | Use "clencli [command] --help" for more information about a command.
218 | ```
219 |
220 |
221 |
222 |
223 | ## Contributors
224 | ---
225 |
226 | Expand
227 |
228 | | Name | Email | Role |
229 | |:------------:|:--------------------:|:---------------:|
230 | | Silva, Valter | valterh@amazon.com | AWS Professional Services - Cloud Architect |
231 |
232 |
233 |
234 |
235 |
236 | ## Acknowledgments
237 | ---
238 |
239 | Expand
240 |
241 | Gratitude for assistance:
242 | * Sia, William - AWS Professional Service - Senior Cloud Architect
243 | * Dhingra, Prashit - AWS Professional Service - Cloud Architect
244 |
245 |
246 |
247 |
248 |
249 |
250 | ## References
251 | ---
252 |
253 | Expand
254 |
255 | * [cobra](https://github.com/spf13/cobra) - Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.
256 | * [viper](https://github.com/spf13/viper) - Viper is a complete configuration solution for Go applications including 12-Factor apps.
257 | * [twelve-factor-app](https://12factor.net) - The Twelve-Factor App
258 | * [gomplate](https://github.com/hairyhenderson/gomplate) - gomplate is a template renderer which supports a growing list of datasources, such as JSON (including EJSON - encrypted JSON), YAML, AWS EC2 metadata, BoltDB, Hashicorp Consul and Hashicorp Vault secrets.
259 | * [unsplash](https://unsplash.com) - The most powerful photo engine in the world.
260 | * [placeholder](https://placeholder.com) - The Free Image Placeholder Service Favoured By Designers
261 | * [pirate-ipsum](https://pirateipsum.me) - The best Lorem Ipsum Generator in all the sea
262 | * [recordit](https://recordit.co) - Record Fast Screencasts
263 | * [ttystudio](https://github.com/chjj/ttystudio) - A terminal-to-gif recorder minus the headaches.
264 | * [gihub-super-linter](https://github.com/github/super-linter) - GitHub Super Linter
265 | * [github-actions](https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/introduction-to-github-actions) - GitHub Actions
266 | * [gitignore.io](https://www.toptal.com/developers/gitignore) - Create useful .gitignore files for your project
267 |
268 |
269 |
270 |
271 |
272 |
273 | ## License
274 | ---
275 | This project is licensed under the Apache License 2.0.
276 |
277 | For more information please read [LICENSE](LICENSE).
278 |
279 |
280 |
281 | ## Copyright
282 | ---
283 | ```
284 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
285 | ```
286 |
287 |
--------------------------------------------------------------------------------
/VERSIONING.md:
--------------------------------------------------------------------------------
1 | ## Branching strategy
2 | This project has adopted [GitFlow](https://nvie.com/posts/a-successful-git-branching-model/) for its branching strategy model.
3 |
4 | ## Release process
5 | This project has adopted [Nebula Release Plugin]() for the release process.
6 |
7 | ### Explanation
8 |
9 | `final` - Sets the version to the appropriate `..`, creates tag `v..`
10 |
11 | `candidate` - Sets the version to the appropriate `..-rc.#`, creates tag `v..-rc.#` where `#` is the number of release candidates for this version produced so far. 1st 1.0.0 will be 1.0.0-rc.1, 2nd 1.0.0-rc.2 and so on.
12 |
13 | `devSnapshot` - Sets the version to the appropriate `..-dev.#+`, does not create a tag. Where `#` is the number of commits since the last release and hash is the git hash of the current commit. If releasing a `devSnapshot` from a branch not listed in the releaseBranchPatterns and not excluded by excludeBranchPatterns the version will be `..-dev.#+.`
14 | You can use nebula.release.features.replaceDevWithImmutableSnapshot=true in your gradle.properties file to change pattern of version to ..-snapshot.+. Where timestamp is UTC time in YYYYMMddHHmm format, ex. 201907052105 and hash is the git hash of the current commit. If releasing a immutableSnapshot from a branch not listed in the releaseBranchPatterns and not excluded by excludeBranchPatterns the version will be `..-snapshot.+.`
15 |
--------------------------------------------------------------------------------
/box/.gitignore:
--------------------------------------------------------------------------------
1 | blob.go
--------------------------------------------------------------------------------
/box/box.go:
--------------------------------------------------------------------------------
1 | //go:generate go run gen.go
2 |
3 | package box
4 |
5 | type resourceBox struct {
6 | storage map[string][]byte
7 | }
8 |
9 | func newResourceBox() *resourceBox {
10 | return &resourceBox{storage: make(map[string][]byte)}
11 | }
12 |
13 | // Find for a file
14 | func (r *resourceBox) Has(file string) bool {
15 | if _, ok := r.storage[file]; ok {
16 | return true
17 | }
18 | return false
19 | }
20 |
21 | // Get file's content
22 | // Always use / for looking up
23 | // For example: /init/README.md is actually resources/init/README.md
24 | func (r *resourceBox) Get(file string) ([]byte, bool) {
25 | if f, ok := r.storage[file]; ok {
26 | return f, ok
27 | }
28 | return nil, false
29 | }
30 |
31 | // Add a file to box
32 | func (r *resourceBox) Add(file string, content []byte) {
33 | r.storage[file] = content
34 | }
35 |
36 | // Resource expose
37 | var resources = newResourceBox()
38 |
39 | // Get a file from box
40 | func Get(file string) ([]byte, bool) {
41 | return resources.Get(file)
42 | }
43 |
44 | // Add a file content to box
45 | func Add(file string, content []byte) {
46 | resources.Add(file, content)
47 | }
48 |
49 | // Has a file in box
50 | func Has(file string) bool {
51 | return resources.Has(file)
52 | }
53 |
--------------------------------------------------------------------------------
/box/gen.go:
--------------------------------------------------------------------------------
1 | //+build ignore
2 |
3 | package main
4 |
5 | import (
6 | "bytes"
7 | "fmt"
8 | "go/format"
9 | "io/ioutil"
10 | "log"
11 | "os"
12 | "path/filepath"
13 | "strings"
14 | "text/template"
15 | )
16 |
17 | const blob = "blob.go"
18 |
19 | var packageTemplate = template.Must(template.New("").Funcs(map[string]interface{}{"conv": FormatByteSlice}).Parse(`// Code generated by go generate; DO NOT EDIT.
20 | // generated using files from resources directory
21 | // DO NOT COMMIT this file
22 | package box
23 |
24 | func init(){
25 | {{- range $name, $file := . }}
26 | resources.Add("{{ $name }}", []byte{ {{ conv $file }} })
27 | {{- end }}
28 | }
29 | `))
30 |
31 | func FormatByteSlice(sl []byte) string {
32 | builder := strings.Builder{}
33 | for _, v := range sl {
34 | builder.WriteString(fmt.Sprintf("%d,", int(v)))
35 | }
36 | return builder.String()
37 | }
38 |
39 | func main() {
40 | log.Println("Baking resources... \U0001F4E6")
41 |
42 | if _, err := os.Stat("resources"); os.IsNotExist(err) {
43 | log.Fatal("Resources directory does not exists")
44 | }
45 |
46 | resources := make(map[string][]byte)
47 | err := filepath.Walk("resources", func(path string, info os.FileInfo, err error) error {
48 | if err != nil {
49 | log.Println("Error :", err)
50 | return err
51 | }
52 | relativePath := filepath.ToSlash(strings.TrimPrefix(path, "resources"))
53 | if info.IsDir() {
54 | log.Println(path, "is a directory, skipping... \U0001F47B")
55 | return nil
56 | } else {
57 | log.Println(path, "is a file, baking in... \U0001F31F")
58 | b, err := ioutil.ReadFile(path)
59 | if err != nil {
60 | log.Printf("Error reading %s: %s", path, err)
61 | return err
62 | }
63 | resources[relativePath] = b
64 | }
65 | return nil
66 | })
67 |
68 | if err != nil {
69 | log.Fatal("Error walking through resources directory:", err)
70 | }
71 |
72 | f, err := os.Create(blob)
73 | if err != nil {
74 | log.Fatal("Error creating blob file:", err)
75 | }
76 | defer f.Close()
77 |
78 | builder := &bytes.Buffer{}
79 |
80 | err = packageTemplate.Execute(builder, resources)
81 | if err != nil {
82 | log.Fatal("Error executing template", err)
83 | }
84 |
85 | data, err := format.Source(builder.Bytes())
86 | if err != nil {
87 | log.Fatal("Error formatting generated code", err)
88 | }
89 | err = ioutil.WriteFile(blob, data, os.ModePerm)
90 | if err != nil {
91 | log.Fatal("Error writing blob file", err)
92 | }
93 |
94 | log.Println("Baking resources done... \U0001F680")
95 | log.Println("DO NOT COMMIT box/blob.go \U0001F47B")
96 | }
97 |
--------------------------------------------------------------------------------
/box/resources/VERSION:
--------------------------------------------------------------------------------
1 | 0.3.6
--------------------------------------------------------------------------------
/box/resources/init/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.toptal.com/developers/gitignore/api/go,java,linux,macos,python,windows,virtualenv,visualstudiocode,terraform,intellij
3 | # Edit at https://www.toptal.com/developers/gitignore?templates=go,java,linux,macos,python,windows,virtualenv,visualstudiocode,terraform,intellij
4 |
5 | ### Go ###
6 | # Binaries for programs and plugins
7 | *.exe
8 | *.exe~
9 | *.dll
10 | *.so
11 | *.dylib
12 |
13 | # Test binary, built with `go test -c`
14 | *.test
15 |
16 | # Output of the go coverage tool, specifically when used with LiteIDE
17 | *.out
18 |
19 | # Dependency directories (remove the comment below to include it)
20 | # vendor/
21 |
22 | ### Go Patch ###
23 | /vendor/
24 | /Godeps/
25 |
26 | ### Intellij ###
27 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
28 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
29 |
30 | # User-specific stuff
31 | .idea/**/workspace.xml
32 | .idea/**/tasks.xml
33 | .idea/**/usage.statistics.xml
34 | .idea/**/dictionaries
35 | .idea/**/shelf
36 |
37 | # Generated files
38 | .idea/**/contentModel.xml
39 |
40 | # Sensitive or high-churn files
41 | .idea/**/dataSources/
42 | .idea/**/dataSources.ids
43 | .idea/**/dataSources.local.xml
44 | .idea/**/sqlDataSources.xml
45 | .idea/**/dynamic.xml
46 | .idea/**/uiDesigner.xml
47 | .idea/**/dbnavigator.xml
48 |
49 | # Gradle
50 | .idea/**/gradle.xml
51 | .idea/**/libraries
52 |
53 | # Gradle and Maven with auto-import
54 | # When using Gradle or Maven with auto-import, you should exclude module files,
55 | # since they will be recreated, and may cause churn. Uncomment if using
56 | # auto-import.
57 | # .idea/artifacts
58 | # .idea/compiler.xml
59 | # .idea/jarRepositories.xml
60 | # .idea/modules.xml
61 | # .idea/*.iml
62 | # .idea/modules
63 | # *.iml
64 | # *.ipr
65 |
66 | # CMake
67 | cmake-build-*/
68 |
69 | # Mongo Explorer plugin
70 | .idea/**/mongoSettings.xml
71 |
72 | # File-based project format
73 | *.iws
74 |
75 | # IntelliJ
76 | out/
77 |
78 | # mpeltonen/sbt-idea plugin
79 | .idea_modules/
80 |
81 | # JIRA plugin
82 | atlassian-ide-plugin.xml
83 |
84 | # Cursive Clojure plugin
85 | .idea/replstate.xml
86 |
87 | # Crashlytics plugin (for Android Studio and IntelliJ)
88 | com_crashlytics_export_strings.xml
89 | crashlytics.properties
90 | crashlytics-build.properties
91 | fabric.properties
92 |
93 | # Editor-based Rest Client
94 | .idea/httpRequests
95 |
96 | # Android studio 3.1+ serialized cache file
97 | .idea/caches/build_file_checksums.ser
98 |
99 | ### Intellij Patch ###
100 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
101 |
102 | # *.iml
103 | # modules.xml
104 | # .idea/misc.xml
105 | # *.ipr
106 |
107 | # Sonarlint plugin
108 | # https://plugins.jetbrains.com/plugin/7973-sonarlint
109 | .idea/**/sonarlint/
110 |
111 | # SonarQube Plugin
112 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
113 | .idea/**/sonarIssues.xml
114 |
115 | # Markdown Navigator plugin
116 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
117 | .idea/**/markdown-navigator.xml
118 | .idea/**/markdown-navigator-enh.xml
119 | .idea/**/markdown-navigator/
120 |
121 | # Cache file creation bug
122 | # See https://youtrack.jetbrains.com/issue/JBR-2257
123 | .idea/$CACHE_FILE$
124 |
125 | # CodeStream plugin
126 | # https://plugins.jetbrains.com/plugin/12206-codestream
127 | .idea/codestream.xml
128 |
129 | ### Java ###
130 | # Compiled class file
131 | *.class
132 |
133 | # Log file
134 | *.log
135 |
136 | # BlueJ files
137 | *.ctxt
138 |
139 | # Mobile Tools for Java (J2ME)
140 | .mtj.tmp/
141 |
142 | # Package Files #
143 | *.jar
144 | *.war
145 | *.nar
146 | *.ear
147 | *.zip
148 | *.tar.gz
149 | *.rar
150 |
151 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
152 | hs_err_pid*
153 |
154 | ### Linux ###
155 | *~
156 |
157 | # temporary files which can be created if a process still has a handle open of a deleted file
158 | .fuse_hidden*
159 |
160 | # KDE directory preferences
161 | .directory
162 |
163 | # Linux trash folder which might appear on any partition or disk
164 | .Trash-*
165 |
166 | # .nfs files are created when an open file is removed but is still being accessed
167 | .nfs*
168 |
169 | ### macOS ###
170 | # General
171 | .DS_Store
172 | .AppleDouble
173 | .LSOverride
174 |
175 | # Icon must end with two \r
176 | Icon
177 |
178 |
179 | # Thumbnails
180 | ._*
181 |
182 | # Files that might appear in the root of a volume
183 | .DocumentRevisions-V100
184 | .fseventsd
185 | .Spotlight-V100
186 | .TemporaryItems
187 | .Trashes
188 | .VolumeIcon.icns
189 | .com.apple.timemachine.donotpresent
190 |
191 | # Directories potentially created on remote AFP share
192 | .AppleDB
193 | .AppleDesktop
194 | Network Trash Folder
195 | Temporary Items
196 | .apdisk
197 |
198 | ### Python ###
199 | # Byte-compiled / optimized / DLL files
200 | __pycache__/
201 | *.py[cod]
202 | *$py.class
203 |
204 | # C extensions
205 |
206 | # Distribution / packaging
207 | .Python
208 | build/
209 | develop-eggs/
210 | dist/
211 | downloads/
212 | eggs/
213 | .eggs/
214 | lib/
215 | lib64/
216 | parts/
217 | sdist/
218 | var/
219 | wheels/
220 | pip-wheel-metadata/
221 | share/python-wheels/
222 | *.egg-info/
223 | .installed.cfg
224 | *.egg
225 | MANIFEST
226 |
227 | # PyInstaller
228 | # Usually these files are written by a python script from a template
229 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
230 | *.manifest
231 | *.spec
232 |
233 | # Installer logs
234 | pip-log.txt
235 | pip-delete-this-directory.txt
236 |
237 | # Unit test / coverage reports
238 | htmlcov/
239 | .tox/
240 | .nox/
241 | .coverage
242 | .coverage.*
243 | .cache
244 | nosetests.xml
245 | coverage.xml
246 | *.cover
247 | *.py,cover
248 | .hypothesis/
249 | .pytest_cache/
250 | pytestdebug.log
251 |
252 | # Translations
253 | *.mo
254 | *.pot
255 |
256 | # Django stuff:
257 | local_settings.py
258 | db.sqlite3
259 | db.sqlite3-journal
260 |
261 | # Flask stuff:
262 | instance/
263 | .webassets-cache
264 |
265 | # Scrapy stuff:
266 | .scrapy
267 |
268 | # Sphinx documentation
269 | docs/_build/
270 | doc/_build/
271 |
272 | # PyBuilder
273 | target/
274 |
275 | # Jupyter Notebook
276 | .ipynb_checkpoints
277 |
278 | # IPython
279 | profile_default/
280 | ipython_config.py
281 |
282 | # pyenv
283 | .python-version
284 |
285 | # pipenv
286 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
287 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
288 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
289 | # install all needed dependencies.
290 | #Pipfile.lock
291 |
292 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
293 | __pypackages__/
294 |
295 | # Celery stuff
296 | celerybeat-schedule
297 | celerybeat.pid
298 |
299 | # SageMath parsed files
300 | *.sage.py
301 |
302 | # Environments
303 | .env
304 | .venv
305 | env/
306 | venv/
307 | ENV/
308 | env.bak/
309 | venv.bak/
310 | pythonenv*
311 |
312 | # Spyder project settings
313 | .spyderproject
314 | .spyproject
315 |
316 | # Rope project settings
317 | .ropeproject
318 |
319 | # mkdocs documentation
320 | /site
321 |
322 | # mypy
323 | .mypy_cache/
324 | .dmypy.json
325 | dmypy.json
326 |
327 | # Pyre type checker
328 | .pyre/
329 |
330 | # pytype static type analyzer
331 | .pytype/
332 |
333 | # profiling data
334 | .prof
335 |
336 | ### Terraform ###
337 | # Local .terraform directories
338 | **/.terraform/*
339 |
340 | # .tfstate files
341 | *.tfstate
342 | *.tfstate.*
343 |
344 | # Crash log files
345 | crash.log
346 |
347 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most
348 | # .tfvars files are managed as part of configuration and so should be included in
349 | # version control.
350 | #
351 | # example.tfvars
352 |
353 | # Ignore override files as they are usually used to override resources locally and so
354 | # are not checked in
355 | override.tf
356 | override.tf.json
357 | *_override.tf
358 | *_override.tf.json
359 |
360 | # Include override files you do wish to add to version control using negated pattern
361 | # !example_override.tf
362 |
363 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
364 | # example: *tfplan*
365 |
366 | ### VirtualEnv ###
367 | # Virtualenv
368 | # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
369 | [Bb]in
370 | [Ii]nclude
371 | [Ll]ib
372 | [Ll]ib64
373 | [Ll]ocal
374 | [Ss]cripts
375 | pyvenv.cfg
376 | pip-selfcheck.json
377 |
378 | ### VisualStudioCode ###
379 | .vscode/*
380 | !.vscode/tasks.json
381 | !.vscode/launch.json
382 | *.code-workspace
383 |
384 | ### VisualStudioCode Patch ###
385 | # Ignore all local history of files
386 | .history
387 | .ionide
388 |
389 | ### Windows ###
390 | # Windows thumbnail cache files
391 | Thumbs.db
392 | Thumbs.db:encryptable
393 | ehthumbs.db
394 | ehthumbs_vista.db
395 |
396 | # Dump file
397 | *.stackdump
398 |
399 | # Folder config file
400 | [Dd]esktop.ini
401 |
402 | # Recycle Bin used on file shares
403 | $RECYCLE.BIN/
404 |
405 | # Windows Installer files
406 | *.cab
407 | *.msi
408 | *.msix
409 | *.msm
410 | *.msp
411 |
412 | # Windows shortcuts
413 | *.lnk
414 |
415 | # End of https://www.toptal.com/developers/gitignore/api/go,java,linux,macos,python,windows,virtualenv,visualstudiocode,terraform,intellij
416 |
417 | # CLENCLI Files
418 | clencli/log.json
--------------------------------------------------------------------------------
/box/resources/init/clencli/aws-well-architected.tmpl:
--------------------------------------------------------------------------------
1 | # AWS Well-Architected
2 |
3 | AWS Well-Architected helps cloud architects build secure, high-performing, resilient, and efficient infrastructure for their applications and workloads. Based on five pillars — operational excellence, security, reliability, performance efficiency, and cost optimization — AWS Well-Architected provides a consistent approach for customers and partners to evaluate architectures, and implement designs that can scale over time.
4 |
5 | The AWS Well-Architected Framework started as a single whitepaper but has expanded to include domain-specific lenses, hands-on labs, and the AWS Well-Architected Tool. The AWS WA Tool, available at no cost in the AWS Management Console, provides a mechanism for regularly evaluating your workloads, identifying high risk issues, and recording your improvements.
6 |
7 | AWS has an ecosystem of hundreds of members of the Well-Architected Partner Program. Engage a partner in your area to help you analyze and review your applications.
8 |
9 | ## AWS Well-Architected and the Five Pillars
10 | ### Framework Overview
11 |
12 | The AWS Well-Architected Framework describes the key concepts, design principles, and architectural best practices for designing and running workloads in the cloud. By answering a set of foundational questions, you learn how well your architecture aligns with cloud best practices and are provided guidance for making improvements.
13 |
14 | ### Operational Excellence Pillar
15 |
16 | The operational excellence pillar focuses on running and monitoring systems to deliver business value, and continually improving processes and procedures. Key topics include automating changes, responding to events, and defining standards to manage daily operations.
17 |
18 | ### Security Pillar
19 |
20 | The security pillar focuses on protecting information and systems. Key topics include confidentiality and integrity of data, identifying and managing who can do what with privilege management, protecting systems, and establishing controls to detect security events.
21 |
22 | ### Reliability Pillar
23 |
24 | The reliability pillar focuses on ensuring a workload performs its intended function correctly and consistently when it’s expected to. A resilient workload quickly recovers from failures to meet business and customer demand. Key topics include distributed system design, recovery planning, and how to handle change.
25 |
26 | ### Performance Efficiency Pillar
27 |
28 | The performance efficiency pillar focuses on using IT and computing resources efficiently. Key topics include selecting the right resource types and sizes based on workload requirements, monitoring performance, and making informed decisions to maintain efficiency as business needs evolve
29 |
30 | ### Cost Optimization Pillar
31 |
32 | The cost optimization pillar focuses on avoiding unnecessary costs. Key topics include understanding and controlling where money is being spent, selecting the most appropriate and right number of resource types, analyzing spend over time, and scaling to meet business needs without overspending.
--------------------------------------------------------------------------------
/box/resources/init/clencli/aws-well-architected.yaml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awslabs/clencli/7ecf17182a209ce8ea2de534263b58850cfa2bd7/box/resources/init/clencli/aws-well-architected.yaml
--------------------------------------------------------------------------------
/box/resources/init/clencli/hld.tmpl:
--------------------------------------------------------------------------------
1 | # High Level Design
2 |
3 | ## Table of contents
4 |
5 | {{ if (file.Exists "clencli/hld.yaml") }}
6 |
7 | {{ if (file.Exists "INPUTS.md") }} - [Inputs](#inputs) {{end}}
8 | {{ if (file.Exists "OUTPUTS.md") }} - [Outputs](#outputs) {{end}}
9 |
10 | {{ if has (ds "db") "architecture" }} - [Architecture](#architecture) {{end}}
11 | {{ if has (ds "db") "automation" }} - [Automation](#automation) {{end}}
12 | {{ if has (ds "db") "availability" }} - [Availability](#availability) {{end}}
13 | {{ if has (ds "db") "compliance" }} - [Compliance](#compliance) {{end}}
14 | {{ if has (ds "db") "criticality" }} - [Criticality](#criticality) {{end}}
15 | {{ if has (ds "db") "data" }} - [Data](#data) {{end}}
16 | {{ if has (ds "db") "decisions" }} - [Decisions](#decisions) {{end}}
17 | {{ if has (ds "db") "devops" }} - [Devops](#devops) {{end}}
18 | {{ if has (ds "db") "environments" }} - [Environments](#environments) {{end}}
19 | {{ if has (ds "db") "integration" }} - [integration](#integration) {{end}}
20 | {{ if has (ds "db") "reliability" }} - [Reliability](#reliability) {{end}}
21 | {{ if has (ds "db") "reusable" }} - [Reusable](#Reusable) {{end}}
22 | {{ if has (ds "db") "scalability" }} - [Scalability](#scalability) {{end}}
23 | {{ if has (ds "db") "target" }} - [Target](#target) {{end}}
24 | {{ if has (ds "db") "team" }} - [Team](#team) {{end}}
25 |
26 | {{end}}
27 |
28 | {{ if (file.Exists "clencli/hld.yaml") }}
29 |
30 | {{ if has (ds "db") "architecture" }}
31 | ## Architecture
32 | ---
33 |
34 | Expand
35 |
36 | {{ (ds "db").architecture.description }}
37 |
38 | ### Current state
39 | ---
40 | {{ (ds "db").architecture.currentstate.description }}
41 |
42 | | .architecture.currentstate.diagram.url }}) |
43 | |:--:|
44 | | *{{ (ds "db").architecture.currentstate.diagram.label }}* |
45 |
46 | ### Target state
47 | ---
48 | {{ (ds "db").architecture.targetstate.description }}
49 |
50 | | .architecture.targetstate.diagram.url }}) |
51 | |:--:|
52 | | *{{ (ds "db").architecture.targetstate.diagram.label }}* |
53 |
54 |
55 | {{end}}
56 |
57 | {{ if has (ds "db") "automation" }}
58 | ## Automation
59 | ---
60 |
61 | Expand
62 |
63 | {{ (ds "db").automation }}
64 |
65 | {{end}}
66 |
67 | {{ if has (ds "db") "availability" }}
68 | ## Availability
69 | ---
70 |
71 | Expand
72 |
73 | {{ (ds "db").availability }}
74 |
75 | {{end}}
76 |
77 | {{ if has (ds "db").compliance "requirements" }}
78 | ## Compliance
79 | ---
80 |
81 | Expand
82 |
83 | {{ (ds "db").compliance.requirements }}
84 |
85 | {{end}}
86 |
87 | {{ if has (ds "db").criticality "category" }}
88 | ## Criticality
89 | ---
90 |
91 | Expand
92 |
93 | {{ (ds "db").criticality.category }}
94 |
95 | {{end}}
96 |
97 | {{ if has (ds "db").data "classification" }}
98 | ## Data
99 | ---
100 |
101 | Expand
102 |
103 | {{ (ds "db").data.classification }}
104 |
105 | {{end}}
106 |
107 | {{ if has (ds "db") "decisions" }}
108 | ## Decisions
109 | ---
110 |
111 | Expand
112 |
113 | All known decisions:
114 | {{ range $decision := (ds "db").decisions }}
115 | {{ printf " * %s - *%s* - %s\n ```\n%s\n```" $decision.date $decision.status $decision.context $decision.description }}
116 |
117 | {{end}}
118 |
119 | {{end}}
120 |
121 | {{ if has (ds "db") "devops" }}
122 | ## Devops
123 | ---
124 |
125 | Expand
126 |
127 | {{ range $devop := (ds "db").devops }}
128 | {{ printf " * [%s](%s)" $devop.label $devop.url }}{{end}}
129 |
130 | {{end}}
131 |
132 | {{ if has (ds "db") "environments" }}
133 | ## Environments
134 | ---
135 |
136 | Expand
137 |
138 | | Name | Identifier |
139 | |:------------:|:--------------------:|
140 | {{ range $env := (ds "db").environments }}{{ printf "| %s | %s |\n" $env.name $env.identifier }}{{end}}
141 |
142 | {{end}}
143 |
144 | {{ if has (ds "db") "integration" }}
145 | ## Integration
146 | ---
147 |
148 | Expand
149 |
150 | {{ (ds "db").integration }}
151 |
152 | {{end}}
153 |
154 | {{ if has (ds "db") "reliability" }}
155 | ## Reliability
156 | ---
157 |
158 | Expand
159 |
160 | {{ (ds "db").reliability }}
161 |
162 | {{end}}
163 |
164 | {{ if has (ds "db") "reusable" }}
165 | ## Reusable
166 | ---
167 |
168 | Expand
169 |
170 | {{ (ds "db").reusable }}
171 |
172 | {{end}}
173 |
174 | {{ if has (ds "db") "scalability" }}
175 | ## Scalability
176 | ---
177 |
178 | Expand
179 |
180 | {{ (ds "db").scalability }}
181 |
182 | {{end}}
183 |
184 | {{ if has (ds "db").target "golive" }}
185 | ## Target
186 | ---
187 |
188 | Expand
189 |
190 | Go-Live Date: {{ (ds "db").target.golive }}
191 |
192 | {{end}}
193 |
194 | {{end}}
--------------------------------------------------------------------------------
/box/resources/init/clencli/hld.yaml:
--------------------------------------------------------------------------------
1 | # Show at a high level how:
2 | # * Users interact with the app as a whole
3 | # * Data lifecycle is managed
4 | # * Integrations with and dependencies on other systems
5 | # * Use numbers/letters on diagram to populate table showing what each object does."
6 | # * Do not include deployment mechanism in same diagram as high-level application design.
7 | architecture:
8 | description: Blandit massa enim nec dui nunc mattis.
9 | currentstate:
10 | description: Lorem ipsum dolor sit amet.
11 | diagram:
12 | label: Dui ut ornare lectus sit amet est.
13 | url: https://via.placeholder.com/512x512.png
14 | targetstate:
15 | description: Senectus et netus et malesuada fames ac turpis.
16 | diagram:
17 | label: Elementum curabitur vitae nunc sed velit.
18 | url: https://via.placeholder.com/512x512.png
19 |
20 | # List applicable automation techniques used in the solution:
21 | # * OS
22 | # * Application bootstrap/packaging
23 | automation: |-
24 | Gravida arcu ac tortor dignissim. Magna etiam tempor orci eu lobortis. Magna sit amet purus gravida.
25 | * aliquet
26 | * risus
27 | * feugiat
28 |
29 | # What is the overall availability achieved as a result on individual components availability targets.
30 | # Include exceptions where a single point-of-failure exists
31 | availability: |-
32 | Sagittis purus sit amet volutpat consequat mauris nunc congue nisi.
33 | Congue quisque egestas diam in.
34 | Vulputate eu scelerisque felis imperdiet.
35 | Blandit massa enim nec dui nunc mattis.
36 |
37 | # requirements: details of any compliance requirements to be adhered by the solution
38 | compliance:
39 | requirements: Fermentum leo vel orci porta non.
40 |
41 | # category: application's criticality rating. RTO/RPO
42 | criticality:
43 | category: Volutpat blandit aliquam etiam erat velit scelerisque.
44 |
45 | data:
46 | classification: In tellus integer feugiat scelerisque varius morbi.
47 |
48 | decisions:
49 | - context: Tellus at urna condimentum mattis.Nisl nisi scelerisque eu ultrices vitae auctor.
50 | date: January 1st, 2019
51 | description: Adipiscing enim eu turpis egestas pretium aenean.
52 | status: backlog
53 | - context: Integer malesuada nunc vel risus commodo.
54 | date: January 1st, 2020
55 | description: In metus vulputate eu scelerisque felis imperdiet proin.
56 | status: in-progress
57 |
58 | devops:
59 | - label: code
60 | url: https://
61 | - label: build
62 | url: https://
63 | - label: release
64 | url: https://
65 | - label: artifacts
66 | url: https://
67 |
68 | environments:
69 | - name: Development
70 | identifier: dev
71 | - name: Test
72 | identifier: tst
73 | - name: Production
74 | identifier: prd
75 |
76 | # List all systems the solution will integrate with:
77 | # * AD
78 | # * NAS Filer
79 | # * Logging solution
80 | # * Batch system
81 | # * Alarming system
82 | # * ITSM tool
83 | integration: |-
84 | * Leo - integer malesuada nunc vel.
85 | * Gravida - neque convallis a cras semper.
86 |
87 | # What level of reliability is achieved for the data hosted in cloud (e.g. s3 reliability)
88 | reliability: Viverra vitae congue eu consequat ac.
89 |
90 | # List components that are re-used from others services:
91 | # * AD
92 | # * OS Images
93 | # * Backups
94 | # * Internet Proxy
95 | # * Anti-virus Agents
96 | # * AWS CloudTrail
97 | # * Naming Standards
98 | # * Tagging Standards
99 | reusable: |-
100 | * Hendrerit - dolor magna eget.
101 | * Integer - malesuada nunc vel risus commodo.
102 |
103 | # Describe how the solution components meet scalability standards,
104 | # include if it does not need/meet any scalability targets.
105 | scalability: Pretium vulputate sapien nec sagittis.
106 |
107 | target:
108 | golive: dd/mm/yyyy
109 |
--------------------------------------------------------------------------------
/box/resources/init/clencli/readme.tmpl:
--------------------------------------------------------------------------------
1 |
13 |
14 | {{ if has (ds "db") "logo" }}
15 | .logo.url }})
16 |
17 | > {{ (ds "db").logo.label }}
18 | {{end}}
19 |
20 | {{ if has (ds "db") "shields" }}{{ range $badge := (ds "db").shields.badges }}{{ if ne $badge.image "" }}[]({{$badge.url}}){{ else }}{{ end }}{{ end }}{{ end }}
21 |
22 | # {{ (ds "db").app.name }} {{ if has (ds "db").app "id" }} ( {{ (ds "db").app.id }} ) {{end}}
23 |
24 | {{ if has (ds "db").app "function" }}{{ (ds "db").app.function }}{{end}}
25 |
26 | ## Table of Contents
27 | ---
28 |
29 |
30 | {{ $db := ds "db" }}
31 |
32 | {{ if has (ds "db") "usage" }}{{ $usage := $db.usage }}{{ if ne $usage "" }} - [Usage](#usage) {{end}}{{end}}
33 | {{ if has (ds "db") "prerequisites" }}{{ $prerequisites := len $db.prerequisites }}{{ if gt $prerequisites 0 }} - [Prerequisites](#prerequisites) {{end}}{{end}}
34 | {{ if has (ds "db") "installing" }}{{ $installing := $db.installing }}{{ if ne $installing "" }} - [Installing](#installing) {{end}}{{end}}
35 | {{ if has (ds "db") "testing" }}{{ $testing := $db.testing }}{{ if ne $testing "" }} - [Testing](#testing) {{end}}{{end}}
36 | {{ if has (ds "db") "deployment" }}{{ $deployment := $db.deployment }}{{ if ne $deployment "" }} - [Deployment](#deployment) {{end}}{{end}}
37 | {{ if has (ds "db") "acknowledgments" }}{{ $acknowledgments := len $db.acknowledgments }}{{ if gt $acknowledgments 0 }} - [Acknowledgments](#acknowledgments) {{end}}{{end}}
38 | {{ if has (ds "db") "contributors" }}{{ $contributors := len $db.contributors }}{{ if gt $contributors 0 }} - [Contributors](#contributors) {{end}}{{end}}
39 | {{ if has (ds "db") "references" }}{{ $references := len $db.references }}{{ if gt $references 0 }} - [References](#references) {{end}}{{end}}
40 | {{ if has (ds "db") "license" }}{{ $license := $db.license }}{{ if ne $license "" }} - [License](#license) {{end}}{{end}}
41 | {{ if has (ds "db") "copyright" }}{{ $copyright := $db.copyright }}{{ if ne $copyright "" }} - [Copyright](#copyright) {{end}}{{end}}
42 |
43 | {{ if has (ds "db") "screenshots" }}
44 | ## Screenshots
45 | ---
46 |
47 | Expand
48 |
49 | {{ range $screenshot := (ds "db").screenshots }}
50 | |  |
51 | |:--:|
52 | | *{{ $screenshot.caption }}* |
53 | {{ end }}
54 |
55 | {{ end }}
56 |
57 | {{ if has (ds "db") "usage" }}
58 | ## Usage
59 | ---
60 |
61 | Expand
62 |
63 | {{ (ds "db").usage }}
64 |
65 | {{ end }}
66 |
67 | {{ if has (ds "db") "prerequisites" }}
68 | ## Prerequisites
69 | ---
70 |
71 | Expand
72 |
73 | {{ range $prerequisite := (ds "db").prerequisites }}{{ printf "- [%s](%s) - %s\n" $prerequisite.name $prerequisite.url $prerequisite.description }}{{end}}
74 |
75 | {{end}}
76 |
77 | {{ if has (ds "db") "installing" }}
78 | ## Installing
79 | ---
80 |
81 | Expand
82 |
83 | {{ (ds "db").installing }}
84 |
85 | {{end}}
86 |
87 | {{ if has (ds "db") "testing" }}
88 | ## Testing
89 | ---
90 |
91 | Expand
92 |
93 | {{ (ds "db").testing }}
94 |
95 | {{end}}
96 |
97 | {{ if has (ds "db") "deployment" }}
98 | ## Deployment
99 | ---
100 |
101 | Expand
102 |
103 | {{ (ds "db").deployment }}
104 |
105 | {{end}}
106 |
107 | {{ if has (ds "db") "include" }}
108 | {{ range $file := (ds "db").include }}
109 | {{ defineDatasource $file $file }}
110 | {{ include $file }}{{end}}
111 | {{end}}
112 |
113 | {{ if has (ds "db") "contributors" }}
114 | ## Contributors
115 | ---
116 |
117 | Expand
118 |
119 | | Name | Email | Role |
120 | |:------------:|:--------------------:|:---------------:|
121 | {{ range $contributor := (ds "db").contributors }}{{ printf "| %s | %s | %s |\n" $contributor.name $contributor.email $contributor.role}}{{end}}
122 |
123 | {{end}}
124 |
125 | {{ if has (ds "db") "acknowledgments" }}
126 | ## Acknowledgments
127 | ---
128 |
129 | Expand
130 |
131 | Gratitude for assistance:
132 | {{ range $ack := (ds "db").acknowledgments }}{{ printf " * %s - %s\n" $ack.name $ack.role }}{{end}}
133 |
134 |
135 | {{end}}
136 |
137 | {{ if has (ds "db") "references" }}
138 | ## References
139 | ---
140 |
141 | Expand
142 |
143 | {{ range $ref := (ds "db").references }}{{ printf " * [%s](%s) - %s\n" $ref.name $ref.url $ref.description }}{{end}}
144 |
145 |
146 | {{end}}
147 |
148 | {{ if has (ds "db") "license" }}
149 | ## License
150 | ---
151 | {{ (ds "db").license}}{{ end }}
152 | {{ if (file.Exists "LICENSE") }}
153 | For more information please read [LICENSE](LICENSE).
154 | {{ end }}
155 |
156 | {{ if has (ds "db") "copyright" }}
157 | ## Copyright
158 | ---
159 | ```
160 | {{ (ds "db").copyright}}
161 | ```
162 | {{end}}
163 |
--------------------------------------------------------------------------------
/box/resources/init/clencli/readme.yaml:
--------------------------------------------------------------------------------
1 | logo:
2 | label: logo
3 | url: https://via.placeholder.com/512x90.png
4 | app:
5 | name: Application
6 | function: Lorem ipsum dolor
7 | id: application-id
8 | screenshots:
9 | - caption: How to build
10 | label: how-to-build
11 | url: https://via.placeholder.com/512x256.png
12 | - caption: How to run
13 | label: how-to-run
14 | url: https://via.placeholder.com/512x256.png
15 | usage: |-
16 | Magnis dis parturient montes nascetur.
17 | Convallis posuere morbi leo urna molestie at.
18 | prerequisites:
19 | - description: Nisi quis eleifend quam adipiscing.Lacus vel facilisis volutpat est velit egestas dui id.
20 | name: Eget arcu dictum
21 | url: https://
22 | installing: |-
23 | Donec adipiscing tristique risus nec feugiat.
24 | ```
25 | $ sudo apt-get install vim
26 | ```
27 | testing: |-
28 | Varius morbi enim nunc faucibus a pellentesque.
29 | ```
30 | $ app test
31 | ```
32 | deployment: |-
33 | Adipiscing bibendum est ultricies integer.
34 | ```
35 | $ app deploy
36 | ```
37 | contributors:
38 | - name: LastName, FirstName
39 | role: Job Role
40 | email: name@email.com
41 | acknowledgments:
42 | - name: LastName, FirstName
43 | role: Job Role
44 | references:
45 | - description: Cloud Engineer CLI
46 | name: clencli
47 | url: https://github.com/awslabs/clencli
48 | license: This project is licensed under the Apache License 2.0.
49 | copyright: Company, Inc. or its affiliates. All Rights Reserved.
50 |
--------------------------------------------------------------------------------
/box/resources/init/project/type/clouformation/skeleton.json:
--------------------------------------------------------------------------------
1 | {
2 | "StackName": "",
3 | "TemplateBody": "",
4 | "TemplateURL": "",
5 | "Parameters": [
6 | {
7 | "ParameterKey": "",
8 | "ParameterValue": "",
9 | "UsePreviousValue": true,
10 | "ResolvedValue": ""
11 | }
12 | ],
13 | "DisableRollback": true,
14 | "RollbackConfiguration": {
15 | "RollbackTriggers": [
16 | {
17 | "Arn": "",
18 | "Type": ""
19 | }
20 | ],
21 | "MonitoringTimeInMinutes": 0
22 | },
23 | "TimeoutInMinutes": 0,
24 | "NotificationARNs": [
25 | ""
26 | ],
27 | "Capabilities": [
28 | "CAPABILITY_IAM"
29 | ],
30 | "ResourceTypes": [
31 | ""
32 | ],
33 | "RoleARN": "",
34 | "OnFailure": "DELETE",
35 | "StackPolicyBody": "",
36 | "StackPolicyURL": "",
37 | "Tags": [
38 | {
39 | "Key": "",
40 | "Value": ""
41 | }
42 | ],
43 | "ClientRequestToken": "",
44 | "EnableTerminationProtection": true
45 | }
46 |
--------------------------------------------------------------------------------
/box/resources/init/project/type/clouformation/skeleton.yaml:
--------------------------------------------------------------------------------
1 | StackName: '' # [REQUIRED] The name that is associated with the stack.
2 | TemplateBody: '' # Structure containing the template body with a minimum length of 1 byte and a maximum length of 51,200 bytes.
3 | TemplateURL: '' # Location of file containing the template body.
4 | Parameters: # A list of Parameter structures that specify input parameters for the stack.
5 | - ParameterKey: '' # The key associated with the parameter.
6 | ParameterValue: '' # The input value associated with the parameter.
7 | UsePreviousValue: true # During a stack update, use the existing parameter value that the stack is using for a given parameter key.
8 | ResolvedValue: '' # Read-only.
9 | DisableRollback: true # Set to true to disable rollback of the stack if stack creation failed.
10 | RollbackConfiguration: # The rollback triggers for AWS CloudFormation to monitor during stack creation and updating operations, and for the specified monitoring period afterwards.
11 | RollbackTriggers: # The triggers to monitor during stack creation or update actions.
12 | - Arn: '' # [REQUIRED] The Amazon Resource Name (ARN) of the rollback trigger.
13 | Type: '' # [REQUIRED] The resource type of the rollback trigger.
14 | MonitoringTimeInMinutes: 0 # The amount of time, in minutes, during which CloudFormation should monitor all the rollback triggers after the stack creation or update operation deploys all necessary resources.
15 | TimeoutInMinutes: 0 # The amount of time that can pass before the stack status becomes CREATE_FAILED; if DisableRollback is not set or is set to false, the stack will be rolled back.
16 | NotificationARNs: # The Simple Notification Service (SNS) topic ARNs to publish stack related events.
17 | - ''
18 | Capabilities: # In some cases, you must explicitly acknowledge that your stack template contains certain capabilities in order for AWS CloudFormation to create the stack.
19 | - CAPABILITY_IAM
20 | ResourceTypes: # The template resource types that you have permissions to work with for this create stack action, such as AWS.
21 | - ''
22 | RoleARN: '' # The Amazon Resource Name (ARN) of an AWS Identity and Access Management (IAM) role that AWS CloudFormation assumes to create the stack.
23 | OnFailure: DO_NOTHING # Determines what action will be taken if stack creation fails. Valid values are: DO_NOTHING, ROLLBACK, DELETE.
24 | StackPolicyBody: '' # Structure containing the stack policy body.
25 | StackPolicyURL: '' # Location of a file containing the stack policy.
26 | Tags: # Key-value pairs to associate with this stack.
27 | - Key: '' # [REQUIRED] Required.
28 | Value: '' # [REQUIRED] Required.
29 | ClientRequestToken: '' # A unique identifier for this CreateStack request.
30 | EnableTerminationProtection: true # Whether to enable termination protection on the specified stack.
31 |
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/LICENSE:
--------------------------------------------------------------------------------
1 | # License under which this code is distributed
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: aws/get-caller-identity
2 | aws/get-caller-identity: ## Returns details about the IAM user or role whose credentials are used to call the operation.
3 | aws sts get-caller-identity
4 |
5 | .PHONY: terraform/init
6 | terraform/init: ## Initializes a Terraform working directory
7 | terraform init
8 |
9 | .PHONY: terraform/get
10 | terraform/get: ## Downloads and installs modules for the configuration
11 | terraform get
12 |
13 | .PHONY: terraform/fmt
14 | terraform/fmt: ## Rewrites config files to canonical format
15 | terraform fmt
16 |
17 | .PHONY: terraform/plan
18 | terraform/plan: terraform/fmt terraform/validate terraform/workspace ## Generate and show an execution plan
19 | ifdef environment
20 | terraform plan -out=plan.tfplan -var-file=environments/$(environment).tf
21 | else
22 | @echo "argument environment NOT defined" && exit 1
23 | endif
24 |
25 | .PHONY: terraform/apply
26 | terraform/apply: ## Generates and shows the execution plan
27 | terraform apply plan.tfplan
28 |
29 | .PHONY: terraform/validate
30 | terraform/validate: ## Validates the Terraform files
31 | terraform validate
32 |
33 | .PHONY: terraform/clean
34 | terraform/clean: ## Removes local .terraform directory
35 | rm -rf .terraform/
36 | rm -rf terraform.tfstate.d
37 | rm -f *.tfplan
38 | rm -f terraform.tfstate*
39 | rm -f .terraform.tfstate*
40 |
41 | .PHONY: terraform/workspace
42 | terraform/workspace: ## Selects a workspace based on environment
43 | ifdef environment
44 | @terraform workspace select $(environment) || (echo "terraform workspace not found, creating a new one..."; terraform workspace new $(environment))
45 | else
46 | @echo "argument environment NOT defined" && exit 1
47 | endif
48 |
49 | .PHONY: terraform/destroy
50 | terraform/destroy: ## Destroys Terraform-managed infrastructure
51 | ifdef environment
52 | @terraform plan -destroy -out=destroy.tfplan -var-file=environments/$(environment).tf
53 | @terraform apply destroy.tfplan
54 | else
55 | echo "argument environment NOT defined"
56 | endif
57 |
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/environments/dev.tf:
--------------------------------------------------------------------------------
1 | environment="dev"
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/environments/prod.tf:
--------------------------------------------------------------------------------
1 | environment="prod"
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/main.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = var.region
3 | }
4 |
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/outputs.tf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awslabs/clencli/7ecf17182a209ce8ea2de534263b58850cfa2bd7/box/resources/init/project/type/terraform/outputs.tf
--------------------------------------------------------------------------------
/box/resources/init/project/type/terraform/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | type = string
3 | description = "AWS Region"
4 | }
5 |
--------------------------------------------------------------------------------
/box/resources/manual/configure.yaml:
--------------------------------------------------------------------------------
1 | use: configure [delete]
2 | example: >
3 | If you want to create a new named profile:
4 | clencli configure --profile work
5 |
6 | If you want to delete a named profile:
7 | clencli configure delete --profile work
8 | short: Configures CLENCLI global settings
9 | long: Configures CLENCLI global credentials and configurations used by commands
--------------------------------------------------------------------------------
/box/resources/manual/gitignore.yaml:
--------------------------------------------------------------------------------
1 | use: gitignore
2 | example: >
3 | if you want to see a list of valid project types:
4 | clencli gitignore list
5 |
6 | If you want to create a .gitignore file for your terraform project:
7 | clencli gitignore --input terraform
8 |
9 | If you want to create a .gitignore file for your project with multiple rules:
10 | clencli gitignore --input terraform,vscode
11 |
12 | short: Download .gitignore based on the given input
13 | long: Download .gitignore based on the given input
--------------------------------------------------------------------------------
/box/resources/manual/init.yaml:
--------------------------------------------------------------------------------
1 | use: init [project] [--project-name ] [ --project-type [basic|cloudformation|terraform] ]
2 | example: >
3 | If you want to initialize a basic project:
4 | clencli init project --project-name foo
5 |
6 | If you want to generate a cloud project:
7 | clencli init project --project-name foo --project-type cloud
8 |
9 | If you want to generate a cloudFormation project:
10 | clencli init project --project-name foo --project-type cloudformation
11 |
12 | If you want to generate a terraform project:
13 | clencli init project --project-name foo --project-type terraform
14 | short: Initialize a project
15 | long: Initialize a project with code structure and templates
--------------------------------------------------------------------------------
/box/resources/manual/render.yaml:
--------------------------------------------------------------------------------
1 | use: render template [ --name ]
2 | short: Render a template
3 | long: Render a template
--------------------------------------------------------------------------------
/box/resources/manual/root.yaml:
--------------------------------------------------------------------------------
1 | use: clencli
2 | short: The Cloud Engineer CLI
3 | long: The Cloud Engineer CLI
--------------------------------------------------------------------------------
/box/resources/manual/unsplash.yaml:
--------------------------------------------------------------------------------
1 | use: unsplash [options]
2 | short: Downloads random photos from Unsplash.com
3 | long: Retrieve a single random photo, given optional filters.
--------------------------------------------------------------------------------
/box/resources/manual/version.yaml:
--------------------------------------------------------------------------------
1 | use: version [options]
2 | short: Displays the version of CLENCLI and all installed plugins
3 | long: |
4 | Displays the version of Terraform and all installed plugins in the following format:
5 | clencli/{git-tag} {golang-version} {architecture} {source}
--------------------------------------------------------------------------------
/clencli/logo.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/awslabs/clencli/7ecf17182a209ce8ea2de534263b58850cfa2bd7/clencli/logo.jpeg
--------------------------------------------------------------------------------
/clencli/readme.tmpl:
--------------------------------------------------------------------------------
1 |
13 |
14 | {{ if has (ds "db") "logo" }}
15 | .logo.url }})
16 |
17 | > {{ (ds "db").logo.label }}
18 | {{end}}
19 |
20 | {{ if has (ds "db") "shields" }}{{ range $badge := (ds "db").shields.badges }}{{ if ne $badge.image "" }}[]({{$badge.url}}){{ else }}{{ end }}{{ end }}{{ end }}
21 |
22 | # {{ (ds "db").app.name }} {{ if has (ds "db").app "id" }} ( {{ (ds "db").app.id }} ) {{end}}
23 |
24 | {{ if has (ds "db").app "function" }}{{ (ds "db").app.function }}{{end}}
25 |
26 | ## Table of Contents
27 | ---
28 |
29 |
30 | {{ $db := ds "db" }}
31 |
32 | {{ if has (ds "db") "usage" }}{{ $usage := $db.usage }}{{ if ne $usage "" }} - [Usage](#usage) {{end}}{{end}}
33 | {{ if has (ds "db") "prerequisites" }}{{ $prerequisites := len $db.prerequisites }}{{ if gt $prerequisites 0 }} - [Prerequisites](#prerequisites) {{end}}{{end}}
34 | {{ if has (ds "db") "installing" }}{{ $installing := $db.installing }}{{ if ne $installing "" }} - [Installing](#installing) {{end}}{{end}}
35 | {{ if has (ds "db") "testing" }}{{ $testing := $db.testing }}{{ if ne $testing "" }} - [Testing](#testing) {{end}}{{end}}
36 | {{ if has (ds "db") "deployment" }}{{ $deployment := $db.deployment }}{{ if ne $deployment "" }} - [Deployment](#deployment) {{end}}{{end}}
37 | {{ if has (ds "db") "acknowledgments" }}{{ $acknowledgments := len $db.acknowledgments }}{{ if gt $acknowledgments 0 }} - [Acknowledgments](#acknowledgments) {{end}}{{end}}
38 | {{ if has (ds "db") "contributors" }}{{ $contributors := len $db.contributors }}{{ if gt $contributors 0 }} - [Contributors](#contributors) {{end}}{{end}}
39 | {{ if has (ds "db") "references" }}{{ $references := len $db.references }}{{ if gt $references 0 }} - [References](#references) {{end}}{{end}}
40 | {{ if has (ds "db") "license" }}{{ $license := $db.license }}{{ if ne $license "" }} - [License](#license) {{end}}{{end}}
41 | {{ if has (ds "db") "copyright" }}{{ $copyright := $db.copyright }}{{ if ne $copyright "" }} - [Copyright](#copyright) {{end}}{{end}}
42 |
43 | {{ if has (ds "db") "screenshots" }}
44 | ## Screenshots
45 | ---
46 |
47 | Expand
48 |
49 | {{ range $screenshot := (ds "db").screenshots }}
50 | |  |
51 | |:--:|
52 | | *{{ $screenshot.caption }}* |
53 | {{ end }}
54 |
55 | {{ end }}
56 |
57 | {{ if has (ds "db") "usage" }}
58 | ## Usage
59 | ---
60 |
61 | Expand
62 |
63 | {{ (ds "db").usage }}
64 |
65 | {{ end }}
66 |
67 | {{ if has (ds "db") "prerequisites" }}
68 | ## Prerequisites
69 | ---
70 |
71 | Expand
72 |
73 | {{ range $prerequisite := (ds "db").prerequisites }}{{ printf "- [%s](%s) - %s\n" $prerequisite.name $prerequisite.url $prerequisite.description }}{{end}}
74 |
75 | {{end}}
76 |
77 | {{ if has (ds "db") "installing" }}
78 | ## Installing
79 | ---
80 |
81 | Expand
82 |
83 | {{ (ds "db").installing }}
84 |
85 | {{end}}
86 |
87 | {{ if has (ds "db") "testing" }}
88 | ## Testing
89 | ---
90 |
91 | Expand
92 |
93 | {{ (ds "db").testing }}
94 |
95 | {{end}}
96 |
97 | {{ if has (ds "db") "deployment" }}
98 | ## Deployment
99 | ---
100 |
101 | Expand
102 |
103 | {{ (ds "db").deployment }}
104 |
105 | {{end}}
106 |
107 | {{ if has (ds "db") "include" }}
108 | {{ range $file := (ds "db").include }}
109 | {{ defineDatasource $file $file }}
110 | {{ include $file }}{{end}}
111 | {{end}}
112 |
113 | {{ if has (ds "db") "contributors" }}
114 | ## Contributors
115 | ---
116 |
117 | Expand
118 |
119 | | Name | Email | Role |
120 | |:------------:|:--------------------:|:---------------:|
121 | {{ range $contributor := (ds "db").contributors }}{{ printf "| %s | %s | %s |\n" $contributor.name $contributor.email $contributor.role}}{{end}}
122 |
123 | {{end}}
124 |
125 | {{ if has (ds "db") "acknowledgments" }}
126 | ## Acknowledgments
127 | ---
128 |
129 | Expand
130 |
131 | Gratitude for assistance:
132 | {{ range $ack := (ds "db").acknowledgments }}{{ printf " * %s - %s\n" $ack.name $ack.role }}{{end}}
133 |
134 |
135 | {{end}}
136 |
137 | {{ if has (ds "db") "references" }}
138 | ## References
139 | ---
140 |
141 | Expand
142 |
143 | {{ range $ref := (ds "db").references }}{{ printf " * [%s](%s) - %s\n" $ref.name $ref.url $ref.description }}{{end}}
144 |
145 |
146 | {{end}}
147 |
148 | {{ if has (ds "db") "license" }}
149 | ## License
150 | ---
151 | {{ (ds "db").license}}{{ end }}
152 | {{ if (file.Exists "LICENSE") }}
153 | For more information please read [LICENSE](LICENSE).
154 | {{ end }}
155 |
156 | {{ if has (ds "db") "copyright" }}
157 | ## Copyright
158 | ---
159 | ```
160 | {{ (ds "db").copyright}}
161 | ```
162 | {{end}}
163 |
--------------------------------------------------------------------------------
/clencli/readme.yaml:
--------------------------------------------------------------------------------
1 | logo:
2 | url: clencli/logo.jpeg
3 | label: Photo by [Felipe Dias](https://unsplash.com/fdiascreator) on [Unsplash](https://unsplash.com)
4 | shields:
5 | badges:
6 | - description: GitHub issues
7 | image: https://img.shields.io/github/issues/awslabs/clencli
8 | url: https://github.com/awslabs/clencli/issues
9 | - description: GitHub forks
10 | image: https://img.shields.io/github/forks/awslabs/clencli
11 | url: https://github.com/awslabs/clencli/network
12 | - description: GitHub stars
13 | image: https://img.shields.io/github/stars/awslabs/clencli
14 | url: https://github.com/awslabs/clencli/stargazers
15 | - description: GitHub license
16 | image: https://img.shields.io/github/license/awslabs/clencli
17 | url: https://github.com/awslabs/clencli/blob/master/LICENSE
18 | - description: Twitter
19 | image: https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Fgithub.com%2Fawslabs%2Fclencli
20 | url: https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fawslabs%2Fclencli
21 | app:
22 | name: Cloud Engineer CLI
23 | function: A CLI built to assist Cloud Engineers.
24 | id: clencli
25 | usage: |-
26 | In a polyglot world where a team can choose it's programming language, often this flexibility can spill into chaos as every repo looks different.
27 | CLENCLI solves this issue by giving developers a quick and easy way to create a standardised repo structure and easily rendering documentation via a YAML file.
28 |
29 | ### Create a new project
30 | ```
31 | $ clencli init project --project-name foo
32 | $ tree -a moon/
33 | foo/
34 | ├── clencli
35 | │ ├── readme.tmpl
36 | │ └── readme.yaml
37 | └── .gitignore
38 | ```
39 |
40 | ### Create a new CloudFormation project
41 | ```
42 | $ clencli init project --project-name foo --project-type cloudformation
43 | $ tree -a sun/
44 | foo/
45 | ├── clencli
46 | │ ├── hld.tmpl
47 | │ ├── hld.yaml
48 | │ ├── readme.tmpl
49 | │ └── readme.yaml
50 | ├── environments
51 | │ ├── dev
52 | │ └── prod
53 | ├── .gitignore
54 | ├── skeleton.json
55 | └── skeleton.yaml
56 | ```
57 |
58 | ### Create a new Terraform project
59 | ```
60 | $ clencli init project --project-name foo --project-type terraform
61 | $ tree -a foo/
62 | foo/
63 | ├── clencli
64 | │ ├── hld.tmpl
65 | │ ├── hld.yaml
66 | │ ├── readme.tmpl
67 | │ └── readme.yaml
68 | ├── environments
69 | │ ├── dev.tf
70 | │ └── prod.tf
71 | ├── .gitignore
72 | ├── LICENSE
73 | ├── main.tf
74 | ├── Makefile
75 | ├── outputs.tf
76 | └── variables.tf
77 | ```
78 |
79 | ## Render a template
80 | ```
81 | $ clencli init project --project-name foo
82 | foo was successfully initialized as a basic project
83 | $ cd foo/
84 | $ clencli render template
85 | Template readme.tmpl rendered as README.md
86 | ```
87 |
88 | The `README.md` you are reading right now was generated and it's maintained by `CLENCLI` itself.
89 | Please check [readme.yaml](clencli/readme.yaml) for more details.
90 |
91 | ## Download a .gitignore for your project
92 | ```
93 | $ clencli gitignore --input="terraform,visualstudiocode"
94 | .gitignore created successfully
95 | $ less .gitignore
96 |
97 | # Created by https://www.toptal.com/developers/gitignore/api/terraform,visualstudiocode
98 | # Edit at https://www.toptal.com/developers/gitignore?templates=terraform,visualstudiocode
99 |
100 | ### Terraform ###
101 | # Local .terraform directories
102 | **/.terraform/*
103 |
104 | # .tfstate files
105 | *.tfstate
106 | *.tfstate.*
107 |
108 | # Crash log files
109 | crash.log
110 |
111 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most
112 | # .tfvars files are managed as part of configuration and so should be included in
113 | # version control.
114 | #
115 | # example.tfvars
116 |
117 | # Ignore override files as they are usually used to override resources locally and so
118 | # are not checked in
119 | override.tf
120 | override.tf.json
121 | *_override.tf
122 | *_override.tf.json
123 |
124 | # Include override files you do wish to add to version control using negated pattern
125 | # !example_override.tf
126 |
127 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
128 | # example: *tfplan*
129 |
130 | ### VisualStudioCode ###
131 | .vscode/*
132 | !.vscode/settings.json
133 | !.vscode/tasks.json
134 | !.vscode/launch.json
135 | !.vscode/extensions.json
136 | *.code-workspace
137 |
138 | ### VisualStudioCode Patch ###
139 | # Ignore all local history of files
140 | .history
141 | .ionide
142 |
143 | # End of https://www.toptal.com/developers/gitignore/api/terraform,visualstudiocode
144 |
145 | ```
146 | Additionally, you can also *customize the initialization* of your projects (scaffolding) and download photos for your projects from [unsplash](https://unsplash.com), please read more [here](https://github.com/awslabs/clencli/wiki/Configuration).
147 | installing: Download the latest version [released](https://github.com/awslabs/clencli/releases)
148 | according to your platform and execute it directly. I recommend placing the binary
149 | into your `$PATH`, so it's easily accessible.
150 | include:
151 | - COMMANDS.md
152 | contributors:
153 | - name: Silva, Valter
154 | role: AWS Professional Services - Cloud Architect
155 | email: valterh@amazon.com
156 | acknowledgments:
157 | - name: Sia, William
158 | role: AWS Professional Service - Senior Cloud Architect
159 | - name: Dhingra, Prashit
160 | role: AWS Professional Service - Cloud Architect
161 | references:
162 | - description: Cobra is both a library for creating powerful modern CLI applications
163 | as well as a program to generate applications and command files.
164 | name: cobra
165 | url: https://github.com/spf13/cobra
166 | - description: Viper is a complete configuration solution for Go applications including
167 | 12-Factor apps.
168 | name: viper
169 | url: https://github.com/spf13/viper
170 | - description: The Twelve-Factor App
171 | name: twelve-factor-app
172 | url: https://12factor.net
173 | - description: gomplate is a template renderer which supports a growing list of datasources,
174 | such as JSON (including EJSON - encrypted JSON), YAML, AWS EC2 metadata, BoltDB,
175 | Hashicorp Consul and Hashicorp Vault secrets.
176 | name: gomplate
177 | url: https://github.com/hairyhenderson/gomplate
178 | - description: The most powerful photo engine in the world.
179 | name: unsplash
180 | url: https://unsplash.com
181 | - description: The Free Image Placeholder Service Favoured By Designers
182 | name: placeholder
183 | url: https://placeholder.com
184 | - description: The best Lorem Ipsum Generator in all the sea
185 | name: pirate-ipsum
186 | url: https://pirateipsum.me
187 | - description: Record Fast Screencasts
188 | name: recordit
189 | url: https://recordit.co
190 | - description: A terminal-to-gif recorder minus the headaches.
191 | name: ttystudio
192 | url: https://github.com/chjj/ttystudio
193 | - description: GitHub Super Linter
194 | name: gihub-super-linter
195 | url: https://github.com/github/super-linter
196 | - description: GitHub Actions
197 | name: github-actions
198 | url: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/introduction-to-github-actions
199 | - description: Create useful .gitignore files for your project
200 | name: gitignore.io
201 | url: https://www.toptal.com/developers/gitignore
202 | license: This project is licensed under the Apache License 2.0.
203 | copyright: Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
204 |
--------------------------------------------------------------------------------
/clencli/unsplash.yaml:
--------------------------------------------------------------------------------
1 | randomphotoparameters:
2 | collections: ""
3 | featured: ""
4 | filter: ""
5 | orientation: ""
6 | query: cats
7 | size: ""
8 | username: ""
9 | randomphotoresponse:
10 | id: ldFbYytgEHE
11 | createdat: "2020-03-31T00:33:54-04:00"
12 | updatedat: "2020-10-07T01:19:23-04:00"
13 | promotedat: null
14 | width: 3024
15 | height: 4032
16 | color: '#0C060B'
17 | description: ""
18 | altdescription: white horse on brown field during daytime
19 | urls:
20 | raw: https://images.unsplash.com/photo-1585629220785-8039e6b5c009?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjE1MjY5OH0
21 | full: https://images.unsplash.com/photo-1585629220785-8039e6b5c009?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE1MjY5OH0
22 | regular: https://images.unsplash.com/photo-1585629220785-8039e6b5c009?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjE1MjY5OH0
23 | small: https://images.unsplash.com/photo-1585629220785-8039e6b5c009?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjE1MjY5OH0
24 | thumb: https://images.unsplash.com/photo-1585629220785-8039e6b5c009?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjE1MjY5OH0
25 | links:
26 | self: https://api.unsplash.com/photos/ldFbYytgEHE
27 | html: https://unsplash.com/photos/ldFbYytgEHE
28 | download: https://unsplash.com/photos/ldFbYytgEHE/download
29 | downloadlocation: https://api.unsplash.com/photos/ldFbYytgEHE/download
30 | categories: []
31 | likes: 25
32 | likedbyuser: false
33 | currentusercollections: []
34 | sponsorship: null
35 | user:
36 | id: GQBRmp3ZWTM
37 | updatedat: "2020-10-13T09:57:06-04:00"
38 | username: sharifmatar
39 | name: Sharif Matar
40 | firstname: Sharif
41 | lastname: Matar
42 | twitterusername: ""
43 | portfoliourl: ""
44 | bio: ""
45 | location: ""
46 | links:
47 | self: https://api.unsplash.com/users/sharifmatar
48 | html: https://unsplash.com/@sharifmatar
49 | photos: https://api.unsplash.com/users/sharifmatar/photos
50 | likes: https://api.unsplash.com/users/sharifmatar/likes
51 | portfolio: https://api.unsplash.com/users/sharifmatar/portfolio
52 | following: https://api.unsplash.com/users/sharifmatar/following
53 | followers: https://api.unsplash.com/users/sharifmatar/followers
54 | profileimage:
55 | small: https://images.unsplash.com/profile-1587538413056-d264b0cf4b4eimage?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=32&w=32
56 | medium: https://images.unsplash.com/profile-1587538413056-d264b0cf4b4eimage?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=64&w=64
57 | large: https://images.unsplash.com/profile-1587538413056-d264b0cf4b4eimage?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=128&w=128
58 | instagramusername: ""
59 | totalcollections: 0
60 | totallikes: 16
61 | totalphotos: 13
62 | acceptedtos: true
63 | exif:
64 | make: Apple
65 | model: iPhone 11 Pro Max
66 | exposuretime: 1/950
67 | aperture: "2.0"
68 | focallength: "6.0"
69 | iso: 20
70 | location:
71 | title: ""
72 | name: ""
73 | city: null
74 | country: ""
75 | position:
76 | latitude: 0
77 | longitude: 0
78 | views: 10029
79 | downloads: 49
80 |
--------------------------------------------------------------------------------
/cobra/README.md:
--------------------------------------------------------------------------------
1 | # cobra
2 |
3 | ## Packages
4 |
5 | Below you can find the responsibility and purpose for each package.
6 |
7 | ### aid
8 |
9 | Assist Cobra commands individually. Example: a command under `cmd/foo.go`, has its respective `aid/foo.go`.
10 | This allows a more cleaner and readable code.
11 |
12 | ### cmd
13 |
14 | Cobra commands. [reference](https://github.com/spf13/cobra)
15 |
16 | ### controller
17 |
18 | > Controller acts on both model and view. It controls the data flow into model object and updates the view whenever data changes. It keeps view and model separate. [reference](https://www.tutorialspoint.com/design_pattern/mvc_pattern.htm)
19 |
20 | ### dao (Data Access Object)
21 |
22 | > Data Access Object Pattern or DAO pattern is used to separate low level data accessing API or operations from high level business services. Following are the participants in Data Access Object Pattern.
23 | > Data Access Object Interface - This interface defines the standard operations to be performed on a model object(s).
24 | > Data Access Object concrete class - This class implements above interface. This class is responsible to get data from a data source which can be database / xml or any other storage mechanism.
25 | > Model Object or Value Object - This object is simple POJO containing get/set methods to store data retrieved using DAO class. [reference](https://www.tutorialspoint.com/design_pattern/data_access_object_pattern.htm)
26 |
27 | ### model
28 |
29 | > Model represents an object carrying data. It can also have logic to update controller if its data changes. [reference](https://www.tutorialspoint.com/design_pattern/mvc_pattern.htm)
30 |
31 | ### view
32 |
33 | > View represents the visualization of the data that model contains. [reference](https://www.tutorialspoint.com/design_pattern/mvc_pattern.htm)
34 |
35 |
36 |
--------------------------------------------------------------------------------
/cobra/aid/configure.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright © 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | package aid
17 |
18 | import (
19 | "bufio"
20 | "encoding/json"
21 | "fmt"
22 | "io/ioutil"
23 | "os"
24 | "runtime"
25 | "strconv"
26 | "strings"
27 |
28 | "github.com/awslabs/clencli/helper"
29 | "github.com/sirupsen/logrus"
30 | "github.com/spf13/cobra"
31 | "github.com/spf13/viper"
32 | "gopkg.in/yaml.v2"
33 | )
34 |
35 | // ConfigurationsDirectoryExist returns `true` if the configuration directory exist, `false` otherwise
36 | func ConfigurationsDirectoryExist() bool {
37 | return helper.DirOrFileExists(GetAppInfo().ConfigurationsDir)
38 | }
39 |
40 | // ConfigurationsFileExist returns `true` if the configuration file exist, `false` otherwise
41 | func ConfigurationsFileExist() bool {
42 | return helper.DirOrFileExists(GetAppInfo().ConfigurationsPath)
43 | }
44 |
45 | // CreateConfigurationsDirectory creates the configuration directory, returns `true` if the configuration directory exist, `false` otherwise
46 | func CreateConfigurationsDirectory() (bool, string) {
47 | dir := GetAppInfo().ConfigurationsDir
48 | return helper.MkDirsIfNotExist(dir), dir
49 | }
50 |
51 | // CredentialsFileExist returns `true` if the credentials file exist, `false` otherwise
52 | func CredentialsFileExist() bool {
53 | return helper.DirOrFileExists(GetAppInfo().CredentialsPath)
54 | }
55 |
56 | // ReadConfig returns the viper instance of the given configuration `name`
57 | func ReadConfig(name string) (*viper.Viper, error) {
58 | v := viper.New()
59 | app := GetAppInfo()
60 |
61 | v.SetConfigName(name)
62 | v.SetConfigType("yaml")
63 | v.AddConfigPath(app.ConfigurationsDir)
64 |
65 | err := v.ReadInConfig()
66 | if err != nil {
67 | return v, fmt.Errorf("unable to read configuration:%s\n%v", name, err)
68 | }
69 | return v, err
70 | }
71 |
72 | // ReadConfigAsViper returns...
73 | func ReadConfigAsViper(configPath string, configName string, configType string) (*viper.Viper, error) {
74 | v := viper.New()
75 |
76 | v.AddConfigPath(configPath)
77 | v.SetConfigName(configName)
78 | v.SetConfigType(configType)
79 |
80 | err := v.ReadInConfig()
81 | if err != nil {
82 | return v, fmt.Errorf("unable to read configuration as viper\n%v", err)
83 | }
84 | return v, err
85 | }
86 |
87 | // ReadTemplate read the given template under clencli/*.yaml
88 | func ReadTemplate(fileName string) (*viper.Viper, error) {
89 | c := viper.New()
90 | c.AddConfigPath("clencli")
91 | c.SetConfigName(fileName)
92 | c.SetConfigType("yaml")
93 | c.SetConfigPermissions(os.ModePerm)
94 |
95 | err := c.ReadInConfig() // Find and read the c file
96 | if err != nil { // Handle errors reading the c file
97 | return c, fmt.Errorf("Unable to read "+fileName+" via Viper"+"\n%v", err)
98 | }
99 |
100 | return c, nil
101 | }
102 |
103 | // WriteInterfaceToFile write the given interface into a file
104 | func WriteInterfaceToFile(in interface{}, path string) error {
105 | b, err := yaml.Marshal(&in)
106 | if err != nil {
107 | _, ok := err.(*json.UnsupportedTypeError)
108 | if ok {
109 | return fmt.Errorf("json unsupported type error")
110 | }
111 | }
112 |
113 | err = ioutil.WriteFile(path, b, os.ModePerm)
114 | if err != nil {
115 | return fmt.Errorf("unable to update:%s\n%v", path, err)
116 | }
117 |
118 | return err
119 | }
120 |
121 | // DeleteCredentialFile delete the credentials file
122 | func DeleteCredentialFile() error {
123 | return helper.DeleteFile(GetAppInfo().CredentialsPath)
124 | }
125 |
126 | // DeleteConfigurationFile delete the credentials file
127 | func DeleteConfigurationFile() error {
128 | return helper.DeleteFile(GetAppInfo().ConfigurationsPath)
129 | }
130 |
131 | // DeleteConfigurationsDirectory delete the configurations directory
132 | func DeleteConfigurationsDirectory() error {
133 | return os.RemoveAll(GetAppInfo().ConfigurationsDir)
134 | }
135 |
136 | // GetSensitiveUserInput get sensitive input as string
137 | func GetSensitiveUserInput(cmd *cobra.Command, text string, info string) (string, error) {
138 | return getUserInput(cmd, text+" ["+maskString(info, 3)+"]", "")
139 | }
140 |
141 | func maskString(s string, showLastChars int) string {
142 | maskSize := len(s) - showLastChars
143 | if maskSize <= 0 {
144 | return s
145 | }
146 |
147 | return strings.Repeat("*", maskSize) + s[maskSize:]
148 | }
149 |
150 | // GetSensitiveUserInputAsString get sensitive input as string
151 | func GetSensitiveUserInputAsString(cmd *cobra.Command, text string, info string) string {
152 | answer, err := GetSensitiveUserInput(cmd, text, info)
153 | if err != nil {
154 | logrus.Fatalf("unable to get user input about profile's name\n%v", err)
155 | }
156 |
157 | // if user typed ENTER, keep the current value
158 | if answer != "" {
159 | return answer
160 | }
161 |
162 | return info
163 | }
164 |
165 | func getInput() (string, error) {
166 |
167 | reader := bufio.NewReader(os.Stdin)
168 |
169 | text, err := reader.ReadString('\n')
170 | if err != nil {
171 | return "", err
172 | }
173 |
174 | if runtime.GOOS == "windows" {
175 | // convert LF to CRLF
176 | text = strings.Replace(text, "\r\n", "", -1)
177 | } else {
178 | // convert CRLF to LF
179 | text = strings.Replace(text, "\n", "", -1)
180 | }
181 |
182 | return text, nil
183 | }
184 |
185 | func getUserInput(cmd *cobra.Command, text string, info string) (string, error) {
186 | if info == "" {
187 | cmd.Print(text + ": ")
188 | } else {
189 | cmd.Print(text + " [" + info + "]: ")
190 | }
191 |
192 | input, err := getInput()
193 |
194 | return input, err
195 | }
196 |
197 | // GetUserInputAsBool prints `text` on console and return answer as `boolean`
198 | func GetUserInputAsBool(cmd *cobra.Command, text string, info bool) bool {
199 | answer, err := getUserInput(cmd, text, strconv.FormatBool(info))
200 | if err != nil {
201 | logrus.Fatalf("unable to get user input as boolean\n%s", err)
202 | }
203 |
204 | if answer == "true" {
205 | return true
206 | } else if answer == "false" {
207 | return false
208 | }
209 |
210 | return info
211 | }
212 |
213 | // GetUserInputAsString prints `text` on console and return answer as `string`
214 | func GetUserInputAsString(cmd *cobra.Command, text string, info string) string {
215 | answer, err := getUserInput(cmd, text, info)
216 | if err != nil {
217 | logrus.Fatalf("unable to get user input about profile's name\n%v", err)
218 | }
219 |
220 | // if user typed ENTER, keep the current value
221 | if answer != "" {
222 | return answer
223 | }
224 |
225 | return info
226 | }
227 |
--------------------------------------------------------------------------------
/cobra/aid/gitignore.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright © 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 | */
15 |
16 | package aid
17 |
18 | import (
19 | "fmt"
20 | "io/ioutil"
21 | "net/http"
22 |
23 | "github.com/awslabs/clencli/helper"
24 | "github.com/sirupsen/logrus"
25 | "github.com/spf13/cobra"
26 | )
27 |
28 | // DownloadGitIgnore ..
29 | func DownloadGitIgnore(cmd *cobra.Command, input string) (bool, error) {
30 | bytes, err := requestGitIgnore(cmd, input)
31 | if err != nil {
32 | logrus.Errorf("unable to download gitignore file\n%v", err)
33 | return false, err
34 | }
35 |
36 | if !saveGitIgnoreAsFile(bytes) {
37 | logrus.Errorln("unable to save gitignore API response as file")
38 | return false, fmt.Errorf("unable to create .gitignore file")
39 | }
40 |
41 | return true, nil
42 | }
43 |
44 | // GetGitIgnoreList ...
45 | func GetGitIgnoreList() string {
46 | bytes, err := requestGitIgnoreList()
47 | if err != nil {
48 | logrus.Errorf("unable to fetch the gitignore list")
49 | }
50 | return string(bytes)
51 | }
52 |
53 | func requestGitIgnore(cmd *cobra.Command, input string) ([]byte, error) {
54 | url := fmt.Sprintf("https://www.toptal.com/developers/gitignore/api/%s", input)
55 | var response []byte
56 |
57 | var client http.Client
58 | resp, err := client.Get(url)
59 | if err != nil {
60 | logrus.Errorf("unexpected error while performing GET on Toptal API\n%v", err)
61 | return response, fmt.Errorf("unable to fetch gitignore API\n%v", err)
62 | }
63 | defer resp.Body.Close()
64 |
65 | if resp.StatusCode == http.StatusOK {
66 | response, err = ioutil.ReadAll(resp.Body)
67 | if err != nil {
68 | return response, fmt.Errorf("unexpected error while reading Unsplash response \n%v", err)
69 | }
70 |
71 | return response, nil
72 | }
73 |
74 | return response, err
75 | }
76 |
77 | func requestGitIgnoreList() ([]byte, error) {
78 | url := fmt.Sprintf("https://www.toptal.com/developers/gitignore/api/list")
79 | var response []byte
80 |
81 | var client http.Client
82 | resp, err := client.Get(url)
83 | if err != nil {
84 | logrus.Errorf("unexpected error while performing GET on Toptal API\n%v", err)
85 | return response, fmt.Errorf("unable to fetch gitignore API\n%v", err)
86 | }
87 | defer resp.Body.Close()
88 |
89 | if resp.StatusCode == http.StatusOK {
90 | response, err = ioutil.ReadAll(resp.Body)
91 | if err != nil {
92 | return response, fmt.Errorf("unexpected error while reading Unsplash response \n%v", err)
93 | }
94 |
95 | return response, nil
96 | }
97 |
98 | return response, err
99 | }
100 |
101 | func saveGitIgnoreAsFile(bytes []byte) bool {
102 | return helper.WriteFile(".gitignore", bytes)
103 | }
104 |
--------------------------------------------------------------------------------
/cobra/aid/init.go:
--------------------------------------------------------------------------------
1 | package aid
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "strings"
7 |
8 | "github.com/awslabs/clencli/cobra/model"
9 | "github.com/awslabs/clencli/helper"
10 | "github.com/sirupsen/logrus"
11 | "github.com/spf13/cobra"
12 | )
13 |
14 | /* BASIC PROJECT */
15 |
16 | // CreateBasicProject creates a basic project
17 | func CreateBasicProject(cmd *cobra.Command, name string) error {
18 | err := createAndEnterProjectDir(name)
19 | if err != nil {
20 | return err
21 | }
22 |
23 | if initalized := initProject(); !initalized {
24 | logrus.Errorf("unable to initialize basic project")
25 | return fmt.Errorf("unable to initalize project %s", name)
26 | }
27 |
28 | return nil
29 | }
30 |
31 | func createAndEnterProjectDir(name string) error {
32 |
33 | if !helper.MkDirsIfNotExist(name) {
34 | return fmt.Errorf("unable to create directory %s", name)
35 | }
36 |
37 | err := os.Chdir(name)
38 | if err != nil {
39 | return fmt.Errorf("unable to enter directory %s", name)
40 | }
41 |
42 | wd, err := os.Getwd()
43 | if err != nil {
44 | return fmt.Errorf("unable to returns a rooted path name corresponding to the current directory:\n%v", err)
45 | }
46 | logrus.Infof("current working directory changed to %s", wd)
47 |
48 | return nil
49 | }
50 |
51 | // create the basic configuration files
52 | func initProject() bool {
53 |
54 | // Create a directory for clencli
55 | a := helper.MkDirsIfNotExist("clencli")
56 | b := helper.WriteFileFromBox("/init/clencli/readme.yaml", "clencli/readme.yaml")
57 | c := helper.WriteFileFromBox("/init/clencli/readme.tmpl", "clencli/readme.tmpl")
58 | d := helper.WriteFileFromBox("/init/.gitignore", ".gitignore")
59 |
60 | return (a && b && c && d)
61 | }
62 |
63 | // InitCustomized TODO...
64 | func InitCustomized(profile string, config model.Configurations) bool {
65 |
66 | for _, p := range config.Profiles {
67 | if p.Name == profile {
68 | for _, c := range p.Configurations {
69 | for _, f := range c.Initialization.Files {
70 | if f.State == "directory" {
71 | if !helper.MkDirsIfNotExist(f.Path) {
72 | logrus.Errorf("unable to create directory based on configuration")
73 | return false
74 | }
75 | } else if f.State == "file" {
76 | if strings.Contains(f.Src, "http") {
77 | if err := helper.DownloadFileTo(f.Src, f.Dest); err != nil {
78 | logrus.Errorf("unable to download file based on configuration")
79 | return false
80 | }
81 | } else {
82 | if err := helper.CopyFileTo(f.Src, f.Dest); err != nil {
83 | logrus.Errorf("unable to copy file based on configuration")
84 | return false
85 | }
86 | }
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
93 | return true
94 | }
95 |
96 | /* CLOUD PROJECT */
97 |
98 | // CreateCloudProject copies the necessary templates for cloud projects
99 | func CreateCloudProject(cmd *cobra.Command, name string) error {
100 | if err := CreateBasicProject(cmd, name); err != nil {
101 | return nil
102 | }
103 |
104 | if initialized := initCloudProject(); !initialized {
105 | logrus.Errorf("unable to initialize cloud project")
106 | return fmt.Errorf("unable to initalize project %s", name)
107 | }
108 |
109 | return nil
110 | }
111 |
112 | // copies the High Level Design template file
113 | func initCloudProject() bool {
114 | a := helper.WriteFileFromBox("/init/clencli/hld.yaml", "clencli/hld.yaml")
115 | b := helper.WriteFileFromBox("/init/clencli/hld.tmpl", "clencli/hld.tmpl")
116 |
117 | return (a && b)
118 | }
119 |
120 | /* CLOUDFORMATION PROJECT */
121 |
122 | // CreateCloudFormationProject creates an AWS CloudFormation project
123 | func CreateCloudFormationProject(cmd *cobra.Command, name string) error {
124 | if err := CreateBasicProject(cmd, name); err != nil {
125 | return nil
126 | }
127 |
128 | if initialized := initCloudProject(); !initialized {
129 | logrus.Errorf("unable to initialize cloud project")
130 | return fmt.Errorf("unable to initalize project %s", name)
131 | }
132 |
133 | if initialized := initCloudFormationProject(); !initialized {
134 | logrus.Errorf("unable to initialize cloudformation project")
135 | return fmt.Errorf("unable to initalize project %s", name)
136 | }
137 |
138 | return nil
139 | }
140 |
141 | // initialize a project with CloudFormation structure and copies template files
142 | func initCloudFormationProject() bool {
143 |
144 | a := helper.MkDirsIfNotExist("environments")
145 | b := helper.MkDirsIfNotExist("environments/dev")
146 | c := helper.MkDirsIfNotExist("environments/prod")
147 | d := helper.WriteFileFromBox("/init/project/type/clouformation/skeleton.yaml", "skeleton.yaml")
148 | e := helper.WriteFileFromBox("/init/project/type/clouformation/skeleton.json", "skeleton.json")
149 |
150 | /* TODO: copy a template to create standard tags for the entire stack easily
151 | https://docs.aws.amazon.com/cli/latest/reference/cloudformation/create-stack.html
152 | example aws cloudformation create-stack ... --tags */
153 |
154 | /* TODO: copy Makefile */
155 | /* TODO: copy LICENSE */
156 |
157 | return (a && b && c && d && e)
158 | }
159 |
160 | /* TERRAFORM PROJECT */
161 |
162 | // CreateTerraformProject creates a HashiCorp Terraform project
163 | func CreateTerraformProject(cmd *cobra.Command, name string) error {
164 | if err := CreateBasicProject(cmd, name); err != nil {
165 | return nil
166 | }
167 |
168 | if initialized := initCloudProject(); !initialized {
169 | logrus.Errorf("unable to initialize terraform project")
170 | return fmt.Errorf("unable to initalize project %s", name)
171 | }
172 |
173 | if initialized := initTerraformProject(); !initialized {
174 | logrus.Errorf("unable to initialize cloud project")
175 | return fmt.Errorf("unable to initalize project %s", name)
176 | }
177 |
178 | return nil
179 | }
180 |
181 | // InitTerraform initialize a project with Terraform structure
182 | func initTerraformProject() bool {
183 | a := helper.WriteFileFromBox("/init/project/type/terraform/Makefile", "Makefile")
184 | b := helper.WriteFileFromBox("/init/project/type/terraform/LICENSE", "LICENSE")
185 |
186 | c := helper.MkDirsIfNotExist("environments")
187 | d := helper.WriteFileFromBox("/init/project/type/terraform/environments/dev.tf", "environments/dev.tf")
188 | e := helper.WriteFileFromBox("/init/project/type/terraform/environments/prod.tf", "environments/prod.tf")
189 |
190 | f := helper.WriteFileFromBox("/init/project/type/terraform/main.tf", "main.tf")
191 | g := helper.WriteFileFromBox("/init/project/type/terraform/variables.tf", "variables.tf")
192 | h := helper.WriteFileFromBox("/init/project/type/terraform/outputs.tf", "outputs.tf")
193 |
194 | return (a && b && c && d && e && f && g && h)
195 |
196 | }
197 |
198 | // TODO: allow users to inform additional files to be added to their project initialization
199 |
--------------------------------------------------------------------------------
/cobra/aid/render.go:
--------------------------------------------------------------------------------
1 | package aid
2 |
3 | import (
4 | "bufio"
5 | "fmt"
6 | "os"
7 | "strings"
8 |
9 | "github.com/awslabs/clencli/cobra/model"
10 | "github.com/awslabs/clencli/helper"
11 | gomplateV3 "github.com/hairyhenderson/gomplate/v3"
12 | "github.com/sirupsen/logrus"
13 | )
14 |
15 | // BuildTemplate build the given template located under clencli/ directory (without the .tmpl extension)
16 | func BuildTemplate(name string) error {
17 | var inputFiles = []string{}
18 | var outputFiles = []string{}
19 |
20 | sep := string(os.PathSeparator)
21 |
22 | if helper.FileExists("clencli" + sep + name + ".tmpl") {
23 | inputFiles = append(inputFiles, "clencli"+sep+name+".tmpl")
24 | outputFiles = append(outputFiles, strings.ToUpper(name)+".md")
25 | }
26 |
27 | var config gomplateV3.Config
28 | config.InputFiles = inputFiles
29 | config.OutputFiles = outputFiles
30 |
31 | dataSources := []string{}
32 | if helper.FileExists("clencli" + sep + name + ".yaml") {
33 | dataSources = append(dataSources, "db=."+sep+"clencli"+sep+name+".yaml")
34 | }
35 |
36 | config.DataSources = dataSources
37 |
38 | err := gomplateV3.RunTemplates(&config)
39 | if err != nil {
40 | logrus.Fatalf("Gomplate.RunTemplates() failed with %s\n", err)
41 | }
42 |
43 | return err
44 | }
45 |
46 | func writeInputs() error {
47 | variables, err := os.Open("variables.tf")
48 | if err != nil {
49 | logrus.Fatal(err)
50 | }
51 | defer variables.Close()
52 |
53 | // create INPUTS.md
54 | inputs, err := os.OpenFile("INPUTS.md", os.O_CREATE|os.O_WRONLY, 0644)
55 | if err != nil {
56 | logrus.Println(err)
57 | }
58 | defer inputs.Close()
59 |
60 | if _, err := inputs.WriteString("| Name | Description | Type | Default | Required |\n|------|-------------|:----:|:-----:|:-----:|\n"); err != nil {
61 | logrus.Println(err)
62 | }
63 |
64 | var varName, varType, varDescription, varDefault string
65 | varRequired := "no"
66 |
67 | // startBlock := false
68 | scanner := bufio.NewScanner(variables)
69 | for scanner.Scan() {
70 | line := scanner.Text()
71 |
72 | // skip empty lines
73 | if len(line) > 0 {
74 | if strings.Contains(line, "variable") && strings.Contains(line, "{") {
75 | out, found := helper.GetStringBetweenDoubleQuotes(line)
76 | if found {
77 | varName = out
78 | }
79 |
80 | }
81 |
82 | if strings.Contains(line, "type") && strings.Contains(line, "=") {
83 | slc := helper.GetStringTrimmed(line, "=")
84 | if slc[0] == "type" {
85 | varType = slc[1]
86 | if strings.Contains(varType, "({") {
87 | slc = helper.GetStringTrimmed(varType, "({")
88 | varType = slc[0]
89 | }
90 | }
91 | }
92 |
93 | if strings.Contains(line, "description") && strings.Contains(line, "=") {
94 | slc := helper.GetStringTrimmed(line, "=")
95 | if slc[0] == "description" {
96 | out, found := helper.GetStringBetweenDoubleQuotes(slc[1])
97 | if found {
98 | varDescription = out
99 | }
100 | }
101 | }
102 |
103 | if strings.Contains(line, "default") && strings.Contains(line, "=") {
104 | slc := helper.GetStringTrimmed(line, "=")
105 | if slc[0] == "default" {
106 | varDefault = slc[1]
107 | if strings.Contains(varDefault, "{") {
108 | varDefault = "