diff --git a/.conform.yaml b/.conform.yaml new file mode 100644 index 0000000..4d85670 --- /dev/null +++ b/.conform.yaml @@ -0,0 +1,24 @@ +--- +policies: + - type: commit + spec: + header: + length: 89 + imperative: true + case: lower + invalidLastCharacters: . + body: + required: true + dco: false + gpg: true + spellcheck: + locale: GB + conventional: + types: + - chore + - docs + - feat + - refactor + - style + - fix + - test diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4aee51a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +Dockerfile* +Jenkinsfile* +**/.terraform +.git/ + +.idea/ +*.iml +.gcloudignore diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f0f6f00 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,26 @@ +root = true + +[*] +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +max_line_length = 120 +trim_trailing_whitespace = true + +[*.py] +indent_size = 4 + +[{Makefile,makefile,**.mk}] +indent_style = tab + +[*.sh] +indent_style = space +indent_size = 2 + +shell_variant = bash # like -ln=posix +binary_next_line = true # like -bn +switch_case_indent = true # like -ci +space_redirects = true # like -sr +keep_padding = false # like -kp + diff --git a/.gcloudignore b/.gcloudignore new file mode 100644 index 0000000..3f2a56c --- /dev/null +++ b/.gcloudignore @@ -0,0 +1,6 @@ +.gcloudignore +# If you would like to upload your .git directory, .gitignore file or +# files from your .gitignore file, remove the corresponding line below: +.git +.gitignore +#!include:.dockerignore diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..bf5c3a4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: bug +assignees: '' +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behaviour: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behaviour** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..ad607fc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. +For example: I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..6f1ea6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,13 @@ +--- +name: Question +about: Post a question about the project +title: '' +labels: question +assignees: '' +--- + +**Your question** +A clear and concise question. + +**Additional context** +Add any other context about your question here. diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..ccb39c7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,25 @@ +--- +name: Pull Request +about: A pull request +title: '' +labels: '' +assignees: '' +--- + +[pull_requests]: https://github.com/controlplaneio/kubesec/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc + + + +**All Submissions.** + +- [ ] Have you followed the guidelines in our [Contributing document](../../CONTRIBUTING.md)? +- [ ] Have you checked to ensure there aren't other open [Pull Requests][pull_requests] for the same update/change? + +**Code Submissions.** + +- [ ] Does your submission pass linting, tests, and security analysis? + +**Changes to Core Features.** + +- [ ] Have you added an explanation of what your changes do and why you'd like us to include them? +- [ ] Have you written new tests for your core changes, as applicable? diff --git a/.github/example_workflows/lint-bash.yaml b/.github/example_workflows/lint-bash.yaml new file mode 100644 index 0000000..ec004dd --- /dev/null +++ b/.github/example_workflows/lint-bash.yaml @@ -0,0 +1,34 @@ +--- +name: Linting - Bash/Bats +on: + push: + branches: [main] + paths: + - "**.bash" + - "**.bats" + - "**.sh" + pull_request: + branches: [main] + paths: + - "**.bash" + - "**.bats" + - "**.sh" + +jobs: + shellcheck: + name: shellcheck + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + extention: ["bash", "bats", "sh"] + steps: + - name: Checkout repository + uses: actions/checkout@v2.4.0 + + - name: Run shellcheck + uses: reviewdog/action-shellcheck@v1.12 + with: + pattern: "*.${{ matrix.extention }}" + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review diff --git a/.github/example_workflows/lint-docker.yaml b/.github/example_workflows/lint-docker.yaml new file mode 100644 index 0000000..0d69649 --- /dev/null +++ b/.github/example_workflows/lint-docker.yaml @@ -0,0 +1,27 @@ +--- +name: Linting - Dockerfile +on: + push: + branches: [main] + paths: + - "Dockerfile" + - "Dockerfile*" + pull_request: + branches: [main] + paths: + - "Dockerfile" + - "Dockerfile*" + +jobs: + hadolint: + name: hadolint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2.4.0 + + - name: Run hadolint + uses: reviewdog/action-hadolint@v1.26 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review diff --git a/.github/example_workflows/lint-misspell.yaml b/.github/example_workflows/lint-misspell.yaml new file mode 100644 index 0000000..aa0e402 --- /dev/null +++ b/.github/example_workflows/lint-misspell.yaml @@ -0,0 +1,23 @@ +--- +name: Linting - Spellcheck +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + misspell: + name: runner / misspell + runs-on: ubuntu-latest + steps: + - name: Check out code. + uses: actions/checkout@v2.4.0 + - name: misspell + uses: reviewdog/action-misspell@v1.9.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + locale: "UK" + exclude: | + "./.git*" + reporter: github-pr-review diff --git a/.github/example_workflows/lint-yaml.yaml b/.github/example_workflows/lint-yaml.yaml new file mode 100644 index 0000000..754cea2 --- /dev/null +++ b/.github/example_workflows/lint-yaml.yaml @@ -0,0 +1,26 @@ +--- +name: Linting - YAML +on: + push: + branches: [main] + paths: + - "**.yml" + - "**.yaml" + pull_request: + branches: [main] + paths: + - "**.yml" + - "**.yaml" + +jobs: + yamllint: + name: yamllint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2.4.0 + - name: Run yamllint + uses: reviewdog/action-yamllint@v1.4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + reporter: github-pr-review diff --git a/.github/example_workflows/stale.yaml b/.github/example_workflows/stale.yaml new file mode 100644 index 0000000..3576633 --- /dev/null +++ b/.github/example_workflows/stale.yaml @@ -0,0 +1,27 @@ +# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions/stale +name: Mark stale issues and pull requests + +on: + schedule: + - cron: '22 16 * * *' + +jobs: + stale: + + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'Stale issue message' + stale-pr-message: 'Stale pull request message' + stale-issue-label: 'no-issue-activity' + stale-pr-label: 'no-pr-activity' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ce8b7d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,116 @@ +# Secrets # +########### +*.pem +*.key +*_rsa + +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sqlite +pip-log.txt + +# OS generated files # +###################### +.DS_Store? +ehthumbs.db +Icon? +Thumbs.db + +# IDE generated files # +####################### +.idea/ +*.iml +atlassian-ide-plugin.xml + +# Test Files # +############## +test/log +.coverage +.tox +nosetests.xml + +# Package Managed Files # +######################### +bower_components/ +vendor/ +composer.lock +node_modules/ +.npm/ +venv/ +.venv/ +.venv2/ +.venv3/ + +# temporary files # +################### +*.*swp +nohup.out +*.tmp + +# Virtual machines # +#################### +.vagrant/ + +# Pythonics # +############# +*.py[cod] + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Complexity +output/*.html +output/*/index.html + +# Sphinx +docs/_build +.scratch.md + +conf/.config/keybase/ + +# Pipenv + +Pipfile* diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000..7e0da6e --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,4 @@ +--- +ignored: + - DL3018 # Pin versions in apk add. + - DL3022 # COPY --from alias diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..5dd5ef4 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,13 @@ +--- +extends: default + +ignore: | + test/bin/ + test/asset/ +rules: + comments: + min-spaces-from-content: 1 + line-length: + max: 120 + truthy: + check-keys: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..701bbef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +## Version (0.0.0) +### Releshed/Unreleased +### Date + +Changes: +- List of changes + +Improvements: +- List of improvements + +Bug Fixes: +- NA + +--- \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..fb1e256 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,7 @@ +# Each line is a file pattern followed by one or more owners. Being an owner +# means those groups or individuals will be added as reviewers to PRs affecting +# those areas of the code. +# +# More on CODEOWNERS files: https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners + +# /example @mSm1th diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0f54927 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,140 @@ +# Contributing to Control Plane + +:+1::tada: First off, thanks for taking the time to contribute! :tada::+1: + +Control Plane use the Apache 2.0 licence and accepts contributions via GitHub pull requests. + +The following is a set of guidelines for contributing to a Control Plane project. We generally have stricter rules as we focus on security but don't let that discourage you from creating your PR, it can be incrementally fixed to fit the rules. Also feel free to propose changes to this document in a pull request. + +## Table Of Contents + +- [Contributing to Control Plane](#contributing-to-control-plane) + - [Table Of Contents](#table-of-contents) + - [I Don't Want To Read This Whole Thing I Just Have a Question!!!](#i-dont-want-to-read-this-whole-thing-i-just-have-a-question) + - [How Can I Contribute?](#how-can-i-contribute) + - [Reporting Bugs](#reporting-bugs) + - [Before Submitting a Bug Report](#before-submitting-a-bug-report) + - [How Do I Submit a (Good) Bug Report?](#how-do-i-submit-a-good-bug-report) + - [Suggesting Enhancements](#suggesting-enhancements) + - [Before Submitting an Enhancement Suggestion](#before-submitting-an-enhancement-suggestion) + - [How Do I Submit A (Good) Enhancement Suggestion?](#how-do-i-submit-a-good-enhancement-suggestion) + - [Your First Code Contribution](#your-first-code-contribution) + - [Development](#development) + - [Pull Requests](#pull-requests) + - [Style Guides](#style-guides) + - [Git Commit Messages](#git-commit-messages) + +--- + +## I Don't Want To Read This Whole Thing I Just Have a Question!!! + +Please message the Zulip `cp-training` stream. We also have an issue template for questions. + +## How Can I Contribute? + +### Reporting Bugs + +This section guides you through submitting a bug report. Following these guidelines helps maintainers understand your report, reproduce the behaviour, and find related reports. + +Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out the issue template for bugs, the information it asks for helps us resolve issues faster. + +> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue +> and include a link to the original issue in the body of your new one. +#### Before Submitting a Bug Report + +- **Perform a cursory search** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one + +#### How Do I Submit a (Good) Bug Report? + +Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). +Create an issue on within the repository and provide the following information by filling in the issue template. + +Explain the problem and include additional details to help maintainers reproduce the problem: + +- **Use a clear and descriptive title** for the issue to identify the problem +- **Describe the exact steps which reproduce the problem** in as many details as possible. +- **Describe the behaviour you observed after following the steps** and point out what exactly is the problem with that behaviour +- **Explain which behaviour you expected to see instead and why.** + +Provide more context by answering these questions: + +- **Did the problem start happening recently** or was this always a problem? +- If the problem started happening recently, **can you reproduce the problem in an older version/release of the Training Infrastructure?** What's the most recent version in which the problem doesn't happen? +- **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens + +### Suggesting Enhancements + +This section guides you through submitting an enhancement suggestion for Training Infrastructure, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers understand your suggestion and find related suggestions. + +Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in the template feature request template, including the steps that you imagine you would take if the feature you're requesting existed. + +#### Before Submitting an Enhancement Suggestion + +- **Check if there's already a covering enhancement** +- **Perform a cursory search** to see if the enhancement has + already been suggested. If it has, add a comment to the existing issue instead of opening a new one + +#### How Do I Submit A (Good) Enhancement Suggestion? + +Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). Make sure to provide the following information: + +- **Use a clear and descriptive title** for the issue to identify the suggestion +- **Provide a step-by-step description of the suggested enhancement** in as many details as possible +- **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, + as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines) +- **Describe the current behaviour** and **explain which behaviour you expected to see instead** and why +- **Explain why this enhancement would be useful** to most Kubesec users and isn't something that can or should be implemented + as a separate community project +- **List some other tools where this enhancement exists.** +- **Specify which version of Kubesec you're using.** You can get the exact version by running `kubesec version` in your terminal +- **Specify the name and version of the OS you're using.** + +### Your First Code Contribution + +Unsure where to begin contributing to the Training infrastructure? You can start by looking through these `Good First Issue` and `Help Wanted` +issues: + +- [Good First Issue issues][good_first_issue] - issues which should only require a few lines of code, and a test or two +- [Help wanted issues][help_wanted] - issues which should be a bit more involved than `Good First Issue` issues + +Both issue lists are sorted by total number of comments. While not perfect, number of comments is a reasonable proxy for impact a given change will have. + +#### Development + +- TBC + +### Pull Requests + +The process described here has several goals: + +- Maintain training quality +- Fix problems that are important to the training team and users +- Enable a sustainable system for training maintainers to review contributions + +Please follow these steps to have your contribution considered by the maintainers: + +1. Follow all instructions in the template +2. Follow the [style guides](#style-guides) +3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) + are passing +
+ What if the status checks are failing? + If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on + the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for + you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our + status check suite. +
+ + +While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional tests, or other changes before your pull request can be ultimately accepted. + +## Style Guides + +### Git Commit Messages + +- It's strongly preferred you [GPG Verify][commit_signing] your commits if you can +- Follow [Conventional Commits](https://www.conventionalcommits.org) +- Use the present tense ("add feature" not "added feature") +- Use the imperative mood ("move cursor to..." not "moves cursor to...") +- Limit the first line to 72 characters or less +- Reference issues and pull requests liberally after the first line diff --git a/DECISIONS.md b/DECISIONS.md new file mode 100644 index 0000000..a9ecd26 --- /dev/null +++ b/DECISIONS.md @@ -0,0 +1,42 @@ +// Example taken from https://github.com/eclipse/winery/blob/master/docs/adr/0027-use-dasherization-for-filenames.md + +# Use dasherization for filenames + +## Context and Problem Statement + +Graphics files have to take a consistent file name + +## Decision Drivers + +* Easy to process by Jekyll +* No WTFs at the creators + +## Considered Options + +* [Dasherization](https://softwareengineering.stackexchange.com/a/104476/52607) (e.g., `architecture-bpmn4tosca.png`) +* Camel Case (e.g., `ArchitectureBPMN4TOSCA.png`) + +## Decision Outcome + +Chosen option: "Dasherization", because + +* clear separation of parts of the name +* consistent to other URLs (which are typically lowercase) + +## Links + +* GADR: https://github.com/adr/gadr-misc/blob/master/gadr--filename-convention.md + +## License + +Copyright (c) 2018 Contributors to the Eclipse Foundation + +See the NOTICE file(s) distributed with this work for additional +information regarding copyright ownership. + +This program and the accompanying materials are made available under the +terms of the Eclipse Public License 2.0 which is available at +http://www.eclipse.org/legal/epl-2.0, or the Apache Software License 2.0 +which is available at https://www.apache.org/licenses/LICENSE-2.0. + +SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f4da5c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM debian:buster + +RUN \ + DEBIAN_FRONTEND=noninteractive \ + apt update && apt install --assume-yes --no-install-recommends \ + bash \ + \ + && rm -rf /var/lib/apt/lists/* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ceb22e7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 control-plane.io + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e70de53 --- /dev/null +++ b/Makefile @@ -0,0 +1,89 @@ +NAME := hamlet-vase-service +GITHUB_ORG := controlplaneio +DOCKER_HUB_ORG := controlplane + +### github.com/controlplaneio/ensure-content.git makefile-header START ### +ifeq ($(NAME),) + $(error NAME required, please add "NAME := project-name" to top of Makefile) +else ifeq ($(GITHUB_ORG),) + $(error GITHUB_ORG required, please add "GITHUB_ORG := controlplaneio" to top of Makefile) +else ifeq ($(DOCKER_HUB_ORG),) + $(error DOCKER_HUB_ORG required, please add "DOCKER_HUB_ORG := controlplane" to top of Makefile) +endif + +PKG := github.com/$(GITHUB_ORG)/$(NAME) +# TODO migrate to quay.io +CONTAINER_REGISTRY_FQDN ?= docker.io +CONTAINER_REGISTRY_URL := $(CONTAINER_REGISTRY_FQDN)/$(DOCKER_HUB_ORG)/$(NAME) + +SHELL := /bin/bash +BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ) + +GIT_MESSAGE := $(shell git -c log.showSignature=false \ + log --max-count=1 --pretty=format:"%H" 2>/dev/null) +GIT_SHA := $(shell git -c log.showSignature=false rev-parse HEAD 2>/dev/null) +GIT_TAG := $(shell bash -c 'TAG=$$(git -c log.showSignature=false \ + describe --tags --exact-match --abbrev=0 $(GIT_SHA) 2>/dev/null); echo "$${TAG:-dev}"') +GIT_UNTRACKED_CHANGES := $(shell git -c log.showSignature=false \ + status --porcelain 2>/dev/null) + +ifneq ($(GIT_UNTRACKED_CHANGES),) + GIT_COMMIT := $(GIT_COMMIT)-dirty + ifneq ($(GIT_TAG),dev) + GIT_TAG := $(GIT_TAG)-dirty + endif +endif + +CONTAINER_TAG ?= $(GIT_TAG) +CONTAINER_TAG_LATEST := $(CONTAINER_TAG) +CONTAINER_NAME := $(CONTAINER_REGISTRY_URL):$(CONTAINER_TAG) + +# if no untracked changes and tag is not dev, release `latest` tag +ifeq ($(GIT_UNTRACKED_CHANGES),) + ifneq ($(GIT_TAG),dev) + CONTAINER_TAG_LATEST = latest + endif +endif + +CONTAINER_NAME_LATEST := $(CONTAINER_REGISTRY_URL):$(CONTAINER_TAG_LATEST) + +# golang buildtime, more at https://github.com/jessfraz/pepper/blob/master/Makefile +CTIMEVAR=-X $(PKG)/version.GITCOMMIT=$(GITCOMMIT) -X $(PKG)/version.VERSION=$(VERSION) +GO_LDFLAGS=-ldflags "-w $(CTIMEVAR)" +GO_LDFLAGS_STATIC=-ldflags "-w $(CTIMEVAR) -extldflags -static" + +export NAME CONTAINER_REGISTRY_URL BUILD_DATE GIT_MESSAGE GIT_SHA GIT_TAG \ + CONTAINER_TAG CONTAINER_NAME CONTAINER_NAME_LATEST CONTAINER_NAME_TESTING +### github.com/controlplaneio/ensure-content.git makefile-header END ### + +.PHONY: all +.SILENT: + +all: help + +.PHONY: build +build: ## builds a docker image + @echo "+ $@" >&2 + docker build --tag "${CONTAINER_NAME}" . + +.PHONY: run +run: ## runs the last build docker image + @echo "+ $@" >&2 + docker run -it "${CONTAINER_NAME}" + +.PHONY: test +test: ## test the application + @echo "+ $@" >&2 + if [[ "$$(bats --count test/)" -lt 1 ]]; then echo 'No tests found' >&2; exit 1; fi + bats --recursive \ + --timing \ + --jobs 10 \ + test/ + +.PHONY: help +help: ## parse jobs and descriptions from this Makefile + @grep -E '^[ a-zA-Z0-9_-]+:([^=]|$$)' $(MAKEFILE_LIST) \ + | grep -Ev '^help\b[[:space:]]*:' \ + | sort \ + | awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac21a27 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Control Plane Repo Template + +- [ROADMAP.md](ROADMAP.md) +- [CHANGELOG.md](CHANGELOG.md) +- [DECISIONS.md](DECISIONS.md) +- [CONTRIBUTING.md](CONTRIBUTING.md) +- [SECURITY.md](SECURITY.md) diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 0000000..d2d3e74 --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,7 @@ +# Roadmap + +## Upcoming Milestone Dates + +| Milestone | Release Date | +|---------------------------|--------------| +| TBC | TBC | diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..cee9a72 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +Contact: security@control-plane.io + +Encryption: https://keybase.io/sublimino/pgp_keys.asc + +Disclosure: Full diff --git a/docs/explanation/index.md b/docs/explanation/index.md new file mode 100644 index 0000000..b1303b4 --- /dev/null +++ b/docs/explanation/index.md @@ -0,0 +1 @@ +# Explanation diff --git a/docs/how-to/diagrams-as-code.md b/docs/how-to/diagrams-as-code.md new file mode 100644 index 0000000..62594a8 --- /dev/null +++ b/docs/how-to/diagrams-as-code.md @@ -0,0 +1,58 @@ +# Diagrams as Code + +## Mermaid + +```mermaid +graph TD +A[Client] --> B[Load Balancer] +B --> C[Server01] +B --> D[Server02] +``` + +## Plant UML + +```puml +@startuml +title CP Theme +'skinparam handwritten true +skinparam { + ArrowColor Black + NoteColor Black + NoteBackgroundColor White + LifeLineBorderColor Black + LifeLineColor Black + ParticipantBorderColor Black + ParticipantBackgroundColor Black + ParticipantFontColor White + defaultFontStyle Bold +} + +== 1. title == + +"Dev Machine"->Github: commit and push +Github->Jenkins: call webhook,\ntrigger build + +Jenkins->"Build Slave": automated trigger:\ncommit + +== 2a. image scan == + +Jenkins->"Build Slave": automated trigger:\nimage scan +@enduml +``` + +## C4 Container Diagram + +See [Mermaid's C4 Syntax](https://mermaid.js.org/syntax/c4c.html) and +[C4 Plant UML](https://github.com/plantuml-stdlib/C4-PlantUML/blob/master/README.md). + +```puml +@startuml C4_Elements +!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml + +Person(personAlias, "Label", "Optional Description") +Container(containerAlias, "Label", "Technology", "Optional Description") +System(systemAlias, "Label", "Optional Description") + +Rel(personAlias, containerAlias, "Label", "Optional Technology") +@enduml +``` diff --git a/docs/how-to/mkdocs.md b/docs/how-to/mkdocs.md new file mode 100644 index 0000000..528320f --- /dev/null +++ b/docs/how-to/mkdocs.md @@ -0,0 +1,23 @@ +# MkDocs + +For full documentation visit [mkdocs.org](https://www.mkdocs.org). + +## Commands + +* `mkdocs new [dir-name]` - Create a new project. +* `mkdocs serve` - Start the live-reloading docs server. +* `mkdocs build` - Build the documentation site. +* `mkdocs -h` - Print help message and exit. + +## Project layout + +See [Diataxis Framework](https://diataxis.fr/tutorials/) + + README.md # The documentation homepage. + mkdocs.yml # The configuration file. + docs/ + index.md # Includes README.md. + tutorials/ # Tutorials. + how-to/ # How to Guides + reference/ # Reference + explanation/ # Explanations diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..612c7a5 --- /dev/null +++ b/docs/index.md @@ -0,0 +1 @@ +--8<-- "README.md" diff --git a/docs/reference/index.md b/docs/reference/index.md new file mode 100644 index 0000000..cf5aa07 --- /dev/null +++ b/docs/reference/index.md @@ -0,0 +1 @@ +# Reference diff --git a/docs/tutorials/index.md b/docs/tutorials/index.md new file mode 100644 index 0000000..81c8590 --- /dev/null +++ b/docs/tutorials/index.md @@ -0,0 +1 @@ +# Tutorials diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..502bf03 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,31 @@ +site_name: CP Repo Template +theme: + name: material +plugins: + - search + - mermaid2 + - plantuml: + puml_url: https://www.plantuml.com/plantuml/ + num_workers: 8 +markdown_extensions: + - admonition + - pymdownx.details + - pymdownx.superfences: + # make exceptions to highlighting of code: + custom_fences: + - name: mermaid + class: mermaid + format: !!python/name:mermaid2.fence_mermaid + - pymdownx.snippets: + check_paths: true +nav: + - 'Home': 'index.md' + - Tutorials: + - Placeholder: tutorials/index.md + - How to Guides: + - MkDocs: how-to/mkdocs.md + - Diagrams as Code: how-to/diagrams-as-code.md + - Reference: + - Placeholder: reference/index.md + - Explanation: + - Placeholder: explanation/index.md diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8c61419 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,30 @@ +beautifulsoup4==4.11.1 +certifi==2023.7.22 +charset-normalizer==3.0.1 +click==8.1.3 +colorama==0.4.6 +EditorConfig==0.12.3 +ghp-import==2.1.0 +idna==3.4 +Jinja2==3.1.2 +jsbeautifier==1.14.7 +Markdown==3.3.7 +MarkupSafe==2.1.2 +mergedeep==1.3.4 +mkdocs==1.4.2 +mkdocs-material==9.0.7 +mkdocs-material-extensions==1.1.1 +mkdocs-mermaid2-plugin==0.6.0 +mkdocs_puml==1.1.0 +packaging==23.0 +Pygments==2.15.0 +pymdown-extensions==10.0 +python-dateutil==2.8.2 +PyYAML==6.0 +pyyaml_env_tag==0.1 +regex==2022.10.31 +requests==2.31.0 +six==1.16.0 +soupsieve==2.3.2.post1 +urllib3==1.26.18 +watchdog==2.2.1