├── .github └── workflows │ ├── security_pipeline.yml │ └── terraform_security_scan.yml ├── .gitignore ├── LICENSE ├── README.md ├── aws ├── add │ ├── help.json │ ├── terraform-eks │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ ├── metadata.json │ │ ├── set_umask.sh │ │ └── src │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── main.go │ │ │ └── pkg │ │ │ ├── eks │ │ │ └── eks.go │ │ │ └── tpl │ │ │ ├── dns_zone.go │ │ │ ├── helm_deps.go │ │ │ ├── iam_k8s.go │ │ │ ├── main.tf │ │ │ ├── maintf.go │ │ │ └── variable.go │ └── terraform-vpc │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ ├── metadata.json │ │ ├── set_umask.sh │ │ └── src │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ └── pkg │ │ ├── tpl │ │ ├── maintf.go │ │ └── variable.go │ │ └── vpc │ │ ├── vpc.go │ │ └── vpc_test.go ├── create │ ├── bucket │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ ├── metadata.json │ │ ├── set_umask.sh │ │ └── src │ │ │ ├── go.mod │ │ │ ├── main.go │ │ │ └── pkg │ │ │ └── bucket │ │ │ └── bucket.go │ ├── cluster │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ ├── metadata.json │ │ ├── set_umask.sh │ │ └── src │ │ │ ├── main.bat │ │ │ ├── main.sh │ │ │ ├── unix │ │ │ └── formula │ │ │ │ └── formula.sh │ │ │ └── windows │ │ │ └── formula │ │ │ └── formula.bat │ └── help.json ├── generate │ ├── help.json │ └── terraform-project │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ └── src │ │ ├── Dockerfile │ │ ├── files │ │ └── circleci-pipeline │ │ │ └── scripts │ │ │ ├── credentials.sh │ │ │ ├── terraform-env.sh │ │ │ └── terraform-run.sh │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ └── pkg │ │ ├── aws │ │ ├── aws.go │ │ └── aws_test.go │ │ └── tpl │ │ ├── circleciconfig.go │ │ ├── gitignore.go │ │ ├── jenkinsfile.go │ │ ├── maintf.go │ │ ├── makefile.go │ │ ├── qa_backendtf.go │ │ ├── readme.go │ │ ├── scaffold.go │ │ └── variable.go └── help.json ├── circleci ├── add │ ├── env │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ ├── metadata.json │ │ ├── set_umask.sh │ │ └── src │ │ │ ├── go.mod │ │ │ ├── main.go │ │ │ └── pkg │ │ │ └── env │ │ │ └── env.go │ └── help.json ├── follow │ ├── help.json │ └── project │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.bat │ │ ├── config.json │ │ ├── help.json │ │ ├── metadata.json │ │ ├── set_umask.sh │ │ └── src │ │ ├── formula │ │ └── formula.js │ │ ├── index.js │ │ └── package.json └── help.json ├── docs └── img │ └── rit-aws-create-cluster.jpg └── github ├── create ├── help.json └── repo │ ├── Dockerfile │ ├── Makefile │ ├── README.md │ ├── build.bat │ ├── config.json │ ├── doc │ └── github-create-repo.gif │ ├── help.json │ ├── metadata.json │ ├── set_umask.sh │ └── src │ ├── main.bat │ ├── main.sh │ ├── unix │ └── repo │ │ └── repo.sh │ └── windows │ └── repo │ └── repo.bat └── help.json /.github/workflows/security_pipeline.yml: -------------------------------------------------------------------------------- 1 | name: Security Pipeline 2 | 3 | on: 4 | push: 5 | branches: [ "**" ] 6 | pull_request: 7 | branches: [ "**" ] 8 | workflow_dispatch: 9 | 10 | jobs: 11 | horusec-security: 12 | name: horusec-security 13 | runs-on: ubuntu-latest 14 | if: "!contains(github.event.head_commit.message, '[skip ci]')" 15 | steps: 16 | - name: Check out code into the Go module directory 17 | uses: actions/checkout@v2 18 | - name: Running Horusec Security Download latest version 19 | shell: bash 20 | run: | 21 | curl -fsSL https://horusec.io/bin/install.sh | bash 22 | horusec start -p="./" -------------------------------------------------------------------------------- /.github/workflows/terraform_security_scan.yml: -------------------------------------------------------------------------------- 1 | name: Terraform Security Scan 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | tfsec: 7 | name: tfsec 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@v2 12 | - name: Terraform security scan 13 | uses: triat/terraform-security-scan@v2.2.3 14 | env: 15 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io 2 | 3 | ### Go ### 4 | # Binaries for programs and plugins 5 | *.dll 6 | *.so 7 | *.dylib 8 | 9 | /bin/ 10 | **/bin/* 11 | /dist/ 12 | **/dist/* 13 | /test/tests.* 14 | /test/coverage.* 15 | 16 | # Test binary, built with " go test -c " 17 | *.test 18 | 19 | # Output of the go coverage tool, specifically when used with LiteIDE 20 | *.out 21 | 22 | ### Vim ### 23 | # Swap 24 | [._]*.s[a-v][a-z] 25 | [._]*.sw[a-p] 26 | [._]s[a-rt-v][a-z] 27 | [._]ss[a-gi-z] 28 | [._]sw[a-p] 29 | 30 | # Session 31 | Session.vim 32 | Sessionx.vim 33 | 34 | # Temporary 35 | .netrwhist 36 | *~ 37 | # Auto-generated tag files 38 | # Persistent undo 39 | [._]*.un~ 40 | 41 | ### VisualStudioCode ### 42 | .vscode/* 43 | 44 | ### VisualStudioCode Patch ### 45 | # Ignore all local history of files 46 | .history 47 | 48 | ### macOS ### 49 | # General 50 | .DS_Store 51 | .AppleDouble 52 | .LSOverride 53 | 54 | # Icon must end with two \r 55 | Icon 56 | 57 | # Thumbnails 58 | ._* 59 | 60 | # Files that might appear in the root of a volume 61 | .DocumentRevisions-V100 62 | .fseventsd 63 | .Spotlight-V100 64 | .TemporaryItems 65 | .Trashes 66 | .VolumeIcon.icns 67 | .com.apple.timemachine.donotpresent 68 | 69 | # Directories potentially created on remote AFP share 70 | .AppleDB 71 | .AppleDesktop 72 | Network Trash Folder 73 | Temporary Items 74 | .apdisk 75 | 76 | # End of https://www.gitignore.io/api/macos 77 | 78 | # End of https://www.gitignore.io/api/macos 79 | # Intellij project files 80 | *.iml 81 | *.ipr 82 | *.iws 83 | .idea/ 84 | 85 | # Created by https://www.toptal.com/developers/gitignore/api/maven 86 | # Edit at https://www.toptal.com/developers/gitignore?templates=maven 87 | 88 | ### Maven ### 89 | target/ 90 | pom.xml.tag 91 | pom.xml.releaseBackup 92 | pom.xml.versionsBackup 93 | pom.xml.next 94 | release.properties 95 | dependency-reduced-pom.xml 96 | buildNumber.properties 97 | .mvn/timing.properties 98 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 99 | .mvn/wrapper/maven-wrapper.jar 100 | 101 | # End of https://www.toptal.com/developers/gitignore/api/maven 102 | 103 | 104 | # Created by https://www.toptal.com/developers/gitignore/api/java 105 | # Edit at https://www.toptal.com/developers/gitignore?templates=java 106 | 107 | ### Java ### 108 | # Compiled class file 109 | *.class 110 | 111 | # Log file 112 | *.log 113 | 114 | # BlueJ files 115 | *.ctxt 116 | 117 | # Mobile Tools for Java (J2ME) 118 | .mtj.tmp/ 119 | 120 | # Package Files # 121 | *.jar 122 | *.war 123 | *.nar 124 | *.ear 125 | *.zip 126 | *.tar.gz 127 | *.rar 128 | 129 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 130 | hs_err_pid* 131 | 132 | # End of https://www.toptal.com/developers/gitignore/api/java 133 | 134 | # Created by https://www.toptal.com/developers/gitignore/api/node 135 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 136 | 137 | ### Node ### 138 | # Logs 139 | *.log 140 | npm-debug.log* 141 | yarn-debug.log* 142 | yarn-error.log* 143 | lerna-debug.log* 144 | 145 | # Diagnostic reports (https://nodejs.org/api/report.html) 146 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 147 | 148 | # Runtime data 149 | pids 150 | *.pid 151 | *.seed 152 | *.pid.lock 153 | 154 | # Directory for instrumented libs generated by jscoverage/JSCover 155 | lib-cov 156 | 157 | # Coverage directory used by tools like istanbul 158 | coverage 159 | *.lcov 160 | 161 | # nyc test coverage 162 | .nyc_output 163 | 164 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 165 | .grunt 166 | 167 | # Bower dependency directory (https://bower.io/) 168 | bower_components 169 | 170 | # node-waf configuration 171 | .lock-wscript 172 | 173 | # Compiled binary addons (https://nodejs.org/api/addons.html) 174 | build/Release 175 | 176 | # Dependency directories 177 | node_modules/ 178 | jspm_packages/ 179 | 180 | # TypeScript v1 declaration files 181 | typings/ 182 | 183 | # TypeScript cache 184 | *.tsbuildinfo 185 | 186 | # Optional npm cache directory 187 | .npm 188 | 189 | # Optional eslint cache 190 | .eslintcache 191 | 192 | # Microbundle cache 193 | .rpt2_cache/ 194 | .rts2_cache_cjs/ 195 | .rts2_cache_es/ 196 | .rts2_cache_umd/ 197 | 198 | # Optional REPL history 199 | .node_repl_history 200 | 201 | # Output of 'npm pack' 202 | *.tgz 203 | 204 | # Yarn Integrity file 205 | .yarn-integrity 206 | 207 | # dotenv environment variables file 208 | .env 209 | .env.test 210 | 211 | # parcel-bundler cache (https://parceljs.org/) 212 | .cache 213 | 214 | # Next.js build output 215 | .next 216 | 217 | # Nuxt.js build / generate output 218 | .nuxt 219 | dist 220 | 221 | # Gatsby files 222 | .cache/ 223 | # Comment in the public line in if your project uses Gatsby and not Next.js 224 | # https://nextjs.org/blog/next-9-1#public-directory-support 225 | # public 226 | 227 | # vuepress build output 228 | .vuepress/dist 229 | 230 | # Serverless directories 231 | .serverless/ 232 | 233 | # FuseBox cache 234 | .fusebox/ 235 | 236 | # DynamoDB Local files 237 | .dynamodb/ 238 | 239 | # TernJS port file 240 | .tern-port 241 | 242 | # Stores VSCode versions used for testing VSCode extensions 243 | .vscode-test 244 | 245 | # End of https://www.toptal.com/developers/gitignore/api/node 246 | 247 | package-lock.json 248 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2021 Guillaume Falourd 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Security Pipeline](https://github.com/GuillaumeFalourd/formulas-aws/actions/workflows/security_pipeline.yml/badge.svg)](https://github.com/GuillaumeFalourd/formulas-aws/actions/workflows/security_pipeline.yml) [![Terraform Security Scan](https://github.com/GuillaumeFalourd/formulas-aws/actions/workflows/terraform_security_scan.yml/badge.svg)](https://github.com/GuillaumeFalourd/formulas-aws/actions/workflows/terraform_security_scan.yml) 2 | 3 | # Formulas AWS 4 | 5 | title 6 | 7 | ## 📚 Documentation 8 | 9 | This repository contains Ritchie formulas which can be executed by the [ritchie-cli](https://github.com/ZupIT/ritchie-cli). 10 | 11 | - [Ritchie CLI documentation](https://docs.ritchiecli.io) 12 | 13 | ## 📦 Use Formulas 14 | 15 | To import this repository, you need [Ritchie CLI installed](https://docs.ritchiecli.io/getting-started/installation) 16 | 17 | Then, you can use the `rit add repo` command manually, or execute the command line below directly on your terminal (since CLI version 2.8.0): 18 | 19 | ```bash 20 | rit add repo --provider="Github" --name="formulas-aws" --repoUrl="https://github.com/GuillaumeFalourd/formulas-aws" --priority=1 21 | ``` 22 | 23 | Finally, you can check if the repository has been imported correctly by executing the `rit list repo` command. 24 | 25 | ### 🆙 How to give priority 26 | 27 | The commons repository installed through the `rit init` command of Ritchie CLI has duplicated commands with the `formulas-aws` repository. 28 | 29 | You have to `set priority 0` for the formulas-aws repository, and `set priority 1` for the commons repository, for the `rit aws create cluster` command to work. 30 | 31 | This can be achieved through the `rit set repo-priority` command. 32 | 33 | ## 🔎 What you'll find in this repository 34 | 35 | ![Rit aws create cluster](/docs/img/rit-aws-create-cluster.jpg) 36 | 37 | ### ⚠️ Caution 38 | 39 | This repository is a **DEMO** to show what is possible to perform using Ritchie CLI. 40 | 41 | The formula's templates use specific and sometimes latest providers versions (for aws, terraform, helm, kubernetes, etc...). 42 | 43 | Therefore, the pipeline created by the formula may not work without updating the versions compatibility in the future. 44 | 45 | If that happens, the recommendation is to fork the repo and update the templates' versions. 46 | 47 | ## ⚙️ How does it work? 48 | 49 | ### Youtube Video 50 | 51 | [![Youtube video](https://user-images.githubusercontent.com/22433243/118325022-38df6700-b4d9-11eb-860b-12131567474f.png)](https://www.youtube.com/watch?v=C3jYQBUf4Us) 52 | 53 | ### 1 - Execute the `rit aws create cluster`command: 54 | 55 | ![](https://user-images.githubusercontent.com/22433243/115786294-f96ca180-a396-11eb-8fe5-227e1c2448c9.png) 56 | 57 | ### 2 - Check the code on your repository: 58 | 59 | [Repository ritchie-tdc-recife](https://github.com/GuillaumeFalourd/ritchie-tdc-recife/tree/qa) 60 | 61 | ### 3 - Wait for the pipeline to run on circleci: 62 | 63 | ![](https://user-images.githubusercontent.com/22433243/115786320-05586380-a397-11eb-8824-f4862326ee00.png) 64 | 65 | ### 4 - Check your cluster on AWS: 66 | 67 | ![](https://user-images.githubusercontent.com/22433243/115786346-11442580-a397-11eb-9288-f48ddc6a7473.png) 68 | 69 | ## 🗃 Sample repositories used for demonstrations: 70 | 71 | - **12.04.2020**: [ritchie-tdc-recife](https://github.com/GuillaumeFalourd/ritchie-tdc-recife) 72 | - **10.28.2020**: [ritchie-tdc-poa](https://github.com/GuillaumeFalourd/ritchie-tdc-poa) 73 | - **30.04.2021**: [ritchie-demo-create-cluster](https://github.com/GuillaumeFalourd/ritchie-demo-create-cluster) 74 | 75 | ## ♻️ Contribute to the repository 76 | 77 | ### 🆕 Creating formulas 78 | 79 | 1. Fork and clone the repository 80 | 2. Create a branch: `git checkout -b ` 81 | 3. Check the step by step of [how to create formulas on Ritchie](https://docs.ritchiecli.io/tutorials/formulas/how-to-create-formulas) 82 | 4. Add your formulas to the repository 83 | and commit your implementation: `git commit -m '` 84 | 5. Push your branch: `git push origin /` 85 | 6. Open a pull request on the repository for analysis. 86 | 87 | ### 🆒 Updating Formulas 88 | 89 | 1. Fork and clone the repository 90 | 2. Create a branch: `git checkout -b ` 91 | 3. Add the cloned repository to your workspaces (`rit add workspace`) with a highest priority (for example: 1). 92 | 4. Check the step by step of [how to implement formulas on Ritchie](https://docs.ritchiecli.io/tutorials/formulas/how-to-implement-a-formula) 93 | and commit your implementation: `git commit -m '` 94 | 5. Push your branch: `git push origin /` 95 | 6. Open a pull request on the repository for analysis. 96 | 97 | - [Contribute to Ritchie community](https://github.com/ZupIT/ritchie-formulas/blob/master/CONTRIBUTING.md) 98 | 99 | -------------------------------------------------------------------------------- /aws/add/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Add AWS objects", 3 | "short": "Add AWS objects" 4 | } 5 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.12 2 | USER root 3 | 4 | RUN mkdir /rit 5 | COPY . /rit 6 | RUN sed -i 's/\r//g' /rit/set_umask.sh 7 | RUN sed -i 's/\r//g' /rit/run.sh 8 | RUN chmod +x /rit/set_umask.sh 9 | 10 | WORKDIR /app 11 | ENTRYPOINT ["/rit/set_umask.sh"] 12 | CMD ["/rit/run.sh"] 13 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/Makefile: -------------------------------------------------------------------------------- 1 | # Go parameters 2 | BIN_FOLDER=bin 3 | SH=$(BIN_FOLDER)/run.sh 4 | BAT=$(BIN_FOLDER)/run.bat 5 | BIN_NAME=main 6 | GOCMD=go 7 | GOBUILD=$(GOCMD) build 8 | GOTEST=$(GOCMD) test 9 | CMD_PATH=main.go 10 | BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin 11 | BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) 12 | BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux 13 | BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) 14 | BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows 15 | BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe 16 | 17 | 18 | build: go-build sh-unix bat-windows docker 19 | 20 | go-build: 21 | cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) 22 | #LINUX 23 | cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) 24 | #MAC 25 | cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) 26 | #WINDOWS 64 27 | cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) 28 | 29 | sh-unix: 30 | echo '#!/bin/sh' > $(SH) 31 | echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) 32 | echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) 33 | echo 'else' >> $(SH) 34 | echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) 35 | echo 'fi' >> $(SH) 36 | chmod +x $(SH) 37 | 38 | bat-windows: 39 | echo '@ECHO OFF' > $(BAT) 40 | echo 'SET mypath=%~dp0' >> $(BAT) 41 | echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) 42 | 43 | test: 44 | $(GOTEST) -short `go list ./... | grep -v vendor/` 45 | 46 | docker: 47 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 48 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/README.md: -------------------------------------------------------------------------------- 1 | # Terraform aws eks 2 | 3 | ## command 4 | 5 | ```bash 6 | rit aws add terraform-eks 7 | ``` 8 | 9 | ## description 10 | 11 | This formula receives 2 inputs (cluster name, domain name) 12 | and adds eks module files into the project. 13 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/build.bat: -------------------------------------------------------------------------------- 1 | :: Go parameters 2 | echo off 3 | SETLOCAL 4 | SET BINARY_NAME=main 5 | SET GOCMD=go 6 | SET GOBUILD=%GOCMD% build 7 | SET CMD_PATH=main.go 8 | SET BIN_FOLDER=..\bin 9 | SET DIST_WIN_DIR=%BIN_FOLDER%\windows 10 | SET DIST_LINUX_DIR=%BIN_FOLDER%\linux 11 | SET BIN_WIN=%BINARY_NAME%.exe 12 | SET BAT_FILE=%BIN_FOLDER%\run.bat 13 | SET SH_FILE=%BIN_FOLDER%\run.sh 14 | 15 | :build 16 | cd src 17 | mkdir %DIST_WIN_DIR% 18 | SET GO111MODULE=on 19 | for /f %%i in ('go list -m') do set MODULE=%%i 20 | CALL :windows 21 | CALL :linux 22 | if %errorlevel% neq 0 exit /b %errorlevel% 23 | GOTO CP_DOCKER 24 | GOTO DONE 25 | cd .. 26 | 27 | :windows 28 | SET CGO_ENABLED= 29 | SET GOOS=windows 30 | SET GOARCH=amd64 31 | %GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% 32 | echo @ECHO OFF > %BAT_FILE% 33 | echo SET mypath=%%~dp0 >> %BAT_FILE% 34 | echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% 35 | GOTO DONE 36 | 37 | :linux 38 | SET CGO_ENABLED=0 39 | SET GOOS=linux 40 | SET GOARCH=amd64 41 | %GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% 42 | echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% 43 | GOTO DONE 44 | 45 | :CP_DOCKER 46 | copy ..\Dockerfile %BIN_FOLDER% 47 | copy ..\set_umask.sh %BIN_FOLDER% 48 | GOTO DONE 49 | :DONE 50 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/go:1.14", 3 | "inputs": [ 4 | { 5 | "label": "Type the cluster name:", 6 | "name": "cluster_name", 7 | "type": "text", 8 | "tutorial": "Your EKS cluster name (ex: projectname)" 9 | }, 10 | { 11 | "label": "Type the domain name:", 12 | "name": "domain_name", 13 | "type": "text", 14 | "tutorial": "Your EKS domain name (ex: projectname.io)" 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Generate terraform AWS eks", 3 | "short": "Generate terraform AWS eks" 4 | } 5 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local", 4 | "docker" 5 | ], 6 | "os": { 7 | "deps": [], 8 | "support": [ 9 | "windows", 10 | "mac", 11 | "linux" 12 | ] 13 | }, 14 | "tags": [ 15 | "aws", 16 | "add", 17 | "terraform-eks" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/go.mod: -------------------------------------------------------------------------------- 1 | module eks 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/ZupIT/ritchie-cli v0.0.0-20200617191317-5498f10a713f 7 | github.com/fatih/color v1.9.0 8 | github.com/hashicorp/hcl/v2 v2.3.0 9 | github.com/hashicorp/terraform v0.12.26 10 | ) 11 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "eks/pkg/eks" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | eks.Run(loadInputs()) 10 | } 11 | 12 | func loadInputs() eks.Inputs { 13 | clusterName := os.Getenv("CLUSTER_NAME") 14 | domainName := os.Getenv("DOMAIN_NAME") 15 | PWD := os.Getenv("CURRENT_PWD") 16 | 17 | return eks.Inputs{ 18 | ClusterName: clusterName, 19 | DomainName: domainName, 20 | PWD: PWD, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/eks/eks.go: -------------------------------------------------------------------------------- 1 | package eks 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "html/template" 7 | "io" 8 | "io/ioutil" 9 | "os" 10 | "path" 11 | 12 | "github.com/hashicorp/hcl/v2" 13 | "github.com/hashicorp/hcl/v2/hclwrite" 14 | 15 | "eks/pkg/tpl" 16 | 17 | "github.com/ZupIT/ritchie-cli/pkg/file/fileutil" 18 | "github.com/fatih/color" 19 | ) 20 | 21 | const ( 22 | projectFile = ".scaffold" 23 | maintfFile = "src/main.tf" 24 | mainEKStfFile = "pkg/tpl/main.tf" 25 | dnsZoneModule = "src/modules/dns_zone" 26 | hemlDeps = "src/modules/helm_deps" 27 | iamK8SModule = "src/modules/iam_k8s" 28 | variableQA = "src/variables/qa.tfvars" 29 | 30 | terraformConfig = "\tkubernetes = \"~> 1.11.0\"\n\tlocal = \"1.4.0\"\n\ttemplate = \"2.1.2\"\n\thelm = \"1.3.0\"\n\texternal = \"1.2.0\"\n\ttls = \"2.1.1\"\n\tarchive = \"1.3.0\"\n\trandom = \"2.2.1\"\n" 31 | ) 32 | 33 | const ( 34 | terraform = "terraform" 35 | ) 36 | 37 | type Inputs struct { 38 | ClusterName string 39 | DomainName string 40 | PWD string 41 | } 42 | 43 | func Run(in Inputs) { 44 | in.checkIfProjectExist() 45 | 46 | in.mergeMain() 47 | 48 | in.addVariables() 49 | 50 | in.addDNSZone() 51 | 52 | in.addHelmDeps() 53 | 54 | in.addIAMK8S() 55 | 56 | fmt.Println() 57 | color.Green(fmt.Sprintln("eks module configured successfully")) 58 | color.Green(fmt.Sprintln("go to the src dir and run [ENVIRONMENT=qa make plan] to check the terraform plan")) 59 | } 60 | 61 | func (in Inputs) addIAMK8S() { 62 | // iam_k8s 63 | iamdir := path.Join(in.PWD, iamK8SModule) 64 | if err := fileutil.CreateDirIfNotExists(iamdir, 0755); err != nil { 65 | color.Red(fmt.Sprintf("error creating dir %q, detail: %q", iamdir, err)) 66 | os.Exit(1) 67 | } 68 | 69 | iammain := path.Join(iamdir, "main.tf") 70 | if err := fileutil.CreateFileIfNotExist(iammain, []byte(tpl.IAMK8SMaintf)); err != nil { 71 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", iammain, err)) 72 | os.Exit(1) 73 | } 74 | 75 | iamvar := path.Join(iamdir, "variables.tf") 76 | if err := fileutil.CreateFileIfNotExist(iamvar, []byte(tpl.IAMK8SVariablestf)); err != nil { 77 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", iamvar, err)) 78 | os.Exit(1) 79 | } 80 | } 81 | 82 | func (in Inputs) addHelmDeps() { 83 | // helm_deps 84 | helmdir := path.Join(in.PWD, hemlDeps) 85 | if err := fileutil.CreateDirIfNotExists(helmdir, 0755); err != nil { 86 | color.Red(fmt.Sprintf("error creating dir %q, detail: %q", helmdir, err)) 87 | os.Exit(1) 88 | } 89 | 90 | helmmain := path.Join(helmdir, "main.tf") 91 | if err := fileutil.CreateFileIfNotExist(helmmain, []byte(tpl.HelmMaintf)); err != nil { 92 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", helmmain, err)) 93 | os.Exit(1) 94 | } 95 | 96 | helmvar := path.Join(helmdir, "variables.tf") 97 | if err := fileutil.CreateFileIfNotExist(helmvar, []byte(tpl.HelmVariablestf)); err != nil { 98 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", helmvar, err)) 99 | os.Exit(1) 100 | } 101 | } 102 | 103 | func (in Inputs) addDNSZone() { 104 | // dns_zone 105 | dzdir := path.Join(in.PWD, dnsZoneModule) 106 | if err := fileutil.CreateDirIfNotExists(dzdir, 0755); err != nil { 107 | color.Red(fmt.Sprintf("error creating dir %q, detail: %q", dzdir, err)) 108 | os.Exit(1) 109 | } 110 | 111 | dzmain := path.Join(dzdir, "main.tf") 112 | if err := fileutil.CreateFileIfNotExist(dzmain, []byte(tpl.DnsZoneMaintf)); err != nil { 113 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", dzmain, err)) 114 | os.Exit(1) 115 | } 116 | 117 | dzout := path.Join(dzdir, "outputs.tf") 118 | if err := fileutil.CreateFileIfNotExist(dzout, []byte(tpl.DnsZoneOutputstf)); err != nil { 119 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", dzout, err)) 120 | os.Exit(1) 121 | } 122 | 123 | dzvar := path.Join(dzdir, "variables.tf") 124 | if err := fileutil.CreateFileIfNotExist(dzvar, []byte(tpl.DnsZoneVariablestf)); err != nil { 125 | color.Red(fmt.Sprintf("error creating file %q, detail: %q", dzvar, err)) 126 | os.Exit(1) 127 | } 128 | } 129 | 130 | func (in Inputs) addVariables() { 131 | // variables 132 | t := template.Must(template.New("Var").Parse(tpl.Variable)) 133 | varf := path.Join(in.PWD, variableQA) 134 | vf, err := os.OpenFile(varf, os.O_APPEND|os.O_WRONLY, 0644) 135 | if err != nil { 136 | color.Red(fmt.Sprintf("error openning %q, detail: %q", varf, err)) 137 | os.Exit(1) 138 | } 139 | defer vf.Close() 140 | err = t.Execute(vf, in) 141 | if err != nil { 142 | color.Red(fmt.Sprintf("error writing %q, detail: %q", varf, err)) 143 | os.Exit(1) 144 | } 145 | } 146 | 147 | func (in Inputs) mergeMain() { 148 | // main.tf current 149 | mfile := path.Join(in.PWD, maintfFile) 150 | mb, _ := fileutil.ReadFile(mfile) 151 | mcfg, diags := hclwrite.ParseConfig(mb, mfile, hcl.InitialPos) 152 | checkDiagnostics(diags) 153 | 154 | // main.tk eks 155 | dir, _ := os.Getwd() 156 | efile := path.Join(dir, mainEKStfFile) 157 | eb, _ := fileutil.ReadFile(efile) 158 | ecfg, diags := hclwrite.ParseConfig(eb, efile, hcl.InitialPos) 159 | checkDiagnostics(diags) 160 | 161 | var reqblk *hclwrite.Block 162 | mbody := mcfg.Body() 163 | for _, block := range mbody.Blocks() { 164 | if block.Type() == terraform { 165 | for _, tf := range block.Body().Blocks() { 166 | if tf.Type() == "required_providers" { 167 | reqblk = tf 168 | break 169 | } 170 | } 171 | } 172 | } 173 | 174 | ebody := ecfg.Body() 175 | for _, block := range ebody.Blocks() { 176 | if block.Type() == terraform { 177 | for _, tf := range block.Body().Blocks() { 178 | if tf.Type() == "required_providers" { 179 | for n, a := range tf.Body().Attributes() { 180 | var tokens hclwrite.Tokens 181 | tokens = a.BuildTokens(tokens) 182 | reqblk.Body().SetAttributeRaw(n, tokens[2:len(tokens)-1]) 183 | } 184 | } 185 | } 186 | } 187 | } 188 | 189 | fileutil.WriteFile(mfile, mcfg.Bytes()) 190 | 191 | // main.tf others 192 | mf, err := os.OpenFile(mfile, os.O_APPEND|os.O_WRONLY, 0644) 193 | if err != nil { 194 | color.Red(fmt.Sprintf("error openning %q, detail: %q", mfile, err)) 195 | os.Exit(1) 196 | } 197 | defer mf.Close() 198 | _, err = mf.Write([]byte(tpl.Maintf)) 199 | if err != nil { 200 | color.Red(fmt.Sprintf("error appending file %q, detail: %q", mfile, err)) 201 | os.Exit(1) 202 | } 203 | 204 | path0 := path.Join(in.PWD, maintfFile) 205 | 206 | err = InsertStringToFile(path0, terraformConfig, 11) 207 | if err != nil { 208 | color.Red(fmt.Sprintf("error TEST")) 209 | } 210 | 211 | } 212 | 213 | func (in Inputs) checkIfProjectExist() { 214 | if !fileutil.Exists(path.Join(in.PWD, projectFile)) { 215 | color.Red("seems that your current dir isn't a terraform project.") 216 | color.Red("you can create one running [rit aws generate terraform-project]") 217 | os.Exit(1) 218 | } 219 | } 220 | 221 | func checkDiagnostics(diags hcl.Diagnostics) { 222 | if len(diags) != 0 { 223 | color.Red("unexpected diagnostics") 224 | for _, diag := range diags { 225 | color.Red(fmt.Sprintf("- %s", diag)) 226 | } 227 | os.Exit(1) 228 | } 229 | } 230 | 231 | func File2lines(filePath string) ([]string, error) { 232 | f, err := os.Open(filePath) 233 | if err != nil { 234 | return nil, err 235 | } 236 | defer f.Close() 237 | return LinesFromReader(f) 238 | } 239 | 240 | func LinesFromReader(r io.Reader) ([]string, error) { 241 | var lines []string 242 | scanner := bufio.NewScanner(r) 243 | for scanner.Scan() { 244 | lines = append(lines, scanner.Text()) 245 | } 246 | if err := scanner.Err(); err != nil { 247 | return nil, err 248 | } 249 | 250 | return lines, nil 251 | } 252 | 253 | func InsertStringToFile(path, str string, index int) error { 254 | lines, err := File2lines(path) 255 | if err != nil { 256 | return err 257 | } 258 | 259 | fileContent := "" 260 | for i, line := range lines { 261 | if i == index { 262 | fileContent += str 263 | } 264 | fileContent += line 265 | fileContent += "\n" 266 | } 267 | 268 | return ioutil.WriteFile(path, []byte(fileContent), 0644) 269 | } 270 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/tpl/dns_zone.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | DnsZoneMaintf = ` 5 | resource "aws_route53_zone" "dns" { 6 | name = var.domain_name 7 | } 8 | ` 9 | 10 | DnsZoneOutputstf = ` 11 | output "zone_id" { 12 | description = "The dns zone id" 13 | value = aws_route53_zone.dns.zone_id 14 | } 15 | ` 16 | 17 | DnsZoneVariablestf = ` 18 | variable "domain_name" { 19 | default = "" 20 | } 21 | ` 22 | ) 23 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/tpl/helm_deps.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | HelmMaintf = ` 5 | data "helm_repository" "codecentric" { 6 | name = "codecentric" 7 | url = "https://codecentric.github.io/helm-charts" 8 | } 9 | 10 | data "helm_repository" "loki" { 11 | name = "loki" 12 | url = "https://grafana.github.io/loki/charts" 13 | } 14 | 15 | 16 | # -------------------------------------------- misc things required to run, expose and auto scale things on k8s 17 | 18 | resource "kubernetes_namespace" "k8s-extras" { 19 | metadata { 20 | name = "k8s-extras" 21 | } 22 | } 23 | 24 | resource "helm_release" "cluster-autoscaler" { 25 | name = "cluster-autoscaler" 26 | repository = "https://kubernetes.github.io/autoscaler" 27 | chart = "cluster-autoscaler" 28 | version = "9.1.0" 29 | timeout = "600" 30 | namespace = "k8s-extras" 31 | 32 | set { 33 | name = "autoDiscovery.clusterName" 34 | value = var.kubernetes_cluster_name 35 | } 36 | 37 | set { 38 | name = "autoDiscovery.tags" 39 | value = "kubernetes.io/cluster/${var.kubernetes_cluster_name}" 40 | } 41 | 42 | set { 43 | name = "cloud-provider" 44 | value = "aws" 45 | } 46 | 47 | set { 48 | name = "awsRegion" 49 | value = var.region 50 | } 51 | 52 | set { 53 | name = "rbac.create" 54 | value = true 55 | } 56 | 57 | set { 58 | name = "image.tag" 59 | value = "v1.18.1" 60 | } 61 | } 62 | 63 | 64 | resource "helm_release" "external-dns" { 65 | name = "external-dns" 66 | repository = "https://charts.bitnami.com/bitnami" 67 | chart = "external-dns" 68 | version = "3.4.1" 69 | namespace = "k8s-extras" 70 | 71 | set { 72 | name = "provider" 73 | value = "aws" 74 | } 75 | 76 | set { 77 | name = "aws.zoneType" 78 | value = "public" 79 | } 80 | 81 | set { 82 | name = "txtOwnerId" 83 | value = var.dns_zone_id 84 | } 85 | 86 | set { 87 | name = "rbac.create" 88 | value = true 89 | } 90 | 91 | set { 92 | name = "policy" 93 | value = "sync" 94 | } 95 | 96 | depends_on = [ 97 | helm_release.aws-load-balancer-controller 98 | ] 99 | } 100 | 101 | 102 | resource "helm_release" "aws-load-balancer-controller" { 103 | name = "aws-load-balancer-controller" 104 | repository = "https://aws.github.io/eks-charts" 105 | chart = "aws-load-balancer-controller" 106 | version = "1.1.2" 107 | namespace = "k8s-extras" 108 | 109 | set { 110 | name = "image.repository" 111 | value = "602401143452.dkr.ecr.sa-east-1.amazonaws.com/amazon/aws-load-balancer-controller" 112 | } 113 | 114 | 115 | set { 116 | name = "clusterName" 117 | value = var.kubernetes_cluster_name 118 | } 119 | 120 | set { 121 | name = "region" 122 | value = var.region 123 | } 124 | 125 | set { 126 | name = "vpcId" 127 | value = var.vpc_id 128 | } 129 | 130 | } 131 | 132 | ` 133 | 134 | HelmVariablestf = ` 135 | variable "kubernetes_cluster" { 136 | default = "" 137 | } 138 | 139 | variable "kubernetes_cluster_name" { 140 | default = "" 141 | } 142 | 143 | variable "region" { 144 | default = "" 145 | } 146 | 147 | variable "dns_zone_id" { 148 | default = "" 149 | } 150 | 151 | variable "vpc_id" { 152 | default = "" 153 | } 154 | ` 155 | ) 156 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/tpl/iam_k8s.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | IAMK8SMaintf = ` 5 | data "aws_iam_policy_document" "aws-assume-role-policy-eks" { 6 | version = "2012-10-17" 7 | statement { 8 | actions = ["sts:AssumeRole"] 9 | effect = "Allow" 10 | principals { 11 | type = "Service" 12 | identifiers = ["eks.amazonaws.com"] 13 | } 14 | } 15 | } 16 | 17 | data "aws_iam_policy_document" "aws-assume-role-policy-ec2" { 18 | version = "2012-10-17" 19 | statement { 20 | actions = ["sts:AssumeRole"] 21 | effect = "Allow" 22 | principals { 23 | type = "Service" 24 | identifiers = ["ec2.amazonaws.com"] 25 | } 26 | } 27 | } 28 | 29 | data "aws_iam_policy_document" "aws-cluster-auto-scaler-policy-document" { 30 | version = "2012-10-17" 31 | statement { 32 | effect = "Allow" 33 | actions = [ 34 | "autoscaling:DescribeAutoScalingGroups", 35 | "autoscaling:DescribeAutoScalingInstances", 36 | "autoscaling:DescribeLaunchConfigurations", 37 | "autoscaling:DescribeTags", 38 | "autoscaling:SetDesiredCapacity", 39 | "autoscaling:TerminateInstanceInAutoScalingGroup" 40 | ] 41 | resources = ["*"] 42 | } 43 | } 44 | 45 | data "aws_iam_policy_document" "aws-ingress-policy-document" { 46 | version = "2012-10-17" 47 | statement { 48 | effect = "Allow" 49 | actions = [ 50 | "acm:DescribeCertificate", 51 | "acm:ListCertificates", 52 | "acm:GetCertificate", 53 | "ec2:AuthorizeSecurityGroupIngress", 54 | "ec2:CreateSecurityGroup", 55 | "ec2:CreateTags", 56 | "ec2:DeleteTags", 57 | "ec2:DeleteSecurityGroup", 58 | "ec2:DescribeAccountAttributes", 59 | "ec2:DescribeAddresses", 60 | "ec2:DescribeInstances", 61 | "ec2:DescribeInstanceStatus", 62 | "ec2:DescribeInternetGateways", 63 | "ec2:DescribeNetworkInterfaces", 64 | "ec2:DescribeSecurityGroups", 65 | "ec2:DescribeSubnets", 66 | "ec2:DescribeTags", 67 | "ec2:DescribeVpcs", 68 | "ec2:ModifyInstanceAttribute", 69 | "ec2:ModifyNetworkInterfaceAttribute", 70 | "ec2:RevokeSecurityGroupIngress", 71 | "elasticloadbalancing:AddListenerCertificates", 72 | "elasticloadbalancing:AddTags", 73 | "elasticloadbalancing:CreateListener", 74 | "elasticloadbalancing:CreateLoadBalancer", 75 | "elasticloadbalancing:CreateRule", 76 | "elasticloadbalancing:CreateTargetGroup", 77 | "elasticloadbalancing:DeleteListener", 78 | "elasticloadbalancing:DeleteLoadBalancer", 79 | "elasticloadbalancing:DeleteRule", 80 | "elasticloadbalancing:DeleteTargetGroup", 81 | "elasticloadbalancing:DeregisterTargets", 82 | "elasticloadbalancing:DescribeListenerCertificates", 83 | "elasticloadbalancing:DescribeListeners", 84 | "elasticloadbalancing:DescribeLoadBalancers", 85 | "elasticloadbalancing:DescribeLoadBalancerAttributes", 86 | "elasticloadbalancing:DescribeRules", 87 | "elasticloadbalancing:DescribeSSLPolicies", 88 | "elasticloadbalancing:DescribeTags", 89 | "elasticloadbalancing:DescribeTargetGroups", 90 | "elasticloadbalancing:DescribeTargetGroupAttributes", 91 | "elasticloadbalancing:DescribeTargetHealth", 92 | "elasticloadbalancing:ModifyListener", 93 | "elasticloadbalancing:ModifyLoadBalancerAttributes", 94 | "elasticloadbalancing:ModifyRule", 95 | "elasticloadbalancing:ModifyTargetGroup", 96 | "elasticloadbalancing:ModifyTargetGroupAttributes", 97 | "elasticloadbalancing:RegisterTargets", 98 | "elasticloadbalancing:RemoveListenerCertificates", 99 | "elasticloadbalancing:RemoveTags", 100 | "elasticloadbalancing:SetIpAddressType", 101 | "elasticloadbalancing:SetSecurityGroups", 102 | "elasticloadbalancing:SetSubnets", 103 | "elasticloadbalancing:SetWebACL", 104 | "iam:CreateServiceLinkedRole", 105 | "iam:GetServerCertificate", 106 | "iam:ListServerCertificates", 107 | "cognito-idp:DescribeUserPoolClient", 108 | "waf-regional:GetWebACLForResource", 109 | "waf-regional:GetWebACL", 110 | "waf-regional:AssociateWebACL", 111 | "waf-regional:DisassociateWebACL", 112 | "waf:GetWebACL", 113 | "tag:GetResources", 114 | "tag:TagResources", 115 | ] 116 | resources = ["*"] 117 | } 118 | } 119 | 120 | data "aws_iam_policy_document" "aws-external-dns-policy-document" { 121 | version = "2012-10-17" 122 | statement { 123 | effect = "Allow" 124 | actions = [ 125 | "route53:ChangeResourceRecordSets", 126 | "route53:ListHostedZones", 127 | "route53:ListResourceRecordSets", 128 | ] 129 | resources = ["*"] 130 | } 131 | } 132 | 133 | 134 | resource "aws_iam_policy" "aws-external-dns-policy" { 135 | name = "aws-external-dns-policy-${var.kubernetes_cluster_name}" 136 | policy = data.aws_iam_policy_document.aws-external-dns-policy-document.json 137 | } 138 | 139 | resource "aws_iam_role_policy_attachment" "aws-external-dns-attachment" { 140 | policy_arn = aws_iam_policy.aws-external-dns-policy.arn 141 | role = var.kubernetes_worker_iam_role_name 142 | } 143 | 144 | resource "aws_iam_policy" "aws-ingress-policy" { 145 | name = "aws-ingress-policy-${var.kubernetes_cluster_name}" 146 | policy = data.aws_iam_policy_document.aws-ingress-policy-document.json 147 | } 148 | 149 | resource "aws_iam_role_policy_attachment" "aws-ingress-policy-attachment" { 150 | policy_arn = aws_iam_policy.aws-ingress-policy.arn 151 | role = var.kubernetes_worker_iam_role_name 152 | } 153 | 154 | resource "aws_iam_policy" "aws-cluster-auto-scaler-policy" { 155 | name = "ClusterAutoScaler-${var.kubernetes_cluster_name}" 156 | policy = data.aws_iam_policy_document.aws-cluster-auto-scaler-policy-document.json 157 | } 158 | 159 | resource "aws_iam_role_policy_attachment" "aws-cluster-auto-scaler-attachment" { 160 | policy_arn = aws_iam_policy.aws-cluster-auto-scaler-policy.arn 161 | role = var.kubernetes_worker_iam_role_name 162 | } 163 | ` 164 | 165 | IAMK8SVariablestf = ` 166 | variable "kubernetes_cluster_name" { 167 | default = "" 168 | description = "The name of your kubernetes cluster" 169 | } 170 | 171 | variable "kubernetes_worker_iam_role_name" { 172 | default = "" 173 | description = "The name of the role attached to your k8s's workload runner nodes" 174 | } 175 | ` 176 | ) 177 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/tpl/main.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = "0.13.5" 3 | required_providers { 4 | aws = { 5 | source = "hashicorp/aws" 6 | version = "3.3.0" 7 | } 8 | kubernetes = { 9 | source = "hashicorp/kubernetes" 10 | version = "1.11.1" 11 | } 12 | local = { 13 | source = "hashicorp/local" 14 | version = "1.4.0" 15 | } 16 | template = { 17 | source = "hashicorp/template" 18 | version = "2.1.2" 19 | } 20 | helm = { 21 | source = "hashicorp/helm" 22 | version = "1.3.0" 23 | } 24 | external = { 25 | source = "hashicorp/external" 26 | version = "1.2.0" 27 | } 28 | tls = { 29 | source = "hashicorp/tls" 30 | version = "2.1.1" 31 | } 32 | archive = { 33 | source = "hashicorp/archive" 34 | version = "1.3.0" 35 | } 36 | random = { 37 | source = "hashicorp/random" 38 | version = "2.2.1" 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/tpl/maintf.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Maintf = ` 5 | # -------------------------------------- 6 | 7 | data "aws_eks_cluster" "cluster" { 8 | name = module.kubernetes_cluster.cluster_id 9 | } 10 | 11 | data "aws_eks_cluster_auth" "cluster" { 12 | name = module.kubernetes_cluster.cluster_id 13 | } 14 | 15 | provider "kubernetes" { 16 | host = data.aws_eks_cluster.cluster.endpoint 17 | cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data) 18 | token = data.aws_eks_cluster_auth.cluster.token 19 | load_config_file = false 20 | version = "~> 1.9" 21 | } 22 | 23 | variable "kubernetes_cluster_name" { 24 | default = "" 25 | } 26 | 27 | module "kubernetes_cluster" { 28 | version = "13.2.1" 29 | source = "terraform-aws-modules/eks/aws" 30 | cluster_name = var.kubernetes_cluster_name 31 | cluster_version = "1.17" 32 | subnets = module.vpc.private_subnets 33 | vpc_id = module.vpc.vpc_id 34 | worker_create_cluster_primary_security_group_rules = true 35 | enable_irsa = true 36 | write_kubeconfig = false 37 | 38 | worker_groups = [ 39 | { 40 | instance_type = "t2.small" 41 | asg_max_size = 5 42 | } 43 | ] 44 | } 45 | 46 | # --------------------------------------- dns zone to expose your applications 47 | variable "domain_name" { 48 | default = "" 49 | } 50 | 51 | module "dns" { 52 | source = "./modules/dns_zone" 53 | domain_name = var.domain_name 54 | } 55 | 56 | # --------------------------------------- iam to do things on k8s 57 | module "iam_k8s" { 58 | source = "./modules/iam_k8s" 59 | 60 | kubernetes_cluster_name = var.kubernetes_cluster_name 61 | kubernetes_worker_iam_role_name = module.kubernetes_cluster.worker_iam_role_name 62 | 63 | } 64 | 65 | # --------------------------------------- helm 66 | provider "helm" { 67 | kubernetes { 68 | host = data.aws_eks_cluster.cluster.endpoint 69 | cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data) 70 | token = data.aws_eks_cluster_auth.cluster.token 71 | load_config_file = false 72 | } 73 | } 74 | 75 | # --------------------------------------- helm repositories 76 | module "helm_deps" { 77 | 78 | source = "./modules/helm_deps" 79 | kubernetes_cluster = module.kubernetes_cluster 80 | kubernetes_cluster_name = var.kubernetes_cluster_name 81 | region = var.region 82 | dns_zone_id = module.dns.zone_id 83 | vpc_id = module.vpc.vpc_id 84 | 85 | } 86 | # -------------------------------- helm test exposure 87 | 88 | variable "namespace" { 89 | default = "" 90 | } 91 | ` 92 | ) 93 | -------------------------------------------------------------------------------- /aws/add/terraform-eks/src/pkg/tpl/variable.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Variable = ` 5 | kubernetes_cluster_name="{{.ClusterName}}" 6 | domain_name="{{.DomainName}}" 7 | namespace = "qa" 8 | ` 9 | ) 10 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.12 2 | USER root 3 | 4 | RUN mkdir /rit 5 | COPY . /rit 6 | RUN sed -i 's/\r//g' /rit/set_umask.sh 7 | RUN sed -i 's/\r//g' /rit/run.sh 8 | RUN chmod +x /rit/set_umask.sh 9 | 10 | WORKDIR /app 11 | ENTRYPOINT ["/rit/set_umask.sh"] 12 | CMD ["/rit/run.sh"] 13 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/Makefile: -------------------------------------------------------------------------------- 1 | # Go parameters 2 | BIN_FOLDER=bin 3 | SH=$(BIN_FOLDER)/run.sh 4 | BAT=$(BIN_FOLDER)/run.bat 5 | BIN_NAME=main 6 | GOCMD=go 7 | GOBUILD=$(GOCMD) build 8 | GOTEST=$(GOCMD) test 9 | CMD_PATH=main.go 10 | BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin 11 | BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) 12 | BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux 13 | BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) 14 | BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows 15 | BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe 16 | 17 | 18 | build: go-build sh-unix bat-windows docker 19 | 20 | go-build: 21 | cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) 22 | #LINUX 23 | cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) 24 | #MAC 25 | cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) 26 | #WINDOWS 64 27 | cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) 28 | 29 | sh-unix: 30 | echo '#!/bin/sh' > $(SH) 31 | echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) 32 | echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) 33 | echo 'else' >> $(SH) 34 | echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) 35 | echo 'fi' >> $(SH) 36 | chmod +x $(SH) 37 | 38 | bat-windows: 39 | echo '@ECHO OFF' > $(BAT) 40 | echo 'SET mypath=%~dp0' >> $(BAT) 41 | echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) 42 | 43 | test: 44 | $(GOTEST) -short `go list ./... | grep -v vendor/` 45 | 46 | docker: 47 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 48 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/README.md: -------------------------------------------------------------------------------- 1 | # Terraform aws vpc 2 | 3 | ## command 4 | 5 | ```bash 6 | rit aws add terraform-vpc 7 | ``` 8 | 9 | ## description 10 | 11 | This formula receives 5 inputs (region, vpc name, vpc cidr, vpc azs, customer name) 12 | and adds vpc module files into the project. 13 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/build.bat: -------------------------------------------------------------------------------- 1 | :: Go parameters 2 | echo off 3 | SETLOCAL 4 | SET BINARY_NAME=main 5 | SET GOCMD=go 6 | SET GOBUILD=%GOCMD% build 7 | SET CMD_PATH=main.go 8 | SET BIN_FOLDER=..\bin 9 | SET DIST_WIN_DIR=%BIN_FOLDER%\windows 10 | SET DIST_LINUX_DIR=%BIN_FOLDER%\linux 11 | SET BIN_WIN=%BINARY_NAME%.exe 12 | SET BAT_FILE=%BIN_FOLDER%\run.bat 13 | SET SH_FILE=%BIN_FOLDER%\run.sh 14 | 15 | :build 16 | cd src 17 | mkdir %DIST_WIN_DIR% 18 | SET GO111MODULE=on 19 | for /f %%i in ('go list -m') do set MODULE=%%i 20 | CALL :windows 21 | CALL :linux 22 | if %errorlevel% neq 0 exit /b %errorlevel% 23 | GOTO CP_DOCKER 24 | GOTO DONE 25 | cd .. 26 | 27 | :windows 28 | SET CGO_ENABLED= 29 | SET GOOS=windows 30 | SET GOARCH=amd64 31 | %GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% 32 | echo @ECHO OFF > %BAT_FILE% 33 | echo SET mypath=%%~dp0 >> %BAT_FILE% 34 | echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% 35 | GOTO DONE 36 | 37 | :linux 38 | SET CGO_ENABLED=0 39 | SET GOOS=linux 40 | SET GOARCH=amd64 41 | %GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% 42 | echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% 43 | GOTO DONE 44 | 45 | :CP_DOCKER 46 | copy ..\Dockerfile %BIN_FOLDER% 47 | copy ..\set_umask.sh %BIN_FOLDER% 48 | GOTO DONE 49 | :DONE 50 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/go:1.14", 3 | "inputs": [ 4 | { 5 | "default": "us-east-1", 6 | "items": [ 7 | "us-east-1", 8 | "us-east-2", 9 | "us-west-1", 10 | "us-west-2", 11 | "af-south-1", 12 | "ap-east-1", 13 | "ap-south-1", 14 | "ap-northeast-1", 15 | "ap-northeast-2", 16 | "ap-northeast-3", 17 | "ap-southeast-1", 18 | "ap-southeast-2", 19 | "ca-central-1", 20 | "eu-central-1", 21 | "eu-west-1", 22 | "eu-west-2", 23 | "eu-south-1", 24 | "eu-west-3", 25 | "eu-north-1", 26 | "me-south-1", 27 | "sa-east-1" 28 | ], 29 | "label": "Pick the region: ", 30 | "name": "region", 31 | "type": "text", 32 | "tutorial": "Choose one option" 33 | }, 34 | { 35 | "label": "Type the vpc name:", 36 | "name": "vpc_name", 37 | "type": "text", 38 | "tutorial": "The vpc name e.g.: some-vpc" 39 | }, 40 | { 41 | "label": "Type the vpc_cidr:", 42 | "name": "vpc_cidr", 43 | "type": "text", 44 | "tutorial": "The vpc cidr e.g.: 10.0.0.0/16" 45 | }, 46 | { 47 | "label": "Type your vpc_azs:", 48 | "name": "vpc_azs", 49 | "type": "text", 50 | "tutorial": "AWS vpc_azs e.g.: us-west-1a, us-west-1b" 51 | }, 52 | { 53 | "label": "Type the customer name:", 54 | "name": "customer_name", 55 | "type": "text", 56 | "tutorial": "A customer name e.g.: Dennis Ritchie" 57 | } 58 | ] 59 | } 60 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Generate terraform AWS vpc", 3 | "short": "Generate terraform AWS vpc" 4 | } 5 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local", 4 | "docker" 5 | ], 6 | "os": { 7 | "deps": [], 8 | "support": [ 9 | "windows", 10 | "mac", 11 | "linux" 12 | ] 13 | }, 14 | "tags": [ 15 | "aws", 16 | "add", 17 | "terraform-vpc" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/src/go.mod: -------------------------------------------------------------------------------- 1 | module vpc 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/ZupIT/ritchie-cli v0.0.0-20200617122056-1aba69da6542 7 | github.com/fatih/color v1.9.0 8 | github.com/hashicorp/terraform v0.12.26 9 | ) 10 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "vpc/pkg/vpc" 6 | ) 7 | 8 | func main() { 9 | vpc.Run(loadInputs()) 10 | } 11 | 12 | func loadInputs() vpc.Inputs { 13 | region := os.Getenv("REGION") 14 | vpcName := os.Getenv("VPC_NAME") 15 | vpcCIDR := os.Getenv("VPC_CIDR") 16 | vpcAZS := os.Getenv("VPC_AZS") 17 | customerName := os.Getenv("CUSTOMER_NAME") 18 | PWD := os.Getenv("CURRENT_PWD") 19 | 20 | return vpc.Inputs{ 21 | Region: region, 22 | VPCName: vpcName, 23 | VPCCIDR: vpcCIDR, 24 | VPCAZS: vpcAZS, 25 | CustomerName: customerName, 26 | PWD: PWD, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/src/pkg/tpl/maintf.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Maintf = ` 5 | variable "vpc_name" { 6 | type = string 7 | } 8 | variable "vpc_cidr" { 9 | type = string 10 | } 11 | 12 | variable "vpc_azs" { 13 | type = list(string) 14 | } 15 | 16 | variable "customer_name" { 17 | default = "" 18 | } 19 | module "vpc" { 20 | source = "terraform-aws-modules/vpc/aws" 21 | 22 | version = "2.57.0" 23 | 24 | name = var.vpc_name 25 | cidr = var.vpc_cidr 26 | 27 | azs = var.vpc_azs 28 | private_subnets = [ 29 | for num in [1,2,3]: 30 | cidrsubnet(var.vpc_cidr, 5, num) 31 | ] 32 | public_subnets = [ 33 | for num in [4,5,6]: 34 | cidrsubnet(var.vpc_cidr, 5, num) 35 | ] 36 | 37 | enable_nat_gateway = true 38 | enable_vpn_gateway = false 39 | 40 | tags = { 41 | Terraform = "true" 42 | Environment = var.customer_name 43 | } 44 | } 45 | 46 | ` 47 | ) 48 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/src/pkg/tpl/variable.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Variable = ` 5 | region="{{.Region}}" 6 | vpc_name="{{.VPCName}}" 7 | vpc_cidr="{{.VPCCIDR}}" 8 | vpc_azs=[{{.VPCAZS}}] 9 | customer_name="{{.CustomerName}}" 10 | 11 | ` 12 | ) 13 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/src/pkg/vpc/vpc.go: -------------------------------------------------------------------------------- 1 | package vpc 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "path" 7 | "strconv" 8 | "strings" 9 | "text/template" 10 | "vpc/pkg/tpl" 11 | 12 | "github.com/ZupIT/ritchie-cli/pkg/file/fileutil" 13 | "github.com/fatih/color" 14 | "github.com/hashicorp/terraform/configs" 15 | ) 16 | 17 | const ( 18 | projectFile = ".scaffold" 19 | maintfFile = "src/main.tf" 20 | variableQA = "src/variables/qa.tfvars" 21 | ) 22 | 23 | type Inputs struct { 24 | Region string 25 | VPCName string 26 | VPCCIDR string 27 | VPCAZS string 28 | CustomerName string 29 | PWD string 30 | } 31 | 32 | func Run(in Inputs) { 33 | cdir := in.PWD 34 | 35 | in.checkIfProjectExist() 36 | 37 | if !in.moduleExist() { 38 | //main.tf 39 | mainf, err := os.OpenFile(path.Join(cdir, maintfFile), os.O_APPEND|os.O_WRONLY, 0644) 40 | if err != nil { 41 | color.Yellow(fmt.Sprintf("error openning main.tf, detail: %q", err)) 42 | os.Exit(1) 43 | } 44 | defer mainf.Close() 45 | if _, err := mainf.WriteString(tpl.Maintf); err != nil { 46 | color.Red(fmt.Sprintf("error writing main.tf, detail: %q", err)) 47 | os.Exit(1) 48 | } 49 | 50 | // variables 51 | in.parseAZS() 52 | t := template.Must(template.New("Var").Parse(tpl.Variable)) 53 | varf := path.Join(cdir, variableQA) 54 | vfile, err := os.OpenFile(varf, os.O_APPEND|os.O_WRONLY, 0644) 55 | if err != nil { 56 | color.Red(fmt.Sprintf("error openning %q, detail: %q", varf, err)) 57 | os.Exit(1) 58 | } 59 | defer vfile.Close() 60 | err = t.Execute(vfile, in) 61 | if err != nil { 62 | color.Red(fmt.Sprintf("error writing %q, detail: %q", varf, err)) 63 | os.Exit(1) 64 | } 65 | } 66 | 67 | fmt.Println() 68 | color.Green(fmt.Sprintln("vpc module configured successfully")) 69 | color.Green(fmt.Sprintln("go to the src dir and run [ENVIRONMENT=qa make plan] to check the terraform plan")) 70 | } 71 | 72 | func (in Inputs) moduleExist() bool { 73 | parser := configs.NewParser(nil) 74 | cfg, diags := parser.LoadConfigFile(path.Join(in.PWD, maintfFile)) 75 | if len(diags) != 0 { 76 | color.Red("unexpected diagnostics") 77 | for _, diag := range diags { 78 | color.Red(fmt.Sprintf("- %s", diag)) 79 | } 80 | os.Exit(1) 81 | } 82 | 83 | for _, m := range cfg.ModuleCalls { 84 | if m.Name == "vpc" { 85 | return true 86 | } 87 | } 88 | return false 89 | } 90 | 91 | func (in *Inputs) parseAZS() { 92 | strings.Replace(in.VPCAZS, " ", "", -1) 93 | ss := strings.Split(in.VPCAZS, ",") 94 | siz := len(ss) - 1 95 | var azs string 96 | for i, s := range ss { 97 | sq := strconv.Quote(s) 98 | if i < siz { 99 | azs += sq + "," 100 | } else { 101 | azs += sq 102 | } 103 | } 104 | in.VPCAZS = azs 105 | } 106 | 107 | func (in Inputs) checkIfProjectExist() { 108 | if !fileutil.Exists(path.Join(in.PWD, projectFile)) { 109 | color.Red("seems that your current dir isn't a terraform project.") 110 | color.Red("you can create one running [rit aws generate terraform-project]") 111 | os.Exit(1) 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /aws/add/terraform-vpc/src/pkg/vpc/vpc_test.go: -------------------------------------------------------------------------------- 1 | package vpc 2 | 3 | import "testing" 4 | 5 | func TestParseAZS(t *testing.T) { 6 | want := "\"us-east-1a\",\"us-east-1b\"" 7 | in := Inputs{ 8 | VPCAZS: "us-east-1a,us-east-1b", 9 | } 10 | 11 | in.parseAZS() 12 | 13 | if in.VPCAZS != want { 14 | t.Errorf("parseAZS got (%v), want (%v)", in.VPCAZS, want) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /aws/create/bucket/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.12 2 | USER root 3 | 4 | RUN mkdir /rit 5 | COPY . /rit 6 | RUN sed -i 's/\r//g' /rit/set_umask.sh 7 | RUN sed -i 's/\r//g' /rit/run.sh 8 | RUN chmod +x /rit/set_umask.sh 9 | 10 | WORKDIR /app 11 | ENTRYPOINT ["/rit/set_umask.sh"] 12 | CMD ["/rit/run.sh"] 13 | -------------------------------------------------------------------------------- /aws/create/bucket/Makefile: -------------------------------------------------------------------------------- 1 | # Go parameters 2 | BIN_FOLDER=bin 3 | SH=$(BIN_FOLDER)/run.sh 4 | BAT=$(BIN_FOLDER)/run.bat 5 | BIN_NAME=main 6 | GOCMD=go 7 | GOBUILD=$(GOCMD) build 8 | GOTEST=$(GOCMD) test 9 | CMD_PATH=main.go 10 | BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin 11 | BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) 12 | BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux 13 | BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) 14 | BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows 15 | BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe 16 | 17 | 18 | build: go-build sh-unix bat-windows docker 19 | 20 | go-build: 21 | cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) 22 | #LINUX 23 | cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) 24 | #MAC 25 | cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) 26 | #WINDOWS 64 27 | cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) 28 | 29 | sh-unix: 30 | echo '#!/bin/sh' > $(SH) 31 | echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) 32 | echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) 33 | echo 'else' >> $(SH) 34 | echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) 35 | echo 'fi' >> $(SH) 36 | chmod +x $(SH) 37 | 38 | bat-windows: 39 | echo '@ECHO OFF' > $(BAT) 40 | echo 'SET mypath=%~dp0' >> $(BAT) 41 | echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) 42 | 43 | test: 44 | $(GOTEST) -short `go list ./... | grep -v vendor/` 45 | 46 | docker: 47 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 48 | -------------------------------------------------------------------------------- /aws/create/bucket/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # Create bucket aws 5 | 6 | ## Premisses 7 | 8 | - Set AWS credentials ($ rit set credential) with accesskeyid, secretaccesskey 9 | 10 | ```bash 11 | rit set credential 12 | ``` 13 | 14 | ## command 15 | 16 | - Prompt 17 | 18 | ```bash 19 | rit aws create bucket 20 | ``` 21 | 22 | - Docker 23 | 24 | ```bash 25 | rit aws create bucket --docker 26 | ``` 27 | 28 | - Stdin 29 | 30 | ```bash 31 | echo '{"region":"us-east-1", "bucket":"ritchie-formulas-demo-stdin"}' | rit aws create bucket --stdin 32 | ``` 33 | 34 | - Stdin + Docker 35 | 36 | ```bash 37 | echo '{"region":"us-east-1", "bucket":"ritchie-formulas-demo-stdin-docker"}' | rit aws create bucket --stdin --docker 38 | ``` 39 | 40 | ## Description 41 | 42 | This AWS Create Bucket command allows the user to create a bucket in AWS S3 43 | If the repository already exists, the user don't receive error. 44 | 45 | The user has to inform 2 different kinds of inputs: 46 | 47 | - the Region Bucket name 48 | 49 | - the Bucket name 50 | 51 | ## Demonstration 52 | 53 | - Command execution 54 | 55 | ![Alt Text](https://media.giphy.com/media/5OI7ywkzgCkbS14LB5/source.gif) 56 | 57 | - Created bucket after executing command 58 | -------------------------------------------------------------------------------- /aws/create/bucket/build.bat: -------------------------------------------------------------------------------- 1 | :: Go parameters 2 | echo off 3 | SETLOCAL 4 | SET BINARY_NAME=main 5 | SET GOCMD=go 6 | SET GOBUILD=%GOCMD% build 7 | SET CMD_PATH=main.go 8 | SET BIN_FOLDER=..\bin 9 | SET DIST_WIN_DIR=%BIN_FOLDER%\windows 10 | SET DIST_LINUX_DIR=%BIN_FOLDER%\linux 11 | SET BIN_WIN=%BINARY_NAME%.exe 12 | SET BAT_FILE=%BIN_FOLDER%\run.bat 13 | SET SH_FILE=%BIN_FOLDER%\run.sh 14 | 15 | :build 16 | cd src 17 | mkdir %DIST_WIN_DIR% 18 | SET GO111MODULE=on 19 | for /f %%i in ('go list -m') do set MODULE=%%i 20 | CALL :windows 21 | CALL :linux 22 | if %errorlevel% neq 0 exit /b %errorlevel% 23 | GOTO CP_DOCKER 24 | GOTO DONE 25 | cd .. 26 | 27 | :windows 28 | SET CGO_ENABLED= 29 | SET GOOS=windows 30 | SET GOARCH=amd64 31 | %GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% 32 | echo @ECHO OFF > %BAT_FILE% 33 | echo SET mypath=%%~dp0 >> %BAT_FILE% 34 | echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% 35 | GOTO DONE 36 | 37 | :linux 38 | SET CGO_ENABLED=0 39 | SET GOOS=linux 40 | SET GOARCH=amd64 41 | %GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% 42 | echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% 43 | GOTO DONE 44 | 45 | :CP_DOCKER 46 | copy ..\Dockerfile %BIN_FOLDER% 47 | copy ..\set_umask.sh %BIN_FOLDER% 48 | GOTO DONE 49 | :DONE 50 | -------------------------------------------------------------------------------- /aws/create/bucket/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/go:1.14", 3 | "inputs": [ 4 | { 5 | "name": "access_key", 6 | "type": "CREDENTIAL_AWS_ACCESSKEYID" 7 | }, 8 | { 9 | "name": "secret_access_key", 10 | "type": "CREDENTIAL_AWS_SECRETACCESSKEY" 11 | }, 12 | { 13 | "cache": { 14 | "active": true, 15 | "newLabel": "Type new value. ", 16 | "qty": 6 17 | }, 18 | "label": "Type your region: ", 19 | "name": "region", 20 | "type": "text", 21 | "tutorial": "AWS region i.e., us-east-1, us-west-1, sa-east-1" 22 | }, 23 | { 24 | "label": "Type bucket name: ", 25 | "name": "bucket", 26 | "type": "text", 27 | "tutorial": "Bucket name e.g.: some-aws-bucket" 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /aws/create/bucket/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Create bucket AWS", 3 | "short": "Create bucket AWS" 4 | } 5 | -------------------------------------------------------------------------------- /aws/create/bucket/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local", 4 | "docker" 5 | ], 6 | "os": { 7 | "deps": [], 8 | "support": [ 9 | "windows", 10 | "mac", 11 | "linux" 12 | ] 13 | }, 14 | "tags": [ 15 | "aws", 16 | "create", 17 | "bucket" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /aws/create/bucket/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /aws/create/bucket/src/go.mod: -------------------------------------------------------------------------------- 1 | module aws/bucket 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/aws/aws-sdk-go v1.34.0 7 | github.com/davecgh/go-spew v1.1.1 // indirect 8 | github.com/kr/pretty v0.1.0 // indirect 9 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect 10 | ) 11 | -------------------------------------------------------------------------------- /aws/create/bucket/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "aws/bucket/pkg/bucket" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | loadInputs().Run() 10 | } 11 | 12 | func loadInputs() bucket.Inputs { 13 | return bucket.Inputs{ 14 | Key: os.Getenv("ACCESS_KEY"), 15 | Secret: os.Getenv("SECRET_ACCESS_KEY"), 16 | Region: os.Getenv("REGION"), 17 | BucketName: os.Getenv("BUCKET"), 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /aws/create/bucket/src/pkg/bucket/bucket.go: -------------------------------------------------------------------------------- 1 | package bucket 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aws/aws-sdk-go/aws" 7 | "github.com/aws/aws-sdk-go/aws/credentials" 8 | "github.com/aws/aws-sdk-go/aws/session" 9 | "github.com/aws/aws-sdk-go/service/s3" 10 | ) 11 | 12 | type Inputs struct { 13 | Key string 14 | Secret string 15 | Region string 16 | BucketName string 17 | } 18 | 19 | func (in Inputs) Run() { 20 | if in.Key == "" || in.Secret == "" { 21 | fmt.Println("Verify your credentials saved! Not received.") 22 | return 23 | } 24 | sess, err := session.NewSession(&aws.Config{ 25 | Region: aws.String(in.Region), 26 | Credentials: credentials.NewStaticCredentials(in.Key, in.Secret, ""), 27 | }) 28 | if err != nil { 29 | fmt.Println("Failed to create session, verify credentials") 30 | return 31 | } 32 | svc := s3.New(sess) 33 | in.runCreate(svc) 34 | } 35 | 36 | func (in Inputs) runCreate(svc *s3.S3) { 37 | if in.BucketName == "" { 38 | fmt.Println("Not received bucket name!") 39 | return 40 | } 41 | bn := &s3.CreateBucketInput{ 42 | Bucket: aws.String(in.BucketName), 43 | } 44 | _, err := svc.CreateBucket(bn) 45 | if err != nil { 46 | fmt.Printf("Failed create bucket. error: %v\n", err) 47 | return 48 | } 49 | fmt.Println("Bucket created") 50 | } 51 | -------------------------------------------------------------------------------- /aws/create/cluster/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ritclizup/rit-shell-bat-runner 2 | 3 | USER root 4 | 5 | RUN mkdir /rit 6 | COPY . /rit 7 | RUN sed -i 's/\r//g' /rit/set_umask.sh 8 | RUN sed -i 's/\r//g' /rit/run.sh 9 | RUN chmod +x /rit/set_umask.sh 10 | 11 | RUN echo "Installing Golang on image" 12 | RUN apk add --no-cache git make musl-dev go 13 | # Configure Go 14 | ENV GOROOT /usr/lib/go 15 | ENV GOPATH /go 16 | ENV PATH /go/bin:$PATH 17 | RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin 18 | # Install Glide 19 | RUN go get -u github.com/Masterminds/glide/... 20 | WORKDIR $GOPATH 21 | CMD ["make"] 22 | RUN go version 23 | 24 | RUN echo "Installing Node and NPM on image" 25 | RUN apk add --update nodejs nodejs-npm 26 | RUN node -v 27 | RUN npm -v 28 | 29 | RUN echo "Installing Git on image" 30 | RUN apk add git 31 | RUN git version 32 | 33 | WORKDIR /app 34 | ENTRYPOINT ["/rit/set_umask.sh"] 35 | CMD ["/rit/run.sh"] 36 | -------------------------------------------------------------------------------- /aws/create/cluster/Makefile: -------------------------------------------------------------------------------- 1 | # SH 2 | 3 | BIN_FOLDER=bin 4 | BINARY_NAME_UNIX=run.sh 5 | BINARY_NAME_WINDOWS=run.bat 6 | ENTRY_POINT_UNIX=main.sh 7 | ENTRY_POINT_WINDOWS=main.bat 8 | 9 | build: bash-build bat-build docker 10 | 11 | bash-build: 12 | mkdir $(BIN_FOLDER) 13 | cp -r src/* $(BIN_FOLDER) 14 | mv $(BIN_FOLDER)/$(ENTRY_POINT_UNIX) $(BIN_FOLDER)/$(BINARY_NAME_UNIX) 15 | chmod +x $(BIN_FOLDER)/$(BINARY_NAME_UNIX) 16 | 17 | bat-build: 18 | mv $(BIN_FOLDER)/$(ENTRY_POINT_WINDOWS) $(BIN_FOLDER)/$(BINARY_NAME_WINDOWS) 19 | 20 | docker: 21 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 22 | -------------------------------------------------------------------------------- /aws/create/cluster/README.md: -------------------------------------------------------------------------------- 1 | # Ritchie Formula 2 | 3 | ## Premisses 4 | 5 | - Github account. 6 | - CircleCI account (associated with the Github Account). 7 | - AWS account. 8 | - [Ritchie-formulas repository](https://github.com/ZupIT/ritchie-formulas) imported. 9 | 10 | ## Dependencies 11 | 12 | - This formula has been implemented using Shell, and manipulates formulas implemented with Golang and Node from the ritchie-formulas repository. Therefore, to execute this formula locally, it will be necessary to have all those programming languages installed, to build the formulas binaries. 13 | 14 | ## Commands 15 | 16 | ```bash 17 | rit aws create cluster 18 | ``` 19 | 20 | ```bash 21 | echo '{"project_name":"dennis-ritchie-repo", "private":false, "region":"sa-east-1", "bucket":"dennis-ritchie-bucket", "vpc_name":"dennis-ritchie-vpc", "vpc_cidr":"10.0.0.0/16", "vpc_azs":"sa-east-1a,sa-east-1b", "customer_name":"DennisRitchie", "cluster_name":"dennis-ritchie-cluster", "domain_name":"dennisritchiedomain.io"}' | rit aws create cluster --stdin 22 | ``` 23 | 24 | ## Note 25 | 26 | This formula IS NOT compatible with the DOCKER flag. 27 | 28 | ## Description 29 | 30 | This formula allows to create and configure an EKS on AWS using Github, CircleCI and Terraform. 31 | To do so, it performs 8 steps: 32 | 33 | - 1️⃣ Create a Github Project 34 | - 2️⃣ Follow the Github project on CircleCI 35 | - 3️⃣ Create a Bucket on AWS 36 | - 4️⃣ Generate a terraform project 37 | - 5️⃣ Add VPC configurations to terraform project 38 | - 6️⃣ Add EKS configurations to terraform project 39 | - 7️⃣ Configure the CircleCI environment 40 | - 8️⃣ Commit the project on Github 41 | 42 | ![Rit aws create cluster](/docs/img/rit-aws-create-cluster.jpg) 43 | -------------------------------------------------------------------------------- /aws/create/cluster/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | SETLOCAL 4 | SET BIN_FOLDER=bin 5 | SET BINARY_NAME=run.bat 6 | SET BINARY_NAME_UNIX=run.sh 7 | SET ENTRY_POINT=main.bat 8 | SET ENTRY_POINT_UNIX=main.sh 9 | 10 | :BUILD 11 | mkdir %BIN_FOLDER% 12 | xcopy /e/h/i/c src %BIN_FOLDER% 13 | cd %BIN_FOLDER% 14 | call :SH_UNIX 15 | call :BAT_WINDOWS 16 | GOTO EXIT 17 | 18 | :SH_UNIX 19 | rename %ENTRY_POINT_UNIX% %BINARY_NAME_UNIX% 20 | 21 | :BAT_WINDOWS 22 | rename %ENTRY_POINT% %BINARY_NAME% 23 | 24 | :CP_DOCKER 25 | cd .. 26 | copy Dockerfile %BIN_FOLDER% 27 | copy set_umask.sh %BIN_FOLDER% 28 | 29 | :EXIT 30 | ENDLOCAL 31 | exit /b 32 | -------------------------------------------------------------------------------- /aws/create/cluster/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "ritclizup/rit-shell-bat-builder", 3 | "inputs": [ 4 | { 5 | "name": "username", 6 | "type": "CREDENTIAL_GITHUB_USERNAME" 7 | }, 8 | { 9 | "name": "token", 10 | "type": "CREDENTIAL_GITHUB_TOKEN" 11 | }, 12 | { 13 | "name": "email", 14 | "type": "CREDENTIAL_GITHUB_EMAIL" 15 | }, 16 | { 17 | "name": "circleci_token", 18 | "type": "CREDENTIAL_CIRCLECI_TOKEN" 19 | }, 20 | { 21 | "name": "access_key", 22 | "type": "CREDENTIAL_AWS_ACCESSKEYID" 23 | }, 24 | { 25 | "name": "secret_access_key", 26 | "type": "CREDENTIAL_AWS_SECRETACCESSKEY" 27 | }, 28 | { 29 | "label": "Project name: ", 30 | "name": "project_name", 31 | "type": "text", 32 | "tutorial": "Your project name | e.g.: awesome-project" 33 | }, 34 | { 35 | "default": "false", 36 | "items": [ 37 | "false", 38 | "true" 39 | ], 40 | "label": "Project will be a private repo on Github?", 41 | "name": "private", 42 | "type": "bool", 43 | "tutorial": "Choose one option form the list" 44 | }, 45 | { 46 | "label": "Type your region: ", 47 | "name": "region", 48 | "type": "text", 49 | "tutorial": "AWS region | i.e.: us-east-1, us-west-1, sa-east-1", 50 | "cache": { 51 | "active": true, 52 | "newLabel": "Type new value. ", 53 | "qty": 6 54 | } 55 | }, 56 | { 57 | "label": "Type bucket name: ", 58 | "name": "bucket", 59 | "type": "text", 60 | "tutorial": "Bucket name | e.g.: some-aws-bucket" 61 | }, 62 | { 63 | "label": "Type the vpc name:", 64 | "name": "vpc_name", 65 | "type": "text", 66 | "tutorial": "The vpc name | e.g.: some-vpc" 67 | }, 68 | { 69 | "label": "Type the vpc_cidr:", 70 | "name": "vpc_cidr", 71 | "type": "text", 72 | "tutorial": "The vpc cidr (Classless Inter-Domain Routing) | e.g.: 10.0.0.0/16" 73 | }, 74 | { 75 | "label": "Type your vpc_azs:", 76 | "name": "vpc_azs", 77 | "type": "text", 78 | "tutorial": "AWS vpc azs (Available Zones) | e.g.: us-west-1a, us-west-1b" 79 | }, 80 | { 81 | "label": "Type the customer name:", 82 | "name": "customer_name", 83 | "type": "text", 84 | "tutorial": "A customer name | e.g.: Dennis Ritchie" 85 | }, 86 | { 87 | "label": "Type the cluster name:", 88 | "name": "cluster_name", 89 | "type": "text", 90 | "tutorial": "Your EKS cluster name | e.g.: awesome-project-cluster" 91 | }, 92 | { 93 | "label": "Type the domain name:", 94 | "name": "domain_name", 95 | "type": "text", 96 | "tutorial": "Your EKS domain name | e.g.: projectname.io" 97 | } 98 | ] 99 | } 100 | -------------------------------------------------------------------------------- /aws/create/cluster/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "short": "Formula that create an EKS on AWS", 3 | "long": "Formula that configures a EKS on AWS using Github, CircleCI and Terraform" 4 | } -------------------------------------------------------------------------------- /aws/create/cluster/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local", 4 | "docker" 5 | ], 6 | "os": { 7 | "deps": [], 8 | "support": [ 9 | "mac", 10 | "linux" 11 | ] 12 | }, 13 | "tags": [ 14 | "aws", "create", "cluster" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /aws/create/cluster/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /aws/create/cluster/src/main.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call windows\formula\formula.bat runFormula 4 | -------------------------------------------------------------------------------- /aws/create/cluster/src/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # shellcheck source=/dev/null 4 | . "$(dirname "$0")"/unix/formula/formula.sh --source-only 5 | #In sh for receive inputs of CLI use: $SAMPLE_TEXT, $SAMPLE_LIST and $SAMPLE_BOOL for this example 6 | 7 | runFormula 8 | -------------------------------------------------------------------------------- /aws/create/cluster/src/unix/formula/formula.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | runFormula() { 4 | echo 5 | echo -e '\033[1m🛠 STARTING CLUSTER CREATION AUTOMATION\033[0m' 6 | 7 | if [ -f /.dockerenv ] ; then 8 | echo 9 | echo -e '\033[1m💡 PROCESS EXECUTED EXCLUSIVELY ON DOCKER\033[0m' 10 | fi 11 | 12 | echo 13 | echo -e '\033[1m1️⃣ CREATE GITHUB PROJECT\033[0m' 14 | echo 15 | if [ -f /.dockerenv ] ; then 16 | git config --global user.name $USERNAME 17 | git config --global user.email $EMAIL 18 | fi 19 | echo '{"rit_project_name":"'$PROJECT_NAME'", "rit_repo_privacy":"'$PRIVATE'", "rit_workspace_path":" ", "rit_project_description":"Terraform project created with Ritchie CLI ^(https://ritchiecli.io^)"}' | rit github create repo --stdin 20 | sleep 2s 21 | git clone https://github.com/$USERNAME/$PROJECT_NAME.git 22 | sleep 1s 23 | 24 | echo 25 | echo -e '\033[1m2️⃣ FOLLOW PROJECT ON CIRCLECI\033[0m' 26 | echo 27 | echo '{"provider":"github", "project":"'$PROJECT_NAME'"}' | rit circleci follow project --stdin 28 | sleep 3s 29 | 30 | echo 31 | echo -e '\033[1m3️⃣ CREATE BUCKET ON AWS\033[0m' 32 | echo 33 | echo '{"region":"'$REGION'", "bucket":"'$BUCKET'"}' | rit aws create bucket --stdin 34 | sleep 3s 35 | 36 | echo 37 | echo -e '\033[1m4️⃣ GENERATE TERRAFORM PROJECT\033[0m' 38 | echo 39 | cd $CURRENT_PWD 40 | if [ $? != 0 ]; then 41 | cd - 42 | exit 1; 43 | fi 44 | echo '{"project_name":"'$PROJECT_NAME'", "project_location":"'$CURRENT_PWD'", "bucket_name":"'$BUCKET'", "bucket_region":"'$REGION'"}' | rit aws generate terraform-project --stdin 45 | sleep 3s 46 | 47 | echo 48 | echo -e '\033[1m5️⃣ ADD VPC CONFIGURATIONS\033[0m' 49 | cd $CURRENT_PWD'/'$PROJECT_NAME 50 | if [ $? != 0 ]; then 51 | cd - 52 | exit 1; 53 | fi 54 | echo '{"region":"'$REGION'", "vpc_name":"'$VPC_NAME'", "vpc_cidr":"'$VPC_CIDR'", "vpc_azs":"'$VPC_AZS'", "customer_name":"'$CUSTOMER_NAME'"}' | rit aws add terraform-vpc --stdin 55 | sleep 3s 56 | 57 | echo 58 | echo -e '\033[1m6️⃣ ADD EKS CONFIGURATIONS\033[0m' 59 | echo '{"cluster_name":"'$CLUSTER_NAME'", "domain_name":"'$DOMAINE_NAME'"}' | rit aws add terraform-eks --stdin 60 | sleep 3s 61 | 62 | echo 63 | echo -e '\033[1m7️⃣ CONFIGURE CIRCLECI ENVIRONMENT (QA)\033[0m' 64 | echo 65 | echo '{"repo_owner":"'$USERNAME'", "repo_name":"'$PROJECT_NAME'", "env_name":"AWS_ACCESS_KEY_ID_QA", "env_value":"'$ACCESS_KEY'"}' | rit circleci add env --stdin 66 | echo '{"repo_owner":"'$USERNAME'", "repo_name":"'$PROJECT_NAME'", "env_name":"AWS_SECRET_ACCESS_KEY_QA", "env_value":"'$SECRET_ACCESS_KEY'"}' | rit circleci add env --stdin 67 | sleep 3s 68 | 69 | echo 70 | echo -e '\033[1m8️⃣ COMMIT PROJECT ON GITHUB (QA)\033[0m' 71 | echo 72 | cd $CURRENT_PWD'/'$PROJECT_NAME 73 | if [ $? != 0 ]; then 74 | cd - 75 | exit 1; 76 | fi 77 | pwd 78 | git init 79 | git checkout -b qa 80 | git add . 81 | git commit -m "First commit from Ritchie (rit aws create cluster) formula" 82 | git remote add origin https://$USERNAME:$TOKEN@github.com/$USERNAME/$PROJECT_NAME.git 83 | git push origin qa 84 | sleep 3s 85 | 86 | echo 87 | echo "🚀 CircleCI pipeline initiated at:" 88 | echo "🔎 https://app.circleci.com/pipelines/github/$USERNAME/$PROJECT_NAME?branch=qa" 89 | } 90 | -------------------------------------------------------------------------------- /aws/create/cluster/src/windows/formula/formula.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | @REM The line below makes a temporary correction to the directory 5 | SET proj_loc=%CURRENT_PWD:\=\\% 6 | 7 | call:%~1 8 | goto exit 9 | 10 | :runFormula 11 | echo --- Starting Cluster Creation Automation -------- 12 | echo ------------------------------------------------- 13 | echo --- Create Github Project ----------------------- 14 | SET tmp1=%cd% 15 | cd %CURRENT_PWD% 16 | echo {"rit_project_name":"%PROJECT_NAME%", "rit_repo_privacy":"%PRIVATE%", "rit_workspace_path":" ", "rit_project_description":"Terraform project created with Ritchie CLI ^(https://ritchiecli.io^)"}' | rit github create repo --stdin 17 | timeout /t 10 /nobreak > nul 18 | 19 | echo --- Follow project on CircleCI ------------------ 20 | echo {"provider":"github", "project":"%PROJECT_NAME%"} | rit circleci follow project --stdin 21 | timeout /t 3 /nobreak > nul 22 | 23 | echo --- Create Bucket on AWS ------------------------ 24 | echo {"region":"%REGION%", "bucket":"%BUCKET%"} | rit aws create bucket --stdin 25 | timeout /t 3 /nobreak > nul 26 | 27 | echo --- Generate terraform project ------------------ 28 | echo ------------------------------------------------- 29 | echo %cd% 30 | echo {"project_name":"%PROJECT_NAME%", "project_location":"%proj_loc%", "bucket_name":"%BUCKET%", "bucket_region":"%REGION%"} | rit aws generate terraform-project --stdin 31 | timeout /t 3 /nobreak > nul 32 | cd %PROJECT_NAME% 33 | 34 | echo --- Add VPC configurations ---------------------- 35 | echo {"region":"%REGION%", "vpc_name":"%VPC_NAME%", "vpc_cidr":"%VPC_CIDR%", "vpc_azs":"%VPC_AZS%", "customer_name":"%CUSTOMER_NAME%"} | rit aws add terraform-vpc --stdin 36 | timeout /t 3 /nobreak > nul 37 | 38 | echo --- Add EKS configurations ---------------------- 39 | echo {"cluster_name":"%CLUSTER_NAME%", "domain_name":"%DOMAINE_NAME%"} | rit aws add terraform-eks --stdin 40 | timeout /t 3 /nobreak > nul 41 | 42 | echo --- Configure CircleCI environment (QA) --------- 43 | echo {"repo_owner":"%USERNAME%", "repo_name":"%PROJECT_NAME%", "env_name":"AWS_ACCESS_KEY_ID_QA", "env_value":"%ACCESS_KEY%"} | rit circleci add env --stdin 44 | echo {"repo_owner":"%USERNAME%", "repo_name":"%PROJECT_NAME%", "env_name":"AWS_SECRET_ACCESS_KEY_QA", "env_value":"%SECRET_ACCESS_KEY%"} | rit circleci add env --stdin 45 | timeout /t 3 /nobreak > nul 46 | 47 | echo --- Commit project (QA) ------------------------- 48 | git checkout -b qa 49 | git add . 50 | git commit -m "First commit from Ritchie (rit aws create cluster) formula" > nul 51 | git push origin qa 52 | cd %tmp1% 53 | timeout /t 3 /nobreak > nul 54 | 55 | SET URL=https://app.circleci.com/pipelines/github/%USERNAME%/%PROJECT_NAME%?branch=qa 56 | echo CircleCI pipeline initiated at %URL% 57 | 58 | goto exit 59 | 60 | :exit 61 | ENDLOCAL 62 | exit /b 0 -------------------------------------------------------------------------------- /aws/create/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "short": "Create objects on AWS", 3 | "long": "Formulas that create objects using AWS" 4 | } -------------------------------------------------------------------------------- /aws/generate/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Generate AWS objects", 3 | "short": "Generate AWS objects" 4 | } 5 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/Makefile: -------------------------------------------------------------------------------- 1 | # Go parameters 2 | BIN_FOLDER=bin 3 | SH=$(BIN_FOLDER)/run.sh 4 | BAT=$(BIN_FOLDER)/run.bat 5 | BIN_NAME=main 6 | GOCMD=go 7 | GOBUILD=$(GOCMD) build 8 | GOTEST=$(GOCMD) test 9 | CMD_PATH=main.go 10 | BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin 11 | BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) 12 | BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux 13 | BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) 14 | BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows 15 | BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe 16 | 17 | 18 | build: go-build sh-unix bat-windows 19 | 20 | go-build: 21 | cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) 22 | #LINUX 23 | cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) 24 | #MAC 25 | cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) 26 | #WINDOWS 64 27 | cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) 28 | 29 | cp -r src/files $(BIN_FOLDER)/files 30 | 31 | sh-unix: 32 | echo '#!/bin/sh' > $(SH) 33 | echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) 34 | echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) 35 | echo 'else' >> $(SH) 36 | echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) 37 | echo 'fi' >> $(SH) 38 | chmod +x $(SH) 39 | 40 | bat-windows: 41 | echo '@ECHO OFF' > $(BAT) 42 | echo 'SET mypath=%~dp0' >> $(BAT) 43 | echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) 44 | 45 | test: 46 | $(GOTEST) -short `go list ./... | grep -v vendor/` 47 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/README.md: -------------------------------------------------------------------------------- 1 | # Terraform aws project 2 | 3 | ## command 4 | 5 | ```bash 6 | rit aws generate terraform-project 7 | ``` 8 | 9 | ## description 10 | 11 | This formula receives 2 inputs (project name, project location) 12 | and builds a terraform project with commons folders and files. 13 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/build.bat: -------------------------------------------------------------------------------- 1 | :: Go parameters 2 | echo off 3 | SETLOCAL 4 | SET BINARY_NAME=main 5 | SET GOCMD=go 6 | SET GOBUILD=%GOCMD% build 7 | SET CMD_PATH=main.go 8 | SET BIN_FOLDER=..\bin 9 | SET DIST_WIN_DIR=%BIN_FOLDER%\windows 10 | SET DIST_LINUX_DIR=%BIN_FOLDER%\linux 11 | SET BIN_WIN=%BINARY_NAME%.exe 12 | SET BAT_FILE=%BIN_FOLDER%\run.bat 13 | SET SH_FILE=%BIN_FOLDER%\run.sh 14 | 15 | :build 16 | cd src 17 | xcopy /e/h/i files %BIN_FOLDER%\files 18 | mkdir %DIST_WIN_DIR% 19 | SET GO111MODULE=on 20 | for /f %%i in ('go list -m') do set MODULE=%%i 21 | CALL :windows 22 | CALL :linux 23 | if %errorlevel% neq 0 exit /b %errorlevel% 24 | GOTO CP_DOCKER 25 | GOTO DONE 26 | cd .. 27 | 28 | :windows 29 | SET CGO_ENABLED= 30 | SET GOOS=windows 31 | SET GOARCH=amd64 32 | %GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% 33 | echo @ECHO OFF > %BAT_FILE% 34 | echo SET mypath=%%~dp0 >> %BAT_FILE% 35 | echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% 36 | GOTO DONE 37 | 38 | :linux 39 | SET CGO_ENABLED=0 40 | SET GOOS=linux 41 | SET GOARCH=amd64 42 | %GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% 43 | echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% 44 | GOTO DONE 45 | 46 | :CP_DOCKER 47 | copy ..\Dockerfile %BIN_FOLDER% 48 | copy ..\set_umask.sh %BIN_FOLDER% 49 | GOTO DONE 50 | :DONE 51 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/go:1.14", 3 | "inputs": [ 4 | { 5 | "label": "Type the project name: ", 6 | "name": "project_name", 7 | "type": "text", 8 | "tutorial": "Project name e.g.: awesome-project" 9 | }, 10 | { 11 | "label": "Type the location: ", 12 | "name": "project_location", 13 | "type": "text", 14 | "tutorial": "Project location e.g.: /home/user/projects" 15 | }, 16 | { 17 | "label": "Type the terraform bucket name: ", 18 | "name": "bucket_name", 19 | "type": "text", 20 | "tutorial": "Bucket name e.g.: some-aws-bucket" 21 | }, 22 | { 23 | "label": "Type the bucket region: ", 24 | "name": "bucket_region", 25 | "type": "text", 26 | "tutorial": "AWS region i.e., us-east-1, us-west-1, sa-east-1" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Create terraform project with common structure.", 3 | "short": "Create terraform project with common structure." 4 | } 5 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GuillaumeFalourd/formulas-aws/91a6cea7fd4b6a2dd86c7bf46aaa0a35f5c9127f/aws/generate/terraform-project/src/Dockerfile -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/files/circleci-pipeline/scripts/credentials.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if expr "$CIRCLE_BRANCH" : 'qa' >/dev/null; then 4 | export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_QA" 5 | export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_QA" 6 | 7 | elif expr "$CIRCLE_BRANCH" : 'master' >/dev/null; then 8 | export AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID_PROD" 9 | export AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY_PROD" 10 | else 11 | echo "" 12 | fi 13 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/files/circleci-pipeline/scripts/terraform-env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if expr "$CIRCLE_BRANCH" : 'qa' >/dev/null; then 4 | export ENVIRONMENT="qa" 5 | 6 | elif expr "$CIRCLE_BRANCH" : 'master' >/dev/null; then 7 | export ENVIRONMENT="prod" 8 | else 9 | echo "" 10 | fi 11 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/files/circleci-pipeline/scripts/terraform-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Downloading terraform" 4 | 5 | curl -fsSL "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -o terraform.zip 6 | 7 | unzip terraform.zip 8 | 9 | mv terraform /usr/local/bin 10 | 11 | echo "Applying changes to ${TERRAFORM_ENV} ${ENVIRONMENT}" 12 | 13 | cd src && AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} make apply-ci 14 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/go.mod: -------------------------------------------------------------------------------- 1 | module project 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/ZupIT/ritchie-cli v0.0.0-20200618194422-158bebeda04e 7 | github.com/fatih/color v1.9.0 8 | ) 9 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= 4 | github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= 5 | github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= 6 | github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= 7 | github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= 8 | github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= 9 | github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= 10 | github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= 11 | github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= 12 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 13 | github.com/MakeNowJust/heredoc v0.0.0-20170808103936-bb23615498cd/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E= 14 | github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= 15 | github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= 16 | github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= 17 | github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= 18 | github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= 19 | github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= 20 | github.com/ZupIT/ritchie-cli v0.0.0-20200618194422-158bebeda04e/go.mod h1:1JpYsLfI6ogZSJ7uGePn6DXKhK3ywL5gW4LONi4N7Aw= 21 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 22 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 23 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 24 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 25 | github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= 26 | github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= 27 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= 28 | github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw= 29 | github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 30 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 31 | github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= 32 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 33 | github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= 34 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 35 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= 36 | github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= 37 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 38 | github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 39 | github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= 40 | github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= 41 | github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= 42 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 43 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 44 | github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE= 45 | github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI= 46 | github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= 47 | github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= 48 | github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= 49 | github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= 50 | github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= 51 | github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= 52 | github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= 53 | github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= 54 | github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= 55 | github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= 56 | github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= 57 | github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= 58 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 59 | github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 60 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 61 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 62 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 63 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= 64 | github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= 65 | github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= 66 | github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= 67 | github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= 68 | github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= 69 | github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= 70 | github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= 71 | github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= 72 | github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= 73 | github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= 74 | github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= 75 | github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= 76 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 77 | github.com/gofrs/flock v0.7.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= 78 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 79 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 80 | github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 81 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 82 | github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 83 | github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 84 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 85 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 86 | github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 87 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 88 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 89 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 90 | github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho= 91 | github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkYFkPcDKwRXegd+iM6E7matEszMG5HhwytU8= 92 | github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk= 93 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 94 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 95 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 96 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 97 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 98 | github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 99 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 100 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 101 | github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 102 | github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= 103 | github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 104 | github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 105 | github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= 106 | github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= 107 | github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= 108 | github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= 109 | github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= 110 | github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 111 | github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 112 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 113 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 114 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 115 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 116 | github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= 117 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 118 | github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= 119 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 120 | github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 121 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 122 | github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= 123 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 124 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 125 | github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= 126 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 127 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 128 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 129 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 130 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 131 | github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= 132 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 133 | github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= 134 | github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= 135 | github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= 136 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 137 | github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 138 | github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 139 | github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 140 | github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= 141 | github.com/manifoldco/promptui v0.7.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ= 142 | github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= 143 | github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= 144 | github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= 145 | github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= 146 | github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= 147 | github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= 148 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 149 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 150 | github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= 151 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 152 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 153 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 154 | github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 155 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 156 | github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 157 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 158 | github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= 159 | github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= 160 | github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 161 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 162 | github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 163 | github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 164 | github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 165 | github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= 166 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 167 | github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= 168 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 169 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 170 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 171 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 172 | github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= 173 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 174 | github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= 175 | github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= 176 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 177 | github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 178 | github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 179 | github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 180 | github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 181 | github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 182 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 183 | github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 184 | github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 185 | github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= 186 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 187 | github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= 188 | github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 189 | github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 190 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 191 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 192 | github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= 193 | github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 194 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 195 | github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= 196 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 197 | github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= 198 | github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= 199 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 200 | github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 201 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 202 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 203 | github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= 204 | github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 205 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 206 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 207 | github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= 208 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 209 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 210 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 211 | github.com/thoas/go-funk v0.6.0/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q= 212 | github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= 213 | github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= 214 | github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= 215 | github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= 216 | github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8= 217 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 218 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 219 | go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= 220 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 221 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 222 | go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 223 | go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 224 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 225 | golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 226 | golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 227 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 228 | golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 229 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 230 | golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 231 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 232 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 233 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 234 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 235 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 236 | golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 237 | golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 238 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 239 | golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 240 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 241 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 242 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 243 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 244 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 245 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 246 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 247 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 248 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 249 | golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 250 | golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 251 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 252 | golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 253 | golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 254 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 255 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 256 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 257 | golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 258 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 259 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 260 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 261 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 262 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 263 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 264 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 265 | golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 266 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 267 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 268 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 269 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 270 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 271 | golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 272 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 273 | golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 274 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 275 | golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 276 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 277 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 278 | golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 279 | golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 280 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 281 | golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 282 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 283 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 284 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 285 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 286 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 287 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 288 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 289 | golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 290 | golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 291 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 292 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 293 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 294 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 295 | golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 296 | golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 297 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 298 | golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 299 | golang.org/x/tools v0.0.0-20200507205054-480da3ebd79c/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 300 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 301 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 302 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 303 | google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= 304 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 305 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 306 | google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 307 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 308 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 309 | google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 310 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 311 | google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= 312 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 313 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 314 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 315 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 316 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 317 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 318 | gopkg.in/square/go-jose.v2 v2.5.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= 319 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 320 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 321 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 322 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 323 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 324 | gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 325 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 326 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 327 | k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= 328 | k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= 329 | k8s.io/cli-runtime v0.18.2/go.mod h1:yfFR2sQQzDsV0VEKGZtrJwEy4hLZ2oj4ZIfodgxAHWQ= 330 | k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= 331 | k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= 332 | k8s.io/component-base v0.18.2/go.mod h1:kqLlMuhJNHQ9lz8Z7V5bxUUtjFZnrypArGl58gmDfUM= 333 | k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= 334 | k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= 335 | k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 336 | k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 337 | k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= 338 | k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= 339 | k8s.io/kubectl v0.18.2/go.mod h1:OdgFa3AlsPKRpFFYE7ICTwulXOcMGXHTc+UKhHKvrb4= 340 | k8s.io/metrics v0.18.2/go.mod h1:qga8E7QfYNR9Q89cSCAjinC9pTZ7yv1XSVGUB0vJypg= 341 | k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= 342 | sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= 343 | sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= 344 | sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= 345 | sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 346 | sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= 347 | vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI= 348 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "project/pkg/aws" 6 | ) 7 | 8 | func main() { 9 | name := os.Getenv("PROJECT_NAME") 10 | loc := os.Getenv("PROJECT_LOCATION") 11 | bucketName := os.Getenv("BUCKET_NAME") 12 | bucketRegion := os.Getenv("BUCKET_REGION") 13 | pwd := os.Getenv("CURRENT_PWD") 14 | 15 | aws.Input{ 16 | ProjectName: name, 17 | ProjectLocation: loc, 18 | BucketName: bucketName, 19 | BucketRegion: bucketRegion, 20 | PWD: pwd, 21 | }.Run() 22 | } 23 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/aws/aws.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "os" 7 | "path" 8 | "text/template" 9 | 10 | "project/pkg/tpl" 11 | 12 | "github.com/fatih/color" 13 | 14 | "github.com/ZupIT/ritchie-cli/pkg/file/fileutil" 15 | ) 16 | 17 | const ( 18 | dirFormat = "%s/%s" 19 | scaffoldFormat = "%s/.scaffold" 20 | readmeFormat = "%s/README.md" 21 | gitignoreFormat = "%s/.gitignore" 22 | jenkinsfileFormat = "%s/Jenkinsfile" 23 | srcDir = "%s/src" 24 | mainFormat = "%s/src/main.tf" 25 | makefileFormat = "%s/src/Makefile" 26 | modulesDir = "%s/src/modules" 27 | templatesDir = "%s/src/templates" 28 | variablesDir = "%s/src/variables" 29 | varFilesFormat = "%s/src/variables/%s.tfvars" 30 | QABackendtfFormat = "%s/src/qa.tfbackend" 31 | CircleCIPath = "files/circleci-pipeline" 32 | CircleCIConfigPath = "%s/.circleci/config.yml" 33 | ) 34 | 35 | type Input struct { 36 | ProjectName string 37 | ProjectLocation string 38 | BucketName string 39 | BucketRegion string 40 | PWD string 41 | } 42 | 43 | func (in Input) Path() string { 44 | return fmt.Sprintf(dirFormat, in.ProjectLocation, in.ProjectName) 45 | } 46 | 47 | func (in Input) Run() { 48 | 49 | if err := CreateDirIfNotExists(in.Path(), 0755); err != nil { 50 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 51 | os.Exit(1) 52 | } 53 | 54 | scaffold := fmt.Sprintf(scaffoldFormat, in.Path()) 55 | if err := CreateFileIfNotExist(scaffold, []byte(tpl.Scaffold)); err != nil { 56 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 57 | os.Exit(1) 58 | } 59 | 60 | readme := fmt.Sprintf(readmeFormat, in.Path()) 61 | if err := CreateFileIfNotExist(readme, []byte(tpl.Readme)); err != nil { 62 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 63 | os.Exit(1) 64 | } 65 | 66 | gitignore := fmt.Sprintf(gitignoreFormat, in.Path()) 67 | if err := CreateFileIfNotExist(gitignore, []byte(tpl.GitIgnore)); err != nil { 68 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 69 | os.Exit(1) 70 | } 71 | 72 | jenkinsfile := fmt.Sprintf(jenkinsfileFormat, in.Path()) 73 | if err := CreateFileIfNotExist(jenkinsfile, []byte(tpl.Jenkinsfile)); err != nil { 74 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 75 | os.Exit(1) 76 | } 77 | 78 | src := fmt.Sprintf(srcDir, in.Path()) 79 | if err := CreateDirIfNotExists(src, 0755); err != nil { 80 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 81 | os.Exit(1) 82 | } 83 | 84 | maintf := fmt.Sprintf(mainFormat, in.Path()) 85 | if err := CreateFileIfNotExist(maintf, []byte(tpl.Maintf)); err != nil { 86 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 87 | os.Exit(1) 88 | } 89 | 90 | makefile := fmt.Sprintf(makefileFormat, in.Path()) 91 | if err := CreateFileIfNotExist(makefile, []byte(tpl.Makefile)); err != nil { 92 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 93 | os.Exit(1) 94 | } 95 | 96 | modules := fmt.Sprintf(modulesDir, in.Path()) 97 | if err := CreateDirIfNotExists(modules, 0755); err != nil { 98 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 99 | os.Exit(1) 100 | } 101 | 102 | templates := fmt.Sprintf(templatesDir, in.Path()) 103 | if err := CreateDirIfNotExists(templates, 0755); err != nil { 104 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 105 | os.Exit(1) 106 | } 107 | 108 | variables := fmt.Sprintf(variablesDir, in.Path()) 109 | if err := CreateDirIfNotExists(variables, 0755); err != nil { 110 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 111 | os.Exit(1) 112 | } 113 | 114 | commonvar := fmt.Sprintf(varFilesFormat, in.Path(), "common") 115 | if err := CreateFileIfNotExist(commonvar, []byte(tpl.Variable)); err != nil { 116 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 117 | os.Exit(1) 118 | } 119 | 120 | prodvar := fmt.Sprintf(varFilesFormat, in.Path(), "prod") 121 | if err := CreateFileIfNotExist(prodvar, []byte(tpl.Variable)); err != nil { 122 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 123 | os.Exit(1) 124 | } 125 | 126 | qavar := fmt.Sprintf(varFilesFormat, in.Path(), "qa") 127 | if err := CreateFileIfNotExist(qavar, []byte(tpl.Variable)); err != nil { 128 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 129 | os.Exit(1) 130 | } 131 | 132 | stgvar := fmt.Sprintf(varFilesFormat, in.Path(), "stg") 133 | if err := CreateFileIfNotExist(stgvar, []byte(tpl.Variable)); err != nil { 134 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 135 | os.Exit(1) 136 | } 137 | 138 | //qa.backendtf 139 | backendtf := fmt.Sprintf(QABackendtfFormat, in.Path()) 140 | if err := CreateFileIfNotExist(backendtf, []byte("")); err != nil { 141 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 142 | os.Exit(1) 143 | } 144 | 145 | t := template.Must(template.New("QABackendtf").Parse(tpl.QABackendtf)) 146 | bfile, err := os.OpenFile(backendtf, os.O_APPEND|os.O_WRONLY, 0644) 147 | if err != nil { 148 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 149 | os.Exit(1) 150 | } 151 | defer bfile.Close() 152 | err = t.Execute(bfile, in) 153 | if err != nil { 154 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 155 | os.Exit(1) 156 | } 157 | 158 | color.Blue("Copying circleci pipeline files") 159 | 160 | circleDir := path.Join(in.PWD, in.ProjectName, ".circleci") 161 | 162 | if err := fileutil.CreateDirIfNotExists(circleDir, 0755); err != nil { 163 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 164 | os.Exit(1) 165 | } 166 | 167 | if err = fileutil.CopyDirectory(CircleCIPath, circleDir); err != nil { 168 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 169 | os.Exit(1) 170 | } 171 | 172 | circleciConfig := fmt.Sprintf(CircleCIConfigPath, in.Path()) 173 | if err := CreateFileIfNotExist(circleciConfig, []byte("")); err != nil { 174 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 175 | os.Exit(1) 176 | } 177 | 178 | t = template.Must(template.New("circleciConfig").Parse(tpl.Circleciconfig)) 179 | bfile, err = os.OpenFile(circleciConfig, os.O_APPEND|os.O_WRONLY, 0644) 180 | if err != nil { 181 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 182 | os.Exit(1) 183 | } 184 | defer bfile.Close() 185 | err = t.Execute(bfile, in) 186 | if err != nil { 187 | color.Red(fmt.Sprintf("failed to create project: %q, error: %q", in.Path(), err.Error())) 188 | os.Exit(1) 189 | } 190 | 191 | color.Green(fmt.Sprintln("project created successfully")) 192 | color.Green(fmt.Sprintln("location:", in.Path())) 193 | color.Green(fmt.Sprintln("go to the location and run [rit aws add] and check the options for your project")) 194 | 195 | } 196 | 197 | func IsNotExist(name string) bool { 198 | _, err := os.Stat(name) 199 | return err != nil && os.IsNotExist(err) 200 | } 201 | 202 | func CreateDirIfNotExists(dir string, perm os.FileMode) error { 203 | if IsNotExist(dir) { 204 | if err := os.MkdirAll(dir, perm); err != nil { 205 | return fmt.Errorf("failed to create directory: %q, error: %q", dir, err) 206 | } 207 | } 208 | return nil 209 | } 210 | 211 | func CreateFileIfNotExist(file string, content []byte) error { 212 | if IsNotExist(file) { 213 | if err := ioutil.WriteFile(file, content, 0644); err != nil { 214 | return err 215 | } 216 | } 217 | return nil 218 | } 219 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/aws/aws_test.go: -------------------------------------------------------------------------------- 1 | package aws 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | func TestPath(t *testing.T) { 9 | input := Input{ 10 | ProjectName: "test", 11 | ProjectLocation: os.TempDir(), 12 | } 13 | 14 | want := os.TempDir() + "/test" 15 | got := input.Path() 16 | if want != got { 17 | t.Errorf("RepoPath got %v, want %v", got, want) 18 | } 19 | } 20 | 21 | func TestRun(t *testing.T) { 22 | input := Input{ 23 | ProjectName: "test", 24 | ProjectLocation: os.TempDir(), 25 | } 26 | input.Run() 27 | 28 | if _, err := os.Stat(input.Path()); os.IsNotExist(err) { 29 | t.Errorf("Run got %v, want %v", err, "project created") 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/circleciconfig.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const Circleciconfig = ` 4 | version: 2.1 5 | 6 | orbs: 7 | windows: circleci/windows@2.4.0 8 | 9 | references: 10 | images: 11 | ubuntu: &UBUNTU_IMAGE cimg/base:2020.01 12 | 13 | environment: &ENVIRONMENT 14 | TERRAFORM_ENV : "{{.ProjectName}}" 15 | TERRAFORM_VERSION: "0.13.5" 16 | 17 | 18 | filters: &FILTERS_DELIVERY 19 | branches: 20 | only: 21 | - qa 22 | - master 23 | 24 | executors: 25 | ubuntu-executor: 26 | docker: 27 | - image: *UBUNTU_IMAGE 28 | user: root 29 | working_directory: /workspace 30 | 31 | jobs: 32 | terraform: 33 | environment: 34 | <<: *ENVIRONMENT 35 | executor: ubuntu-executor 36 | steps: 37 | - checkout 38 | - run: 39 | name: Applying terraform changes to the environment 40 | command: | 41 | . ./.circleci/scripts/credentials.sh 42 | . ./.circleci/scripts/terraform-env.sh 43 | . ./.circleci/scripts/terraform-run.sh 44 | 45 | workflows: 46 | 47 | delivery: 48 | jobs: 49 | - terraform: 50 | filters: 51 | <<: *FILTERS_DELIVERY 52 | ` 53 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/gitignore.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | GitIgnore = `# Created by https://www.toptal.com/developers/gitignore/api/terraform,intellij,macos,visualstudiocode 5 | # Edit at https://www.toptal.com/developers/gitignore?templates=terraform,intellij,macos,visualstudiocode 6 | 7 | ### Intellij ### 8 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 9 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 10 | 11 | # User-specific stuff 12 | .idea/**/workspace.xml 13 | .idea/**/tasks.xml 14 | .idea/**/usage.statistics.xml 15 | .idea/**/dictionaries 16 | .idea/**/shelf 17 | 18 | # Generated files 19 | .idea/**/contentModel.xml 20 | 21 | # Sensitive or high-churn files 22 | .idea/**/dataSources/ 23 | .idea/**/dataSources.ids 24 | .idea/**/dataSources.local.xml 25 | .idea/**/sqlDataSources.xml 26 | .idea/**/dynamic.xml 27 | .idea/**/uiDesigner.xml 28 | .idea/**/dbnavigator.xml 29 | 30 | # Gradle 31 | .idea/**/gradle.xml 32 | .idea/**/libraries 33 | 34 | # Gradle and Maven with auto-import 35 | # When using Gradle or Maven with auto-import, you should exclude module files, 36 | # since they will be recreated, and may cause churn. Uncomment if using 37 | # auto-import. 38 | # .idea/artifacts 39 | # .idea/compiler.xml 40 | # .idea/jarRepositories.xml 41 | # .idea/modules.xml 42 | # .idea/*.iml 43 | # .idea/modules 44 | # *.iml 45 | # *.ipr 46 | 47 | # CMake 48 | cmake-build-*/ 49 | 50 | # Mongo Explorer plugin 51 | .idea/**/mongoSettings.xml 52 | 53 | # File-based project format 54 | *.iws 55 | 56 | # IntelliJ 57 | out/ 58 | 59 | # mpeltonen/sbt-idea plugin 60 | .idea_modules/ 61 | 62 | # JIRA plugin 63 | atlassian-ide-plugin.xml 64 | 65 | # Cursive Clojure plugin 66 | .idea/replstate.xml 67 | 68 | # Crashlytics plugin (for Android Studio and IntelliJ) 69 | com_crashlytics_export_strings.xml 70 | crashlytics.properties 71 | crashlytics-build.properties 72 | fabric.properties 73 | 74 | # Editor-based Rest Client 75 | .idea/httpRequests 76 | 77 | # Android studio 3.1+ serialized cache file 78 | .idea/caches/build_file_checksums.ser 79 | 80 | ### Intellij Patch ### 81 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 82 | 83 | # *.iml 84 | # modules.xml 85 | # .idea/misc.xml 86 | # *.ipr 87 | 88 | # Sonarlint plugin 89 | .idea/**/sonarlint/ 90 | 91 | # SonarQube Plugin 92 | .idea/**/sonarIssues.xml 93 | 94 | # Markdown Navigator plugin 95 | .idea/**/markdown-navigator.xml 96 | .idea/**/markdown-navigator-enh.xml 97 | .idea/**/markdown-navigator/ 98 | 99 | # Cache file creation bug 100 | # See https://youtrack.jetbrains.com/issue/JBR-2257 101 | .idea/$CACHE_FILE$ 102 | 103 | ### macOS ### 104 | # General 105 | .DS_Store 106 | .AppleDouble 107 | .LSOverride 108 | 109 | # Icon must end with two \r 110 | Icon 111 | 112 | # Thumbnails 113 | ._* 114 | 115 | # Files that might appear in the root of a volume 116 | .DocumentRevisions-V100 117 | .fseventsd 118 | .Spotlight-V100 119 | .TemporaryItems 120 | .Trashes 121 | .VolumeIcon.icns 122 | .com.apple.timemachine.donotpresent 123 | 124 | # Directories potentially created on remote AFP share 125 | .AppleDB 126 | .AppleDesktop 127 | Network Trash Folder 128 | Temporary Items 129 | .apdisk 130 | 131 | ### Terraform ### 132 | # Local .terraform directories 133 | **/.terraform/* 134 | 135 | # .tfstate files 136 | *.tfstate 137 | *.tfstate.* 138 | 139 | # Crash log files 140 | crash.log 141 | 142 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most 143 | # .tfvars files are managed as part of configuration and so should be included in 144 | # version control. 145 | # 146 | # example.tfvars 147 | 148 | # Ignore override files as they are usually used to override resources locally and so 149 | # are not checked in 150 | override.tf 151 | override.tf.json 152 | *_override.tf 153 | *_override.tf.json 154 | 155 | # Include override files you do wish to add to version control using negated pattern 156 | # !example_override.tf 157 | 158 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan 159 | # example: *tfplan* 160 | tf_plan 161 | 162 | src/.terraform 163 | src/kubeconfig* 164 | 165 | ### VisualStudioCode ### 166 | .vscode/* 167 | !.vscode/settings.json 168 | !.vscode/tasks.json 169 | !.vscode/launch.json 170 | !.vscode/extensions.json 171 | *.code-workspace 172 | 173 | ### VisualStudioCode Patch ### 174 | # Ignore all local history of files 175 | .history 176 | 177 | # End of https://www.toptal.com/developers/gitignore/api/terraform,intellij,macos,visualstudiocode 178 | 179 | ` 180 | ) 181 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/jenkinsfile.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Jenkinsfile = `node { 5 | try { 6 | 7 | buildTerraformEnv { 8 | team = "Marte" 9 | } 10 | 11 | } catch (e) { 12 | notifyBuildStatus { 13 | buildStatus = "FAILED" 14 | } 15 | throw e 16 | } 17 | 18 | } 19 | 20 | ` 21 | ) 22 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/maintf.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Maintf = `variable "region" { 5 | default = "" 6 | } 7 | provider "aws" { 8 | region = var.region 9 | } 10 | 11 | terraform { 12 | required_version = "0.13.5" 13 | required_providers { 14 | aws = "3.3.0" 15 | } 16 | 17 | backend "s3" { 18 | } 19 | } 20 | ` 21 | ) 22 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/makefile.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Makefile = `.ONESHELL: 5 | .SHELL := /usr/bin/bash 6 | .PHONY: apply plan prep 7 | ENV = $(ENVIRONMENT) 8 | VARS="variables/$(ENV).tfvars" 9 | 10 | help: 11 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 12 | 13 | set-env: 14 | @if [ -z $(ENV) ]; then \ 15 | echo "ENV was not set"; \ 16 | ERROR=1; \ 17 | fi 18 | @if [ ! -z $${ERROR} ] && [ $${ERROR} -eq 1 ]; then \ 19 | echo "Example usage: ENVIRONMENT=demo make plan "; \ 20 | exit 1; \ 21 | fi 22 | @if [ ! -f "$(VARS)" ]; then \ 23 | echo "Could not find variables file: $(VARS)"; \ 24 | exit 1; \ 25 | fi 26 | 27 | prep: set-env ## Prepare the environment if needed 28 | @echo "Configuring the terraform backend" 29 | @terraform init -var-file=./variables/common.tfvars -var-file=$(VARS) -reconfigure -backend-config=$(ENV).tfbackend 30 | 31 | plan: prep ## Show what terraform wants to do 32 | @echo "Planning the terraform steps" 33 | @terraform plan -var-file=./variables/common.tfvars -var-file=$(VARS) 34 | 35 | apply: plan ## Let Terraform do his thing 36 | @echo "Applying the terraform plan" 37 | @terraform apply -var-file=./variables/common.tfvars -var-file=$(VARS) 38 | 39 | apply-ci: plan ## Let Terraform do his thing on CI 40 | @echo "Applying the terraform plan" 41 | @terraform apply -var-file=./variables/common.tfvars -var-file=$(VARS) -auto-approve 42 | 43 | destroy: set-env ## Let Terraform destroy everything 44 | @echo "Destroying the terraform environment" 45 | @terraform destroy -var-file=./variables/common.tfvars -var-file=$(VARS) 46 | ` 47 | ) 48 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/qa_backendtf.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | QABackendtf = ` 5 | region = "{{.BucketRegion}}" 6 | bucket = "{{.BucketName}}" 7 | key = "terraform.tfstate" 8 | ` 9 | ) 10 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/readme.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Readme = `Scaffold terraform aws 5 | ` 6 | ) 7 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/scaffold.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Scaffold = `scaffold=terraform-aws 5 | ` 6 | ) 7 | -------------------------------------------------------------------------------- /aws/generate/terraform-project/src/pkg/tpl/variable.go: -------------------------------------------------------------------------------- 1 | package tpl 2 | 3 | const ( 4 | Variable = `#put here your variables 5 | ` 6 | ) 7 | -------------------------------------------------------------------------------- /aws/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "short": "AWS formulas", 3 | "long": "Formulas manipulating AWS objects" 4 | } -------------------------------------------------------------------------------- /circleci/add/env/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.12 2 | USER root 3 | 4 | RUN mkdir /rit 5 | COPY . /rit 6 | RUN sed -i 's/\r//g' /rit/set_umask.sh 7 | RUN sed -i 's/\r//g' /rit/run.sh 8 | RUN chmod +x /rit/set_umask.sh 9 | 10 | WORKDIR /app 11 | ENTRYPOINT ["/rit/set_umask.sh"] 12 | CMD ["/rit/run.sh"] 13 | -------------------------------------------------------------------------------- /circleci/add/env/Makefile: -------------------------------------------------------------------------------- 1 | # Go parameters 2 | BIN_FOLDER=bin 3 | SH=$(BIN_FOLDER)/run.sh 4 | BAT=$(BIN_FOLDER)/run.bat 5 | BIN_NAME=main 6 | GOCMD=go 7 | GOBUILD=$(GOCMD) build 8 | GOTEST=$(GOCMD) test 9 | CMD_PATH=main.go 10 | BIN_FOLDER_DARWIN=../$(BIN_FOLDER)/darwin 11 | BIN_DARWIN=$(BIN_FOLDER_DARWIN)/$(BIN_NAME) 12 | BIN_FOLDER_LINUX=../$(BIN_FOLDER)/linux 13 | BIN_LINUX=$(BIN_FOLDER_LINUX)/$(BIN_NAME) 14 | BIN_FOLDER_WINDOWS=../$(BIN_FOLDER)/windows 15 | BIN_WINDOWS=$(BIN_FOLDER_WINDOWS)/$(BIN_NAME).exe 16 | 17 | 18 | build: go-build sh-unix bat-windows docker 19 | 20 | go-build: 21 | cd src; mkdir -p $(BIN_FOLDER_DARWIN) $(BIN_FOLDER_LINUX) $(BIN_FOLDER_WINDOWS) 22 | #LINUX 23 | cd src; CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o '$(BIN_LINUX)' $(CMD_PATH) 24 | #MAC 25 | cd src; GOOS=darwin GOARCH=amd64 $(GOBUILD) -o '$(BIN_DARWIN)' $(CMD_PATH) 26 | #WINDOWS 64 27 | cd src; GOOS=windows GOARCH=amd64 $(GOBUILD) -o '$(BIN_WINDOWS)' $(CMD_PATH) 28 | 29 | sh-unix: 30 | echo '#!/bin/sh' > $(SH) 31 | echo 'if [ $$(uname) = "Darwin" ]; then' >> $(SH) 32 | echo ' "$$(dirname "$$0")"/darwin/$(BIN_NAME)' >> $(SH) 33 | echo 'else' >> $(SH) 34 | echo ' "$$(dirname "$$0")"/linux/$(BIN_NAME)' >> $(SH) 35 | echo 'fi' >> $(SH) 36 | chmod +x $(SH) 37 | 38 | bat-windows: 39 | echo '@ECHO OFF' > $(BAT) 40 | echo 'SET mypath=%~dp0' >> $(BAT) 41 | echo 'start /B /WAIT %mypath:~0,-1%/windows/main.exe' >> $(BAT) 42 | 43 | test: 44 | $(GOTEST) -short `go list ./... | grep -v vendor/` 45 | 46 | docker: 47 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 48 | -------------------------------------------------------------------------------- /circleci/add/env/README.md: -------------------------------------------------------------------------------- 1 | # CircleCI add env 2 | 3 | ## command 4 | 5 | ```bash 6 | rit circleci add env 7 | ``` 8 | 9 | ## description 10 | 11 | This formula receives 5 inputs (token, repo owner, repo name, env name, env value) 12 | and adds a new env to circle ci project. 13 | -------------------------------------------------------------------------------- /circleci/add/env/build.bat: -------------------------------------------------------------------------------- 1 | :: Go parameters 2 | echo off 3 | SETLOCAL 4 | SET BINARY_NAME=main 5 | SET GOCMD=go 6 | SET GOBUILD=%GOCMD% build 7 | SET CMD_PATH=main.go 8 | SET BIN_FOLDER=..\bin 9 | SET DIST_WIN_DIR=%BIN_FOLDER%\windows 10 | SET DIST_LINUX_DIR=%BIN_FOLDER%\linux 11 | SET BIN_WIN=%BINARY_NAME%.exe 12 | SET BAT_FILE=%BIN_FOLDER%\run.bat 13 | SET SH_FILE=%BIN_FOLDER%\run.sh 14 | 15 | :build 16 | cd src 17 | mkdir %DIST_WIN_DIR% 18 | SET GO111MODULE=on 19 | for /f %%i in ('go list -m') do set MODULE=%%i 20 | CALL :windows 21 | CALL :linux 22 | if %errorlevel% neq 0 exit /b %errorlevel% 23 | GOTO CP_DOCKER 24 | GOTO DONE 25 | cd .. 26 | 27 | :windows 28 | SET CGO_ENABLED= 29 | SET GOOS=windows 30 | SET GOARCH=amd64 31 | %GOBUILD% -tags release -o %DIST_WIN_DIR%\%BIN_WIN% %CMD_PATH% 32 | echo @ECHO OFF > %BAT_FILE% 33 | echo SET mypath=%%~dp0 >> %BAT_FILE% 34 | echo start /B /WAIT %%mypath:~0,-1%%/windows/main.exe >> %BAT_FILE% 35 | GOTO DONE 36 | 37 | :linux 38 | SET CGO_ENABLED=0 39 | SET GOOS=linux 40 | SET GOARCH=amd64 41 | %GOBUILD% -tags release -o %DIST_LINUX_DIR%\%BINARY_NAME% %CMD_PATH% 42 | echo "$(dirname "$0")"/linux/%BINARY_NAME% > %SH_FILE% 43 | GOTO DONE 44 | 45 | :CP_DOCKER 46 | copy ..\Dockerfile %BIN_FOLDER% 47 | copy ..\set_umask.sh %BIN_FOLDER% 48 | GOTO DONE 49 | :DONE 50 | -------------------------------------------------------------------------------- /circleci/add/env/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/go:1.14", 3 | "inputs": [ 4 | { 5 | "name": "token", 6 | "type": "CREDENTIAL_CIRCLECI_TOKEN" 7 | }, 8 | { 9 | "cache": { 10 | "active": true, 11 | "newLabel": "Type new value. ", 12 | "qty": 3 13 | }, 14 | "label": "Type the repository owner: ", 15 | "name": "repo_owner", 16 | "type": "text", 17 | "tutorial": "Project owner i.e., yourname" 18 | }, 19 | { 20 | "cache": { 21 | "active": true, 22 | "newLabel": "Type new value. ", 23 | "qty": 3 24 | }, 25 | "label": "Type repository name: ", 26 | "name": "repo_name", 27 | "type": "text", 28 | "tutorial": "Your target project repository i.e., awesome-project" 29 | }, 30 | { 31 | "label": "Type the ENV name : ", 32 | "name": "env_name", 33 | "type": "text", 34 | "tutorial": "Pipeline environment variable name i.e., SOME_NOME" 35 | }, 36 | { 37 | "label": "Type the ENV value : ", 38 | "name": "env_value", 39 | "type": "password", 40 | "tutorial": "Pipeline environment variable value i.e., 1234" 41 | } 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /circleci/add/env/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Add env for circle ci project", 3 | "short": "Add env for circle ci project" 4 | } 5 | -------------------------------------------------------------------------------- /circleci/add/env/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local", 4 | "docker" 5 | ], 6 | "os": { 7 | "deps": [], 8 | "support": [ 9 | "windows", 10 | "mac", 11 | "linux" 12 | ] 13 | }, 14 | "tags": [ 15 | "circleci", 16 | "add", 17 | "env" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /circleci/add/env/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /circleci/add/env/src/go.mod: -------------------------------------------------------------------------------- 1 | module env 2 | 3 | go 1.14 4 | 5 | require github.com/fatih/color v1.9.0 6 | -------------------------------------------------------------------------------- /circleci/add/env/src/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "env/pkg/env" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | token := os.Getenv("TOKEN") 10 | repoOwner := os.Getenv("REPO_OWNER") 11 | repoName := os.Getenv("REPO_NAME") 12 | envName := os.Getenv("ENV_NAME") 13 | envValue := os.Getenv("ENV_VALUE") 14 | 15 | env.Input{ 16 | Token: token, 17 | RepoOwner: repoOwner, 18 | RepoName: repoName, 19 | ENVName: envName, 20 | ENVValue: envValue, 21 | }.Run() 22 | } 23 | -------------------------------------------------------------------------------- /circleci/add/env/src/pkg/env/env.go: -------------------------------------------------------------------------------- 1 | package env 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "io/ioutil" 8 | "net/http" 9 | "os" 10 | 11 | "github.com/fatih/color" 12 | ) 13 | 14 | const ( 15 | URL = "https://circleci.com/api/v1.1/project/gh/%s/%s/envvar?circle-token=%s" 16 | ) 17 | 18 | type Input struct { 19 | Token string 20 | RepoOwner string 21 | RepoName string 22 | ENVName string 23 | ENVValue string 24 | } 25 | 26 | func (in Input) Run() { 27 | env := struct { 28 | Name string `json:"name"` 29 | Value string `json:"value"` 30 | }{ 31 | in.ENVName, 32 | in.ENVValue, 33 | } 34 | 35 | b, err := json.Marshal(&env) 36 | if err != nil { 37 | color.Red(fmt.Sprintf("error marshalling env: %q, error: %q", env, err)) 38 | os.Exit(1) 39 | } 40 | 41 | url := fmt.Sprintf(URL, in.RepoOwner, in.RepoName, in.Token) 42 | resp, err := http.Post(url, "application/json", bytes.NewBuffer(b)) 43 | if err != nil { 44 | color.Red(fmt.Sprintf("error sending env: %q", err)) 45 | os.Exit(1) 46 | } 47 | 48 | if resp.StatusCode != http.StatusCreated { 49 | defer resp.Body.Close() 50 | b, err := ioutil.ReadAll(resp.Body) 51 | if err != nil { 52 | color.Red(fmt.Sprintf("error reading response body: %q", err)) 53 | os.Exit(1) 54 | } 55 | msg := fmt.Sprintf("%s - %s", resp.Status, string(b)) 56 | color.Red(fmt.Sprintf("error sending env: %q", msg)) 57 | os.Exit(1) 58 | } 59 | 60 | color.Green(fmt.Sprintf("env (%s) added successfully!\n", in.ENVName)) 61 | color.Green(fmt.Sprintf("project: %s/%s\n", in.RepoOwner, in.RepoName)) 62 | } 63 | -------------------------------------------------------------------------------- /circleci/add/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Add different circle ci resources", 3 | "short": "Add different circle ci resources" 4 | } 5 | -------------------------------------------------------------------------------- /circleci/follow/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Follows circle ci projects", 3 | "short": "Follows circle ci projects" 4 | } 5 | -------------------------------------------------------------------------------- /circleci/follow/project/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM cimg/node:14.0 2 | 3 | USER root 4 | 5 | RUN curl -fsSL https://commons-repo.ritchiecli.io/install.sh | bash 6 | 7 | RUN mkdir /rit 8 | COPY . /rit 9 | RUN sed -i 's/\r//g' /rit/set_umask.sh 10 | RUN sed -i 's/\r//g' /rit/run.sh 11 | RUN chmod +x /rit/set_umask.sh 12 | 13 | WORKDIR /app 14 | ENTRYPOINT ["/rit/set_umask.sh"] 15 | CMD ["/rit/run.sh"] 16 | -------------------------------------------------------------------------------- /circleci/follow/project/Makefile: -------------------------------------------------------------------------------- 1 | # Make Run Node 2 | BINARY_NAME_UNIX=run.sh 3 | BINARY_NAME_WINDOWS=run.bat 4 | BIN_FOLDER=bin 5 | 6 | build: node-build docker 7 | 8 | node-build: 9 | mkdir -p $(BIN_FOLDER) 10 | cp -r src/* $(BIN_FOLDER) 11 | npm install --silent --no-progress --prefix $(BIN_FOLDER) 12 | echo '#!/bin/sh' > $(BIN_FOLDER)/$(BINARY_NAME_UNIX) 13 | echo 'node "$$(dirname "$$0")"/index.js' >> $(BIN_FOLDER)/$(BINARY_NAME_UNIX) 14 | echo 'node index.js' > $(BIN_FOLDER)/$(BINARY_NAME_WINDOWS) 15 | chmod +x $(BIN_FOLDER)/$(BINARY_NAME_UNIX) 16 | 17 | docker: 18 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 19 | -------------------------------------------------------------------------------- /circleci/follow/project/README.md: -------------------------------------------------------------------------------- 1 | # Ritchie Formula 2 | 3 | ## command 4 | 5 | ```bash 6 | rit circleci follow project 7 | ``` 8 | 9 | ## description 10 | 11 | Whenever you need to setup a ci pipeline remotely, just issue 12 | this command to follow circle ci projects. Once followed, CircleCI will automatically 13 | read the `config.yml` file of the project and launch the workflow. 14 | 15 | ![Circle ci gif](https://media.giphy.com/media/ZFCUfzItfSTKhMXRaA/giphy.gif) 16 | -------------------------------------------------------------------------------- /circleci/follow/project/build.bat: -------------------------------------------------------------------------------- 1 | :: Node parameters 2 | echo off 3 | SETLOCAL 4 | SET BIN_FOLDER=bin 5 | SET BAT_FILE=%BIN_FOLDER%\run.bat 6 | SET SH_FILE=%BIN_FOLDER%\run.sh 7 | :build 8 | mkdir %BIN_FOLDER% 9 | xcopy /E /I src %BIN_FOLDER% 10 | cd %BIN_FOLDER% 11 | call npm install --silent 12 | cd .. 13 | call :BAT_WINDOWS 14 | call :SH_LINUX 15 | call :CP_DOCKER 16 | GOTO DONE 17 | 18 | :BAT_WINDOWS 19 | echo @ECHO OFF > %BAT_FILE% 20 | echo SET mypath=%%~dp0 >> %BAT_FILE% 21 | echo start /B /WAIT node %%mypath:~0,-1%%/index.js >> %BAT_FILE% 22 | 23 | :SH_LINUX 24 | echo node "$(dirname "$0")"/index.js > %SH_FILE% 25 | GOTO DONE 26 | 27 | :CP_DOCKER 28 | copy Dockerfile %BIN_FOLDER% 29 | copy set_umask.sh %BIN_FOLDER% 30 | GOTO DONE 31 | 32 | :DONE 33 | -------------------------------------------------------------------------------- /circleci/follow/project/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/node:14.0", 3 | "inputs": [ 4 | { 5 | "items": [ 6 | "github", 7 | "bitbucket" 8 | ], 9 | "label": "Select your provider: ", 10 | "name": "provider", 11 | "type": "text", 12 | "tutorial": "Choose one option" 13 | }, 14 | { 15 | "name": "circleci_token", 16 | "type": "CREDENTIAL_CIRCLECI_TOKEN" 17 | }, 18 | { 19 | "condition": { 20 | "operator": "==", 21 | "value": "github", 22 | "variable": "provider" 23 | }, 24 | "name": "user", 25 | "type": "CREDENTIAL_GITHUB_USERNAME" 26 | }, 27 | { 28 | "cache": { 29 | "active": true, 30 | "newLabel": "Enter new project: ", 31 | "qty": 6 32 | }, 33 | "label": "Enter the project name to follow: ", 34 | "name": "project", 35 | "type": "text", 36 | "tutorial": "Your target project repository i.e., awesome-project" 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /circleci/follow/project/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Follows circle ci projects", 3 | "short": "Follows circle ci projects" 4 | } 5 | -------------------------------------------------------------------------------- /circleci/follow/project/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local", 4 | "docker" 5 | ], 6 | "os": { 7 | "deps": [], 8 | "support": [ 9 | "windows", 10 | "mac", 11 | "linux" 12 | ] 13 | }, 14 | "tags": [ 15 | "circleci", 16 | "follow", 17 | "project" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /circleci/follow/project/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /circleci/follow/project/src/formula/formula.js: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const clc = require("cli-color"); 3 | 4 | async function Run(provider, token, user, project) { 5 | axios.post( 6 | `https://circleci.com/api/v1.1/project/${provider}/${user}/${project}/follow`, 7 | {}, 8 | {headers: {Accept: 'application/json', 'Circle-Token': token}} 9 | ).then(() => { 10 | console.log(clc.green("CircleCI successfully followed your project")); 11 | }).catch(error => { 12 | console.log(clc.red("Error while following project"), error.response); 13 | }); 14 | } 15 | 16 | const formula = Run; 17 | module.exports = formula; 18 | -------------------------------------------------------------------------------- /circleci/follow/project/src/index.js: -------------------------------------------------------------------------------- 1 | const run = require("./formula/formula"); 2 | 3 | run(process.env.PROVIDER, process.env.CIRCLECI_TOKEN, process.env.USER, process.env.PROJECT); 4 | -------------------------------------------------------------------------------- /circleci/follow/project/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "axios": "^0.21.1", 4 | "cli-color": "^2.0.0" 5 | }, 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "version": "1.0.0" 11 | } 12 | -------------------------------------------------------------------------------- /circleci/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Circle ci commands", 3 | "short": "Circle ci commands" 4 | } 5 | -------------------------------------------------------------------------------- /docs/img/rit-aws-create-cluster.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GuillaumeFalourd/formulas-aws/91a6cea7fd4b6a2dd86c7bf46aaa0a35f5c9127f/docs/img/rit-aws-create-cluster.jpg -------------------------------------------------------------------------------- /github/create/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Create GitHub objects", 3 | "short": "Create GitHub objects" 4 | } 5 | -------------------------------------------------------------------------------- /github/create/repo/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM cimg/base:stable-20.04 2 | 3 | USER root 4 | 5 | RUN mkdir /rit 6 | COPY . /rit 7 | RUN sed -i 's/\r//g' /rit/set_umask.sh 8 | RUN sed -i 's/\r//g' /rit/run.sh 9 | RUN chmod +x /rit/set_umask.sh 10 | 11 | ENV DOCKER_EXECUTION=true 12 | 13 | WORKDIR /app 14 | ENTRYPOINT ["/rit/set_umask.sh"] 15 | CMD ["/rit/run.sh"] 16 | -------------------------------------------------------------------------------- /github/create/repo/Makefile: -------------------------------------------------------------------------------- 1 | # SH 2 | BINARY_NAME=run.sh 3 | BIN_FOLDER=bin 4 | 5 | build: bash-build docker 6 | 7 | bash-build: 8 | mkdir -p $(BIN_FOLDER) 9 | cp -r src/* $(BIN_FOLDER) 10 | mv $(BIN_FOLDER)/main.sh $(BIN_FOLDER)/$(BINARY_NAME) 11 | chmod +x $(BIN_FOLDER)/$(BINARY_NAME) 12 | 13 | docker: 14 | cp Dockerfile set_umask.sh $(BIN_FOLDER) 15 | -------------------------------------------------------------------------------- /github/create/repo/README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | This Github create command allows the user to create a new Github repository. 4 | 5 | ## Command 6 | 7 | ```bash 8 | rit github create repo 9 | ``` 10 | 11 | ## Requirements 12 | 13 | - [Git Installed](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) 14 | - Github Account 15 | 16 | ## Demonstration 17 | 18 | ![gif](https://github.com/ZupIT/ritchie-formulas/raw/master/github/create/repo/doc/github-create-repo.gif) 19 | -------------------------------------------------------------------------------- /github/create/repo/build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | SET BINARY_NAME=run.bat 4 | SET BIN_FOLDER=bin 5 | SET ENTRY_POINT=main.bat 6 | 7 | :build 8 | mkdir %BIN_FOLDER% 9 | xcopy src %BIN_FOLDER% /e/h/i/c 10 | xcopy src %BIN_FOLDER% /e/h/i/c 11 | cd %BIN_FOLDER% 12 | rename %ENTRY_POINT% %BINARY_NAME% 13 | exit /b 0 14 | 15 | ENDLOCAL 16 | -------------------------------------------------------------------------------- /github/create/repo/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "dockerImageBuilder": "cimg/base:stable-20.04", 3 | "inputs": [ 4 | { 5 | "label": "Project name: ", 6 | "name": "rit_project_name", 7 | "tutorial": "Your project name e.g.: awesome-project", 8 | "type": "text" 9 | }, 10 | { 11 | "label": "Project description: ", 12 | "name": "rit_project_description", 13 | "tutorial": "Your project description e.g.: Some awesome description", 14 | "type": "text", 15 | "default": "Project created with Ritchie CLI" 16 | }, 17 | { 18 | "default": "false", 19 | "items": [ 20 | "false", 21 | "true" 22 | ], 23 | "label": "Create a private repository?: ", 24 | "name": "rit_repo_privacy", 25 | "tutorial": "Choose one option", 26 | "type": "bool" 27 | }, 28 | { 29 | "default": " ", 30 | "label": "Workspace path: ", 31 | "name": "rit_workspace_path", 32 | "tutorial": "Your workspace path i.e., /home/user/my-project \n Note: An empty value create a GitHub repo with just a README file", 33 | "type": "text" 34 | }, 35 | { 36 | "name": "rit_github_user", 37 | "type": "CREDENTIAL_GITHUB_USERNAME" 38 | }, 39 | { 40 | "name": "rit_github_token", 41 | "type": "CREDENTIAL_GITHUB_TOKEN" 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /github/create/repo/doc/github-create-repo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GuillaumeFalourd/formulas-aws/91a6cea7fd4b6a2dd86c7bf46aaa0a35f5c9127f/github/create/repo/doc/github-create-repo.gif -------------------------------------------------------------------------------- /github/create/repo/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "Github create repo", 3 | "short": "Github create repo" 4 | } 5 | -------------------------------------------------------------------------------- /github/create/repo/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "execution": [ 3 | "local" 4 | ], 5 | "os": { 6 | "deps": [], 7 | "support": [ 8 | "mac", 9 | "linux", 10 | "windows" 11 | ] 12 | }, 13 | "tags": [ 14 | "github", 15 | "create", 16 | "repo" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /github/create/repo/set_umask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | umask 0011 3 | $1 4 | -------------------------------------------------------------------------------- /github/create/repo/src/main.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call windows\repo\repo.bat run 4 | -------------------------------------------------------------------------------- /github/create/repo/src/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # shellcheck source=/dev/null 4 | . "$(dirname "$0")"/unix/repo/repo.sh --source-only 5 | 6 | run 7 | -------------------------------------------------------------------------------- /github/create/repo/src/unix/repo/repo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | checkCommand() { 4 | if ! command -v "$1" >/dev/null; then 5 | echo "Error: $1 command required" 6 | exit 1 7 | fi 8 | } 9 | 10 | removeSpaces() { 11 | echo "${1}" | xargs | tr " " - 12 | } 13 | 14 | checkSpace() { 15 | tmp="$1" 16 | 17 | if [[ "$1" = *" "* ]]; then 18 | echo >&2 "Removing spaces from Project name..." 19 | tmp=$(removeSpaces "$1") 20 | echo >&2 "Project name without spaces: $tmp" 21 | fi 22 | 23 | echo "$tmp" 24 | } 25 | 26 | checkProjectName() { 27 | if [[ ! "$1" =~ ^[a-zA-Z0-9-]+$ ]]; then 28 | echo "Project name cannot contain special characters" 29 | exit 1 30 | fi 31 | } 32 | 33 | run() { 34 | checkCommand git 35 | 36 | RIT_PROJECT_NAME=$(checkSpace "$RIT_PROJECT_NAME") 37 | 38 | checkProjectName "$RIT_PROJECT_NAME" 39 | 40 | if [[ "$RIT_WORKSPACE_PATH" != " " ]]; then 41 | cd "$RIT_WORKSPACE_PATH" || exit 1 42 | else 43 | mkdir "$RIT_PROJECT_NAME" 44 | cd "$RIT_PROJECT_NAME" || exit 1 45 | echo "$RIT_PROJECT_DESCRIPTION" >> README.md 46 | fi 47 | 48 | git init 49 | 50 | git add . 51 | git commit -m "Initial Commit" 52 | 53 | curl -H 'Authorization: token '"$RIT_GITHUB_TOKEN" https://api.github.com/user/repos -d '{"name":"'"$RIT_PROJECT_NAME"'", "private":'"$RIT_REPO_PRIVACY"'}' && 54 | git remote add origin https://"$RIT_GITHUB_USER":"$RIT_GITHUB_TOKEN"@github.com/"$RIT_GITHUB_USER"/"$RIT_PROJECT_NAME".git && 55 | git push origin master 56 | 57 | echo "✅ Repository successfully initialized with git and added on Github!!" 58 | } 59 | -------------------------------------------------------------------------------- /github/create/repo/src/windows/repo/repo.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SETLOCAL 3 | 4 | call:%~1 5 | goto exit 6 | 7 | :run 8 | if "%RIT_WORKSPACE_PATH%" == " " ( 9 | mkdir %CURRENT_PWD%\%RIT_PROJECT_NAME% 10 | cd %CURRENT_PWD%\%RIT_PROJECT_NAME% 11 | echo %RIT_PROJECT_DESCRIPTION% >> README.md 12 | ) else ( 13 | cd %RIT_WORKSPACE_PATH% 14 | ) 15 | 16 | git init 17 | git add . 18 | git commit -m "Initial Commit" 19 | 20 | curl -H "Authorization: token %RIT_GITHUB_TOKEN%" https://api.github.com/user/repos -d "{\"name\":\"%RIT_PROJECT_NAME%\", \"private\": %PRIVATE%}" 21 | git remote add origin https://%RIT_GITHUB_USER%:%RIT_GITHUB_TOKEN%@github.com/%RIT_GITHUB_USER%/%RIT_PROJECT_NAME%.git 22 | git push origin master 23 | 24 | echo Repository successfully initialized with git and added on Github!! 25 | 26 | :exit 27 | ENDLOCAL 28 | exit /b 29 | -------------------------------------------------------------------------------- /github/help.json: -------------------------------------------------------------------------------- 1 | { 2 | "long": "GitHub commands", 3 | "short": "GitHub commands" 4 | } 5 | --------------------------------------------------------------------------------