diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..95365e3 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,2 @@ + +Read the [contributor guide](../CONTRIBUTING.md) for more details. diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..ecf69ed --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +github: [cubxxw] +liberapay: "xiongxinwei/donate" +paypal: ["paypal.me/cubxxw", paypal.me] +custom: ["https://www.paypal.me/cubxxw", nsddd.top] \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/RFC.md b/.github/ISSUE_TEMPLATE/RFC.md new file mode 100644 index 0000000..4a6b111 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/RFC.md @@ -0,0 +1,133 @@ +--- +name: RFC +about: The kubecub RFC design template, which you should use if you have a detailed and precise feature design in mind. +title: "๐Ÿ”ฎ[RFC #0000]: " +labels: "proposal,RFC,kind/feature,enhancement" + +--- + +# [RFC #0000] kubecub proposal template + +## Meta +[meta]: #meta +- Name: (fill in the feature name: My Feature) +- Start Date: (fill in today's date: YYYY-MM-DD) +- Author(s): (Github usernames) +- Status: Draft +- RFC Pull Request: (leave blank) +- kubecub Pull Request: (leave blank) +- kubecub Issue: (leave blank) +- Supersedes: (put "N/A" unless this replaces an existing RFC, then link to that RFC) + + +## ๐Ÿ“‡Topics +- [\[RFC #0000\] kubecub proposal template](#rfc-0000-kubecub-proposal-template) + - [Meta](#meta) + - [๐Ÿ“‡Topics](#topics) + - [Summary](#summary) + - [Definitions](#definitions) + - [Motivation](#motivation) + - [What it is](#what-it-is) + - [How it Works](#how-it-works) + - [Migration](#migration) + - [Drawbacks](#drawbacks) + - [Alternatives](#alternatives) + - [Prior Art](#prior-art) + - [Unresolved Questions](#unresolved-questions) + - [Spec. Changes (OPTIONAL)](#spec-changes-optional) + - [History](#history) + + +## Summary +[summary]: #summary + +One paragraph explanation of the feature. + +## Definitions +[definitions]: #definitions + +Make a list of the definitions that may be useful for those reviewing. Include phrases and words that kubecub authors or other interested parties may not be familiar with. + +## Motivation +[motivation]: #motivation + +- Why should we do this? +- What use cases does it support? +- What is the expected outcome? + +## What it is +[what-it-is]: #what-it-is + +This provides a high level overview of the feature. + +- Define any new terminology. +- Define the target persona: kubecub author, kubecub user, platform operator, platform implementor, and/or project contributor. +- Explaining the feature largely in terms of examples. +- If applicable, provide sample error messages, deprecation warnings, or migration guidance. +- If applicable, describe the differences between teaching this to existing users and new users. + +## How it Works +[how-it-works]: #how-it-works + +This is the technical portion of the RFC, where you explain the design in sufficient detail. + +The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work. + +## Migration +[migration]: #migration + +This section should document breaks to public API and breaks in compatibility due to this RFC's proposed changes. In addition, it should document the proposed steps that one would need to take to work through these changes. Care should be give to include all applicable personas, such as platform developers, kubecub developers, kubecub users and consumers of kubecub images. + +## Drawbacks +[drawbacks]: #drawbacks + +Why should we *not* do this? + +## Alternatives +[alternatives]: #alternatives + +- What other designs have been considered? +- Why is this proposal the best? +- What is the impact of not doing this? + +## Prior Art +[prior-art]: #prior-art + +Discuss prior art, both the good and bad. + +## Unresolved Questions +[unresolved-questions]: #unresolved-questions + +- What parts of the design do you expect to be resolved before this gets merged? +- What parts of the design do you expect to be resolved through implementation of the feature? +- What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC? + +## Spec. Changes (OPTIONAL) +[spec-changes]: #spec-changes +Does this RFC entail any proposed changes to the core specifications or extensions? If so, please document changes here. +Examples of a spec. change might be new lifecycle flags, new `kubecub.toml` fields, new fields in the kubecubage label, etc. +This section is not intended to be binding, but as discussion of an RFC unfolds, if spec changes are necessary, they should be documented here. + +## History +[history]: #history + + \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml new file mode 100644 index 0000000..af51c39 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -0,0 +1,81 @@ +name: Bug Report +description: Report a bug encountered while operating kubecub +title: "Bug: " +labels: ["kind/bug"] +body: + - type: textarea + id: problem + attributes: + label: What happened? + description: | + Please provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. + validations: + required: true + + - type: textarea + id: expected + attributes: + label: What did you expect to happen? + validations: + required: true + + - type: textarea + id: repro + attributes: + label: How can we reproduce it (as minimally and precisely as possible)? + validations: + required: true + + - type: textarea + id: additional + attributes: + label: Anything else we need to know? + + - type: textarea + id: Version + attributes: + label: version + value: | +
+ ```console + $ {name} version + # paste output here + ``` +
+ validations: + required: true + + - type: textarea + id: cloudProvider + attributes: + label: Cloud provider + value: | +
+
+ validations: + required: true + + - type: textarea + id: osVersion + attributes: + label: OS version + value: | +
+ ```console + # On Linux: + $ cat /etc/os-release + # paste output here + $ uname -a + # paste output here + # On Windows: + C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture + # paste output here + ``` +
+ - type: textarea + id: installer + attributes: + label: Install tools + value: | +
+
\ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..adbdccd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +contact_links: + - name: Connect on slack + url: https://join.slack.com/t/c-ub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ + about: Support kubecub-related requests or issues, get in touch with developers and help on slack + contact_links: \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/failing-test.yaml b/.github/ISSUE_TEMPLATE/failing-test.yaml new file mode 100644 index 0000000..8621098 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/failing-test.yaml @@ -0,0 +1,42 @@ +name: Failing Test +description: Report continuously failing tests or jobs in kubecub CI +title: "๐Ÿค–Failing test: " +labels: kind/failing-test +body: + - type: textarea + id: jobs + attributes: + label: Which job are failing? + placeholder: | + Please only use this template for submitting reports about continuously failing tests or jobs in kubecub CI. + validations: + required: true + + - type: textarea + id: tests + attributes: + label: Which test are failing? + validations: + required: true + + - type: textarea + id: since + attributes: + label: Since when has it been failing? + validations: + required: true + + - type: input + id: testgrid + attributes: + label: Testgrid link + + - type: textarea + id: reason + attributes: + label: Reason for failure (if possible) + + - type: textarea + id: additional + attributes: + label: Anything else we need to know? \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature-request.yaml b/.github/ISSUE_TEMPLATE/feature-request.yaml new file mode 100644 index 0000000..a66af7f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yaml @@ -0,0 +1,60 @@ +name: Feature Request +description: Suggest and idea for this project +title: "[Feature]: " +labels: ["type:feature"] +assignees: + - kubecub/maintainers +body: + - type: markdown + attributes: + value: | + Thank you for initiating this feature request !๐Ÿค— + - type: checkboxes + id: checklist + attributes: + label: Checklist + description: "Please check the following before submitting this feature request" + options: + - label: I've searched for similar issues and couldn't find anything matching + required: true + - label: I've discussed this feature request in the [kubecub Slack](https://join.slack.com/t/c-ub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ) and got positive feedback + required: true + + - type: dropdown + id: problem + attributes: + label: Is this feature request related to a problem? + options: + - "Yes" + - "No" + - type: textarea + id: problem_description + attributes: + label: Problem Description + description: If yes, please provide a clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + validations: + required: false + - type: textarea + id: solution_description + attributes: + label: Solution Description + description: A clear and concise description of what you want to happen + validations: + required: true + - type: textarea + id: benefits_description + attributes: + label: Benefits + description: Describe the benefits this feature will bring to the project and its users + validations: + required: true + - type: textarea + id: drawbacks + attributes: + label: Potential Drawbacks + description: Describe any potential drawbacks this feature might bring to the project and its users. + - type: textarea + id: additional_information + attributes: + label: Additional Information + description: Add any other context about your feature request here. If applicable, add drawings to help explain. \ No newline at end of file diff --git a/.github/OWNERS b/.github/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/.github/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..440053a --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,72 @@ +
+ + +#### ๐Ÿ” What type of PR is this? + + + +#### ๐Ÿ‘€ What this PR does / why we need it: + +- [ ] My pull request adheres to the code style of this project +- [ ] My code requires changes to the documentation +- [ ] I have updated the documentation as required +- [ ] All the tests have passed + + + + +#### ๐Ÿ…ฐ Which issue(s) this PR fixes: + + +Fixes # + + +#### ๐Ÿ“ Special notes for your reviewer: + + + + +#### ๐ŸŽฏ Describe how to verify it + + + +#### ๐Ÿ“‘ Additional documentation e.g., RFC, notion, Google docs, usage docs, etc.: + \ No newline at end of file diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..ce5eb44 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,26 @@ +command: +- any: ['cmd/**/*', 'docs/commandline/**/*'] + +area/doc: +- any: ['docs/**/*'] + +faq: +- 'FAQ.md' + +test: +- any: ['**/*_test.go'] + +e2e-test: +- any: ['test/**/*'] + +plugin: +- any: ['pkg/plugin/**/*'] + +Clusterfile: +- any: ['types/**/*'] + +Adopter-Info: +- 'Adopters.md' + +ImageBuilding: +- any: ['build/**/*'] diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..eacb157 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,27 @@ +XS: + name: size/XS + lines: 0 + color: 3CBF00 +S: + name: size/S + lines: 10 + color: 5D9801 +M: + name: size/M + lines: 30 + color: 7F7203 +L: + name: size/L + lines: 100 + color: A14C05 +XL: + name: size/XL + lines: 500 + color: C32607 +XXL: + name: size/XXL + lines: 1000 + color: E50009 + comment: | + # Whoa! Easy there, Partner!๐Ÿค– + This `PR` is too big. Please break it up into smaller `PRs`๐Ÿฅฐ. \ No newline at end of file diff --git a/.github/workflows/auto-invite.yml b/.github/workflows/auto-invite.yml new file mode 100644 index 0000000..f4a83a0 --- /dev/null +++ b/.github/workflows/auto-invite.yml @@ -0,0 +1,50 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +name: Invite users to join our group +on: + issue_comment: + types: + - created +jobs: + issue_comment: + name: Invite users to join our group + if: ${{ github.event.comment.body == '/invite' || github.event.comment.body == '/close' || github.event.comment.body == '/comment' }} + runs-on: ubuntu-latest + permissions: + issues: write + steps: + + - name: Invite user to join our group + uses: peter-evans/create-or-update-comment@v1 + with: + issue-number: ${{ github.event.issue.number }} + token: "${{ secrets.BOT_GITHUB_TOKEN }}" + body: | + We value close connections with our users, developers, and contributors here at kubecub. With a large community and maintainer team, we're always here to help and support you. Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us. + + Our most recommended way to get in touch is through [Slack](https://join.slack.com/t/c-ub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ). Even if you're in China, Slack is usually not blocked by firewalls, making it an easy way to connect with us. Our Slack community is the ideal place to discuss and share ideas and suggestions with other users and developers of kubecub. You can ask technical questions, seek help, or share your experiences with other users of kubecub. + + In addition to Slack, we also offer the following ways to get in touch: + + + We also have Slack channels for you to communicate and discuss. To join, visit https://slack.com/ and join our [๐Ÿ‘€ kubecub slack](https://join.slack.com/t/kubecub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ) team channel. + + Get in touch with us on [๐Ÿ“จGmail: 3293172751nss@gmail.com](mailto:3293172751nss@gmail.com). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email. + + Read our [๐Ÿค–kubecub](nsddd.top). Our kubecub is a great place to stay up-to-date with kubecub projects and trends. On the kubecub, we share our latest developments, tech trends, and other interesting information. + + Add [๐Ÿ•Š๏ธTwitter](https://twitter.com/xxw3293172751) . If you prefer social media, our Twitter account is a great way to stay up-to-date with kubecub project news and trends. On Twitter, we share our latest tech and trends, as well as relevant news and events. + + Add [๐Ÿ“ฒWechat](https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-smile-brightgreen?kubecubo=wechat&style=flat-square) and indicate that you are a user or developer of kubecub. We will process your request as soon as possible. + + Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us. + + - name: Close Issue + uses: peter-evans/close-issue@v3 + with: + issue-number: ${{ github.event.issue.number }} + comment: ๐Ÿค– Auto-closing issue, if you still need help please reopen the issue or ask for help in the community above + labels: | + triage/accepted + token: "${{ secrets.BOT_GITHUB_TOKEN }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..de86c18 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,76 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: "*" +# schedule: +# - cron: '23 2 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # โ„น๏ธ Command-line programs to run using the OS shell. + # ๐Ÿ“š https://git.io/JvXDl + + # โœ๏ธ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/gpt-translate.yml b/.github/workflows/gpt-translate.yml new file mode 100644 index 0000000..9e53d87 --- /dev/null +++ b/.github/workflows/gpt-translate.yml @@ -0,0 +1,27 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# .github/workflows/gpt-translate.yml +name: GPT Translate + +on: + issue_comment: + types: [ created ] + +jobs: + gpt_translate: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Run GPT Translate + if: | + contains(github.event.comment.body, '/gpt-translate') || + contains(github.event.comment.body, '/gt') + uses: 3ru/gpt-translate@v1.0 + with: + apikey: ${{ secrets.OPENAI_API_KEY }} + token: "${{ secrets.BOT_GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/issue-robot.yml b/.github/workflows/issue-robot.yml new file mode 100644 index 0000000..eadd6ef --- /dev/null +++ b/.github/workflows/issue-robot.yml @@ -0,0 +1,22 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +name: 'issue translator' +on: + issue_comment: + types: [created] + issues: + types: [opened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: usthe/issues-translate-action@v2.7 + with: + # it is not necessary to decide whether you need to modify the issue header content + IS_MODIFY_TITLE: true + BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} + # Required, input your bot github token \ No newline at end of file diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml new file mode 100644 index 0000000..0e0c219 --- /dev/null +++ b/.github/workflows/jekyll-gh-pages.yml @@ -0,0 +1,73 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# 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. +# +# +# /* +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. +# */ + +# Sample workflow for building and deploying a Jekyll site to GitHub Pages +name: Deploy Jekyll with GitHub Pages dependencies preinstalled + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Pages + uses: actions/configure-pages@v3 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./docs + token: ${{ secrets.BOT_GITHUB_TOKEN }} + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..3e50e82 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,14 @@ +name: Pull request labeler +on: +- pull_request_target + +jobs: + triage: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.BOT_GITHUB_TOKEN }}" diff --git a/.github/workflows/link-pr.yml b/.github/workflows/link-pr.yml new file mode 100644 index 0000000..ace8809 --- /dev/null +++ b/.github/workflows/link-pr.yml @@ -0,0 +1,49 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +name: Github Rebot for Link check error + +on: + pull_request: + branches: [ main ] + paths: + - '**.md' + - 'docs/**' + - '.lycheeignore' + push: + branches: [ main ] + +jobs: + linkChecker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v1.7.0 + with: + # For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters + # Actions Link address -> https://github.com/lycheeverse/lychee-action + # -E, --exclude-all-private Exclude all private IPs from checking. + # -i, --insecure Proceed for server connections considered insecure (invalid TLS) + # -n, --no-progress Do not show progress bar. + # -t, --timeout Website timeout in seconds from connect to response finished [default:20] + # --max-concurrency Maximum number of concurrent network requests [default: 128] + # -a --accept Comma-separated list of accepted status codes for valid links + # docs/.vitepress/dist the site directory to check + # ./*.md all markdown files in the root directory + args: --verbose -E -i --no-progress --exclude-path './CHANGELOG' './**/*.md' + env: + GITHUB_TOKEN: ${{secrets.GH_PAT}} + + - name: Create Issue From File + if: env.lychee_exit_code != 0 + uses: peter-evans/create-issue-from-file@v4 + with: + title: Bug reports for links in kubecub docs + content-filepath: ./lychee/out.md + labels: kind/documentation, triage/unresolved, report + token: ${{ secrets.BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bdec46c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +name: Test Makefile build + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y make + + - name: Build project + run: make build + + - name: Test build artifacts + run: | + # Add your tests here to check the build artifacts \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a66bee --- /dev/null +++ b/.gitignore @@ -0,0 +1,349 @@ +# Created by https://www.toptal.com/developers/gitignore/api/vim,jetbrains,vscode,git,go,tags,backup,test,emacs +# Edit at https://www.toptal.com/developers/gitignore?templates=vim,jetbrains,vscode,git,go,tags,backup,test,emacs + +### Backup ### +*.bak +*.gho +*.ori +*.orig +*.tmp + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### Go ### +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +### Go Patch ### +/vendor/ +/Godeps/ + +### JetBrains ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 +.idea + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Tags ### +# Ignore tags created by etags, ctags, gtags (GNU global) and cscope +TAGS +.TAGS +!TAGS/ +tags +.tags +!tags/ +gtags.files +GTAGS +GRTAGS +GPATH +GSYMS +cscope.files +cscope.out +cscope.in.out +cscope.po.out + + +### Test ### +### Ignore all files that could be used to test your code and +### you wouldn't want to push + +# Reference https://en.wikipedia.org/wiki/Metasyntactic_variable + +# Most common +*foo +*bar +*fubar +*foobar +*baz + +# Less common +*qux +*quux +*bongo +*bazola +*ztesch + +# UK, Australia +*wibble +*wobble +*wubble +*flob +*blep +*blah +*boop +*beep + +# Japanese +*hoge +*piyo +*fuga +*hogera +*hogehoge + +# Portugal, Spain +*fulano +*sicrano +*beltrano +*mengano +*perengano +*zutano + +# France, Italy, the Netherlands +*toto +*titi +*tata +*tutu +*pipppo +*pluto +*paperino +*aap +*noot +*mies + +# Other names that would make sense +*tests +*testsdir +*testsfile +*testsfiles +*testdir +*testfile +*testfiles +*testing +*testingdir +*testingfile +*testingfiles +*temp +*tempdir +*tempfile +*tempfiles +*tmp +*tmpdir +*tmpfile +*tmpfiles +*lol + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +# Persistent undo +[._]*.un~ + +### Emacs ### +# -*- mode: gitignore; -*- +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +*.elc +auto-save-list +tramp +.\#* + +# Org-mode +.org-id-locations +*_archive +ltximg/** + +# flymake-mode +*_flymake.* + +# eshell files +/eshell/history +/eshell/lastdir + +# elpa packages +/elpa/ + +# reftex files +*.rel + +# AUCTeX auto folder +/auto/ + +# cask packages +.cask/ +dist/ + +# Flycheck +flycheck_*.el + +# server auth directory +/server/ + +# projectiles files +.projectile + +# directory configuration +.dir-locals.el + +# network security +/network-security.data + +### vscode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# End of https://www.toptal.com/developers/gitignore/api/vim,jetbrains,vscode,git,go,tags,backup,test + +# Start by iam + +# log +*.log + +# Output of backend and frontend +/_output +/_debug + +# Misc +.DS_Store +*.env +.env.* +dist + +# files used by the developer +.idea.md +.todo.md +.note.md + +# config files, may contain sensitive information \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..cd8a7e0 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,931 @@ +# Copyright 2020 Lingfei Kong . All rights reserved. +# Use of this source code is governed by a MIT style +# license that can be found in the LICENSE file. + +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # default concurrency is a available CPU number + concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + # list of build tags, all linters use it. Default is empty list. + build-tags: + - mytag + + # which dirs to skip: issues from them won't be reported; + # can use regexp here: generated.*, regexp is applied on full path; + # default value is empty list, but default dirs are skipped independently + # from this option's value (see skip-dirs-use-default). + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + skip-dirs: + - util + - .*~ + - api/swagger/docs + + # default is true. Enables skipping of directories: + # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ + skip-dirs-use-default: true + + # which files to skip: they will be analyzed, but issues from them + # won't be reported. Default value is empty list, but there is + # no need to include all autogenerated files, we confidently recognize + # autogenerated files. If it's not please let us know. + # "/" will be replaced by current OS file path separator to properly work + # on Windows. + skip-files: + - ".*\\.my\\.go$" + - _test.go + + # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + #modules-download-mode: release|readonly|vendor + + # Allow multiple parallel golangci-lint instances running. + # If false (default) - golangci-lint acquires file lock on start. + allow-parallel-runners: true + + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + format: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + + # make issues output unique by line, default is true + uniq-by-line: true + + # add a prefix to the output file references; default is no prefix + path-prefix: "" + + # sorts results by: filepath, line and column + sort-results: true + +# all available settings of specific linters +linters-settings: + bidichk: + # The following configurations check for all mentioned invisible unicode + # runes. It can be omitted because all runes are enabled by default. + left-to-right-embedding: true + right-to-left-embedding: true + pop-directional-formatting: true + left-to-right-override: true + right-to-left-override: true + left-to-right-isolate: true + right-to-left-isolate: true + first-strong-isolate: true + pop-directional-isolate: true + dogsled: + # checks assignments with too many blank identifiers; default is 2 + max-blank-identifiers: 2 + dupl: + # tokens count to trigger issue, 150 by default + threshold: 100 + errcheck: + # report about not checking of errors in type assertions: `a := b.(MyStruct)`; + # default is false: such cases aren't reported by default. + check-type-assertions: false + + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; + # default is false: such cases aren't reported by default. + check-blank: false + + # [deprecated] comma-separated list of pairs of the form pkg:regex + # the regex is used to ignore names within pkg. (default "fmt:.*"). + # see https://github.com/kisielk/errcheck#the-deprecated-method for details + #ignore: GenMarkdownTree,os:.*,BindPFlags,WriteTo,Help + #ignore: (os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv + + # path to a file containing a list of functions to exclude from checking + # see https://github.com/kisielk/errcheck#excluding-functions for details + #exclude: errcheck.txt + + errorlint: + # Check whether fmt.Errorf uses the %w verb for formatting errors. See the readme for caveats + errorf: true + # Check for plain type assertions and type switches + asserts: true + # Check for plain error comparisons + comparison: true + + exhaustive: + # check switch statements in generated files also + check-generated: false + # indicates that switch statements are to be considered exhaustive if a + # 'default' case is present, even if all enum members aren't listed in the + # switch + default-signifies-exhaustive: false + # enum members matching the supplied regex do not have to be listed in + # switch statements to satisfy exhaustiveness + ignore-enum-members: "" + # consider enums only in package scopes, not in inner scopes + package-scope-only: false + exhaustivestruct: + struct-patterns: + - '*.Test' + - '*.Test2' + - '*.Embedded' + - '*.External' + + forbidigo: + # Forbid the following identifiers (identifiers are written using regexp): + forbid: + - ^print.*$ + - 'fmt\.Print.*' + - fmt.Println.* # too much log noise + - ginkgo\\.F.* # these are used just for local development + # Exclude godoc examples from forbidigo checks. Default is true. + exclude_godoc_examples: false + funlen: + lines: 150 + statements: 50 + gci: + # put imports beginning with prefix after 3rd-party packages; + # only support one prefix + # if not set, use goimports.local-prefixes + prefix: github.com/marmotedu/iam + gocognit: + # minimal code complexity to report, 30 by default (but we recommend 10-20) + min-complexity: 30 + goconst: + # minimal length of string constant, 3 by default + min-len: 3 + # minimal occurrences count to trigger, 3 by default + min-occurrences: 3 + # ignore test files, false by default + ignore-tests: false + # look for existing constants matching the values, true by default + match-constant: true + # search also for duplicated numbers, false by default + numbers: false + # minimum value, only works with goconst.numbers, 3 by default + min: 3 + # maximum value, only works with goconst.numbers, 3 by default + max: 3 + # ignore when constant is not used as function argument, true by default + ignore-calls: true + + gocritic: + # Which checks should be enabled; can't be combined with 'disabled-checks'; + # See https://go-critic.github.io/overview#checks-overview + # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run` + # By default list of stable checks is used. + enabled-checks: + #- rangeValCopy + - nestingreduce + - truncatecmp + - unnamedresult + - ruleguard + + # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty + disabled-checks: + - regexpMust + - ifElseChain + #- exitAfterDefer + + # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks. + # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags". + enabled-tags: + - performance + disabled-tags: + - experimental + + # Settings passed to gocritic. + # The settings key is the name of a supported gocritic checker. + # The list of supported checkers can be find in https://go-critic.github.io/overview. + settings: + captLocal: # must be valid enabled check name + # whether to restrict checker to params only (default true) + paramsOnly: true + elseif: + # whether to skip balanced if-else pairs (default true) + skipBalanced: true + hugeParam: + # size in bytes that makes the warning trigger (default 80) + sizeThreshold: 80 + nestingReduce: + # min number of statements inside a branch to trigger a warning (default 5) + bodyWidth: 5 + rangeExprCopy: + # size in bytes that makes the warning trigger (default 512) + sizeThreshold: 512 + # whether to check test functions (default true) + skipTestFuncs: true + rangeValCopy: + # size in bytes that makes the warning trigger (default 128) + sizeThreshold: 32 + # whether to check test functions (default true) + skipTestFuncs: true + ruleguard: + # path to a gorules file for the ruleguard checker + rules: '' + truncateCmp: + # whether to skip int/uint/uintptr types (default true) + skipArchDependent: true + underef: + # whether to skip (*x).method() calls where x is a pointer receiver (default true) + skipRecvDeref: true + unnamedResult: + # whether to check exported functions + checkExported: true + gocyclo: + # minimal code complexity to report, 30 by default (but we recommend 10-20) + min-complexity: 30 + cyclop: + # the maximal code complexity to report + max-complexity: 50 + # the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0) + package-average: 0.0 + # should ignore tests (default false) + skip-tests: false + godot: + # comments to be checked: `declarations`, `toplevel`, or `all` + scope: declarations + # list of regexps for excluding particular comment lines from check + exclude: + # example: exclude comments which contain numbers + # - '[0-9]+' + # check that each sentence starts with a capital letter + capital: false + godox: + # report any comments starting with keywords, this is useful for TODO or FIXME comments that + # might be left in the code accidentally and should be resolved before merging + keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting + #- TODO + - BUG + - FIXME + #- NOTE + - OPTIMIZE # marks code that should be optimized before merging + - HACK # marks hack-arounds that should be removed before merging + gofmt: + # simplify code: gofmt with `-s` option, true by default + simplify: true + + gofumpt: + # Select the Go version to target. The default is `1.15`. + lang-version: "1.15" + + # Choose whether or not to use the extra rules that are disabled + # by default + extra-rules: false + + goheader: + values: + const: + # define here const type values in format k:v, for example: + # COMPANY: MY COMPANY + regexp: + # define here regexp type values, for example + # AUTHOR: .*@mycompany\.com + template: # |- + # put here copyright header template for source code files, for example: + # Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time. + # + # {{ AUTHOR }} {{ COMPANY }} {{ YEAR }} + # SPDX-License-Identifier: Apache-2.0 + + # 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. + template-path: + # also as alternative of directive 'template' you may put the path to file with the template source + goimports: + # put imports beginning with prefix after 3rd-party packages; + # it's a comma-separated list of prefixes + local-prefixes: github.com/marmotedu/iam + golint: + # minimal confidence for issues, default is 0.8 + min-confidence: 0.9 + gomnd: + settings: + mnd: + # the list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description. + checks: argument,case,condition,operation,return,assign + # ignored-numbers: 1000 + # ignored-files: magic_.*.go + # ignored-functions: math.* + gomoddirectives: + # Allow local `replace` directives. Default is false. + replace-local: true + # List of allowed `replace` directives. Default is empty. + replace-allow-list: + - google.golang.org/grpc + - github.com/marmotedu/api + - github.com/marmotedu/component-base + - github.com/marmotedu/marmotedu-sdk-go + + # Allow to not explain why the version has been retracted in the `retract` directives. Default is false. + retract-allow-no-explanation: false + # Forbid the use of the `exclude` directives. Default is false. + exclude-forbidden: false + gomodguard: + allowed: + modules: # List of allowed modules + - gorm.io/gorm + - gorm.io/driver/mysql + - k8s.io/klog + # - gopkg.in/yaml.v2 + domains: # List of allowed module domains + - google.golang.org + - gopkg.in + - golang.org + - github.com + - go.uber.org + - go.etcd.io + blocked: + modules: + - github.com/pkg/errors: + recommendations: + - github.com/marmotedu/errors + reason: "`github.com/marmotedu/errors` is the log package used by marmotedu projects." + versions: + - github.com/MakeNowJust/heredoc: + version: "> 2.0.9" + reason: "use the latest version" + local_replace_directives: false # Set to true to raise lint issues for packages that are loaded from a local path via replace directive + + gosec: + # To select a subset of rules to run. + # Available rules: https://github.com/securego/gosec#available-rules + includes: + - G401 + - G306 + - G101 + # To specify a set of rules to explicitly exclude. + # Available rules: https://github.com/securego/gosec#available-rules + excludes: + - G204 + # Exclude generated files + exclude-generated: true + # Filter out the issues with a lower severity than the given value. Valid options are: low, medium, high. + severity: "low" + # Filter out the issues with a lower confidence than the given value. Valid options are: low, medium, high. + confidence: "low" + # To specify the configuration of rules. + # The configuration of rules is not fully documented by gosec: + # https://github.com/securego/gosec#configuration + # https://github.com/securego/gosec/blob/569328eade2ccbad4ce2d0f21ee158ab5356a5cf/rules/rulelist.go#L60-L102 + config: + G306: "0600" + G101: + pattern: "(?i)example" + ignore_entropy: false + entropy_threshold: "80.0" + per_char_threshold: "3.0" + truncate: "32" + + gosimple: + # Select the Go version to target. The default is '1.13'. + go: "1.15" + # https://staticcheck.io/docs/options#checks + checks: [ "all" ] + + govet: + # report about shadowed variables + check-shadowing: true + + # settings per analyzer + settings: + printf: # analyzer name, run `go tool vet help` to see all analyzers + funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf + - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf + + # enable or disable analyzers by name + enable: + - atomicalign + enable-all: false + disable: + - shadow + disable-all: false + depguard: + list-type: blacklist + include-go-root: false + packages: + - github.com/Sirupsen/logrus + packages-with-error-message: + # specify an error message to output when a blacklisted package is used + - github.com/Sirupsen/logrus: "logging is allowed only by logutils.Log" + ifshort: + # Maximum length of variable declaration measured in number of lines, after which linter won't suggest using short syntax. + # Has higher priority than max-decl-chars. + max-decl-lines: 1 + # Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax. + max-decl-chars: 30 + + importas: + # if set to `true`, force to use alias. + no-unaliased: true + # List of aliases + alias: + # using `servingv1` alias for `knative.dev/serving/pkg/apis/serving/v1` package + - pkg: knative.dev/serving/pkg/apis/serving/v1 + alias: servingv1 + # using `autoscalingv1alpha1` alias for `knative.dev/serving/pkg/apis/autoscaling/v1alpha1` package + - pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1 + alias: autoscalingv1alpha1 + # You can specify the package path by regular expression, + # and alias by regular expression expansion syntax like below. + # see https://github.com/julz/importas#use-regular-expression for details + - pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+) + alias: $1$2 + # using `jwt` alias for `github.com/appleboy/gin-jwt/v2` package + jwt: github.com/appleboy/gin-jwt/v2 + # using `metav1` alias for `github.com/marmotedu/component-base/pkg/meta/v1` package + metav1: github.com/marmotedu/component-base/pkg/meta/v1 + + ireturn: + # ireturn allows using `allow` and `reject` settings at the same time. + # Both settings are lists of the keywords and regular expressions matched to interface or package names. + # keywords: + # - `empty` for `interface{}` + # - `error` for errors + # - `stdlib` for standard library + # - `anon` for anonymous interfaces + + # By default, it allows using errors, empty interfaces, anonymous interfaces, + # and interfaces provided by the standard library. + allow: + - anon + - error + - empty + - stdlib + # You can specify idiomatic endings for interface + - (or|er)$ + + # Reject patterns + reject: + - github.com\/user\/package\/v4\.Type + + lll: + # max line length, lines longer will be reported. Default is 120. + # '\t' is counted as 1 character by default, and can be changed with the tab-width option + line-length: 240 + # tab width in spaces. Default to 1. + tab-width: 4 + maligned: + # print struct with more effective memory layout or not, false by default + suggest-new: true + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + ignore-words: + - someword + nakedret: + # make an issue if func has more lines of code than this setting and it has naked returns; default is 30 + max-func-lines: 30 + + nestif: + # minimal complexity of if statements to report, 5 by default + min-complexity: 4 + + nilnil: + # By default, nilnil checks all returned types below. + checked-types: + - ptr + - func + - iface + - map + - chan + + nlreturn: + # size of the block (including return statement that is still "OK") + # so no return split required. + block-size: 1 + + nolintlint: + # Disable to ensure that all nolint directives actually have an effect. Default is true. + allow-unused: false + # Disable to ensure that nolint directives don't have a leading space. Default is true. + allow-leading-space: true + # Exclude following linters from requiring an explanation. Default is []. + allow-no-explanation: [ ] + # Enable to require an explanation of nonzero length after each nolint directive. Default is false. + require-explanation: false + # Enable to require nolint directives to mention the specific linter being suppressed. Default is false. + require-specific: true + + prealloc: + # XXX: we don't recommend using this linter before doing performance profiling. + # For most programs usage of prealloc will be a premature optimization. + + # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. + # True by default. + simple: true + range-loops: true # Report preallocation suggestions on range loops, true by default + for-loops: false # Report preallocation suggestions on for loops, false by default + + promlinter: + # Promlinter cannot infer all metrics name in static analysis. + # Enable strict mode will also include the errors caused by failing to parse the args. + strict: false + # Please refer to https://github.com/yeya24/promlinter#usage for detailed usage. + disabled-linters: + # - "Help" + # - "MetricUnits" + # - "Counter" + # - "HistogramSummaryReserved" + # - "MetricTypeInName" + # - "ReservedChars" + # - "CamelCase" + # - "lintUnitAbbreviations" + + predeclared: + # comma-separated list of predeclared identifiers to not report on + ignore: "" + # include method names and field names (i.e., qualified names) in checks + q: false + rowserrcheck: + packages: + - github.com/jmoiron/sqlx + revive: + # see https://github.com/mgechev/revive#available-rules for details. + ignore-generated-header: true + severity: warning + rules: + - name: indent-error-flow + severity: warning + staticcheck: + # Select the Go version to target. The default is '1.13'. + go: "1.16" + # https://staticcheck.io/docs/options#checks + checks: [ "all" ] + + stylecheck: + # Select the Go version to target. The default is '1.13'. + go: "1.16" + + # https://staticcheck.io/docs/options#checks + checks: [ "all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022" ] + # https://staticcheck.io/docs/options#dot_import_whitelist + dot-import-whitelist: + - fmt + # https://staticcheck.io/docs/options#initialisms + initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS" ] + # https://staticcheck.io/docs/options#http_status_code_whitelist + http-status-code-whitelist: [ "200", "400", "404", "500" ] + + + tagliatelle: + # check the struck tag name case + case: + # use the struct field name to check the name of the struct tag + use-field-name: true + rules: + # any struct tag type can be used. + # support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower` + json: camel + yaml: camel + xml: camel + bson: camel + avro: snake + mapstructure: kebab + + testpackage: + # regexp pattern to skip files + skip-regexp: (id|export|internal)_test\.go + thelper: + # The following configurations enable all checks. It can be omitted because all checks are enabled by default. + # You can enable only required checks deleting unnecessary checks. + test: + first: true + name: true + begin: true + benchmark: + first: true + name: true + begin: true + tb: + first: true + name: true + begin: true + + tenv: + # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. + # By default, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. + all: false + + unparam: + # Inspect exported functions, default is false. Set to true if no external program/library imports your code. + # XXX: if you enable this setting, unparam will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find external interfaces. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + check-exported: false + unused: + # treat code as a program (not a library) and report unused exported identifiers; default is false. + # XXX: if you enable this setting, unused will report a lot of false-positives in text editors: + # if it's called for subdir of a project it can't find funcs usages. All text editor integrations + # with golangci-lint call it on a directory with the changed file. + check-exported: false + whitespace: + multi-if: false # Enforces newlines (or comments) after every multi-line if statement + multi-func: false # Enforces newlines (or comments) after every multi-line function signature + + wrapcheck: + # An array of strings that specify substrings of signatures to ignore. + # If this set, it will override the default set of ignored signatures. + # See https://github.com/tomarrell/wrapcheck#configuration for more information. + ignoreSigs: + - .Errorf( + - errors.New( + - errors.Unwrap( + - .Wrap( + - .Wrapf( + - .WithMessage( + - .WithMessagef( + - .WithStack( + ignorePackageGlobs: + - encoding/* + - github.com/pkg/* + + wsl: + # If true append is only allowed to be cuddled if appending value is + # matching variables, fields or types on line above. Default is true. + strict-append: true + # Allow calls and assignments to be cuddled as long as the lines have any + # matching variables, fields or types. Default is true. + allow-assign-and-call: true + # Allow assignments to be cuddled with anything. Default is false. + allow-assign-and-anything: false + # Allow multiline assignments to be cuddled. Default is true. + allow-multiline-assign: true + # Allow declarations (var) to be cuddled. + allow-cuddle-declarations: false + # Allow trailing comments in ending of blocks + allow-trailing-comment: false + # Force newlines in end of case at this limit (0 = never). + force-case-trailing-whitespace: 0 + # Force cuddling of err checks with err var assignment + force-err-cuddling: false + # Allow leading comments to be separated with empty liens + allow-separated-leading-comment: false + makezero: + # Allow only slices initialized with a length of zero. Default is false. + always: false + + + # The custom section can be used to define linter plugins to be loaded at runtime. See README doc + # for more info. + #custom: + # Each custom linter should have a unique name. + #example: + # The path to the plugin *.so. Can be absolute or local. Required for each custom linter + #path: /path/to/example.so + # The description of the linter. Optional, just for documentation purposes. + #description: This is an example usage of a plugin linter. + # Intended to point to the repo location of the linter. Optional, just for documentation purposes. + #original-url: github.com/golangci/example-linter + +linters: + # please, do not use `enable-all`: it's deprecated and will be removed soon. + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint + # enable-all: true + disable-all: true + enable: + - typecheck + - asciicheck + - bodyclose + - cyclop + - deadcode + - depguard + - dogsled + - dupl + - durationcheck + - errcheck + - errorlint + - exhaustive + - exportloopref + - forbidigo + - funlen + #- gci + - gochecknoinits + - gocognit + - goconst + - gocyclo + - godot + - godox + - gofmt + - gofumpt + - goheader + - goimports + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - gosimple + - govet + - ifshort + - importas + - ineffassign + - lll + - makezero + - misspell + - nakedret + - nestif + - nilerr + - nlreturn + - noctx + - nolintlint + - paralleltest + - prealloc + - predeclared + - promlinter + - revive + - rowserrcheck + - sqlclosecheck + - staticcheck + - structcheck + - stylecheck + - thelper + - tparallel + - unconvert + - unparam + - unused + - varcheck + - wastedassign + - whitespace + - bidichk + - wastedassign + - golint + - execinquery + - nosprintfhostport + - grouper + - decorder + - errchkjson + - maintidx + #- containedctx + #- tagliatelle + #- nonamedreturns + #- nilnil + #- tenv + #- varnamelen + #- contextcheck + #- errname + #- ForceTypeAssert + #- nilassign + fast: false + +issues: + # List of regexps of issue texts to exclude, empty list by default. + # But independently from this option we use default exclude patterns, + # it can be disabled by `exclude-use-default: false`. To list all + # excluded by default patterns execute `golangci-lint run --help` + exclude: + - tools/.* + - test/.* + - third_party/.* + + # Excluding configuration per-path, per-linter, per-text and per-source + exclude-rules: + - linters: + - errorlint + path: (pkg/validator/.*)\.go + - linters: + - revive + path: (log/.*)\.go + + - linters: + - wrapcheck + path: (cmd/.*|pkg/.*)\.go + + - linters: + - typecheck + #path: (pkg/storage/.*)\.go + path: (internal/.*|pkg/.*)\.go + + - path: (cmd/.*|test/.*|tools/.*|internal/pump/pumps/.*)\.go + linters: + - forbidigo + + - path: (cmd/[a-z]*/.*|store/.*)\.go + linters: + - dupl + + - linters: + - gocritic + text: (hugeParam:|rangeValCopy:) + + - path: (cmd/[a-z]*/.*)\.go + linters: + - lll + + - path: (validator/.*|code/.*|validator/.*|watcher/watcher/.*) + linters: + - gochecknoinits + + - path: (internal/.*/options|internal/pump|pkg/log/options.go|internal/authzserver|tools/) + linters: + - tagliatelle + + - path: (pkg/app/.*)\.go + linters: + - deadcode + - unused + - varcheck + - forbidigo + + # Exclude some staticcheck messages + - linters: + - staticcheck + text: "SA9003:" + + # Exclude lll issues for long lines with go:generate + - linters: + - lll + source: "^//go:generate " + + # Independently from option `exclude` we use default exclude patterns, + # it can be disabled by this option. To list all + # excluded by default patterns execute `golangci-lint run --help`. + # Default value for this option is true. + exclude-use-default: true + + # The default value is false. If set to true exclude and exclude-rules + # regular expressions become case sensitive. + exclude-case-sensitive: false + + # The list of ids of default excludes to include or disable. By default it's empty. + include: + - EXC0002 # disable excluding of issues about comments from golint + + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 + + # Show only new issues: if there are unstaged changes or untracked files, + # only those changes are analyzed, else only changes in HEAD~ are analyzed. + # It's a super-useful option for integration of golangci-lint into existing + # large codebase. It's not practical to fix all existing issues at the moment + # of integration: much better don't allow issues in new code. + # Default is false. + new: false + + # Show only new issues created after git revision `REV` + # new-from-rev: REV + + # Show only new issues created in git patch with set file path. + #new-from-patch: path/to/patch/file + + # Fix found issues (if it's supported by the linter) + fix: true + +severity: + # Default value is empty string. + # Set the default severity for issues. If severity rules are defined and the issues + # do not match or no severity is provided to the rule this will be the default + # severity applied. Severities should match the supported severity names of the + # selected out format. + # - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity + # - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity + # - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message + default-severity: error + + # The default value is false. + # If set to true severity-rules regular expressions become case sensitive. + case-sensitive: false + + # Default value is empty list. + # When a list of severity rules are provided, severity information will be added to lint + # issues. Severity rules have the same filtering capability as exclude rules except you + # are allowed to specify one matcher per severity rule. + # Only affects out formats that support setting severity information. + rules: + - linters: + - dupl + severity: info \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e69de29 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..510bb56 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,359 @@ +# Contributing to github-label-syncer + +So, you want to hack on github-label-syncer? Yay! + +First of all, thank you for considering contributing to our project! We appreciate your time and effort, and we value any contribution, whether it's reporting a bug, suggesting a new feature, or submitting a pull request. + +This document provides guidelines and best practices to help you contribute effectively. + +## ๐Ÿ“‡Topics + +- [What we expect of you](#What-we-expect-of-you) +- [Code of Conduct](#Code-of-Conduct) +- [Getting Started](#Getting-Started) +- [Style and Specification](#Style-and-Specification) +- [Engage to help anything](#Engage-to-help-anything) +- [Release version](#Release-version) +- [Contact Us](#Contact-Us) + +## What we expect of you + +We hope that anyone can join github-label-syncer , even if you are a student, writer, translator + +Please meet the minimum version of the Go language published in [go.mod](https://github.com/kubecub/github-label-syncer/tree/main/go.mod). If you want to manage the Go language version, we provide tools to install [gvm](https://github.com/moovweb/gvm) in our [Makefile](./Makefile) + +You'd better use Linux OR WSL as the development environment, Linux with [Makefile](./Makefile) can help you quickly build and test github-label-syncer project. + +If you are familiar with [Makefile](./Makefile) , you can easily see the clever design of the github-label-syncer Makefile. Storing the necessary tools such as golangci in the `/tools` directory can avoid some tool version issues. + +The [Makefile](./Makefile) is for every developer, even if you don't know how to use the Makefile tool, don't worry, we provide two great commands to get you up to speed with the Makefile architecture, `make help` and `make help-all`, it can reduce problems of the developing environment. + +## Code of ConductCode of Conduct + +#### Code and doc contribution + +Every action to make project github-label-syncer better is encouraged. On GitHub, every improvement for github-label-syncer could be via a [PR](https://github.com/kubecub/github-label-syncer/pulls) (short for pull request). + ++ If you find a typo, try to fix it! ++ If you find a bug, try to fix it! ++ If you find some redundant codes, try to remove them! ++ If you find some test cases missing, try to add them! ++ If you could enhance a feature, please **DO NOT** hesitate! ++ If you find code implicit, try to add comments to make it clear! ++ If you find code ugly, try to refactor that! ++ If you can help to improve documents, it could not be better! ++ If you find document incorrect, just do it and fix that! ++ ... + +#### Where should I start? + ++ If you are new to the project, don't know how to contribute github-label-syncer, please check out the [good first issue](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aopen+label%3A"good+first+issue"+sort%3Aupdated-desc) label. ++ You should be good at filtering the github-label-syncer issue tags and finding the ones you like, such as [RFC](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) for big initiatives, features for [feature](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+label%3Afeature) proposals, and [bug](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+label%3Abug+) fixes. ++ If you are looking for something to work on, check out our [open issues](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc). ++ If you have an idea for a new feature, please [open an issue](https://github.com/kubecub/github-label-syncer/issues/new/choose), and we can discuss it. + +#### Design documents + +For any substantial design, there should be a well-crafted design document. This document is not just a simple record, but also a detailed description and manifestation, which can help team members better understand the design thinking and grasp the design direction. In the process of writing the design document, we can choose to use tools such as `Google Docs` or `Notion`, and even mark RFC in [issues](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) or [discussions](https://github.com/kubecub/github-label-syncer/discussions) for better collaboration. Of course, after completing the design document, we should also add it to our [Shared Drive](https://drive.google.com/drive/) and notify the appropriate working group to let everyone know of its existence. Only by doing so can we maximize the effectiveness of the design document and provide strong support for the smooth progress of the project. + +Anybody can access the shared Drive for reading. To get access to comment. Once you've done that, head to the [shared Drive](https://drive.google.com/) and behold all the docs. + +In addition to that, we'd love to invite you to [join our Slack](https://join.slack.com/t/c-ub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ) where you can play with your imagination, tell us what you're working on, and get a quick response. + +When documenting a new design, we recommend a 2-step approach: + +1. Use the short-form RFC template to outline your ideas and get early feedback. +2. Once you have received sufficient feedback and consensus, you may use the longer-form design doc template to specify and discuss your design in more details. + +In order to contribute a feature to github-label-syncer you'll need to go through the following steps: + ++ Discuss your idea with the appropriate [working groups](https://join.slack.com/t/c-ub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ) on the working group's Slack channel. ++ Once there is general agreement that the feature is useful, create a GitHub issue to track the discussion. The issue should include information about the requirements and use cases that it is trying to address. ++ Include a discussion of the proposed design and technical details of the implementation in the issue. + +But keep in mind that there is no guarantee of it being accepted and so it is usually best to get agreement on the idea/design before time is spent coding it. However, sometimes seeing the exact code change can help focus discussions, so the choice is up to you. + +## Getting Started + +To propose PR for the github-label-syncer item, we assume you have registered a GitHub ID. Then you could finish the preparation in the following steps: + +1. Fork the repository(github-label-syncer) + +2. **CLONE** your own repository to master locally. Use `git clone https://github.com//github-label-syncer.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make. + +3. **Set Remote** upstream to be `https://github.com/kubecub/github-label-syncer.git` using the following two commands: + + ```bash + โฏ git remote add upstream https://github.com/kubecub/github-label-syncer.git + โฏ git remote set-url --push upstream no-pushing + ``` + + With this remote setting, you can check your git remote configuration like this: + + ```bash + โฏ git remote -v + origin https://github.com//github-label-syncer.git (fetch) + origin https://github.com//github-label-syncer.git (push) + upstream https://github.com/kubecub/github-label-syncer.git (fetch) + upstream no-pushing (push) + ``` + + Adding this, we can easily synchronize local branches with upstream branches. + +4. Create a new branch for your changes (use a descriptive name, such as `fix-bug-123` or `add-new-feature`). + + ```bash + โฏ cd github-label-syncer + โฏ git fetch upstream + โฏ git checkout upstream/main + ``` + + Create a new branch: + + ```bash + โฏ git checkout -b + ``` + + Make any change on the `new-branch` then use [Makefile](./Makefile) build and test your codes. + +5. **Commit your changes** to your local branch, lint before committing and commit with sign-off + + ```bash + โฏ git rebase upstream/main + โฏ make link # golangci-lint run -c .golangci.yml + โฏ git add -A # add changes to staging + โฏ git commit -a -s -m "message for your changes" # -s adds a Signed-off-by trailer + ``` + +6. **Push your branch** to your forked repository, it is recommended to have only one commit for a PR. + + ```bash + # sync up with upstream + โฏ git fetch upstream main + โฏ git rebase upstream/main + โฏ + โฏ git rebase -i # rebase with interactive mode to squash your commits into a single one + โฏ git push # push to the remote repository, if it's a first time push, run git push --set-upstream origin + ``` + + You can also use `git commit -s --amend && git push -f` to update modifications on the previous commit. + + If you have developed multiple features in the same branch, you should create PR separately by rebasing to the main branch between each push: + + ```bash + # create new branch, for example git checkout -b feature/infra + โฏ git checkout -b + # update some code, feature1 + โฏ git add -A + โฏ git commit -m -s "feat: feature one" + โฏ git push # if it's first time push, run git push --set-upstream origin + # then create pull request, and merge + # update some new feature, feature2, rebase main branch first. + โฏ git rebase upstream/main # rebase the current branch to upstream/main branch + โฏ git add -A + โฏ git commit -m -s "feat: feature two" + # then create pull request, and merge + ``` + +7. **Open a pull request** to `kubecub/github-label-syncer:main` + + It is recommended to review your changes before filing a pull request. Check if your code doesn't conflict with the main branch and no redundant code is included. + +## Style and Specification + +We divide the problem into security and general problems: + +#### Reporting security issues + +Security issues are always treated seriously. As our usual principle, we discourage anyone to spread security issues. If you find a security issue of github-label-syncer, please do not discuss it in public and even do not open a public issue. + +Instead we encourage you to send us a private email to [3293172751nss@gmail.com](mailto:3293172751nss@gmail.com) to report this. + +#### Reporting general issues + +To be honest, we regard every user of github-label-synceras a very kind contributor. After experiencing github-label-syncer, you may have some feedback for the project. Then feel free to open an issue via [NEW ISSUE](https://github.com/kubecub/github-label-syncer/issues/new/choose). + +Since we collaborate project github-label-syncer in a distributed way, we appreciate **WELL-WRITTEN**, **DETAILED**, **EXPLICIT** issue reports. To make the communication more efficient, we wish everyone could search if your issue is an existing one in the searching list. If you find it existing, please add your details in comments under the existing issue instead of opening a brand new one. + +To make the issue details as standard as possible, we setup an [ISSUE TEMPLATE](https://github.com/kubecub/github-label-syncer/tree/main/.github/ISSUE_TEMPLATE) for issue reporters. You can find three kinds of issue templates there: question, bug report and feature request. Please **BE SURE** to follow the instructions to fill fields in template. + +**There are a lot of cases when you could open an issue:** + ++ bug report ++ feature request ++ github-label-syncer performance issues ++ feature proposal ++ feature design ++ help wanted ++ doc incomplete ++ test improvement ++ any questions on github-label-syncer project ++ and so on + +Also, we must be reminded when submitting a new question about github-label-syncer, please remember to remove the sensitive data from your post. Sensitive data could be password, secret key, network locations, private business data and so on. + +#### Commit Rules + +Actually in github-label-syncer, we take two rules serious when committing: + +**๐Ÿฅ‡ Commit Message:** + +Commit message could help reviewers better understand what the purpose of submitted PR is. It could help accelerate the code review procedure as well. We encourage contributors to use **EXPLICIT** commit message rather than ambiguous message. In general, we advocate the following commit message type: + +We use [Semantic Commits](https://www.conventionalcommits.org/en/v1.0.0/) to make it easier to understand what a commit does and to build pretty changegithub-label-syncers. Please use the following prefixes for your commits: + ++ `docs: xxxx`. For example, "docs: add docs about storage installation". ++ `feature: xxxx`.For example, "feature: make result show in sorted order". ++ `bugfix: xxxx`. For example, "bugfix: fix panic when input nil parameter". ++ `style: xxxx`. For example, "style: format the code style of Constants.java". ++ `refactor: xxxx.` For example, "refactor: simplify to make codes more readable". ++ `test: xxx`. For example, "test: add unit test case for func InsertIntoArray". ++ `chore: xxx.` For example, "chore: integrate travis-ci". It's the type of mantainance change. ++ other readable and explicit expression ways. + +On the other side, we discourage contributors from committing message like the following ways: + ++ ~~fix bug~~ ++ ~~update~~ ++ ~~add doc~~ + +**๐Ÿฅˆ Commit Content:** + +Commit content represents all content changes included in one commit. We had better include things in one single commit which could support reviewer's complete review without any other commits' help. + +In another word, contents in one single commit can pass the CI to avoid code mess. In brief, there are two minor rules for us to keep in mind: + +1. avoid very large change in a commit. +2. complete and reviewable for each commit. +3. words are written in lowercase English, not uppercase English or other languages such as Chinese. + +No matter what the commit message, or commit content is, we do take more emphasis on code review. + +An example for this could be: + +```bash +โฏ git commit -a -s -m "docs: add a new section to the README" +``` + +#### PR Description + +PR is the only way to make change to github-label-syncer project files. To help reviewers better get your purpose, PR description could not be too detailed. We encourage contributors to follow the [PR template](https://github.com/kubecub/github-label-syncer/tree/main/.github/PULL_REQUEST_TEMPLATE.md) to finish the pull request. + +You can find some very formal PR in [RFC](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+is%3Aopen+RFC+label%3ARFC) issues and learn about them. + +**๐Ÿ“– Opening PRs:** + ++ As long as you are working on your PR, please mark it as a draft ++ Please make sure that your PR is up-to-date with the latest changes in `main` ++ Mention the issue that your PR is addressing (Fix: #{ID_1}, #{ID_2}) ++ Make sure that your PR passes all checks + +**๐Ÿˆด Reviewing PRs:** + ++ Be respectful and constructive ++ Assign yourself to the PR ++ Check if all checks are passing ++ Suggest changes instead of simply commenting on found issues ++ If you are unsure about something, ask the author ++ If you are not sure if the changes work, try them out ++ Reach out to other reviewers if you are unsure about something ++ If you are happy with the changes, approve the PR ++ Merge the PR once it has all approvals and the checks are passing + +**โš ๏ธ DCO check:** + +We have a DCO check that runs on every pull request to ensure code quality and maintainability. This check verifies that the commit has been signed off, indicating that you have read and agreed to the provisions of the Developer Certificate of Origin. If you have not yet signed off on the commit, you can use the following command to sign off on the last commit you made: + +```bash +โฏ git commit --amend --signoff +``` + +Please note that signing off on a commit is a commitment that you have read and agreed to the provisions of the Developer Certificate of Origin. If you have not yet read this document, we strongly recommend that you take some time to read it carefully. If you have any questions about the content of this document, or if you need further assistance, please contact an administrator or relevant personnel. + +You can also automate signing off your commits by adding the following to your `.zshrc` or `.bashrc`: + +```go +git() { + if [ $# -gt 0 ] && [[ "$1" == "commit" ]] ; then + shift + command git commit --signoff "$@" + else + command git "$@" + fi +} +``` + + +#### Docs Contribution + +The documentation for github-label-syncer includes: + ++ [README.md](https://github.com/kubecub/github-label-syncer/blob/main/README.md): This file includes the basic information and instructions for getting started with github-label-syncer. ++ [README_zh-CN.md](https://github.com/kubecub/github-label-syncer/blob/main/README_zh-CN.md): This file includes the basic information and instructions for getting started with OpenIM in Chinese. ++ [CONTRIBUTING.md](https://github.com/kubecub/github-label-syncer/blob/main/CONTRIBUTING.md): This file contains guidelines for contributing to github-label-syncer's codebase, such as how to submit issues, pull requests, and code reviews. ++ [Official Documentation](https://nsddd.top): This is the official documentation for github-label-syncer, which includes comprehensive information on all of its features, configuration options, and troubleshooting tips. + +Please obey the following rules to better format the docs, which would greatly improve the reading experience. + +1. Please do not use Chinese punctuations in English docs, and vice versa. +2. Please use upper case letters where applicable, like the first letter of sentences / headings, etc. +3. Please specify a language for each Markdown code blocks, unless there's no associated languages. +4. Please insert a whitespace between Chinese and English words. +5. Please use the correct case for technical terms, such as using `HTTP` instead of http, `MySQL` rather than mysql, `Kubernetes` instead of kubernetes, etc. +6. Please check if there's any typos in the docs before submitting PRs. + +## Engage to help anything + +We choose GitHub as the primary place for github-label-syncer to collaborate. So the latest updates of github-label-syncer are always here. Although contributions via PR is an explicit way to help, we still call for any other ways. + ++ reply to other's [issues](https://github.com/kubecub/github-label-syncer/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) if you could; ++ help solve other user's problems; ++ help review other's [PR](https://github.com/kubecub/github-label-syncer/pulls) design; ++ discuss about github-label-syncer to make things clearer; ++ advocate [github-label-syncer](https://google.com/search?q=github-label-syncer) technogithub-label-syncery beyond GitHub; ++ write bgithub-label-syncers on github-label-syncer and so on. + +In a word, **ANY HELP IS CONTRIBUTION.** + +## Release version + +Releases of github-label-syncer are done using [Release Please](https://github.com/googleapis/release-please) and [GoReleaser](https://goreleaser.com/). The workflow looks like this: + +๐ŸŽฏ A PR is merged to the `main` branch: + ++ Release please is triggered, creates or updates a new release PR ++ This is done with every merge to main, the current release PR is updated every time + +๐ŸŽฏ Merging the 'release please' PR to `main`: + ++ Release please is triggered, creates a new release and updates the changegithub-label-syncer based on the commit messages ++ GoReleaser is triggered, builds the binaries and attaches them to the release ++ Containers are created and pushed to the container registry + +With the next relevant merge, a new release PR will be created and the process starts again + +**๐Ÿ‘€ Manually setting the version:** + +If you want to manually set the version, you can create a PR with an empty commit message that contains the version number in the commit message. For example: + +Such a commit can get produced as follows: + +````bash +โฏ git commit --allow-empty -m "chore: release 0.0.3" -m "Release-As: 0.0.3 +```` + +## Contact Us + +We value close connections with our users, developers, and contributors here at kubecub. With a large community and maintainer team, we're always here to help and support you. Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us. + +Our most recommended way to get in touch is through [Slack](https://join.slack.com/t/c-ub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ). Even if you're in China, Slack is usually not blocked by firewalls, making it an easy way to connect with us. Our Slack community is the ideal place to discuss and share ideas and suggestions with other users and developers of kubecub. You can ask technical questions, seek help, or share your experiences with other users of kubecub. + +In addition to Slack, we also offer the following ways to get in touch: + ++ We also have Slack channels for you to communicate and discuss. To join, visit https://slack.com/ and join our [๐Ÿ‘€ kubecub slack](https://join.slack.com/t/kubecub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ) team channel. ++ Get in touch with us on [๐Ÿ“จGmail: 3293172751nss@gmail.com](mailto:3293172751nss@gmail.com). If you have any questions or issues that need resolving, or any suggestions and feedback for our open source projects, please feel free to contact us via email. ++ Read our [๐Ÿค–kubecub](https://nsddd.top). Our kubecub is a great place to stay up-to-date with kubecub projects and trends. On the kubecub, we share our latest developments, tech trends, and other interesting information. ++ Add [๐Ÿ•Š๏ธTwitter](https://twitter.com/xxw3293172751) . If you prefer social media, our Twitter account is a great way to stay up-to-date with kubecub project news and trends. On Twitter, we share our latest tech and trends, as well as relevant news and events. ++ Add [๐Ÿ“ฒWechat](https://img.shields.io/badge/%E5%BE%AE%E4%BF%A1-smile-brightgreen?kubecubo=wechat&style=flat-square) and indicate that you are a user or developer of kubecub. We will process your request as soon as possible. + +Whether you're looking to join our community or have any questions or suggestions, we welcome you to get in touch with us. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a24fc6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Xinwei Xiong + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7360767 --- /dev/null +++ b/Makefile @@ -0,0 +1,151 @@ +# Copyright 2023 KubeCub. All rights reserved. +# Use of this source code is governed by a MIT style +# license that can be found in the LICENSE file. + +################################################################################ +# ========================== Capture Environment =============================== +# get the repo root and output path +ROOT_PACKAGE=github.com/kubecub/feishu-sheet-parser +OUT_DIR=$(REPO_ROOT)/_output +# ============================================================================== +# define the default goal +# + +SHELL := /bin/bash +DIRS=$(shell ls) +GO=go + +.DEFAULT_GOAL := help + +# include the common makefile +COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +# ROOT_DIR: root directory of the code base +ifeq ($(origin ROOT_DIR),undefined) +ROOT_DIR := $(abspath $(shell cd $(COMMON_SELF_DIR)/. && pwd -P)) +endif +# OUTPUT_DIR: The directory where the build output is stored. +ifeq ($(origin OUTPUT_DIR),undefined) +OUTPUT_DIR := $(ROOT_DIR)/bin +$(shell mkdir -p $(OUTPUT_DIR)) +endif + +ifeq ($(origin VERSION), undefined) +VERSION := $(shell git describe --abbrev=0 --dirty --always --tags | sed 's/-/./g') +endif + +# Check if the tree is dirty. default to dirty(maybe u should commit?) +GIT_TREE_STATE:="dirty" +ifeq (, $(shell git status --porcelain 2>/dev/null)) + GIT_TREE_STATE="clean" +endif +GIT_COMMIT:=$(shell git rev-parse HEAD) + +IMG ?= ghcr.io/kubecub/feishu-sheet-parser:latest + +BUILDFILE = "./main.go" +BUILDAPP = "$(OUTPUT_DIR)/" + +# Define the directory you want to copyright +CODE_DIRS := $(ROOT_DIR)/ #$(ROOT_DIR)/pkg $(ROOT_DIR)/core $(ROOT_DIR)/integrationtest $(ROOT_DIR)/lib $(ROOT_DIR)/mock $(ROOT_DIR)/db $(ROOT_DIR)/openapi +FINDS := find $(CODE_DIRS) + +ifndef V +MAKEFLAGS += --no-print-directory +endif + +# Linux command settings +FIND := find . ! -path './image/*' ! -path './vendor/*' ! -path './bin/*' +XARGS := xargs -r +LICENSE_TEMPLATE ?= $(ROOT_DIR)/scripts/LICENSE_TEMPLATES + +# ============================================================================== +# Targets + +## all: Build all the necessary targets. +.PHONY: all +all: tidy add-copyright lint cover build + +## build: Build binaries by default. +.PHONY: build +build: + @echo "$(shell go version)" + @echo "===========> Building binary $(BUILDAPP) *[Git Info]: $(VERSION)-$(GIT_COMMIT)" + @export CGO_ENABLED=0 && chmod +x ./scripts/build.sh && ./scripts/build.sh + +## build.%: Builds a binary of the specified directory. +.PHONY: build.% +build.%: + @echo "$(shell go version)" + @echo "===========> Building binary $(BUILDAPP) *[Git Info]: $(VERSION)-$(GIT_COMMIT)" + @export CGO_ENABLED=0 && GOOS=linux go build -o $(BUILDAPP)/$*/ -ldflags '-s -w' $*/example/$(BUILDFILE) + @export CGO_ENABLED=0 && GOOS=linux go build -o $(BUILDAPP)/$*/ -ldflags '-s -w' $*/example/$(BUILDFILE) + + +## tidy: tidy go.mod +.PHONY: tidy +tidy: + @$(GO) mod tidy + +## fmt: Run go fmt against code. +.PHONY: fmt +fmt: + @$(GO) fmt ./... + +## vet: Run go vet against code. +.PHONY: vet +vet: + @$(GO) vet ./... + +## generate: Run go generate against code. +.PHONY: generate +generate: + @$(GO) generate ./... + +## lint: Run go lint against code. +.PHONY: lint +lint: + @echo "===========> Run golangci to lint source codes" + @golangci-lint run -c $(ROOT_DIR)/.golangci.yml $(ROOT_DIR)/... + +## style: Code style -> fmt,vet,lint +.PHONY: style +style: fmt vet lint + +## test: Run unit test +.PHONY: test +test: + @$(GO) test ./... + +## cover: Run unit test with coverage. +.PHONY: cover +cover: test + @$(GO) test -cover + +## copyright.verify: Validate boilerplate headers for assign files. +.PHONY: copyright-verify +copyright-verify: + @echo "===========> Validate boilerplate headers for assign files starting in the $(ROOT_DIR) directory" + @addlicense -v -check -ignore **/test/** -f $(LICENSE_TEMPLATE) $(CODE_DIRS) + @echo "===========> End of boilerplate headers check..." + +## copyright-add: Add the boilerplate headers for all files. +.PHONY: copyright-add +copyright-add: + @echo "===========> Adding $(LICENSE_TEMPLATE) the boilerplate headers for all files" + @addlicense -y $(shell date +"%Y") -v -c "KubeCub & Xinwei Xiong(cubxxw)." -f $(LICENSE_TEMPLATE) $(CODE_DIRS) + @echo "===========> End the copyright is added..." + +## go.clean: Clean all builds. +.PHONY: clean +clean: + @echo "===========> Cleaning all builds OUTPUT_DIR($(OUTPUT_DIR))" + @-rm -vrf $(OUTPUT_DIR) + @echo "===========> End clean..." + +## help: Show this help info. +.PHONY: help +help: Makefile + @printf "\n\033[1mUsage: make ...\033[0m\n\n\\033[1mTargets:\\033[0m\n\n" + @sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-28s\033[0m %s\n", $$1, $$2}' | sed -e 's/^/ /' + +################################################################################ diff --git a/README.md b/README.md new file mode 100644 index 0000000..02a0be9 --- /dev/null +++ b/README.md @@ -0,0 +1,228 @@ +

+ + github-label-syncer
+
+

+

+ โญ๏ธ Template for a typical module written on Go. โญ๏ธ
+

+ + +

+A+ +good first + + + + +

+ +

+ +

+ English โ€ข + ไธญๆ–‡ +

+ +

+ +---- + +## ๐Ÿงฉ Awesome features + +At Github, we want to start new projects faster using best practices with a predefined structure and focusing on core ideas implementation rather than wasting time on environment configuration and copying boilerplate code. + +I defined a spec template that I could use to quickly start building a full-fledged project. + +In each directory, there is a README.md and an OWNERS, which explains what the directory does and who owns it. + +**Labels denger:** +Read about the [github-label-syncer](https://github.com/kubecub/github-label-syncer/labels) tag design + + +## ๐Ÿ›ซ Quick start + +> **Note**: You can get started quickly with github-label-syncer. + +1. Generate a [new repository](https://github.com/kubecub/github-label-syncer/generate) from the template. +2. Clone the repository locally. +3. Update files, read the README files in each directory. +4. Write your code and tests. + +
+ Work with Makefile + +```bash +โฏ make help # show help +โฏ make build # build binary +``` + +
+
+ Work with actions + +Actions provide handling of PR and issue. +We used the bot [๐Ÿš€@kubbot](https://github.com/kubbot), It can detect issues in Chinese and translate them to English, and you can interact with it using the command `/comment`. + +Comment in an issue: + +```bash +โฏ /intive +``` + +
+
+ Work with Tools + +```bash +โฏ make tools +``` + +
+
+ Work with Docker + +```bash +โฏ make deploy +``` + +
+ + +## ๐Ÿ•‹ architecture diagram +```mermaid +graph LR + +subgraph External Services +feishuAPI --> sheetParser +end + +subgraph Sheet Parser & Manager +sheetParser[Sheet Parser] --> versionControl +versionControl[Version Control] --> sheetDisplay +end + +subgraph Display +sheetDisplay[Sheet Display] --> UI +end + +subgraph Backend +versionControl --> API +end + +subgraph Frontend +UI[User Interface] +end + +API --> UI +UI --> feishuAPI +``` + +**MVC Architecture Design:** +```mermaid +graph LR +A[View] -->|1. User interaction| B(Controller) +B -->|2. Requests data| C(Model) +C -->|3. Returns data| B +B -->|4. Updates view| A +``` + +## ๐Ÿค– File Directory Description + +Catalog standardization design structure: + +```bash +.github-label-syncer +โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines +โ”œโ”€โ”€ LICENSE # License information +โ”œโ”€โ”€ Makefile # Makefile for building and running the project +โ”œโ”€โ”€ README.md # Project overview in English +โ”œโ”€โ”€ README_zh-CN.md # Project overview in Chinese +โ”œโ”€โ”€ api # API-related files +โ”‚ โ”œโ”€โ”€ OWNERS # API owners +โ”‚ โ””โ”€โ”€ README.md # API documentation +โ”œโ”€โ”€ assets # Static assets, such as images and stylesheets +โ”‚ โ””โ”€โ”€ README.md # Assets documentation +โ”œโ”€โ”€ build # Build-related files +โ”‚ โ”œโ”€โ”€ OWNERS # Build owners +โ”‚ โ””โ”€โ”€ README.md # Build documentation +โ”œโ”€โ”€ cmd # Command-line tools and entry points +โ”‚ โ”œโ”€โ”€ OWNERS # Command owners +โ”‚ โ””โ”€โ”€ README.md # Command documentation +โ”œโ”€โ”€ configs # Configuration files +โ”‚ โ”œโ”€โ”€ OWNERS # Configuration owners +โ”‚ โ”œโ”€โ”€ README.md # Configuration documentation +โ”‚ โ””โ”€โ”€ config.yaml # Main configuration file +โ”œโ”€โ”€ deploy # Deployment-related files +โ”‚ โ”œโ”€โ”€ OWNERS # Deployment owners +โ”‚ โ””โ”€โ”€ README.md # Deployment documentation +โ”œโ”€โ”€ docs # Project documentation +โ”‚ โ”œโ”€โ”€ OWNERS # Documentation owners +โ”‚ โ””โ”€โ”€ README.md # Documentation index +โ”œโ”€โ”€ examples # Example code and usage +โ”‚ โ”œโ”€โ”€ OWNERS # Example owners +โ”‚ โ””โ”€โ”€ README.md # Example documentation +โ”œโ”€โ”€ init # Initialization files +โ”‚ โ”œโ”€โ”€ OWNERS # Initialization owners +โ”‚ โ””โ”€โ”€ README.md # Initialization documentation +โ”œโ”€โ”€ internal # Internal application code +โ”‚ โ”œโ”€โ”€ OWNERS # Internal code owners +โ”‚ โ”œโ”€โ”€ README.md # Internal code documentation +โ”‚ โ”œโ”€โ”€ app # Application logic +โ”‚ โ”œโ”€โ”€ pkg # Internal packages +โ”‚ โ””โ”€โ”€ utils # Utility functions and helpers +โ”œโ”€โ”€ pkg # Public packages and libraries +โ”‚ โ”œโ”€โ”€ OWNERS # Package owners +โ”‚ โ”œโ”€โ”€ README.md # Package documentation +โ”‚ โ”œโ”€โ”€ common # Common utilities and helpers +โ”‚ โ”œโ”€โ”€ log # Log utilities +โ”‚ โ”œโ”€โ”€ tools # Tooling and scripts +โ”‚ โ”œโ”€โ”€ utils # General utility functions +โ”‚ โ””โ”€โ”€ version # Version information +โ”œโ”€โ”€ scripts # Scripts for development and automation +โ”‚ โ”œโ”€โ”€ LICENSE_TEMPLATES # License templates +โ”‚ โ”œโ”€โ”€ OWNERS # Script owners +โ”‚ โ”œโ”€โ”€ README.md # Script documentation +โ”‚ โ”œโ”€โ”€ githooks # Git hooks for development +โ”‚ โ””โ”€โ”€ make-rules # Makefile rules and scripts +โ”œโ”€โ”€ test # Test files and test-related utilities +โ”‚ โ”œโ”€โ”€ OWNERS # Test owners +โ”‚ โ””โ”€โ”€ README.md # Test documentation +โ”œโ”€โ”€ third_party # Third-party dependencies and libraries +โ”‚ โ””โ”€โ”€ README.md # Third-party documentation +โ”œโ”€โ”€ tools # Tooling and utilities for development +โ”‚ โ””โ”€โ”€ README.md # Tool documentation +โ””โ”€โ”€ web # Web-related files, such as HTML and CSS + โ”œโ”€โ”€ OWNERS # Web owners + โ””โ”€โ”€ README.md # Web documentation +``` + +## ๐Ÿ—“๏ธ community meeting + +We welcome everyone to join us and contribute to github-label-syncer, whether you are new to open source or professional. We are committed to promoting an open source culture, so we offer community members neighborhood prizes and reward money in recognition of their contributions. We believe that by working together, we can build a strong community and make valuable open source tools and resources available to more people. So if you are interested in github-label-syncer, please join our community and start contributing your ideas and skills! + +We take notes of each [biweekly meeting](https://github.com/kubecub/github-label-syncer/issues/2) in [GitHub discussions](https://github.com/kubecub/github-label-syncer/discussions/categories/meeting), and our minutes are written in [Google Docs](https://docs.google.com/document/d/1nx8MDpuG74NASx081JcCpxPgDITNTpIIos0DS6Vr9GU/edit?usp=sharing). + +github-label-syncer maintains a [public roadmap](https://github.com/kubecub/community/tree/main/roadmaps). It gives a a high-level view of the main priorities for the project, the maturity of different features and projects, and how to influence the project direction. + +## ๐Ÿคผโ€ Contributing & Development + +kubecub Our goal is to build a top-level open source community. We have a set of standards, in the [Community repository](https://github.com/kubecub/community). + +If you'd like to contribute to this github-label-syncer repository, please read our [contributor documentation](https://github.com/kubecub/github-label-syncer/blob/main/CONTRIBUTING.md). + +Before you start, please make sure your changes are in demand. The best for that is to create a [new discussion](https://github.com/kubecub/github-label-syncer/discussions/new/choose) OR [Slack Communication](https://join.slack.com/t/kubecub/shared_invite/zt-1se0k2bae-lkYzz0_T~BYh3rjkvlcUqQ), or if you find an issue, [report it](https://github.com/kubecub/github-label-syncer/issues/new/choose) first. + + +## ๐Ÿšจ License + +Kubecub is licensed under the MIT License, Version 2.0. See [LICENSE](https://github.com/kubecub/github-label-syncer/tree/main/LICENSE) for the full license text. + +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fkubecub%2Fkubecub.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fkubecub%2Fgithub-label-syncer?ref=badge_large) + + +## ๐Ÿ”ฎ Thanks to our contributors! + + + + diff --git a/README_zh-CN.md b/README_zh-CN.md new file mode 100644 index 0000000..e69de29 diff --git a/api/OWNERS b/api/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/api/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/api/README.md b/api/README.md new file mode 100644 index 0000000..3a4eaf3 --- /dev/null +++ b/api/README.md @@ -0,0 +1,8 @@ +# `/api` + +OpenAPI/Swagger specs, JSON schema files, protocol definition files. + +Examples: + +* https://github.com/kubernetes/kubernetes/tree/master/api +* https://github.com/moby/moby/tree/master/api \ No newline at end of file diff --git a/assets/README.md b/assets/README.md new file mode 100644 index 0000000..f236483 --- /dev/null +++ b/assets/README.md @@ -0,0 +1,3 @@ +# `/assets` + +Other assets to go along with your repository (images, logos, etc). \ No newline at end of file diff --git a/build/OWNERS b/build/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/build/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/build/README.md b/build/README.md new file mode 100644 index 0000000..00bfce3 --- /dev/null +++ b/build/README.md @@ -0,0 +1,11 @@ +# `/build` + +Packaging and Continuous Integration. + +Put your cloud (AMI), container (Docker), OS (deb, rpm, pkg) package configurations and scripts in the `/build/package` directory. + +Put your CI (travis, circle, drone) configurations and scripts in the `/build/ci` directory. Note that some of the CI tools (e.g., Travis CI) are very picky about the location of their config files. Try putting the config files in the `/build/ci` directory linking them to the location where the CI tools expect them when possible (don't worry if it's not and if keeping those files in the root directory makes your life easier :-)). + +Examples: + +* https://github.com/cockroachdb/cockroach/tree/master/build \ No newline at end of file diff --git a/cmd/OWNERS b/cmd/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/cmd/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/cmd/README.md b/cmd/README.md new file mode 100644 index 0000000..194e966 --- /dev/null +++ b/cmd/README.md @@ -0,0 +1,19 @@ +# `/cmd` + +Main applications for this project. + +The directory name for each application should match the name of the executable you want to have (e.g., `/cmd/myapp`). + +Don't put a lot of code in the application directory. If you think the code can be imported and used in other projects, then it should live in the `/pkg` directory. If the code is not reusable or if you don't want others to reuse it, put that code in the `/internal` directory. You'll be surprised what others will do, so be explicit about your intentions! + +It's common to have a small `main` function that imports and invokes the code from the `/internal` and `/pkg` directories and nothing else. + +Examples: + +* https://github.com/vmware-tanzu/velero/tree/main/cmd (just a really small `main` function with everything else in packages) +* https://github.com/moby/moby/tree/master/cmd +* https://github.com/prometheus/prometheus/tree/main/cmd +* https://github.com/influxdata/influxdb/tree/master/cmd +* https://github.com/kubernetes/kubernetes/tree/master/cmd +* https://github.com/dapr/dapr/tree/master/cmd +* https://github.com/ethereum/go-ethereum/tree/master/cmd \ No newline at end of file diff --git a/configs/OWNERS b/configs/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/configs/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/configs/README.md b/configs/README.md new file mode 100644 index 0000000..136f8ad --- /dev/null +++ b/configs/README.md @@ -0,0 +1,5 @@ +# `/configs` + +Configuration file templates or default configs. + +Put your `confd` or `consul-template` template files here. \ No newline at end of file diff --git a/configs/config.yaml b/configs/config.yaml new file mode 100644 index 0000000..e69de29 diff --git a/deploy/OWNERS b/deploy/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/deploy/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000..eab36f1 --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,3 @@ +# `/deployments` + +IaaS, PaaS, system and container orchestration deployment configurations and templates (docker-compose, kubernetes/helm, mesos, terraform, bosh). \ No newline at end of file diff --git a/docs/OWNERS b/docs/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/docs/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..5933803 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,9 @@ +# `/docs` + +Design and user documents (in addition to your godoc generated documentation). + +Examples: + +* https://github.com/gohugoio/hugo/tree/master/docs +* https://github.com/openshift/origin/tree/master/docs +* https://github.com/dapr/dapr/tree/master/docs \ No newline at end of file diff --git a/examples/OWNERS b/examples/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/examples/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..ba10965 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,9 @@ +# `/examples` + +Examples for your applications and/or public libraries. + +Examples: + +* https://github.com/nats-io/nats.go/tree/master/examples +* https://github.com/docker-slim/docker-slim/tree/master/examples +* https://github.com/hashicorp/packer/tree/master/examples \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..048ec9d --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/kubecub/github-label-syncer + +go 1.18 diff --git a/init/OWNERS b/init/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/init/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/init/README.md b/init/README.md new file mode 100644 index 0000000..c805e22 --- /dev/null +++ b/init/README.md @@ -0,0 +1,3 @@ +# `/init` + +System init (systemd, upstart, sysv) and process manager/supervisor (runit, supervisord) configs. \ No newline at end of file diff --git a/internal/OWNERS b/internal/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/internal/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/internal/README.md b/internal/README.md new file mode 100644 index 0000000..de4660a --- /dev/null +++ b/internal/README.md @@ -0,0 +1,34 @@ +# `/internal` + +Private application and library code. This is the code you don't want others importing in their applications or libraries. Note that this layout pattern is enforced by the Go compiler itself. See the Go 1.4 [`release notes`](https://golang.org/doc/go1.4#internalpackages) for more details. Note that you are not limited to the top level `internal` directory. You can have more than one `internal` directory at any level of your project tree. + +You can optionally add a bit of extra structure to your internal packages to separate your shared and non-shared internal code. It's not required (especially for smaller projects), but it's nice to have visual clues showing the intended package use. Your actual application code can go in the `/internal/app` directory (e.g., `/internal/app/myapp`) and the code shared by those apps in the `/internal/pkg` directory (e.g., `/internal/pkg/myprivlib`). + +For example, if you have a directory structure like this: +```go +myapp/ + internal/ + util.go + main.go +``` + +myapp/internal/util.go can only be referenced within the myapp module. For example, main.go can import "myapp/internal/util". +But code from other modules cannot import myapp/internal. If you try to import "myapp/internal/util", the compiler will report an error: +```bash +cannot use "myapp/internal/util" as external package name: myapp/internal/util.go: does not export package internal +``` + +Examples: + +* https://github.com/hashicorp/terraform/tree/main/internal +* https://github.com/influxdata/influxdb/tree/master/internal +* https://github.com/perkeep/perkeep/tree/master/internal +* https://github.com/jaegertracing/jaeger/tree/main/internal +* https://github.com/moby/moby/tree/master/internal +* https://github.com/satellity/satellity/tree/main/internal + +## `/internal/pkg` + +Examples: + +* https://github.com/hashicorp/waypoint/tree/main/internal/pkg \ No newline at end of file diff --git a/internal/app /_your_app_/.keep b/internal/app /_your_app_/.keep new file mode 100644 index 0000000..e69de29 diff --git a/internal/pkg/_your_private_lib_/.keep b/internal/pkg/_your_private_lib_/.keep new file mode 100644 index 0000000..e69de29 diff --git a/internal/utils/utils.go b/internal/utils/utils.go new file mode 100644 index 0000000..d4b585b --- /dev/null +++ b/internal/utils/utils.go @@ -0,0 +1 @@ +package utils diff --git a/pkg/OWNERS b/pkg/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/pkg/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/pkg/README.md b/pkg/README.md new file mode 100644 index 0000000..8fff56d --- /dev/null +++ b/pkg/README.md @@ -0,0 +1,55 @@ +# `/pkg` + +Library code that's ok to use by external applications (e.g., `/pkg/mypubliclib`). Other projects will import these libraries expecting them to work, so think twice before you put something here :-) Note that the `internal` directory is a better way to ensure your private packages are not importable because it's enforced by Go. The `/pkg` directory is still a good way to explicitly communicate that the code in that directory is safe for use by others. The [`I'll take pkg over internal`](https://travisjeffery.com/b/2019/11/i-ll-take-pkg-over-internal/) blog post by Travis Jeffery provides a good overview of the `pkg` and `internal` directories and when it might make sense to use them. + +It's also a way to group Go code in one place when your root directory contains lots of non-Go components and directories making it easier to run various Go tools (as mentioned in these talks: [`Best Practices for Industrial Programming`](https://www.youtube.com/watch?v=PTE4VJIdHPg) from GopherCon EU 2018, [GopherCon 2018: Kat Zien - How Do You Structure Your Go Apps](https://www.youtube.com/watch?v=oL6JBUk6tj0) and [GoLab 2018 - Massimiliano Pippi - Project layout patterns in Go](https://www.youtube.com/watch?v=3gQa1LWwuzk)). + +Note that this is not a universally accepted pattern and for every popular repo that uses it you can find 10 that don't. It's up to you to decide if you want to use this pattern or not. Regardless of whether or not it's a good pattern more people will know what you mean than not. It might a bit confusing for some of the new Go devs, but it's a pretty simple confusion to resolve and that's one of the goals for this project layout repo. + +Ok not to use it if your app project is really small and where an extra level of nesting doesn't add much value (unless you really want to). Think about it when it's getting big enough and your root directory gets pretty busy (especially if you have a lot of non-Go app components). + + +Examples: + +* https://github.com/jaegertracing/jaeger/tree/master/pkg +* https://github.com/istio/istio/tree/master/pkg +* https://github.com/GoogleContainerTools/kaniko/tree/master/pkg +* https://github.com/google/gvisor/tree/master/pkg +* https://github.com/google/syzkaller/tree/master/pkg +* https://github.com/perkeep/perkeep/tree/master/pkg +* https://github.com/heptio/ark/tree/master/pkg +* https://github.com/argoproj/argo/tree/master/pkg +* https://github.com/heptio/sonobuoy/tree/master/pkg +* https://github.com/helm/helm/tree/master/pkg +* https://github.com/kubernetes/kubernetes/tree/master/pkg +* https://github.com/kubernetes/kops/tree/master/pkg +* https://github.com/moby/moby/tree/master/pkg +* https://github.com/grafana/grafana/tree/master/pkg +* https://github.com/influxdata/influxdb/tree/master/pkg +* https://github.com/cockroachdb/cockroach/tree/master/pkg +* https://github.com/derekparker/delve/tree/master/pkg +* https://github.com/etcd-io/etcd/tree/master/pkg +* https://github.com/oklog/oklog/tree/master/pkg +* https://github.com/flynn/flynn/tree/master/pkg +* https://github.com/jesseduffield/lazygit/tree/master/pkg +* https://github.com/gopasspw/gopass/tree/master/pkg +* https://github.com/sosedoff/pgweb/tree/master/pkg +* https://github.com/GoogleContainerTools/skaffold/tree/master/pkg +* https://github.com/knative/serving/tree/master/pkg +* https://github.com/grafana/loki/tree/master/pkg +* https://github.com/bloomberg/goldpinger/tree/master/pkg +* https://github.com/Ne0nd0g/merlin/tree/master/pkg +* https://github.com/jenkins-x/jx/tree/master/pkg +* https://github.com/DataDog/datadog-agent/tree/master/pkg +* https://github.com/dapr/dapr/tree/master/pkg +* https://github.com/cortexproject/cortex/tree/master/pkg +* https://github.com/dexidp/dex/tree/master/pkg +* https://github.com/pusher/oauth2_proxy/tree/master/pkg +* https://github.com/pdfcpu/pdfcpu/tree/master/pkg +* https://github.com/weaveworks/kured/tree/master/pkg +* https://github.com/weaveworks/footloose/tree/master/pkg +* https://github.com/weaveworks/ignite/tree/master/pkg +* https://github.com/tmrts/boilr/tree/master/pkg +* https://github.com/kata-containers/runtime/tree/master/pkg +* https://github.com/okteto/okteto/tree/master/pkg +* https://github.com/solo-io/squash/tree/master/pkg \ No newline at end of file diff --git a/pkg/version/version.go b/pkg/version/version.go new file mode 100644 index 0000000..76f4b34 --- /dev/null +++ b/pkg/version/version.go @@ -0,0 +1,6 @@ +// Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +// +// Licensed under the MIT License (the "License"); +// you may not use this file except in compliance with the License. + +package version diff --git a/scripts/LICENSE_TEMPLATES b/scripts/LICENSE_TEMPLATES new file mode 100644 index 0000000..a837bfe --- /dev/null +++ b/scripts/LICENSE_TEMPLATES @@ -0,0 +1,20 @@ +Copyright ยฉ {{.Year}} {{.Holder}} All rights reserved. + +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. + + +/* +Copyright ยฉ {{.Year}} {{.Holder}} All rights reserved. +Licensed under the MIT License (the "License"); +you may not use this file except in compliance with the License. +*/ \ No newline at end of file diff --git a/scripts/OWNERS b/scripts/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/scripts/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..edb724e --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,11 @@ +# `/scripts` + +Scripts to perform various build, install, analysis, etc operations. + +These scripts keep the root level Makefile small and simple. + +Examples: + +* https://github.com/kubernetes/helm/tree/master/scripts +* https://github.com/cockroachdb/cockroach/tree/master/scripts +* https://github.com/hashicorp/terraform/tree/master/scripts \ No newline at end of file diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg new file mode 100644 index 0000000..7050cfd --- /dev/null +++ b/scripts/githooks/commit-msg @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# +# ============================================================================== +# +# Store this file as .git/hooks/commit-msg in your repository in order to +# enforce checking for proper commit message format before actual commits. +# You may need to make the script executable by 'chmod +x .git/hooks/commit-msg'. + +# commit-msg use go-gitlint tool, install go-gitlint via `go get github.com/llorllale/go-gitlint/cmd/go-gitlint` +# go-gitlint --msg-file="$1" + +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}kubecub : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}kubecub : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}kubecub : $1${ENDCOLOR}\n" +} + +printMessage "Running the kubecub commit-msg hook." + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} + +./tools/go-gitlint \ + --msg-file=$1 \ + --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \ + --subject-maxlen=150 \ + --subject-minlen=10 \ + --body-regex=".*" \ + --max-parents=1 + +if [ $? -ne 0 ] +then + printError "Please fix your commit message to match kubecub coding standards" + printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" + exit 1 +fi \ No newline at end of file diff --git a/scripts/githooks/githooks/commit-msg b/scripts/githooks/githooks/commit-msg new file mode 100644 index 0000000..11b1d2a --- /dev/null +++ b/scripts/githooks/githooks/commit-msg @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# +# ============================================================================== +# +# Store this file as .git/hooks/commit-msg in your repository in order to +# enforce checking for proper commit message format before actual commits. +# You may need to make the script executable by 'chmod +x .git/hooks/commit-msg'. + +# commit-msg use go-gitlint tool, install go-gitlint via `go get github.com/llorllale/go-gitlint/cmd/go-gitlint` +# go-gitlint --msg-file="$1" + +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}OpenIM : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}OpenIM : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}OpenIM : $1${ENDCOLOR}\n" +} + +printMessage "Running the OpenIM commit-msg hook." + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} + +./tools/go-gitlint \ + --msg-file=$1 \ + --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \ + --subject-maxlen=150 \ + --subject-minlen=10 \ + --body-regex=".*" \ + --max-parents=1 + +if [ $? -ne 0 ] +then + printError "Please fix your commit message to match OpenIM coding standards" + printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" + exit 1 +fi \ No newline at end of file diff --git a/scripts/githooks/githooks/pre-commit b/scripts/githooks/githooks/pre-commit new file mode 100644 index 0000000..0c88404 --- /dev/null +++ b/scripts/githooks/githooks/pre-commit @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# ============================================================================== +# This is a pre-commit hook that ensures attempts to commit files that are +# are larger than $limit to your _local_ repo fail, with a helpful error message. + +# You can override the default limit of 2MB by supplying the environment variable: +# GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" +# +# ============================================================================== + + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}OpenIM : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}OpenIM : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}OpenIM : $1${ENDCOLOR}\n" +} + +printMessage "Running local OpenIM pre-commit hook." + +# flutter format . +# https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md +# TODO! GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" +# Maximum file size limit in bytes +limit=${GIT_FILE_SIZE_LIMIT:-2000000} # Default 2MB +limitInMB=$(( $limit / 1000000 )) + +function file_too_large(){ + filename=$0 + filesize=$(( $1 / 2**20 )) + + cat < /dev/null 2>&1 +then + against=HEAD +else + against="$empty_tree" +fi + +# Set split so that for loop below can handle spaces in file names by splitting on line breaks +IFS=' +' + +shouldFail=false +for file in $( git diff-index --cached --name-only $against ); do + file_size=$(([ ! -f $file ] && echo 0) || (ls -la $file | awk '{ print $5 }')) + if [ "$file_size" -gt "$limit" ]; then + printError "File $file is $(( $file_size / 10**6 )) MB, which is larger than our configured limit of $limitInMB MB" + shouldFail=true + fi +done + +if $shouldFail +then + printMessage "If you really need to commit this file, you can override the size limit by setting the GIT_FILE_SIZE_LIMIT environment variable, e.g. GIT_FILE_SIZE_LIMIT=42000000 for 42MB. Or, commit with the --no-verify switch to skip the check entirely." + printError "Commit aborted" + exit 1; +fi \ No newline at end of file diff --git a/scripts/githooks/githooks/pre-push b/scripts/githooks/githooks/pre-push new file mode 100644 index 0000000..73c86e0 --- /dev/null +++ b/scripts/githooks/githooks/pre-push @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}OpenIM : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}OpenIM : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}OpenIM : $1${ENDCOLOR}\n" +} + +printMessage "Running local OpenIM pre-push hook." + +if [[ `git status --porcelain` ]]; then + printError "This script needs to run against committed code only. Please commit or stash you changes." + exit 1 +fi + +# +#printMessage "Running the Flutter analyzer" +#flutter analyze +# +#if [ $? -ne 0 ]; then +# printError "Flutter analyzer error" +# exit 1 +#fi +# +#printMessage "Finished running the Flutter analyzer" diff --git a/scripts/githooks/pre-commit b/scripts/githooks/pre-commit new file mode 100644 index 0000000..7d5d4c0 --- /dev/null +++ b/scripts/githooks/pre-commit @@ -0,0 +1,90 @@ +#!/usr/bin/env bash + +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +# ============================================================================== +# This is a pre-commit hook that ensures attempts to commit files that are +# are larger than $limit to your _local_ repo fail, with a helpful error message. + +# You can override the default limit of 2MB by supplying the environment variable: +# GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" +# +# ============================================================================== + + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}kubecub : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}kubecub : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}kubecub : $1${ENDCOLOR}\n" +} + +printMessage "Running local kubecub pre-commit hook." + +# flutter format . +# https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md +# TODO! GIT_FILE_SIZE_LIMIT=50000000 git commit -m "test: this commit is allowed file sizes up to 50MB" +# Maximum file size limit in bytes +limit=${GIT_FILE_SIZE_LIMIT:-2000000} # Default 2MB +limitInMB=$(( $limit / 1000000 )) + +function file_too_large(){ + filename=$0 + filesize=$(( $1 / 2**20 )) + + cat < /dev/null 2>&1 +then + against=HEAD +else + against="$empty_tree" +fi + +# Set split so that for loop below can handle spaces in file names by splitting on line breaks +IFS=' +' + +shouldFail=false +for file in $( git diff-index --cached --name-only $against ); do + file_size=$(([ ! -f $file ] && echo 0) || (ls -la $file | awk '{ print $5 }')) + if [ "$file_size" -gt "$limit" ]; then + printError "File $file is $(( $file_size / 10**6 )) MB, which is larger than our configured limit of $limitInMB MB" + shouldFail=true + fi +done + +if $shouldFail +then + printMessage "If you really need to commit this file, you can override the size limit by setting the GIT_FILE_SIZE_LIMIT environment variable, e.g. GIT_FILE_SIZE_LIMIT=42000000 for 42MB. Or, commit with the --no-verify switch to skip the check entirely." + printError "Commit aborted" + exit 1; +fi \ No newline at end of file diff --git a/scripts/githooks/pre-push b/scripts/githooks/pre-push new file mode 100644 index 0000000..1d9d67c --- /dev/null +++ b/scripts/githooks/pre-push @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright ยฉ 2023 KubeCub & Xinwei Xiong(cubxxw). All rights reserved. +# +# Licensed under the MIT License (the "License"); +# you may not use this file except in compliance with the License. + +YELLOW="\e[93m" +GREEN="\e[32m" +RED="\e[31m" +ENDCOLOR="\e[0m" + +printMessage() { + printf "${YELLOW}kubecub : $1${ENDCOLOR}\n" +} + +printSuccess() { + printf "${GREEN}kubecub : $1${ENDCOLOR}\n" +} + +printError() { + printf "${RED}kubecub : $1${ENDCOLOR}\n" +} + +printMessage "Running local kubecub pre-push hook." + +if [[ `git status --porcelain` ]]; then + printError "This script needs to run against committed code only. Please commit or stash you changes." + exit 1 +fi + +# +#printMessage "Running the Flutter analyzer" +#flutter analyze +# +#if [ $? -ne 0 ]; then +# printError "Flutter analyzer error" +# exit 1 +#fi +# +#printMessage "Finished running the Flutter analyzer" diff --git a/test/OWNERS b/test/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/test/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..411e574 --- /dev/null +++ b/test/README.md @@ -0,0 +1,8 @@ +# `/test` + +Additional external test apps and test data. Feel free to structure the `/test` directory anyway you want. For bigger projects it makes sense to have a data subdirectory. For example, you can have `/test/data` or `/test/testdata` if you need Go to ignore what's in that directory. Note that Go will also ignore directories or files that begin with "." or "_", so you have more flexibility in terms of how you name your test data directory. + +Examples: + +* https://github.com/openshift/origin/tree/master/test (test data is in the `/testdata` subdirectory) + diff --git a/third_party/README.md b/third_party/README.md new file mode 100644 index 0000000..ecd9930 --- /dev/null +++ b/third_party/README.md @@ -0,0 +1,3 @@ +# `/third_party` + +External helper tools, forked code and other 3rd party utilities (e.g., Swagger UI). \ No newline at end of file diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 0000000..3f729f8 --- /dev/null +++ b/tools/README.md @@ -0,0 +1,9 @@ +# `/tools` + +Supporting tools for this project. Note that these tools can import code from the `/pkg` and `/internal` directories. + +Examples: + +* https://github.com/istio/istio/tree/master/tools +* https://github.com/openshift/origin/tree/master/tools +* https://github.com/dapr/dapr/tree/master/tools \ No newline at end of file diff --git a/web/OWNERS b/web/OWNERS new file mode 100644 index 0000000..a9521f7 --- /dev/null +++ b/web/OWNERS @@ -0,0 +1,4 @@ +reviewers: + - cubxxw +approvers: + - cubxxw \ No newline at end of file diff --git a/web/README.md b/web/README.md new file mode 100644 index 0000000..a5cb800 --- /dev/null +++ b/web/README.md @@ -0,0 +1,3 @@ +# `/web` + +Web application specific components: static web assets, server side templates and SPAs. \ No newline at end of file