Repository: illacloud/illa Branch: main Commit: a23306f77b20 Files: 30 Total size: 68.7 KB Directory structure: gitextract_fq1obx4l/ ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ └── feature_request.md │ ├── PULL_REQUEST_TEMPLATE.md │ └── workflows/ │ ├── cd.yml │ ├── ci.yml │ └── close-stale-issues-and-PRs.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Cargo.toml ├── ISSUES.md ├── LICENSE ├── README.md ├── docs/ │ ├── Code_Contributions_Guidelines.md │ ├── Setup.md │ └── Subcommands.md └── src/ ├── command/ │ ├── deploy.rs │ ├── doctor.rs │ ├── list.rs │ ├── mod.rs │ ├── remove.rs │ ├── restart.rs │ ├── stop.rs │ ├── ui/ │ │ ├── emoji.rs │ │ └── mod.rs │ ├── update.rs │ └── utils.rs ├── lib.rs ├── main.rs └── result.rs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: 🐛 Bug report about: Create a report to help us improve title: "[BUG] Untitled Bug Issue" labels: bug assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See an error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, safari] - Version [e.g. 22] **Additional context** Add any other context about the problem here. ================================================ FILE: .github/ISSUE_TEMPLATE/feature_request.md ================================================ --- name: 🛠 Feature request about: Suggest an idea for this project title: "[FR] Untitled Feature Request Issue" labels: enhancement assignees: '' --- **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] **Describe 1~3 use cases of the purposed feature** A clear and concise description of one or more use cases. Ex. As a ..., I want to ... **Which type of users can benefit from the purposed feature** Ex. Junior Software Engineer **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. ================================================ FILE: .github/PULL_REQUEST_TEMPLATE.md ================================================ ## Description ## What type of PR is this? (check all applicable) - [ ] 🍕 Feature - [ ] 🐛 Bug Fix - [ ] 📝 Documentation Update - [ ] 🎨 Style - [ ] 🧑‍💻 Code Refactor - [ ] 🔥 Performance Improvements - [ ] ✅ Test - [ ] 🤖 Build - [ ] 🔁 CI - [ ] 📦 Chore - [ ] ⏩ Revert ## Related Tickets & Documents ## Tested? - [ ] 👍 yes - [ ] 🙅 no, because they aren't needed - [ ] 🙋 no, because I need help ## Added to documentation? - [ ] 📜 README.md - [ ] 🙅 no documentation needed ## [optional] Are there any post-deployment tasks we need to perform? ================================================ FILE: .github/workflows/cd.yml ================================================ name: Continuous Deployment on: push: tags: - "v*.*.*" jobs: build-linux: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable default: true override: true components: clippy, rustfmt - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.5.0 with: access_token: ${{ github.token }} - name: Check formatting run: cargo fmt -- --check - name: Clippy uses: actions-rs/clippy-check@v1 with: token: ${{ secrets.GITHUB_TOKEN }} args: -- -Dclippy::all - name: Run tests run: cargo test - name: Build run: cargo build --all --release - name: Name Release if: startsWith(github.ref, 'refs/tags/') id: name_release run: echo ::set-output name=RELEASE::illa-x86_64-linux - name: Prepare Release if: startsWith(github.ref, 'refs/tags/') env: NAME: ${{ steps.name_release.outputs.RELEASE }} run: | mkdir $NAME mv target/release/illa $NAME/ cp README.md $NAME/ cp LICENSE $NAME/ tar -zcvf $NAME.tar.gz $NAME/ sha256sum -b --tag $NAME.tar.gz > $NAME.checksum - name: Push Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | ${{ steps.name_release.outputs.RELEASE }}.tar.gz ${{ steps.name_release.outputs.RELEASE }}.checksum env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-mac: runs-on: macos-latest steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable target: x86_64-apple-darwin default: true override: true - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.5.0 with: access_token: ${{ github.token }} - name: Build run: cargo build --all --release - name: Name Release if: startsWith(github.ref, 'refs/tags/') id: name_release run: echo ::set-output name=RELEASE::illa-x86_64-macos - name: Prepare Release if: startsWith(github.ref, 'refs/tags/') env: NAME: ${{ steps.name_release.outputs.RELEASE }} run: | mkdir $NAME mv target/release/illa $NAME/ cp README.md $NAME/ cp LICENSE $NAME/ gtar -zcvf $NAME.tar.gz $NAME/ shasum -a 256 -b --tag $NAME.tar.gz > $NAME.checksum - name: Push Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | ${{ steps.name_release.outputs.RELEASE }}.tar.gz ${{ steps.name_release.outputs.RELEASE }}.checksum env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build-windows: runs-on: windows-latest steps: - name: Cache LLVM and Clang id: cache-llvm uses: actions/cache@v2 with: path: ${{ runner.temp }}/llvm key: llvm-12.0 - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1 with: version: "12.0" directory: ${{ runner.temp }}/llvm cached: ${{ steps.cache-llvm.outputs.cache-hit }} - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable target: x86_64-pc-windows-gnu default: true override: true - name: Cancel previous runs uses: styfle/cancel-workflow-action@0.5.0 with: access_token: ${{ github.token }} - name: Build run: cargo build --all --release - name: Name Release if: startsWith(github.ref, 'refs/tags/') id: name_release run: echo ::set-output name=RELEASE::illa-x86_64-win shell: bash - name: Prepare Release if: startsWith(github.ref, 'refs/tags/') env: NAME: ${{ steps.name_release.outputs.RELEASE }} run: | mkdir $env:NAME mv target/release/illa.exe $env:NAME/ cp README.md $env:NAME/ cp LICENSE $env:NAME/ 7z a "$env:NAME.zip" "$env:NAME/" certUtil -hashfile "$env:NAME.zip" SHA256 > "$env:NAME.checksum" - name: Push Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: files: | ${{ steps.name_release.outputs.RELEASE }}.zip ${{ steps.name_release.outputs.RELEASE }}.checksum env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} publish-cargo: name: Publishing to Cargo runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable override: true - run: | sudo apt-get update - uses: actions-rs/cargo@v1 with: command: publish args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty ================================================ FILE: .github/workflows/ci.yml ================================================ on: pull_request: branches: - develop push: branches: - main - develop name: Continuous Integration jobs: check: name: Check runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal override: true - uses: actions-rs/cargo@v1 with: command: check test: name: Test Suite runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal override: true - uses: Swatinem/rust-cache@v1 - uses: actions-rs/cargo@v1 with: command: test fmt: name: Rustfmt runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal override: true components: rustfmt - uses: Swatinem/rust-cache@v1 - uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check clippy: name: Clippy runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable profile: minimal override: true components: clippy - uses: Swatinem/rust-cache@v1 - uses: actions-rs/cargo@v1 with: command: clippy args: -- -D warnings ================================================ FILE: .github/workflows/close-stale-issues-and-PRs.yml ================================================ name: 'Close stale issues and PR' on: schedule: - cron: '30 1 * * *' jobs: stale: runs-on: ubuntu-latest steps: - uses: actions/stale@v7 with: stale-issue-message: 'This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 2 days.' stale-pr-message: 'This PR is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 2 days.' close-issue-message: 'This issue was closed because it has been stalled for 2 days with no activity.' days-before-issue-stale: 5 days-before-pr-stale: 5 days-before-issue-close: 2 days-before-pr-close: 2 exempt-issue-labels: 'bug,work-in-progress' exempt-all-assignees: true ================================================ FILE: .gitignore ================================================ # VS code .vscode # IntelliJ .idea # macOS .DS_Store # vim *.swp # Added by cargo /target ================================================ FILE: CODE_OF_CONDUCT.md ================================================ # Contributor Covenant Code of Conduct ## Our Pledge We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. ## Our Standards Examples of behavior that contributes to a positive environment for our community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience * Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: * The use of sexualized language or imagery, and sexual attention or advances of any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or email address, without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. ## Scope This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at opensource@illasoft.com. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. ## Enforcement Guidelines Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. ### 2. Warning **Community Impact**: A violation through a single incident or series of actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. ### 3. Temporary Ban **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within the community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see the FAQ at https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing to ILLA cli Thank you for your interest in `ILLA` and for taking the time to contribute to this project. `ILLA` is a project for developers that want to deploy [ILLA Builder](https://github.com/illacloud/illa-builder), and there are many ways you can contribute. Ask us on our [Discord channel](https://discord.com/invite/illacloud) if you don't know where to start contributing. ## Code of conduct Read our [Code of Conduct](CODE_OF_CONDUCT.md) before contributing ## How can I contribute? There are many ways in which you can contribute to ILLA. ### 🐛 Report a bug Report bug issues using the [Bug Report](https://github.com/illacloud/illa/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D+Untitled+Bug+Issue) template. To help resolve your issue as quickly as possible, read the template and provide the requested information. ### 🛠 File a feature request We welcome all feature requests, whether to add new functionality to `ILLA` or to offer an idea for modifying existing functionality. File your feature request using the [Feature Request](https://github.com/illacloud/illa/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=%5BFR%5D+Untitled+Feature+Request+Issue) template. ### ⚙️ Close a Bug / Feature issue We welcome contributions that help make `ILLA` cli bug free & improve the experience of our users. You can also find issues tagged `bug` or `enhancement`. Check out our [Code Contribution Guide](docs/Code_Contributions_Guidelines.md) to begin. ## Read more - [How to file an issue to ILLA and what will happen](ISSUES.md) ================================================ FILE: Cargo.toml ================================================ [package] name = "illa" version = "1.2.14" authors = ["ILLA "] edition = "2021" description = "Deploy a modern low-code platform in 5 Seconds!" readme = "README.md" keywords = ["terminal-app", "low-code", "deployment"] homepage = "https://www.illacloud.com/docs/illa-cli" repository = "https://github.com/illacloud/illa" license = "Apache-2.0" [[bin]] name = "illa" path = "src/main.rs" doc = false [dependencies] anyhow = "1.0" bollard = "0.13" indicatif = "0.17" futures-util = "0.3.23" console = { version = "0.15", default-features = false, features = [ "ansi-parsing", ] } tokio = { version = "1.20", features = ["full"] } clap = { version = "4.0.32", features = ["derive"] } uuid = { version = "1.1.2", features = ["v4"] } prettytable-rs = "0.10" dirs = "5.0.0" ================================================ FILE: ISSUES.md ================================================ # How to file an issue We encourage you to ask for help whenever you think it's needed! We are happy about every question we get because it allows us to better understand your needs, possible misunderstandings, and most importantly a way for you to help us improve `ILLA Builder`. That being said, this document's main purpose is to provide guidelines on how you can report a bug or propose a feature request. ## Filing issues Whether you are trying to report a bug or propose a feature request, [Github issues](https://github.com/illacloud/illa/issues) is for you! The `bug report` and `feature request` issue templates are ready for you! ## The issue life-cycle 1. User files an issue. 2. The `illa cloud` member provides feedback as soon as possible. 3. A conversation or discussion between `illa cloud` and the user. 4. A pull request related to the issue will close it. 5. Otherwise, we'll close the issue after seven days of no update. ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2023 Illa Soft, Inc. 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. ================================================ FILE: README.md ================================================
ILLA Design Logo

ILLA

Accelerate your internal tools development.

Create with ❤︎ by contributors

[![Chat on Discord](https://img.shields.io/badge/chat-Discord-7289DA?logo=discord)](https://discord.gg/illacloud) [![Follow on Twitter](https://img.shields.io/badge/Twitter-1DA1F2?logo=twitter&logoColor=white)](https://twitter.com/illacloudHQ) [![Discuss on GitHub](https://img.shields.io/badge/discussions-GitHub-333333?logo=github)](https://github.com/orgs/illacloud/discussions) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE) [![contributing](https://badgen.net/badge/PRs/Welcome/green?icon=storybook)](./CONTRIBUTING.md) ## ✨ What is ILLA ILLA is a CLI tool for **hosting ILLA Builder at cloud or local**.
We provide a **zero-config developer experience** to save developers' time at deployment.
You can deploy a modern low-code platform in 5 Seconds! ## 🖥 Fast Try ```bash cargo install illa ``` ## 💬 Community Join ILLA Community to share your ideas, suggestions or questions and connect with other users and contributors. Discussion [![Discuss on GitHub](https://img.shields.io/badge/discussions-GitHub-333333?logo=github)](https://github.com/orgs/illacloud/discussions) Hangout together! [![Chat on Discord](https://img.shields.io/badge/chat-Discord-7289DA?logo=discord)](https://discord.gg/illacloud) ## 🌱 Contributing Thinking about contributing? All kinds of contributions to ILLA are greatly appreciated and welcomed! Check out [Contributing Guide](./CONTRIBUTING.md) for details about how you can get involved. ## 📖 Learn more Please visit [ILLA CLI doc](https://illacloud.com/docs/illa-cli) ## 🔥 We're Hiring Looking for a passionate and creative team? We are actively hiring engineers for the following positions: - Frontend Engineer - Golang Engineer Contact Us: hr@illasoft.com ## License This project is [Apache License 2.0](./LICENSE). ================================================ FILE: docs/Code_Contributions_Guidelines.md ================================================ # Contributing Code ## Getting Started We use GitHub to host code, to track issues and feature requests, as well as accept pull requests. Before raising a pull request, ensure you have raised a corresponding issue and discussed a possible solution with a maintainer. This gives your pull request the highest chance of getting merged quickly. ## 🍴 Git Workflow We use [Github Flow](https://guides.github.com/introduction/flow/index.html), so all code changes happen through pull requests. 1. Fork the repo and create a new branch from the `develop` branch. 2. Branches are named as `fix/fix-name` or `feature/feature-name` 3. Please test your changes. 4. Once you are confident in your code changes, create a pull request in your fork to the `develop` branch in the `illacloud/illa` base repository. 5. If you've changed any APIs, please call this out in the pull request and ensure backward compatibility. 6. Link the issue of the base repository in your Pull request description. [Guide](https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue) 7. When you raise a pull request, we automatically run tests on our CI. Please ensure that all the tests are passing for your code change. We will not be able to accept your change if the test suite doesn't pass. ## 🏡 Setup for local development - [Running the illa cli](Setup.md) ## 📄 Read more - [ILLA cli subcommands](Subcommands.md) ================================================ FILE: docs/Setup.md ================================================ # Running ILLA cli Setup This document explains how you can setup a development environment for `illa` cli. ## Pre-requisites - [Rust](https://www.rust-lang.org/tools/install) - [Docker](https://docs.docker.com/get-docker/) ## Local Setup 1. Clone the repository ```bash git clone https://github.com/illacloud/illa.git cd illa ``` 2. Check the default Docker socket ```bash find /var/run/docker.sock ``` 3. Building and running the code ```bash cargo run -- [subcommand] --help ``` ## Need Assistance - If you are unable to resolve any issue while doing the setup, please feel free to ask questions on our [Discord channel](https://discord.com/invite/illacloud) or initiate a [Github discussion](https://github.com/orgs/illacloud/discussions). We'll be happy to help you. - In case you notice any discrepancy, please raise an issue on Github. ================================================ FILE: docs/Subcommands.md ================================================ # ILLA cli subcommands ## Deploy Command name: `deploy` Use: Deploy a new ILLA Builder Docker instance with the given name `illa_builder`. Options: - `-S, --self`: Self-hosted installation - `-C, --cloud`: ILLA Cloud installation - `-V, --builder-version `: Set the version of ILLA Builder. The default value is `latest`. - `-p, --port `: Set the port of ILLA Builder. The default value is `80`. - `-m, --mount `: The mount path for the ILLA Builder. The default value is `/var/lib/illa`. - `-h, --help`: Prints help information ## Stop Command name: `stop` Use: Stop one or more ILLA Builder. Options: - `-S, --self`: Stop Self-hosted ILLA Builder - `-C, --cloud`: Stop ILLA Builder on ILLA Cloud - `-h, --help`: Prints help information ## Restart Command name: `restart` Use: Restart one or more ILLA Builder. Options: - `-S, --self`: Restart Self-hosted ILLA Builder - `-C, --cloud`: Restart ILLA Builder on ILLA Cloud - `-h, --help`: Prints help information ## Remove Command name: `remove` Use: Remove one or more ILLA Builder. Options: - `-S, --self`: Remove Self-hosted ILLA Builder - `-C, --cloud`: Remove ILLA Builder on ILLA Cloud - `-f, --force`: Force the removal of a ILLA Builder Docker instance (uses SIGKILL) - `-d, --data`: Remove the persistent data of ILLA Builder - `-h, --help`: Prints help information ## Update Command name: `update` Use: Update ILLA Builder to latest version. Options: - `-S, --self`: Update Self-hosted ILLA Builder - `-C, --cloud`: Update ILLA Builder on ILLA Cloud - `-h, --help`: Prints help information ## List Command name: `list` Use: List ILLA Builder. Options: - `-A, --all`: All ILLA Builder - `-S, --self`: List Self-hosted ILLA Builder - `-C, --cloud`: List ILLA Builder on ILLA Cloud - `-h, --help`: Prints help information ## Doctor Command name: `doctor` Use: Check the pre-requisites of self-host. Options: - `-h, --help`: Prints help information ## Help Command name: `help` User: Print help information. ================================================ FILE: src/command/deploy.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use bollard::container::{Config, CreateContainerOptions, LogsOptions, StartContainerOptions}; use bollard::image::CreateImageOptions; use bollard::models::{HostConfig, Mount, MountTypeEnum}; use bollard::service::PortBinding; use bollard::{service::CreateImageInfo, Docker}; use clap::{ArgAction::SetTrue, ArgGroup, Args}; use console::style; use futures_util::{StreamExt, TryStreamExt}; use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressStyle}; use std::collections::HashMap; use std::fmt::format; use std::hash::Hash; use std::thread; use std::time::{Duration, Instant}; use std::{env, process, string}; use uuid::Uuid; const ILLA_BUILDER_IMAGE: &str = "illasoft/illa-builder"; const ILLA_BUILDER_VERSION: &str = "latest"; // Executes the `illa deploy` command to // deploy your ILLA Builder #[derive(Debug, Args)] #[clap(group( ArgGroup::new("install") .required(true) .args(&["self_host", "cloud"]), ))] /// Deploy the ILLA Builder pub struct Cmd { /// Self-hosted installation #[clap(short = 'S', long = "self", action = SetTrue)] self_host: bool, /// ILLA Cloud installation #[clap(short = 'C', long = "cloud", action = SetTrue)] cloud: bool, /// Set the version of ILLA Builder [default: latest] #[clap(short = 'V', long = "builder-version", value_name = "X.Y.Z")] builder_version: Option, /// The port on which you want ILLA Builder to run #[clap(short = 'p', long = "port", default_value = "80")] port: u16, /// The mount path for the ILLA Builder #[clap(short = 'm', long = "mount", value_name = "/TEMP/DIR/ILLA-BUILDER")] mount_path: Option, } impl Cmd { pub async fn run(&self) -> Result { let spinner_style = ProgressStyle::with_template("{spinner} {wide_msg}") .unwrap() .tick_strings(&["🔸 ", "🔶 ", "🟠 ", "🟠 ", "🔶 "]); let (self_host, cloud) = (self.self_host, self.cloud); match (self_host, cloud) { (true, _) => { deploy_self_host( self.builder_version.as_ref(), self.port, self.mount_path.as_ref(), spinner_style, ) .await? } (_, true) => deploy_cloud(spinner_style).await?, _ => unreachable!(), }; Ok(()) } } async fn deploy_self_host( version: Option<&String>, port: u16, mount_path: Option<&String>, progress_style: ProgressStyle, ) -> Result { println!("{} Running a self-hosted installation...", ui::emoji::BUILD); let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, style("Please check the status of docker with command: docker info").red(), String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), style("https://docs.docker.com/engine/install/").blue(), String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } let m = MultiProgress::new(); let pb_download = m.add(ProgressBar::new(0)); pb_download.set_style(progress_style.clone()); let finish_spinner_style = ProgressStyle::with_template("{wide_msg}").unwrap(); let default_version = ILLA_BUILDER_VERSION.to_owned(); let builder_version = version.unwrap_or(&default_version); let builder_image = ILLA_BUILDER_IMAGE.to_owned() + ":" + builder_version; let default_mount_path = utils::get_default_mount(); let mount_path = mount_path.unwrap_or(&default_mount_path); let download_started = Instant::now(); let stream_list = &mut _docker.create_image( Some(CreateImageOptions { from_image: builder_image.clone(), ..Default::default() }), None, None, ); while let Some(value) = stream_list.next().await { pb_download.set_message(format!("Downloading {}...", builder_image.clone())); pb_download.inc(1); thread::sleep(Duration::from_millis(100)); if value.is_err() { pb_download.set_style(finish_spinner_style.clone()); pb_download.finish_with_message(format!( "{} {} {}", ui::emoji::FAIL, String::from("Download image error:"), style(value.err().unwrap()).red(), )); process::exit(1); }; } pb_download.set_style(finish_spinner_style.clone()); pb_download.finish_with_message(format!( "{} Downloaded in {}", ui::emoji::SUCCESS, HumanDuration(download_started.elapsed()) )); let pb_deploy = m.add(ProgressBar::new(0)); pb_deploy.set_style(progress_style.clone()); let pg_pwd = Uuid::new_v4(); let builder_env = vec![ "ILLA_SERVER_MODE=release".to_string(), "ILLA_DEPLOY_MODE=self-host".to_string(), format!("POSTGRES_PASSWORD={pg_pwd}"), ]; let mut builder_labels = HashMap::new(); builder_labels.insert( "maintainer".to_string(), "opensource@illasoft.com".to_string(), ); builder_labels.insert("license".to_string(), "Apache-2.0".to_string()); let mut builder_port_bindings = HashMap::new(); builder_port_bindings.insert( "2022/tcp".to_string(), Some(vec![PortBinding { host_port: Some(port.to_string()), host_ip: Some("0.0.0.0".to_string()), }]), ); let local_dir = utils::local_bind_init(mount_path); let mounts = vec![Mount { target: Some("/opt/illa/database".to_string()), source: Some(local_dir), typ: Some(MountTypeEnum::BIND), read_only: Some(false), ..Default::default() }]; let builder_config = Config { image: Some(builder_image), env: Some(builder_env), labels: Some(builder_labels), host_config: Some(HostConfig { port_bindings: Some(builder_port_bindings), mounts: Some(mounts), ..Default::default() }), ..Default::default() }; let create_builder = &_docker .create_container( Some(CreateContainerOptions { name: "illa_builder", }), builder_config, ) .await; let start_builder = &_docker .start_container("illa_builder", None::>) .await; match (create_builder.is_err(), start_builder.is_err()) { (true, _) => { pb_deploy.set_style(finish_spinner_style.clone()); pb_deploy.finish_with_message(format!( "{} {} {}", ui::emoji::FAIL, String::from("Create ILLA Builder error:"), style(create_builder.as_ref().err().unwrap()).red(), )); process::exit(1); } (false, true) => { pb_deploy.set_style(finish_spinner_style.clone()); pb_deploy.finish_with_message(format!( "{} {} {}", ui::emoji::FAIL, String::from("Start ILLA Builder error:"), style(start_builder.as_ref().err().unwrap()).red(), )); process::exit(1); } _ => { pb_deploy.set_style(finish_spinner_style.clone()); pb_deploy.finish_with_message(format!( "{} {} {}", ui::emoji::SPARKLE, String::from("ILLA Builder started, please visit"), style(format!("{}:{}", "http://localhost", port)).blue(), )); process::exit(0); } }; Ok(()) } async fn deploy_cloud(progress_style: ProgressStyle) -> Result { println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND); Ok(()) } ================================================ FILE: src/command/doctor.rs ================================================ use crate::{command::*, result::Result}; use bollard::Docker; use clap::Args; use console::style; use indicatif::{ProgressBar, ProgressStyle}; use std::thread; use std::time::Duration; // Executes the `illa doctor` command to // check the prerequisites of self hosting #[derive(Debug, Args)] /// Checks the prerequisites of self-host pub struct Cmd {} impl Cmd { pub async fn run(&self) -> Result { let spinner_style = ProgressStyle::with_template("{spinner} {wide_msg}") .unwrap() .tick_strings(&["🔸 ", "🔶 ", "🟠 ", "🟠 ", "🔶 "]); println!( "{} Checking the prerequisites of self-host...", ui::emoji::LOOKING_GLASS ); let pb = ProgressBar::new(0); pb.set_style(spinner_style.clone()); for _ in 0..10 { pb.set_message("Checking the version of Docker..."); pb.inc(1); thread::sleep(Duration::from_millis(200)); } let new_spinner_style = ProgressStyle::with_template("{wide_msg}").unwrap(); pb.set_style(new_spinner_style); let _docker = Docker::connect_with_local_defaults().unwrap(); let error_info = |pb: ProgressBar| { pb.println(format!( "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, style("Please check the status of docker with command: docker info").red(), String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), style("https://docs.docker.com/engine/install/").blue(), String::from("Once Docker is installed, please try running the command again."), )); pb.finish_with_message(format!("illa doctor exited.")); }; match _docker.version().await { Ok(version) => pb.finish_with_message(format!( "{} {}: {}\n{} {}", ui::emoji::SUCCESS, String::from("Docker version"), version.version.unwrap(), ui::emoji::SPARKLE, style("Success! The minimum requirement for deploying ILLA has been satisfied. Self-Host your ILLA Builder by command [illa deploy].").green(), )), Err(e) => error_info(pb), } println!(); Ok(()) } } ================================================ FILE: src/command/list.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use bollard::{ container::{ListContainersOptions, StatsOptions}, Docker, }; use clap::{ArgAction::SetTrue, ArgGroup, Args}; use prettytable::{color, Attr}; use prettytable::{Cell, Row, Table}; use std::collections::HashMap; use std::process; // Executes the `illa list` command to // get ILLA Builder info #[derive(Debug, Args)] #[clap(group( ArgGroup::new("list") .required(true) .args(&["all", "self_host", "cloud"]), ))] /// List ILLA Builder pub struct Cmd { /// All ILLA Builder #[clap(short = 'A', long = "all", action = SetTrue)] all: bool, /// Self-hosted ILLA Builder #[clap(short = 'S', long = "self", action = SetTrue)] self_host: bool, /// ILLA Builder on ILLA Cloud #[clap(short = 'C', long = "cloud", action = SetTrue)] cloud: bool, } impl Cmd { pub async fn run(&self) -> Result { let (all, self_host, cloud) = (self.all, self.self_host, self.cloud); match (all, self_host, cloud) { (true, _, _) => println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND), (_, true, _) => list_local().await?, (_, _, true) => println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND), _ => unreachable!(), }; Ok(()) } } async fn list_local() -> Result { let _docker = Docker::connect_with_local_defaults().unwrap(); let mut table = Table::new(); table.add_row(Row::new(vec![ Cell::new("ID").with_style(Attr::ForegroundColor(color::GREEN)), Cell::new("Name").with_style(Attr::ForegroundColor(color::GREEN)), Cell::new("Image").with_style(Attr::ForegroundColor(color::GREEN)), Cell::new("State").with_style(Attr::ForegroundColor(color::GREEN)), ])); if (_docker.ping().await).is_err() { table.printstd(); process::exit(1); } let mut ls_containers_filters = HashMap::new(); ls_containers_filters.insert("name".to_string(), vec!["illa_builder".to_string()]); let builders = &_docker .list_containers(Some(ListContainersOptions:: { all: true, filters: ls_containers_filters, ..Default::default() })) .await .unwrap(); for builder in builders { table.add_row(Row::new(vec![ Cell::new(&builder.id.as_ref().unwrap().as_str()[0..12]) .with_style(Attr::ForegroundColor(color::BLUE)), Cell::new(builder.names.as_ref().unwrap()[0].as_str()), Cell::new(builder.image.as_ref().unwrap().as_str()), Cell::new(builder.state.as_ref().unwrap().as_str()), ])); } table.printstd(); Ok(()) } ================================================ FILE: src/command/mod.rs ================================================ #![allow(unused)] pub mod deploy; pub mod doctor; pub mod list; pub mod remove; pub mod restart; pub mod stop; pub mod ui; pub mod update; pub mod utils; ================================================ FILE: src/command/remove.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use bollard::container::{InspectContainerOptions, RemoveContainerOptions}; use bollard::Docker; use clap::{ArgAction::SetTrue, ArgGroup, Args}; use console::style; use std::process; // Executes the `illa remove` command to // remove one or more ILLA Builder #[derive(Debug, Args)] #[clap(group( ArgGroup::new("remove") .required(true) .args(&["self_host", "cloud"]), ))] /// Remove one or more ILLA Builder pub struct Cmd { /// Remove Self-hosted ILLA Builder #[clap(short = 'S', long = "self", action = SetTrue)] self_host: bool, /// Remove ILLA Builder on ILLA Cloud #[clap(short = 'C', long = "cloud", action = SetTrue)] cloud: bool, /// If the ILLA Builder is running, kill it before removing it #[clap(short = 'f', long = "force", action = SetTrue)] force: bool, /// Remove the persistent data of ILLA Builder #[clap(short = 'd', long = "data", action = SetTrue)] data: bool, } impl Cmd { pub async fn run(&self) -> Result { let (self_host, cloud) = (self.self_host, self.cloud); match (self_host, cloud) { (true, _) => remove_local(self.force, self.data).await?, (_, true) => println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND), _ => unreachable!(), }; Ok(()) } } async fn remove_local(is_force: bool, data: bool) -> Result { println!("{} Trying to remove the ILLA Builder...", ui::emoji::BUILD); let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, style("Please check the status of docker with command: docker info").red(), String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), style("https://docs.docker.com/engine/install/").blue(), String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } if data { let inspect_options = Some(InspectContainerOptions { size: false }); let builder_detail = &_docker .inspect_container("illa_builder", inspect_options) .await; if builder_detail.is_err() { println!( "{} {}\n", ui::emoji::FAIL, String::from("No ILLA Builder found."), ); process::exit(1); } let builder_info = builder_detail.as_ref().unwrap(); let builder_mount_cp = &builder_info .host_config .as_ref() .unwrap() .mounts .clone() .unwrap(); utils::local_bind_delete(builder_mount_cp[0].source.clone().unwrap()); } let options = Some(RemoveContainerOptions { force: is_force, ..Default::default() }); let stop_builder = _docker.remove_container("illa_builder", options).await; if stop_builder.is_err() { println!( "{} {} {}", ui::emoji::FAIL, String::from("Try to remove ILLA Builder error:"), style(stop_builder.err().unwrap()).red(), ); process::exit(1); } println!( "{} {}", ui::emoji::SUCCESS, style("Successfully remove the ILLA Builder.").green(), ); Ok(()) } ================================================ FILE: src/command/restart.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use bollard::{container::RestartContainerOptions, Docker}; use clap::{ArgAction::SetTrue, ArgGroup, Args}; use console::style; use std::process; // Executes the `illa restart` command to // restart one or more ILLA Builder #[derive(Debug, Args)] #[clap(group( ArgGroup::new("restart") .required(true) .args(&["self_host", "cloud"]), ))] /// Restart one or more ILLA Builder pub struct Cmd { /// Restart Self-hosted ILLA Builder #[clap(short = 'S', long = "self", action = SetTrue)] self_host: bool, /// Restart ILLA Builder on ILLA Cloud #[clap(short = 'C', long = "cloud", action = SetTrue)] cloud: bool, } impl Cmd { pub async fn run(&self) -> Result { let (self_host, cloud) = (self.self_host, self.cloud); match (self_host, cloud) { (true, _) => restart_local().await?, (_, true) => println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND), _ => unreachable!(), }; Ok(()) } } async fn restart_local() -> Result { println!("{} Trying to restart the ILLA Builder...", ui::emoji::BUILD); let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, style("Please check the status of docker with command: docker info").red(), String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), style("https://docs.docker.com/engine/install/").blue(), String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } let options = Some(RestartContainerOptions { t: 30 }); let stop_builder = _docker.restart_container("illa_builder", options).await; if stop_builder.is_err() { println!( "{} {} {}", ui::emoji::FAIL, String::from("Try to restart ILLA Builder error:"), style(stop_builder.err().unwrap()).red(), ); process::exit(1); } println!( "{} {}", ui::emoji::SUCCESS, style("Successfully restart the ILLA Builder.").green(), ); Ok(()) } ================================================ FILE: src/command/stop.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use bollard::{container::StopContainerOptions, Docker}; use clap::{ArgAction::SetTrue, ArgGroup, Args}; use console::style; use std::process; // Executes the `illa stop` command to // stop one or more ILLA Builder #[derive(Debug, Args)] #[clap(group( ArgGroup::new("stop") .required(true) .args(&["self_host", "cloud"]), ))] /// Stop one or more ILLA Builder pub struct Cmd { /// Stop Self-hosted ILLA Builder #[clap(short = 'S', long = "self", action = SetTrue)] self_host: bool, /// Stop ILLA Builder on ILLA Cloud #[clap(short = 'C', long = "cloud", action = SetTrue)] cloud: bool, } impl Cmd { pub async fn run(&self) -> Result { let (self_host, cloud) = (self.self_host, self.cloud); match (self_host, cloud) { (true, _) => stop_local().await?, (_, true) => println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND), _ => unreachable!(), }; Ok(()) } } async fn stop_local() -> Result { println!("{} Trying to stop the ILLA Builder...", ui::emoji::BUILD); let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, style("Please check the status of docker with command: docker info").red(), String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), style("https://docs.docker.com/engine/install/").blue(), String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } let options = Some(StopContainerOptions { t: 30 }); let stop_builder = _docker.stop_container("illa_builder", options).await; if stop_builder.is_err() { println!( "{} {} {}", ui::emoji::FAIL, String::from("Try to stop ILLA Builder error:"), style(stop_builder.err().unwrap()).red(), ); process::exit(1); } println!( "{} {}", ui::emoji::SUCCESS, style("Successfully stop the ILLA Builder.").green(), ); Ok(()) } ================================================ FILE: src/command/ui/emoji.rs ================================================ use console::Emoji; pub static LOOKING_GLASS: Emoji<'_, '_> = Emoji("🔍 ", ""); pub static SUCCESS: Emoji<'_, '_> = Emoji("✅ ", ""); pub static FAIL: Emoji<'_, '_> = Emoji("❌ ", ""); pub static SPARKLE: Emoji<'_, '_> = Emoji("✨ ", ""); pub static WARN: Emoji<'_, '_> = Emoji("❗️ ", ""); pub static BUILD: Emoji<'_, '_> = Emoji("🔨 ", ""); pub static DIAMOND: Emoji<'_, '_> = Emoji("💎 ", ""); ================================================ FILE: src/command/ui/mod.rs ================================================ pub mod emoji; ================================================ FILE: src/command/update.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use bollard::{ container::{ Config, CreateContainerOptions, InspectContainerOptions, ListContainersOptions, RemoveContainerOptions, StartContainerOptions, StatsOptions, }, image::CreateImageOptions, models::{HostConfig, Mount, MountTypeEnum}, Docker, }; use clap::{builder, ArgAction::SetTrue, ArgGroup, Args}; use console::style; use futures_util::{StreamExt, TryStreamExt}; use indicatif::{HumanDuration, MultiProgress, ProgressBar, ProgressStyle}; use std::{ collections::HashMap, process, thread, time::{Duration, Instant}, }; // Executes the `illa update` command to // update the ILLA Builder with the latest docker image #[derive(Debug, Args)] #[clap(group( ArgGroup::new("update") .required(true) .args(&["self_host", "cloud"]), ))] /// Update ILLA Builder pub struct Cmd { /// Update Self-hosted ILLA Builder #[clap(short = 'S', long = "self", action = SetTrue)] self_host: bool, /// Update ILLA Builder on ILLA Cloud #[clap(short = 'C', long = "cloud", action = SetTrue)] cloud: bool, } impl Cmd { pub async fn run(&self) -> Result { let spinner_style = ProgressStyle::with_template("{spinner} {wide_msg}") .unwrap() .tick_strings(&["🔸 ", "🔶 ", "🟠 ", "🟠 ", "🔶 "]); let (self_host, cloud) = (self.self_host, self.cloud); match (self_host, cloud) { (true, _) => update_local(spinner_style.clone()).await?, (_, true) => println!("{} Looking forward to onboarding you!", ui::emoji::DIAMOND), _ => unreachable!(), }; Ok(()) } } async fn update_local(progress_style: ProgressStyle) -> Result { println!( "{} Updating the ILLA Builder with the latest docker image...", ui::emoji::BUILD ); let _docker = Docker::connect_with_local_defaults().unwrap(); if (_docker.ping().await).is_err() { println!( "{} {}\n{} {}\n\n{}\n\n{}\n\n{}\n", ui::emoji::FAIL, String::from("No running docker found."), ui::emoji::WARN, style("Please check the status of docker with command: docker info").red(), String::from("If you do not have Docker installed, please refer to the following content for instructions on how to install it: "), style("https://docs.docker.com/engine/install/").blue(), String::from("Once Docker is installed, please try running the command again."), ); process::exit(1); } let m = MultiProgress::new(); let finish_spinner_style = ProgressStyle::with_template("{wide_msg}").unwrap(); let pb_setup = m.add(ProgressBar::new(0)); pb_setup.set_style(progress_style.clone()); for _ in 0..10 { pb_setup.set_message("Initializing..."); pb_setup.inc(1); thread::sleep(Duration::from_millis(200)); } let inspect_options = Some(InspectContainerOptions { size: false }); let builder_detail = &_docker .inspect_container("illa_builder", inspect_options) .await; if builder_detail.is_err() { println!( "{} {}\n", ui::emoji::FAIL, String::from("No ILLA Builder found."), ); process::exit(1); } let builder_info = builder_detail.as_ref().unwrap(); let builder_env_cp = &builder_info.config.as_ref().unwrap().env.clone().unwrap(); let builder_env = vec![ builder_env_cp[0].as_str(), builder_env_cp[1].as_str(), builder_env_cp[2].as_str(), ]; let builder_mount_cp = &builder_info .host_config .as_ref() .unwrap() .mounts .clone() .unwrap(); let mounts = vec![Mount { target: Some("/opt/illa/database".to_string()), source: Some(builder_mount_cp[0].source.clone().unwrap()), typ: Some(MountTypeEnum::BIND), read_only: Some(false), ..Default::default() }]; let mut builder_labels = HashMap::new(); builder_labels.insert("maintainer", "opensource@illasoft.com"); builder_labels.insert("license", "Apache-2.0"); let builder_port_bindings = builder_info .host_config .as_ref() .unwrap() .port_bindings .clone(); let port = builder_port_bindings .clone() .unwrap() .get("2022/tcp") .unwrap() .clone(); pb_setup.set_style(finish_spinner_style.clone()); pb_setup.finish_with_message(format!("{} Setup complete", ui::emoji::SUCCESS)); let pb_rm = m.add(ProgressBar::new(0)); pb_rm.set_style(progress_style.clone()); for _ in 0..10 { pb_rm.set_message("Removing ILLA Builder..."); pb_rm.inc(1); thread::sleep(Duration::from_millis(200)); } let rm_options = Some(RemoveContainerOptions { force: true, ..Default::default() }); let stop_builder = _docker.remove_container("illa_builder", rm_options).await; if stop_builder.is_err() { println!( "{} {} {}", ui::emoji::FAIL, String::from("Try to remove ILLA Builder error:"), style(stop_builder.err().unwrap()).red(), ); process::exit(1); } pb_rm.set_style(finish_spinner_style.clone()); pb_rm.finish_with_message(format!( "{} {}", ui::emoji::SUCCESS, style("Successfully remove the old ILLA Builder."), )); let pb_download = m.add(ProgressBar::new(0)); pb_download.set_style(progress_style.clone()); let builder_image = "illasoft/illa-builder:latest"; let download_started = Instant::now(); let stream_list = &mut _docker.create_image( Some(CreateImageOptions { from_image: builder_image, ..Default::default() }), None, None, ); while let Some(value) = stream_list.next().await { pb_download.set_message(format!("Downloading {builder_image}...")); pb_download.inc(1); thread::sleep(Duration::from_millis(100)); if value.is_err() { pb_download.set_style(finish_spinner_style.clone()); pb_download.finish_with_message(format!( "{} {} {}", ui::emoji::FAIL, String::from("Download image error:"), style(value.err().unwrap()).red(), )); process::exit(1); }; } pb_download.set_style(finish_spinner_style.clone()); pb_download.finish_with_message(format!( "{} Downloaded in {}", ui::emoji::SUCCESS, HumanDuration(download_started.elapsed()) )); let pb_deploy = m.add(ProgressBar::new(0)); pb_deploy.set_style(progress_style.clone()); let builder_config = Config { image: Some(builder_image), env: Some(builder_env), labels: Some(builder_labels), host_config: Some(HostConfig { port_bindings: builder_port_bindings.clone(), mounts: Some(mounts), ..Default::default() }), ..Default::default() }; let create_builder = &_docker .create_container( Some(CreateContainerOptions { name: "illa_builder", }), builder_config, ) .await; let start_builder = &_docker .start_container("illa_builder", None::>) .await; match (create_builder.is_err(), start_builder.is_err()) { (true, _) => { pb_deploy.set_style(finish_spinner_style.clone()); pb_deploy.finish_with_message(format!( "{} {} {}", ui::emoji::FAIL, String::from("Create ILLA Builder error:"), style(create_builder.as_ref().err().unwrap()).red(), )); process::exit(1); } (false, true) => { pb_deploy.set_style(finish_spinner_style.clone()); pb_deploy.finish_with_message(format!( "{} {} {}", ui::emoji::FAIL, String::from("Start ILLA Builder error:"), style(start_builder.as_ref().err().unwrap()).red(), )); process::exit(1); } _ => { pb_deploy.set_style(finish_spinner_style.clone()); pb_deploy.finish_with_message(format!( "{} {} {}", ui::emoji::SPARKLE, String::from("ILLA Builder started, please visit"), style(format!( "{}:{}", "http://localhost", port.clone() .unwrap() .get(0) .unwrap() .host_port .as_ref() .unwrap() )) .blue(), )); process::exit(0); } }; Ok(()) } ================================================ FILE: src/command/utils.rs ================================================ use crate::{command::*, result::Result}; use anyhow::Ok; use dirs; use std::{env, fs}; #[cfg(target_os = "macos")] pub fn local_bind_init(path: &String) -> String { use std::os::unix::fs::PermissionsExt; fs::create_dir_all(path.clone()); let attr = fs::metadata(path.clone()).unwrap(); let mut perms = attr.permissions(); perms.set_mode(0o777); fs::set_permissions(path.clone(), perms); String::from(path) } #[cfg(target_os = "windows")] pub fn local_bind_init(path: &String) -> String { fs::create_dir_all(path.clone()); String::from(path) } #[cfg(target_os = "linux")] pub fn local_bind_init(path: &String) -> String { fs::create_dir_all(path.clone()); String::from(path) } pub fn local_bind_delete(path: String) -> Result { fs::remove_dir_all(path); Ok(()) } pub fn get_default_mount() -> String { let tmp_dir = dirs::home_dir().unwrap(); let temp_dir = tmp_dir.join(".illa-builder"); temp_dir.display().to_string() } ================================================ FILE: src/lib.rs ================================================ pub mod command; pub mod result; ================================================ FILE: src/main.rs ================================================ #![allow(unused)] use clap::{Parser, Subcommand}; use illa::{ command::{deploy, doctor, list, remove, restart, stop, update}, result::Result, }; use std::process; #[derive(Debug, Parser)] #[clap(name = "illa")] #[clap(version)] /// Deploy a modern low-code platform in 5 Seconds! struct Cli { #[clap(subcommand)] cmd: Cmds, } #[derive(Debug, Subcommand)] enum Cmds { List(list::Cmd), Stop(stop::Cmd), Doctor(doctor::Cmd), Deploy(deploy::Cmd), Remove(remove::Cmd), Update(update::Cmd), Restart(restart::Cmd), } #[tokio::main] async fn main() { let cli = Cli::parse(); if let Err(e) = run(cli).await { eprintln!("error: {e:?}"); process::exit(1); } } async fn run(cli: Cli) -> Result { match cli.cmd { Cmds::List(cmd) => cmd.run().await, Cmds::Stop(cmd) => cmd.run().await, Cmds::Doctor(cmd) => cmd.run().await, Cmds::Deploy(cmd) => cmd.run().await, Cmds::Remove(cmd) => cmd.run().await, Cmds::Update(cmd) => cmd.run().await, Cmds::Restart(cmd) => cmd.run().await, } } ================================================ FILE: src/result.rs ================================================ pub type Result = anyhow::Result; pub type Error = anyhow::Error; pub use anyhow::{anyhow, bail};