diff --git a/.NOTICE.template b/.NOTICE.template new file mode 100644 index 00000000..b4ef2ac9 --- /dev/null +++ b/.NOTICE.template @@ -0,0 +1,12 @@ +Codesphere Go SDK & CLI +Copyright (c) Codesphere Inc. + +This project includes code licensed under the following terms: +{{ range . }} {{ if eq .Name "github.com/codesphere-cloud/oms" }} {{ continue }} {{ end }} +---------- +Module: {{ .Name }} +Version: {{ .Version }} +License: {{ .LicenseName }} +License URL: {{ .LicenseURL }} +{{ end }} + diff --git a/.copywrite.hcl b/.copywrite.hcl new file mode 100644 index 00000000..9c362ca0 --- /dev/null +++ b/.copywrite.hcl @@ -0,0 +1,15 @@ +schema_version = 1 + +project { + license = "Apache-2.0" + copyright_year = 2025 + copyright_holder = "Codesphere Inc." + + # (OPTIONAL) A list of globs that should not have copyright/license headers. + # Supports doublestar glob patterns for more flexibility in defining which + # files or folders should be ignored + header_ignore = [ + # "vendor/**", + # "**autogen**", + ] +} diff --git a/.github/dco.yml b/.github/dco.yml new file mode 100644 index 00000000..9b70506d --- /dev/null +++ b/.github/dco.yml @@ -0,0 +1,5 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + +require: + members: false diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a8919cec..b1c8a766 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,3 +1,6 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + version: 2 before: diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..5f1f64d8 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ +# 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, caste, color, 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 email 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 +[INSERT CONTACT METHOD]. +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.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..e8568653 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,132 @@ +# Contributing to Codesphere OMS + +We welcome contributions of all kinds! By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). + +## How to Report Issues + +If you encounter a bug or have a feature request, please [open a new issue](https://github.com/codesphere-cloud/oms/issues/new) on GitHub. Please include the following information: + +* **Operating System and Version:** +* **OMS Version (if applicable):** +* **Steps to Reproduce the Bug:** +* **Expected Behavior:** +* **Actual Behavior:** +* **Any relevant logs or error messages:** + +## How to Suggest Features or Improvements + +We'd love to hear your ideas! Please [open a new issue](https://github.com/codesphere-cloud/oms/issues/new) to discuss your proposed feature or improvement before submitting code. This allows us to align on the design and approach. + +## How to Add a New Subcommand to the CLI + +This project currently uses a fork of cobra-cli with locally-scoped variables: https://github.com/NautiluX/cobra-cli-local. + +Please use it to add new commands to the OMS CLI like following: + +``` +cobra-cli add -c false -L -d cli -p install component +``` + +Run the generated `AddInstallComponent()` function in the parent `cli/cmd/install.go` to add the subcommand. +This will add the following command to the CLI: + +``` +oms-cli install component +``` + +## Contributing Code + +If you'd like to contribute code, please follow these steps: + +1. **Fork the Repository:** Fork this repository to your GitHub account. +2. **Create a Branch:** Create a new branch for your changes: `git checkout -b feature/your-feature-name` +3. **Set Up Development Environment:** + + * Ensure you have Go installed. The minimum required Go version is specified in the `go.mod` file. + * Clone your forked repository: `git clone git@github.com:your-username/oms.git` + * Navigate to the project directory: `cd oms` + * Run `make`: This command should download necessary dependencies and build the CLI. + +4. **Follow Coding Standards:** + + * Please ensure your code is properly formatted using `go fmt`. + * We use [golangci-lint](https://golangci-lint.run/) for static code analysis. Please run it locally before submitting a pull request: `make lint`. + +5. **Write Tests:** + + * We use [Ginkgo](https://github.com/onsi/ginkgo) and [Gomega](https://github.com/onsi/gomega) for testing. + * Please write tests for your code using Ginkgo and Gomega and add them to the `_test.go` files. + * Aim for good test coverage. + +6. **Build and Test:** + + * Ensure everything is working correctly by running the appropriate `make` targets (e.g., `make build`, `make test`). The `make test` target should run the Ginkgo tests. + +7. **Commit Your Changes:** + + * We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for our commit messages. Please format your commit messages according to the Conventional Commits specification. Examples: + * `fix(api): Handle edge case in API client` + * `feat(cli): Add new command for listing resources` + * `docs: Update contributing guide with commit message conventions` + * **Developer Certificate of Origin (DCO)** + + In order to contribute to this project, you must agree to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). This is a simple statement that you, as a contributor, have the right to submit the code you are contributing. + + ```text + Developer's Certificate of Origin 1.1 + + By making a contribution to this project, I certify that: + + (a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + + (b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, or solely by me; or + + (c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + + (d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it) is maintained indefinitely + and may be redistributed consistent with this project or the + open source license(s) involved. + ``` + + To indicate that you accept the DCO, you must add a `Signed-off-by` line to each of your commit messages. Here's an example: + + ``` + Fix: Handle edge case in API client + + This commit fixes a bug where the API client would crash when receiving + an empty response. + + Signed-off-by: John Doe + ``` + + You can add this line to your commit message using the `-s` flag with the `git commit` command: + + ```bash + git commit -s -m "Your commit message" + ``` + +8. **Submit a Pull Request:** [Open a new pull request](https://github.com/codesphere-cloud/oms/compare) to the `main` branch of this repository. Please include a clear description of your changes and reference any related issues. + +## Code Review Process + +All contributions will be reviewed by project maintainers. Please be patient during the review process and be prepared to make revisions based on feedback. We aim for thorough but timely reviews. + +## License + +By contributing to Codesphere OMS, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE). + +## Community + +Connect with the community and ask questions by joining our mailing list: [oms@codesphere.com](mailto:oms@codesphere.com). + +Thank you for your interest in contributing to Codesphere OMS! diff --git a/LICENSE b/LICENSE index 2efa0dc1..b36a7f2c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,203 @@ -/* -Copyright © 2025 Codesphere Inc. -*/ +Copyright (c) 2025 Codesphere Inc. + +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 2025 Codesphere 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. diff --git a/Makefile b/Makefile index 96d50f18..23663575 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,12 @@ endif ifeq (, $(shell which golangci-lint)) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.2 endif +ifeq (, $(shell which go-licenses)) + go install github.com/google/go-licenses@v1.6.0 +endif +ifeq (, $(shell which copywrite)) + go install github.com/hashicorp/copywrite@v0.22.0 +endif generate: install-build-deps mockery @@ -38,3 +44,14 @@ VERSION ?= "0.0.0" release-local: rm -rf dist /bin/bash -c "goreleaser --skip=validate,announce,publish -f <(sed s/{{.Version}}/$(VERSION)/g < .goreleaser.yaml)" + +.PHONY: docs +docs: + rm -rf docs + mkdir docs + go run -ldflags="-X 'github.com/codesphere-cloud/oms/internal/version.binName=oms-cli'" hack/gendocs/main.go + cp docs/oms.md docs/README.md + +generate-license: generate + go-licenses report --template .NOTICE.template ./... > NOTICE + copywrite headers apply diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..c784327d --- /dev/null +++ b/NOTICE @@ -0,0 +1,126 @@ +Codesphere Go SDK & CLI +Copyright (c) Codesphere Inc. + +This project includes code licensed under the following terms: + +---------- +Module: github.com/blang/semver +Version: v3.5.1 +License: MIT +License URL: https://github.com/blang/semver/blob/v3.5.1/LICENSE + +---------- +Module: github.com/codesphere-cloud/cs-go/pkg/io +Version: v0.10.1 +License: Apache-2.0 +License URL: https://github.com/codesphere-cloud/cs-go/blob/v0.10.1/LICENSE + +---------- +Module: github.com/codesphere-cloud/oms +Version: Unknown +License: Apache-2.0 +License URL: https://github.com/codesphere-cloud/oms/blob/HEAD/LICENSE + +---------- +Module: github.com/cpuguy83/go-md2man/v2/md2man +Version: v2.0.6 +License: MIT +License URL: https://github.com/cpuguy83/go-md2man/blob/v2.0.6/LICENSE.md + +---------- +Module: github.com/davecgh/go-spew/spew +Version: v1.1.2-0.20180830191138-d8f796af33cc +License: ISC +License URL: https://github.com/davecgh/go-spew/blob/d8f796af33cc/LICENSE + +---------- +Module: github.com/inconshreveable/go-update +Version: v0.0.0-20160112193335-8152e7eb6ccf +License: Apache-2.0 +License URL: https://github.com/inconshreveable/go-update/blob/8152e7eb6ccf/LICENSE + +---------- +Module: github.com/inconshreveable/go-update/internal/binarydist +Version: v0.0.0-20160112193335-8152e7eb6ccf +License: MIT +License URL: https://github.com/inconshreveable/go-update/blob/8152e7eb6ccf/internal/binarydist/License + +---------- +Module: github.com/inconshreveable/go-update/internal/osext +Version: v0.0.0-20160112193335-8152e7eb6ccf +License: BSD-3-Clause +License URL: https://github.com/inconshreveable/go-update/blob/8152e7eb6ccf/internal/osext/LICENSE + +---------- +Module: github.com/jedib0t/go-pretty/v6 +Version: v6.6.7 +License: MIT +License URL: https://github.com/jedib0t/go-pretty/blob/v6.6.7/LICENSE + +---------- +Module: github.com/mattn/go-runewidth +Version: v0.0.16 +License: MIT +License URL: https://github.com/mattn/go-runewidth/blob/v0.0.16/LICENSE + +---------- +Module: github.com/pmezard/go-difflib/difflib +Version: v1.0.1-0.20181226105442-5d4384ee4fb2 +License: BSD-3-Clause +License URL: https://github.com/pmezard/go-difflib/blob/5d4384ee4fb2/LICENSE + +---------- +Module: github.com/rivo/uniseg +Version: v0.4.7 +License: MIT +License URL: https://github.com/rivo/uniseg/blob/v0.4.7/LICENSE.txt + +---------- +Module: github.com/russross/blackfriday/v2 +Version: v2.1.0 +License: BSD-2-Clause +License URL: https://github.com/russross/blackfriday/blob/v2.1.0/LICENSE.txt + +---------- +Module: github.com/spf13/cobra +Version: v1.9.1 +License: Apache-2.0 +License URL: https://github.com/spf13/cobra/blob/v1.9.1/LICENSE.txt + +---------- +Module: github.com/spf13/pflag +Version: v1.0.6 +License: BSD-3-Clause +License URL: https://github.com/spf13/pflag/blob/v1.0.6/LICENSE + +---------- +Module: github.com/stretchr/objx +Version: v0.5.2 +License: MIT +License URL: https://github.com/stretchr/objx/blob/v0.5.2/LICENSE + +---------- +Module: github.com/stretchr/testify +Version: v1.10.0 +License: MIT +License URL: https://github.com/stretchr/testify/blob/v1.10.0/LICENSE + +---------- +Module: golang.org/x/sync/errgroup +Version: v0.16.0 +License: BSD-3-Clause +License URL: https://cs.opensource.google/go/x/sync/+/v0.16.0:LICENSE + +---------- +Module: golang.org/x/text +Version: v0.28.0 +License: BSD-3-Clause +License URL: https://cs.opensource.google/go/x/text/+/v0.28.0:LICENSE + +---------- +Module: gopkg.in/yaml.v3 +Version: v3.0.1 +License: MIT +License URL: https://github.com/go-yaml/yaml/blob/v3.0.1/LICENSE + + diff --git a/cli/cmd/cmd_suite_test.go b/cli/cmd/cmd_suite_test.go index 0278cc0c..bff03295 100644 --- a/cli/cmd/cmd_suite_test.go +++ b/cli/cmd/cmd_suite_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd_test import ( diff --git a/cli/cmd/download.go b/cli/cmd/download.go index 0c05bd8c..ab79bc3b 100644 --- a/cli/cmd/download.go +++ b/cli/cmd/download.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/download_package.go b/cli/cmd/download_package.go index 367243a7..a3ceb0da 100644 --- a/cli/cmd/download_package.go +++ b/cli/cmd/download_package.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/download_package_test.go b/cli/cmd/download_package_test.go index cb9bce2f..b76b0d7d 100644 --- a/cli/cmd/download_package_test.go +++ b/cli/cmd/download_package_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd_test import ( diff --git a/cli/cmd/list.go b/cli/cmd/list.go index 3b702d57..f6961781 100644 --- a/cli/cmd/list.go +++ b/cli/cmd/list.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/list_packages.go b/cli/cmd/list_packages.go index 4fa6e7fb..c58538ec 100644 --- a/cli/cmd/list_packages.go +++ b/cli/cmd/list_packages.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/list_packages_test.go b/cli/cmd/list_packages_test.go index 352ee540..6d9c1a6a 100644 --- a/cli/cmd/list_packages_test.go +++ b/cli/cmd/list_packages_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd_test import ( diff --git a/cli/cmd/register.go b/cli/cmd/register.go index 1f79144e..90754e7f 100644 --- a/cli/cmd/register.go +++ b/cli/cmd/register.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/register_test.go b/cli/cmd/register_test.go index c3b198db..05c31a39 100644 --- a/cli/cmd/register_test.go +++ b/cli/cmd/register_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd_test import ( diff --git a/cli/cmd/revoke.go b/cli/cmd/revoke.go index e13b2b1c..c97f9858 100644 --- a/cli/cmd/revoke.go +++ b/cli/cmd/revoke.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/revoke_test.go b/cli/cmd/revoke_test.go index 8cc17e7d..8fb0b467 100644 --- a/cli/cmd/revoke_test.go +++ b/cli/cmd/revoke_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd_test import ( diff --git a/cli/cmd/root.go b/cli/cmd/root.go index def6fad1..b4877659 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -14,9 +14,8 @@ type GlobalOptions struct { OmsPortalApiKey string } -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute() { +// GetRootCmd adds all child commands to the root command and sets flags appropriately. +func GetRootCmd() *cobra.Command { opts := GlobalOptions{} rootCmd := &cobra.Command{ Use: "oms", @@ -30,8 +29,12 @@ func Execute() { AddUpdateCmd(rootCmd) AddListCmd(rootCmd, opts) AddDownloadCmd(rootCmd, opts) + return rootCmd +} - err := rootCmd.Execute() +// Execute executes the root command. This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + err := GetRootCmd().Execute() if err != nil { os.Exit(1) } diff --git a/cli/cmd/testdata/testcli.tar.gz b/cli/cmd/testdata/testcli.tar.gz index d6c55d64..3c092de0 100644 Binary files a/cli/cmd/testdata/testcli.tar.gz and b/cli/cmd/testdata/testcli.tar.gz differ diff --git a/cli/cmd/update.go b/cli/cmd/update.go index de68a0fd..819d10a0 100644 --- a/cli/cmd/update.go +++ b/cli/cmd/update.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cli/cmd/update_test.go b/cli/cmd/update_test.go index 48287550..c2be6898 100644 --- a/cli/cmd/update_test.go +++ b/cli/cmd/update_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package cmd_test import ( diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 00000000..c90fac99 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,25 @@ +## oms + +Codesphere Operations Management System (OMS) + +### Synopsis + +Codesphere Operations Management System (OMS) + +This command can be used to run common tasks related to managing codesphere installations, +like downloading new versions. + +### Options + +``` + -h, --help help for oms +``` + +### SEE ALSO + +* [oms download](oms_download.md) - Download resources available through OMS +* [oms list](oms_list.md) - List resources available through OMS +* [oms update](oms_update.md) - Update Codesphere OMS +* [oms version](oms_version.md) - Print version + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms.md b/docs/oms.md new file mode 100644 index 00000000..c90fac99 --- /dev/null +++ b/docs/oms.md @@ -0,0 +1,25 @@ +## oms + +Codesphere Operations Management System (OMS) + +### Synopsis + +Codesphere Operations Management System (OMS) + +This command can be used to run common tasks related to managing codesphere installations, +like downloading new versions. + +### Options + +``` + -h, --help help for oms +``` + +### SEE ALSO + +* [oms download](oms_download.md) - Download resources available through OMS +* [oms list](oms_list.md) - List resources available through OMS +* [oms update](oms_update.md) - Update Codesphere OMS +* [oms version](oms_version.md) - Print version + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms_download.md b/docs/oms_download.md new file mode 100644 index 00000000..29728ade --- /dev/null +++ b/docs/oms_download.md @@ -0,0 +1,25 @@ +## oms download + +Download resources available through OMS + +### Synopsis + +Download resources managed by or available for OMS, +e.g. available Codesphere packages + +``` +oms download [flags] +``` + +### Options + +``` + -h, --help help for download +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) +* [oms download package](oms_download_package.md) - Download a codesphere package + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms_download_package.md b/docs/oms_download_package.md new file mode 100644 index 00000000..de640c62 --- /dev/null +++ b/docs/oms_download_package.md @@ -0,0 +1,37 @@ +## oms download package + +Download a codesphere package + +### Synopsis + +Download a specific version of a Codesphere package +To list available packages, run oms list packages. + +``` +oms download package [flags] +``` + +### Examples + +``` +# Download Codesphere version 1.55.0 +$ /var/folders/h2/qdn9mcsx32j2384qdrqyqlkw0000gn/T/go-build3505592854/b001/exe/main download package --version 1.55.0 + +# Download lite package of Codesphere version 1.55.0 +$ /var/folders/h2/qdn9mcsx32j2384qdrqyqlkw0000gn/T/go-build3505592854/b001/exe/main download package --version 1.55.0 --file installer-lite.tar.gz +``` + +### Options + +``` + -f, --file string Specify artifact to download (default "installer.tar.gz") + -H, --hash string Hash of the version to download if multiple builds exist for the same version + -h, --help help for package + -V, --version string Codesphere version to download +``` + +### SEE ALSO + +* [oms download](oms_download.md) - Download resources available through OMS + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms_list.md b/docs/oms_list.md new file mode 100644 index 00000000..f92c44b4 --- /dev/null +++ b/docs/oms_list.md @@ -0,0 +1,21 @@ +## oms list + +List resources available through OMS + +### Synopsis + +List resources managed by or available for OMS, +eg. available Codesphere packages + +### Options + +``` + -h, --help help for list +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) +* [oms list packages](oms_list_packages.md) - List available packages + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms_list_packages.md b/docs/oms_list_packages.md new file mode 100644 index 00000000..e61d1880 --- /dev/null +++ b/docs/oms_list_packages.md @@ -0,0 +1,23 @@ +## oms list packages + +List available packages + +### Synopsis + +List packages available for download via the OMS portal. + +``` +oms list packages [flags] +``` + +### Options + +``` + -h, --help help for packages +``` + +### SEE ALSO + +* [oms list](oms_list.md) - List resources available through OMS + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms_update.md b/docs/oms_update.md new file mode 100644 index 00000000..1d05476a --- /dev/null +++ b/docs/oms_update.md @@ -0,0 +1,23 @@ +## oms update + +Update Codesphere OMS + +### Synopsis + +Updates the OMS to the latest release from OMS Portal. + +``` +oms update [flags] +``` + +### Options + +``` + -h, --help help for update +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/docs/oms_version.md b/docs/oms_version.md new file mode 100644 index 00000000..1770d52b --- /dev/null +++ b/docs/oms_version.md @@ -0,0 +1,23 @@ +## oms version + +Print version + +### Synopsis + +Print current version of OMS. + +``` +oms version [flags] +``` + +### Options + +``` + -h, --help help for version +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) + +###### Auto generated by spf13/cobra on 19-Sep-2025 diff --git a/go.mod b/go.mod index 7e2ca2a5..9a283aea 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( ) require ( + github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect @@ -26,6 +27,7 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/stretchr/objx v0.5.2 // indirect go.uber.org/automaxprocs v1.6.0 // indirect diff --git a/go.sum b/go.sum index 9275ba3c..bd3a32cc 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/codesphere-cloud/cs-go v0.10.1 h1:QhiBKYkBlAeephPKfl0AY18MLGNdcY2uAjvncu7ezq8= github.com/codesphere-cloud/cs-go v0.10.1/go.mod h1:lJENk49WB9ZIGeZdZdzERYlCxlpL1FNcN8oj/NjgUfw= +github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -44,6 +45,7 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= diff --git a/hack/gendocs/main.go b/hack/gendocs/main.go new file mode 100644 index 00000000..edebc09b --- /dev/null +++ b/hack/gendocs/main.go @@ -0,0 +1,18 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + "log" + + oms "github.com/codesphere-cloud/oms/cli/cmd" + "github.com/spf13/cobra/doc" +) + +func main() { + err := doc.GenMarkdownTree(oms.GetRootCmd(), "docs") + if err != nil { + log.Fatal(err) + } +} diff --git a/internal/env/env.go b/internal/env/env.go index cd1156f7..75470419 100644 --- a/internal/env/env.go +++ b/internal/env/env.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package env import ( diff --git a/internal/internal_suite_test.go b/internal/internal_suite_test.go index c82b65ad..6acfc44a 100644 --- a/internal/internal_suite_test.go +++ b/internal/internal_suite_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package internal_test import ( diff --git a/internal/portal/http.go b/internal/portal/http.go index 3afc1d54..77842a99 100644 --- a/internal/portal/http.go +++ b/internal/portal/http.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal import ( diff --git a/internal/portal/http_test.go b/internal/portal/http_test.go index 60add015..a4981ba9 100644 --- a/internal/portal/http_test.go +++ b/internal/portal/http_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal_test import ( diff --git a/internal/portal/package.go b/internal/portal/package.go index 15d41540..9f3d1185 100644 --- a/internal/portal/package.go +++ b/internal/portal/package.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal import ( diff --git a/internal/portal/package_test.go b/internal/portal/package_test.go index 6d614759..10bfd761 100644 --- a/internal/portal/package_test.go +++ b/internal/portal/package_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal_test import ( diff --git a/internal/portal/portal_suite_test.go b/internal/portal/portal_suite_test.go index c8032732..09ab247f 100644 --- a/internal/portal/portal_suite_test.go +++ b/internal/portal/portal_suite_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal_test import ( diff --git a/internal/portal/write_counter.go b/internal/portal/write_counter.go index 5bd79969..81c01721 100644 --- a/internal/portal/write_counter.go +++ b/internal/portal/write_counter.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal import ( diff --git a/internal/util/filewriter.go b/internal/util/filewriter.go index 733f70f7..c6cbb1ab 100644 --- a/internal/util/filewriter.go +++ b/internal/util/filewriter.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package util import "os" diff --git a/internal/util/table.go b/internal/util/table.go index 3aa6f097..cdb98715 100644 --- a/internal/util/table.go +++ b/internal/util/table.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package util import ( diff --git a/internal/util/tar.go b/internal/util/tar.go index 768bc43c..14b1c84d 100644 --- a/internal/util/tar.go +++ b/internal/util/tar.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package util import ( diff --git a/internal/util/tar_test.go b/internal/util/tar_test.go index 8a112013..02978419 100644 --- a/internal/util/tar_test.go +++ b/internal/util/tar_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package util_test import ( diff --git a/internal/util/testdata/testdata1.tar.gz b/internal/util/testdata/testdata1.tar.gz index f68266a7..83539149 100644 Binary files a/internal/util/testdata/testdata1.tar.gz and b/internal/util/testdata/testdata1.tar.gz differ diff --git a/internal/util/util_suite_test.go b/internal/util/util_suite_test.go index 6d6903e9..f15d7535 100644 --- a/internal/util/util_suite_test.go +++ b/internal/util/util_suite_test.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package util_test import ( diff --git a/internal/version/version.go b/internal/version/version.go index 39023c4e..ecd0fd42 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package version // Variables are injected by goreleaser on release @@ -7,6 +10,7 @@ var ( date string = "unknown" os string = "unknown" arch string = "unknown" + binName string = "oms-cli" ) type Version interface { @@ -38,3 +42,7 @@ func (b *Build) Os() string { func (b *Build) Arch() string { return arch } + +func (b *Build) BinName() string { + return binName +}