diff --git a/.github/workflows/cli-build_test.yml b/.github/workflows/cli-build_test.yml index ea4d33c1..242e8818 100644 --- a/.github/workflows/cli-build_test.yml +++ b/.github/workflows/cli-build_test.yml @@ -1,3 +1,6 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml index 14e37f2a..29e0d01b 100644 --- a/.github/workflows/go-lint.yml +++ b/.github/workflows/go-lint.yml @@ -1,3 +1,6 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + name: golangci-lint on: push: diff --git a/.github/workflows/service-build_test.yml b/.github/workflows/service-build_test.yml index 101190b1..e1d95753 100644 --- a/.github/workflows/service-build_test.yml +++ b/.github/workflows/service-build_test.yml @@ -1,3 +1,6 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + # This workflow will build a golang project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml index d17de3a6..4aab3d22 100644 --- a/.github/workflows/tag-release.yml +++ b/.github/workflows/tag-release.yml @@ -1,3 +1,6 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + name: Tag on: diff --git a/.github/workflows/update-docs-and-licenses.yml b/.github/workflows/update-docs-and-licenses.yml new file mode 100644 index 00000000..51106dd6 --- /dev/null +++ b/.github/workflows/update-docs-and-licenses.yml @@ -0,0 +1,42 @@ +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + +name: 'Auto-Update Docs & Licenses' + +permissions: + contents: write + +on: + pull_request: + types: [opened, synchronize] + push: + branches: + - main + +jobs: + update-files: + # skip runs triggered by the bot's own commit to avoid loops + if: github.actor != 'github-actions[bot]' + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + # on push to main, use main; on PR, check out the PR head + ref: ${{ github.event.pull_request.head.ref || github.ref }} + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Update docs & licenses + run: | + ./hack/update-docs-and-licenses.sh + + - name: Amend last commit with auto-generated changes + run: | + if [ -n "$(git status --porcelain)" ]; then + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add . + git commit --amend --no-edit --signoff + git push --force-with-lease origin ${{ github.event.pull_request.head.ref || github.ref_name }} + fi diff --git a/docs/oms.md b/docs/oms.md index c90fac99..b1478448 100644 --- a/docs/oms.md +++ b/docs/oms.md @@ -17,9 +17,12 @@ like downloading new versions. ### SEE ALSO +* [oms beta](oms_beta.md) - Commands for early testing * [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 register](oms_register.md) - Register a new API key +* [oms revoke](oms_revoke.md) - Revoke resources available through OMS +* [oms update](oms_update.md) - Update OMS related resources * [oms version](oms_version.md) - Print version -###### Auto generated by spf13/cobra on 19-Sep-2025 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_beta.md b/docs/oms_beta.md new file mode 100644 index 00000000..97fb981a --- /dev/null +++ b/docs/oms_beta.md @@ -0,0 +1,21 @@ +## oms beta + +Commands for early testing + +### Synopsis + +OMS CLI commands for early adoption and testing. +Be aware that that usage and behavior may change as the features are developed. + +### Options + +``` + -h, --help help for beta +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) +* [oms beta extend](oms_beta_extend.md) - Extend Codesphere ressources such as base images. + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_beta_extend.md b/docs/oms_beta_extend.md new file mode 100644 index 00000000..7f598058 --- /dev/null +++ b/docs/oms_beta_extend.md @@ -0,0 +1,20 @@ +## oms beta extend + +Extend Codesphere ressources such as base images. + +### Synopsis + +Extend Codesphere ressources such as base images to customize them for your needs. + +### Options + +``` + -h, --help help for extend +``` + +### SEE ALSO + +* [oms beta](oms_beta.md) - Commands for early testing +* [oms beta extend baseimage](oms_beta_extend_baseimage.md) - Extend Codesphere's workspace base image for customization + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_beta_extend_baseimage.md b/docs/oms_beta_extend_baseimage.md new file mode 100644 index 00000000..704dd207 --- /dev/null +++ b/docs/oms_beta_extend_baseimage.md @@ -0,0 +1,30 @@ +## oms beta extend baseimage + +Extend Codesphere's workspace base image for customization + +### Synopsis + +Loads the baseimage from Codesphere package and generates a Dockerfile based on it. +This enables you to extend Codesphere's base image with specific dependencies. + +To use the custom base image, you need to push the resulting image to your container registry and +reference it in your install-config for the Codesphere installation process to pick it up and include it in Codesphere + +``` +oms beta extend baseimage [flags] +``` + +### Options + +``` + -d, --dockerfile string Output Dockerfile to generate for extending the base image (default "Dockerfile") + -f, --force Enforce package extraction + -h, --help help for baseimage + -p, --package string Package file (e.g. codesphere-v1.2.3-installer.tar.gz) to load base image from +``` + +### SEE ALSO + +* [oms beta extend](oms_beta_extend.md) - Extend Codesphere ressources such as base images. + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_download.md b/docs/oms_download.md index 29728ade..1eedf18e 100644 --- a/docs/oms_download.md +++ b/docs/oms_download.md @@ -7,10 +7,6 @@ Download resources available through OMS Download resources managed by or available for OMS, e.g. available Codesphere packages -``` -oms download [flags] -``` - ### Options ``` @@ -22,4 +18,4 @@ oms download [flags] * [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 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_download_package.md b/docs/oms_download_package.md index de640c62..2046400c 100644 --- a/docs/oms_download_package.md +++ b/docs/oms_download_package.md @@ -15,10 +15,10 @@ oms download package [flags] ``` # Download Codesphere version 1.55.0 -$ /var/folders/h2/qdn9mcsx32j2384qdrqyqlkw0000gn/T/go-build3505592854/b001/exe/main download package --version 1.55.0 +$ /tmp/go-build1735421141/b001/exe/main download package --version codesphere-v1.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 +$ /tmp/go-build1735421141/b001/exe/main download package --version codesphere-v1.55.0 --file installer-lite.tar.gz ``` ### Options @@ -34,4 +34,4 @@ $ /var/folders/h2/qdn9mcsx32j2384qdrqyqlkw0000gn/T/go-build3505592854/b001/exe/m * [oms download](oms_download.md) - Download resources available through OMS -###### Auto generated by spf13/cobra on 19-Sep-2025 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_list.md b/docs/oms_list.md index f92c44b4..84a56737 100644 --- a/docs/oms_list.md +++ b/docs/oms_list.md @@ -16,6 +16,7 @@ eg. available Codesphere packages ### SEE ALSO * [oms](oms.md) - Codesphere Operations Management System (OMS) +* [oms list api-keys](oms_list_api-keys.md) - List API keys * [oms list packages](oms_list_packages.md) - List available packages -###### Auto generated by spf13/cobra on 19-Sep-2025 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_list_api-keys.md b/docs/oms_list_api-keys.md new file mode 100644 index 00000000..3e3b4950 --- /dev/null +++ b/docs/oms_list_api-keys.md @@ -0,0 +1,23 @@ +## oms list api-keys + +List API keys + +### Synopsis + +List API keys registered in the OMS portal. + +``` +oms list api-keys [flags] +``` + +### Options + +``` + -h, --help help for api-keys +``` + +### SEE ALSO + +* [oms list](oms_list.md) - List resources available through OMS + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_list_packages.md b/docs/oms_list_packages.md index e61d1880..f61569b1 100644 --- a/docs/oms_list_packages.md +++ b/docs/oms_list_packages.md @@ -20,4 +20,4 @@ oms list packages [flags] * [oms list](oms_list.md) - List resources available through OMS -###### Auto generated by spf13/cobra on 19-Sep-2025 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_register.md b/docs/oms_register.md new file mode 100644 index 00000000..d015c8d3 --- /dev/null +++ b/docs/oms_register.md @@ -0,0 +1,27 @@ +## oms register + +Register a new API key + +### Synopsis + +Register a new API key for accessing the OMS portal. + +``` +oms register [flags] +``` + +### Options + +``` + -e, --expires string Expiration date of the new API key. Default is 1 year from now. Format: RFC3339 (e.g., 2024-12-31T23:59:59Z) + -h, --help help for register + -g, --organization string Organization of the new API key + -o, --owner string Owner of the new API key + -r, --role string Role of the new API key. Available roles: Admin, Dev, Ext (default "Ext") +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_revoke.md b/docs/oms_revoke.md new file mode 100644 index 00000000..064f605b --- /dev/null +++ b/docs/oms_revoke.md @@ -0,0 +1,21 @@ +## oms revoke + +Revoke resources available through OMS + +### Synopsis + +Revoke resources managed by or available for OMS, +eg. api keys. + +### Options + +``` + -h, --help help for revoke +``` + +### SEE ALSO + +* [oms](oms.md) - Codesphere Operations Management System (OMS) +* [oms revoke api-key](oms_revoke_api-key.md) - Revoke an API key + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_revoke_api-key.md b/docs/oms_revoke_api-key.md new file mode 100644 index 00000000..f18f2228 --- /dev/null +++ b/docs/oms_revoke_api-key.md @@ -0,0 +1,24 @@ +## oms revoke api-key + +Revoke an API key + +### Synopsis + +Revoke an OMS portal API key. + +``` +oms revoke api-key [flags] +``` + +### Options + +``` + -h, --help help for api-key + -i, --id string API key id to revoke +``` + +### SEE ALSO + +* [oms revoke](oms_revoke.md) - Revoke resources available through OMS + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_update.md b/docs/oms_update.md index 1d05476a..306be3bf 100644 --- a/docs/oms_update.md +++ b/docs/oms_update.md @@ -1,10 +1,10 @@ ## oms update -Update Codesphere OMS +Update OMS related resources ### Synopsis -Updates the OMS to the latest release from OMS Portal. +Updates resources, e.g. OMS or OMS API keys. ``` oms update [flags] @@ -19,5 +19,8 @@ oms update [flags] ### SEE ALSO * [oms](oms.md) - Codesphere Operations Management System (OMS) +* [oms update api-key](oms_update_api-key.md) - Update an API key's expiration date +* [oms update oms](oms_update_oms.md) - Update the OMS CLI +* [oms update package](oms_update_package.md) - Download a codesphere package -###### Auto generated by spf13/cobra on 19-Sep-2025 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_update_api-key.md b/docs/oms_update_api-key.md new file mode 100644 index 00000000..57d2b6f4 --- /dev/null +++ b/docs/oms_update_api-key.md @@ -0,0 +1,25 @@ +## oms update api-key + +Update an API key's expiration date + +### Synopsis + +Updates the expiration date for a given API key using the --id and --valid-to flags. + +``` +oms update api-key [flags] +``` + +### Options + +``` + -h, --help help for api-key + -i, --id string The ID of the API key to update + -v, --valid-to string The new expiration date in RFC3339 format (e.g., "2025-12-31T23:59:59Z") +``` + +### SEE ALSO + +* [oms update](oms_update.md) - Update OMS related resources + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_update_oms.md b/docs/oms_update_oms.md new file mode 100644 index 00000000..4a70fac0 --- /dev/null +++ b/docs/oms_update_oms.md @@ -0,0 +1,23 @@ +## oms update oms + +Update the OMS CLI + +### Synopsis + +Updates the OMS CLI to the latest release from OMS Portal. + +``` +oms update oms [flags] +``` + +### Options + +``` + -h, --help help for oms +``` + +### SEE ALSO + +* [oms update](oms_update.md) - Update OMS related resources + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_update_package.md b/docs/oms_update_package.md new file mode 100644 index 00000000..8eeb88a3 --- /dev/null +++ b/docs/oms_update_package.md @@ -0,0 +1,37 @@ +## oms update package + +Download a codesphere package + +### Synopsis + +Download a specific version of a Codesphere package +To list available packages, run oms list packages. + +``` +oms update package [flags] +``` + +### Examples + +``` +# Download Codesphere version 1.55.0 +$ /tmp/go-build1735421141/b001/exe/main download package --version codesphere-v1.55.0 + +# Download lite package of Codesphere version 1.55.0 +$ /tmp/go-build1735421141/b001/exe/main download package --version codesphere-v1.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 update](oms_update.md) - Update OMS related resources + +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/docs/oms_version.md b/docs/oms_version.md index 1770d52b..f6a3f274 100644 --- a/docs/oms_version.md +++ b/docs/oms_version.md @@ -20,4 +20,4 @@ oms version [flags] * [oms](oms.md) - Codesphere Operations Management System (OMS) -###### Auto generated by spf13/cobra on 19-Sep-2025 +###### Auto generated by spf13/cobra on 14-Oct-2025 diff --git a/hack/update-docs-and-licenses.sh b/hack/update-docs-and-licenses.sh new file mode 100755 index 00000000..c9b01837 --- /dev/null +++ b/hack/update-docs-and-licenses.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Copyright (c) Codesphere Inc. +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail +IFS=$'\n\t' + +here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +root=$(cd "$here/.." && pwd) + +echo "Working directory: $root" + +cd "$root" + +echo "1/2: Generating docs" + +if command -v go >/dev/null 2>&1; then + go run ./hack/gendocs/main.go + echo "Docs generated into: $root/docs" +else + echo "ERROR: 'go' binary not found in PATH. Install Go and retry." >&2 + exit 2 +fi + +echo "2/2: Updating licenses" + +echo "Checking license tooling: go-licenses + addlicense" + +export GOBIN="$(go env GOBIN 2>/dev/null || echo "$HOME/go/bin")" +export PATH="$GOBIN:$PATH" + +need_install=() +if ! command -v go-licenses >/dev/null 2>&1; then + need_install+=("github.com/google/go-licenses@latest") +fi +if ! command -v addlicense >/dev/null 2>&1; then + need_install+=("github.com/google/addlicense@latest") +fi + +if [ ${#need_install[@]} -ne 0 ]; then + echo "Installing missing tools: ${need_install[*]}" + for pkg in "${need_install[@]}"; do + if command -v go >/dev/null 2>&1; then + go install "$pkg" + else + echo "ERROR: 'go' binary not found; cannot install $pkg" >&2 + exit 2 + fi + done +fi + +echo "Generating NOTICE via go-licenses" +if command -v go-licenses >/dev/null 2>&1; then + + if ! go-licenses report --template .NOTICE.template ./... > NOTICE 2> >(grep -v "module .* has empty version, defaults to HEAD" >&2); then + echo "go-licenses report failed" >&2 + fi + echo "NOTICE generated/updated" +else + echo "go-licenses not available; skipping NOTICE generation" >&2 +fi + +echo "Done." diff --git a/internal/portal/api_key.go b/internal/portal/api_key.go index 20de7892..1d7d161e 100644 --- a/internal/portal/api_key.go +++ b/internal/portal/api_key.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package portal import "time" diff --git a/internal/util/mocks.go b/internal/util/mocks.go index c9fcabf6..23487339 100644 --- a/internal/util/mocks.go +++ b/internal/util/mocks.go @@ -5,10 +5,9 @@ package util import ( - "os" - "github.com/jedib0t/go-pretty/v6/table" mock "github.com/stretchr/testify/mock" + "os" ) // NewMockFileIO creates a new instance of MockFileIO. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. diff --git a/internal/util/required_flag.go b/internal/util/required_flag.go index 600c1e62..e9109b84 100644 --- a/internal/util/required_flag.go +++ b/internal/util/required_flag.go @@ -1,3 +1,6 @@ +// Copyright (c) Codesphere Inc. +// SPDX-License-Identifier: Apache-2.0 + package util import (