diff --git a/.dockerignore b/.dockerignore index 21420b1..aa923cb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,4 +3,3 @@ .idea node_modules dist -npm/dist diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1ef800..bbdfb8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,9 @@ jobs: load: true build-args: VERSION=${{ steps.tags.outputs.version }} - name: Test container - run: docker run --rm ${{ steps.build.outputs.imageid }} -V + # The version is stamped in at build time; a binary reporting anything else was built + # without it. + run: test "$(docker run --rm ${{ steps.build.outputs.imageid }} -V)" = "${{ steps.tags.outputs.version }}" - name: Run container smoke tests run: | docker run --rm -v "$PWD/e2e:/e2e" --entrypoint sh \ @@ -142,7 +144,6 @@ jobs: runs-on: ubuntu-latest permissions: contents: write - id-token: write steps: - uses: actions/checkout@v7 with: @@ -150,11 +151,6 @@ jobs: - uses: actions/setup-go@v7 with: go-version-file: go.mod - - uses: actions/setup-node@v7 - with: - node-version: 24 - registry-url: 'https://registry.npmjs.org' - - run: npm install -g npm@12 - name: Binaries, archives and the GitHub release uses: goreleaser/goreleaser-action@v7 with: @@ -162,15 +158,6 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: npm packages from the same binaries - run: go run ./internal/tools/npmpkg -version "${GITHUB_REF_NAME}" -dist dist -out npm/dist - - name: Publish to npm - # The platform packages first: `steadybit` depends on them. - run: | - for dir in npm/dist/cli-*; do - (cd "$dir" && npm publish --provenance --access public) - done - (cd npm/dist/steadybit && npm publish --provenance --access public) - name: 'snyk monitor' uses: snyk/actions/golang@master env: diff --git a/.gitignore b/.gitignore index d7f467d..2dfc1e8 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ build/Release # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules /dist -/npm/dist /.steadybit.yml .idea diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 337307d..2358128 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,9 +1,8 @@ # SPDX-License-Identifier: MIT # SPDX-FileCopyrightText: 2026 Steadybit GmbH -# Builds the release binaries, archives and checksums. The npm packages and the container -# image are made from these binaries by the release workflow, so every channel ships the -# same build. +# Builds the release binaries, archives and checksums, and the GitHub release that carries +# them. The container image is built by the docker-build job. version: 2 project_name: steadybit @@ -17,7 +16,7 @@ builds: goarch: [amd64, arm64] flags: [-trimpath] ldflags: - - -s -w -X github.com/steadybit/cli/internal/platform.Version={{ .Version }} + - -s -w -X github.com/steadybit/cli/v6/internal/platform.Version={{ .Version }} mod_timestamp: '{{ .CommitTimestamp }}' archives: diff --git a/CHANGELOG.md b/CHANGELOG.md index c7ba81e..583a58a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,11 @@ ## v6.0.0 -- **The CLI is now a single binary written in Go.** It runs without Node.js, and is installed - the same ways: `npm install -g steadybit`, which now installs the binary for your platform - and works with any Node.js from 18 on, or the `steadybit/cli` container image, now 18 MB - instead of 249 MB. It can also be downloaded directly from the GitHub releases. Commands, +- **The CLI is now a single binary written in Go, and no longer needs Node.js.** It is + downloaded from the GitHub releases, installed with `go install`, or used as the + `steadybit/cli` container image, now 18 MB instead of 249 MB. +- **Breaking:** the CLI is no longer published to npm; `steadybit@5.0.0` there is the last + version. Uninstall it with `npm uninstall -g steadybit` and install the binary. Commands, flags, messages, exit codes, profiles in `~/.steadybit` and the `STEADYBIT_*` variables are unchanged, and experiment, schedule and service files are written byte for byte as before. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2a8c744..b7e11f4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,8 +34,7 @@ go test ./... | `internal/platform` | The HTTP client: authentication, retries, rate limiting, errors | | `internal/jsyaml` | YAML and JSON output byte-compatible with the former TypeScript CLI | | `api` | The platform client, generated from `openapi/platform-api.json` | -| `internal/tools` | The spec fetcher and the npm package builder, used by CI | -| `npm/steadybit` | The launcher the `steadybit` npm package runs | +| `internal/tools` | The spec fetcher, used by CI | ## Tests @@ -96,8 +95,7 @@ not generated structs, so that fields the spec does not know yet are never dropp ## Releasing Releases are published by CI, not from a workstation: pushing a `v*` tag builds the -binaries with goreleaser, creates the GitHub release, publishes the npm packages (one per -platform, and `steadybit`, which installs the right one), and pushes the Docker image. +binaries with goreleaser, creates the GitHub release with them, and pushes the Docker image. ```sh # 1. Head the CHANGELOG.md entry with the version being released diff --git a/Dockerfile b/Dockerfile index 85311f2..63dde46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ COPY api ./api COPY cmd ./cmd COPY internal ./internal RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath \ - -ldflags "-s -w -X github.com/steadybit/cli/internal/platform.Version=${VERSION}" \ + -ldflags "-s -w -X github.com/steadybit/cli/v6/internal/platform.Version=${VERSION}" \ -o /steadybit ./cmd/steadybit # Alpine rather than scratch: pipelines use the image with a shell, and the e2e suite diff --git a/README.md b/README.md index f6ff082..7b69689 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,7 @@ You need a Steadybit account. You can create a free account [via our website](ht The CLI is a single binary for Linux, macOS and Windows, on amd64 and arm64. -Via npm, which installs the binary for your platform (any Node.js from 18 on): - -```sh -npm install -g steadybit -``` - -Or download the archive for your platform from the +Download the archive for your platform from the [releases](https://github.com/steadybit/cli/releases) (`checksums.txt` lists their SHA-256) and put `steadybit` on your `PATH`: @@ -33,6 +27,19 @@ curl -sL https://github.com/steadybit/cli/releases/latest/download/steadybit_lin sudo mv steadybit /usr/local/bin/ ``` +With Go installed: + +```sh +go install github.com/steadybit/cli/cmd/steadybit@latest +``` + +The CLI is also available as the [container image](#container-image) `steadybit/cli`, and +in GitHub Actions through [`steadybit/cli`](#github-actions). + +Up to version 5, the CLI was installed with `npm install -g steadybit`. That package is no +longer updated; uninstall it with `npm uninstall -g steadybit` and install the binary instead. +Profiles in `~/.steadybit` keep working. + Shell completion is available for bash, zsh, fish and PowerShell, see `steadybit completion --help`. ## Authorization diff --git a/cmd/steadybit/main.go b/cmd/steadybit/main.go index 5c94141..83a5383 100644 --- a/cmd/steadybit/main.go +++ b/cmd/steadybit/main.go @@ -6,9 +6,9 @@ package main import ( "os" - "github.com/steadybit/cli/internal/cli" + "github.com/steadybit/cli/v6/internal/cli" // Imported for its signal handling, which every command needs from the start. - _ "github.com/steadybit/cli/internal/interrupt" + _ "github.com/steadybit/cli/v6/internal/interrupt" ) func main() { diff --git a/go.mod b/go.mod index ef6c63d..d3b3aaa 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/steadybit/cli +module github.com/steadybit/cli/v6 go 1.26.2 diff --git a/internal/accesstoken/accesstoken.go b/internal/accesstoken/accesstoken.go index 7a6d2dd..1e11df1 100644 --- a/internal/accesstoken/accesstoken.go +++ b/internal/accesstoken/accesstoken.go @@ -10,11 +10,11 @@ import ( "net/http" "strings" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) func notFoundOr(err error, id, format string) error { diff --git a/internal/accesstoken/accesstoken_test.go b/internal/accesstoken/accesstoken_test.go index a9881a0..4adbb25 100644 --- a/internal/accesstoken/accesstoken_test.go +++ b/internal/accesstoken/accesstoken_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/steadybit/cli/internal/accesstoken" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/accesstoken" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/action/action.go b/internal/action/action.go index c801cdb..5ed4c05 100644 --- a/internal/action/action.go +++ b/internal/action/action.go @@ -11,10 +11,10 @@ import ( "net/http" "strings" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) type ListOptions struct { diff --git a/internal/action/action_test.go b/internal/action/action_test.go index 28fdc62..a4c96d6 100644 --- a/internal/action/action_test.go +++ b/internal/action/action_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/steadybit/cli/internal/action" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/action" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/advice/advice.go b/internal/advice/advice.go index 0900bc3..8f69a8d 100644 --- a/internal/advice/advice.go +++ b/internal/advice/advice.go @@ -10,9 +10,9 @@ import ( "regexp" "strings" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/table" ) type Options struct { diff --git a/internal/advice/advice_test.go b/internal/advice/advice_test.go index 945fcd3..d7066a8 100644 --- a/internal/advice/advice_test.go +++ b/internal/advice/advice_test.go @@ -7,8 +7,8 @@ import ( "context" "testing" - "github.com/steadybit/cli/internal/advice" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/advice" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/auditlog/auditlog.go b/internal/auditlog/auditlog.go index 65c1da3..549a629 100644 --- a/internal/auditlog/auditlog.go +++ b/internal/auditlog/auditlog.go @@ -10,12 +10,12 @@ import ( "fmt" "net/http" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) type Options struct { diff --git a/internal/auditlog/auditlog_test.go b/internal/auditlog/auditlog_test.go index 56765e4..d7a57e2 100644 --- a/internal/auditlog/auditlog_test.go +++ b/internal/auditlog/auditlog_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/steadybit/cli/internal/auditlog" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/auditlog" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/cli/accesstoken.go b/internal/cli/accesstoken.go index 3c1fea6..549943b 100644 --- a/internal/cli/accesstoken.go +++ b/internal/cli/accesstoken.go @@ -7,9 +7,9 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/accesstoken" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/accesstoken" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) const ( diff --git a/internal/cli/advice.go b/internal/cli/advice.go index 6167c5b..c7c7eee 100644 --- a/internal/cli/advice.go +++ b/internal/cli/advice.go @@ -7,8 +7,8 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/advice" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/advice" + "github.com/steadybit/cli/v6/internal/platform" ) func newAdvice() *cobra.Command { diff --git a/internal/cli/auditlog.go b/internal/cli/auditlog.go index 7245c90..32491c8 100644 --- a/internal/cli/auditlog.go +++ b/internal/cli/auditlog.go @@ -7,8 +7,8 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/auditlog" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/auditlog" + "github.com/steadybit/cli/v6/internal/platform" ) func newAuditLog() *cobra.Command { diff --git a/internal/cli/complete.go b/internal/cli/complete.go index 29a499e..042fabe 100644 --- a/internal/cli/complete.go +++ b/internal/cli/complete.go @@ -12,9 +12,9 @@ import ( "time" "github.com/spf13/cobra" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/config" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/config" + "github.com/steadybit/cli/v6/internal/platform" ) // Shell completion offers what exists on the platform: experiment keys, team keys and diff --git a/internal/cli/complete_test.go b/internal/cli/complete_test.go index 269fa71..6727662 100644 --- a/internal/cli/complete_test.go +++ b/internal/cli/complete_test.go @@ -10,7 +10,7 @@ import ( "testing" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/cli/config.go b/internal/cli/config.go index 280864e..996566c 100644 --- a/internal/cli/config.go +++ b/internal/cli/config.go @@ -8,9 +8,9 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/config" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/prompt" + "github.com/steadybit/cli/v6/internal/config" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/prompt" ) func newConfig() *cobra.Command { diff --git a/internal/cli/environment.go b/internal/cli/environment.go index 53495c0..cd2cb00 100644 --- a/internal/cli/environment.go +++ b/internal/cli/environment.go @@ -7,9 +7,9 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/environment" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/environment" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) const environmentID = "0190d7b2-1c5e-7f3a-8e4b-2d6f9a1c3e57" diff --git a/internal/cli/execution.go b/internal/cli/execution.go index 301ad7d..c6b1609 100644 --- a/internal/cli/execution.go +++ b/internal/cli/execution.go @@ -9,9 +9,9 @@ import ( "time" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/execution" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/execution" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) func runID(cmd *cobra.Command, id *int64) { diff --git a/internal/cli/experiment.go b/internal/cli/experiment.go index eec52b6..e9df192 100644 --- a/internal/cli/experiment.go +++ b/internal/cli/experiment.go @@ -10,10 +10,10 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/platform" ) func newExperiment() *cobra.Command { diff --git a/internal/cli/gitops.go b/internal/cli/gitops.go index ec52906..58b599a 100644 --- a/internal/cli/gitops.go +++ b/internal/cli/gitops.go @@ -8,8 +8,8 @@ import ( "errors" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/platform" ) // newDiff is the `diff` command of a kind of file: `experiment diff`, `schedule diff`... diff --git a/internal/cli/hub.go b/internal/cli/hub.go index bb7083b..8d7a3a4 100644 --- a/internal/cli/hub.go +++ b/internal/cli/hub.go @@ -7,9 +7,9 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/hub" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/hub" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) func newHub() *cobra.Command { diff --git a/internal/cli/integration.go b/internal/cli/integration.go index b39722e..9e24b6a 100644 --- a/internal/cli/integration.go +++ b/internal/cli/integration.go @@ -8,9 +8,9 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/integration" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/integration" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) const integrationID = "0190d7b2-7d3e-7a4b-8c5d-6e7f8a9b0c1d" diff --git a/internal/cli/killswitch.go b/internal/cli/killswitch.go index 1393794..cecd10a 100644 --- a/internal/cli/killswitch.go +++ b/internal/cli/killswitch.go @@ -7,8 +7,8 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/killswitch" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/killswitch" + "github.com/steadybit/cli/v6/internal/platform" ) func newKillswitch() *cobra.Command { diff --git a/internal/cli/property.go b/internal/cli/property.go index e20045a..2a63df7 100644 --- a/internal/cli/property.go +++ b/internal/cli/property.go @@ -7,9 +7,9 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/property" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/property" + "github.com/steadybit/cli/v6/internal/resource" ) const associationID = "0190d7b2-9e8f-7c6d-b5a4-3f2e1d0c9b8a" diff --git a/internal/cli/report.go b/internal/cli/report.go index b423e6d..602b16c 100644 --- a/internal/cli/report.go +++ b/internal/cli/report.go @@ -8,8 +8,8 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/report" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/report" ) func newReport() *cobra.Command { diff --git a/internal/cli/root.go b/internal/cli/root.go index 5a739f2..d03f7bf 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -13,11 +13,11 @@ import ( "strings" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/config" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/config" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" ) // Laid out like the TypeScript CLI's help, which pipelines and the e2e suite read. @@ -56,7 +56,7 @@ func newRoot() *cobra.Command { root := &cobra.Command{ Use: "steadybit", Short: "Command-line interface to interact with the Steadybit API", - Version: platform.Version, + Version: platform.CurrentVersion(), SilenceUsage: true, SilenceErrors: true, Example: examples( diff --git a/internal/cli/schedule.go b/internal/cli/schedule.go index 2ae498e..958b1af 100644 --- a/internal/cli/schedule.go +++ b/internal/cli/schedule.go @@ -7,10 +7,10 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/schedule" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/schedule" ) const scheduleID = "01951394-727f-76a0-8675-c7519ebd0ff5" diff --git a/internal/cli/service.go b/internal/cli/service.go index 9ac2241..1bc010f 100644 --- a/internal/cli/service.go +++ b/internal/cli/service.go @@ -7,11 +7,11 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/service" - "github.com/steadybit/cli/internal/serviceprofile" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/service" + "github.com/steadybit/cli/v6/internal/serviceprofile" ) const ( diff --git a/internal/cli/target.go b/internal/cli/target.go index 0538346..33270eb 100644 --- a/internal/cli/target.go +++ b/internal/cli/target.go @@ -7,10 +7,10 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/action" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/target" + "github.com/steadybit/cli/v6/internal/action" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/target" ) const listTypeHelp = `Print the list as "json" or "yaml" instead of a table.` diff --git a/internal/cli/team.go b/internal/cli/team.go index 7d7c71e..cfc63a2 100644 --- a/internal/cli/team.go +++ b/internal/cli/team.go @@ -7,9 +7,9 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/team" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/team" ) func teamKeyFlag(cmd *cobra.Command, key *string) { diff --git a/internal/cli/template.go b/internal/cli/template.go index a44539d..ddfd86e 100644 --- a/internal/cli/template.go +++ b/internal/cli/template.go @@ -7,9 +7,9 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/template" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/template" ) const ( diff --git a/internal/cli/user.go b/internal/cli/user.go index 435f530..10e65b6 100644 --- a/internal/cli/user.go +++ b/internal/cli/user.go @@ -7,8 +7,8 @@ import ( "context" "github.com/spf13/cobra" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/user" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/user" ) func newUser() *cobra.Command { diff --git a/internal/environment/environment.go b/internal/environment/environment.go index c685706..d9574ac 100644 --- a/internal/environment/environment.go +++ b/internal/environment/environment.go @@ -10,11 +10,11 @@ import ( "net/http" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // The state is the platform's, and the version is dropped as `service get` drops it: kept diff --git a/internal/environment/environment_test.go b/internal/environment/environment_test.go index a5011da..d466a9a 100644 --- a/internal/environment/environment_test.go +++ b/internal/environment/environment_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/environment" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/environment" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/execution/execution.go b/internal/execution/execution.go index da85823..e3ba769 100644 --- a/internal/execution/execution.go +++ b/internal/execution/execution.go @@ -14,12 +14,12 @@ import ( "path/filepath" "time" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) func notFoundOr(err error, id int64, format string, args ...any) error { diff --git a/internal/execution/execution_test.go b/internal/execution/execution_test.go index 0709351..6fbd3c4 100644 --- a/internal/execution/execution_test.go +++ b/internal/execution/execution_test.go @@ -12,9 +12,9 @@ import ( "testing" "time" - "github.com/steadybit/cli/internal/execution" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/execution" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/execution/watch.go b/internal/execution/watch.go index 55bf036..1166095 100644 --- a/internal/execution/watch.go +++ b/internal/execution/watch.go @@ -11,10 +11,10 @@ import ( "strings" "time" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/table" "golang.org/x/term" ) diff --git a/internal/experiment/dump.go b/internal/experiment/dump.go index 10cd211..bb0081e 100644 --- a/internal/experiment/dump.go +++ b/internal/experiment/dump.go @@ -15,10 +15,10 @@ import ( "strings" "sync" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" ) // A dump walks every experiment of every team and every execution of every experiment. diff --git a/internal/experiment/experiment.go b/internal/experiment/experiment.go index 41839c6..d7a3dbe 100644 --- a/internal/experiment/experiment.go +++ b/internal/experiment/experiment.go @@ -23,12 +23,12 @@ import ( "strings" "time" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/interrupt" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/prompt" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/interrupt" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/prompt" ) type Document = *output.Document diff --git a/internal/experiment/experiment_test.go b/internal/experiment/experiment_test.go index 1910d90..07b6957 100644 --- a/internal/experiment/experiment_test.go +++ b/internal/experiment/experiment_test.go @@ -13,13 +13,13 @@ import ( "testing" "time" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/interrupt" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/prompt" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/interrupt" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/prompt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/experiment/init.go b/internal/experiment/init.go index 2ec0910..226aac9 100644 --- a/internal/experiment/init.go +++ b/internal/experiment/init.go @@ -14,11 +14,11 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/prompt" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/prompt" "golang.org/x/term" ) diff --git a/internal/experiment/template.go b/internal/experiment/template.go index e9378b2..afefd16 100644 --- a/internal/experiment/template.go +++ b/internal/experiment/template.go @@ -13,10 +13,10 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" ) type TemplateOptions struct { diff --git a/internal/gitops/commands.go b/internal/gitops/commands.go index b0a0ce4..cdb0237 100644 --- a/internal/gitops/commands.go +++ b/internal/gitops/commands.go @@ -8,10 +8,10 @@ import ( "errors" "fmt" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) // ErrDifferent ends `diff` with exit status 2 when files and platform disagree, so a diff --git a/internal/gitops/compare.go b/internal/gitops/compare.go index 0ff8eb8..1511973 100644 --- a/internal/gitops/compare.go +++ b/internal/gitops/compare.go @@ -10,7 +10,7 @@ import ( "strings" "github.com/pmezard/go-difflib/difflib" - "github.com/steadybit/cli/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/jsyaml" ) // Comparable projects the platform's version of a document onto the file's: every field diff --git a/internal/gitops/gitops_test.go b/internal/gitops/gitops_test.go index 4b77ab3..bbe491f 100644 --- a/internal/gitops/gitops_test.go +++ b/internal/gitops/gitops_test.go @@ -10,9 +10,9 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/gitops/kinds.go b/internal/gitops/kinds.go index e407c04..4044f8e 100644 --- a/internal/gitops/kinds.go +++ b/internal/gitops/kinds.go @@ -9,10 +9,10 @@ import ( "net/http" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" ) // Kind is a type of file kept in Git and how to find its counterpart on the platform. diff --git a/internal/gitops/project.go b/internal/gitops/project.go index e642248..83126b8 100644 --- a/internal/gitops/project.go +++ b/internal/gitops/project.go @@ -14,14 +14,14 @@ import ( "regexp" "strings" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/schedule" - "github.com/steadybit/cli/internal/service" - "github.com/steadybit/cli/internal/serviceprofile" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/schedule" + "github.com/steadybit/cli/v6/internal/service" + "github.com/steadybit/cli/v6/internal/serviceprofile" ) // A project is a directory holding what a team keeps in Git, one kind per directory, diff --git a/internal/gitops/project_test.go b/internal/gitops/project_test.go index 50544f7..9eb2c6c 100644 --- a/internal/gitops/project_test.go +++ b/internal/gitops/project_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" - "github.com/steadybit/cli/internal/gitops" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/gitops" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/hub/hub.go b/internal/hub/hub.go index c2abd3f..be96f24 100644 --- a/internal/hub/hub.go +++ b/internal/hub/hub.go @@ -10,11 +10,11 @@ import ( "net/http" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // What the last synchronisation found and who edited the hub is the platform's. The diff --git a/internal/hub/hub_test.go b/internal/hub/hub_test.go index 6f277d9..9a0c98a 100644 --- a/internal/hub/hub_test.go +++ b/internal/hub/hub_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/hub" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/hub" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/integration/integration.go b/internal/integration/integration.go index ccf778e..0dc0067 100644 --- a/internal/integration/integration.go +++ b/internal/integration/integration.go @@ -13,10 +13,10 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // The version is dropped as `service get` drops it: kept in a file, it turns every apply diff --git a/internal/integration/integration_test.go b/internal/integration/integration_test.go index 25255d6..08a7c02 100644 --- a/internal/integration/integration_test.go +++ b/internal/integration/integration_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/integration" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/integration" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/killswitch/killswitch.go b/internal/killswitch/killswitch.go index 4ed5bd4..2d83014 100644 --- a/internal/killswitch/killswitch.go +++ b/internal/killswitch/killswitch.go @@ -9,9 +9,9 @@ import ( "encoding/json" "fmt" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) type StatusOptions struct { diff --git a/internal/killswitch/killswitch_test.go b/internal/killswitch/killswitch_test.go index 9e13f5d..e7d1920 100644 --- a/internal/killswitch/killswitch_test.go +++ b/internal/killswitch/killswitch_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/steadybit/cli/internal/killswitch" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/killswitch" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/output/document.go b/internal/output/document.go index 6972231..da5ffe1 100644 --- a/internal/output/document.go +++ b/internal/output/document.go @@ -14,7 +14,7 @@ import ( "strings" "time" - "github.com/steadybit/cli/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/jsyaml" "go.yaml.in/yaml/v3" ) diff --git a/internal/platform/client.go b/internal/platform/client.go index e496529..8a0ef97 100644 --- a/internal/platform/client.go +++ b/internal/platform/client.go @@ -16,17 +16,32 @@ import ( "net/http" "net/url" "os" + "runtime/debug" "strconv" "strings" "time" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/config" - "github.com/steadybit/cli/internal/output" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/config" + "github.com/steadybit/cli/v6/internal/output" ) +// Version is set at build time for releases, with -ldflags -X, which only works on a +// variable initialised to a constant. Read it through CurrentVersion. var Version = "dev" +// CurrentVersion is the release version, or for a binary built with `go install`, the +// module version its build info carries. +func CurrentVersion() string { + if Version != "dev" { + return Version + } + if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" && info.Main.Version != "(devel)" { + return strings.TrimPrefix(info.Main.Version, "v") + } + return Version +} + // ErrNoAccessToken is reported with the setup help, before any request is made. var ErrNoAccessToken = errors.New("no API access token") @@ -109,7 +124,7 @@ func New() (*Client, error) { authorize := func(_ context.Context, req *http.Request) error { req.Header.Set("Authorization", "accessToken "+cfg.APIAccessToken) req.Header.Set("Accept", "application/json, */*") - req.Header.Set("User-Agent", "steadybit@"+Version) + req.Header.Set("User-Agent", "steadybit@"+CurrentVersion()) return nil } client, err := api.NewClientWithResponses(cfg.BaseURL, api.WithHTTPClient(httpClient), api.WithRequestEditorFn(authorize)) diff --git a/internal/platform/client_test.go b/internal/platform/client_test.go index 2a9fe4c..8e6c561 100644 --- a/internal/platform/client_test.go +++ b/internal/platform/client_test.go @@ -12,8 +12,8 @@ import ( "testing" "time" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/platformtest" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/platformtest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/platform/response.go b/internal/platform/response.go index e8ef33e..74df51c 100644 --- a/internal/platform/response.go +++ b/internal/platform/response.go @@ -11,7 +11,7 @@ import ( "io" "net/http" - "github.com/steadybit/cli/internal/output" + "github.com/steadybit/cli/v6/internal/output" ) // Read takes a generated client call's result and returns the body, failing on any diff --git a/internal/platformtest/platformtest.go b/internal/platformtest/platformtest.go index 2d8883b..24ed910 100644 --- a/internal/platformtest/platformtest.go +++ b/internal/platformtest/platformtest.go @@ -17,7 +17,7 @@ import ( "testing" "time" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/platform" ) type Request struct { diff --git a/internal/prompt/prompt.go b/internal/prompt/prompt.go index e66ef76..936c9b9 100644 --- a/internal/prompt/prompt.go +++ b/internal/prompt/prompt.go @@ -12,7 +12,7 @@ import ( "os" "strings" - "github.com/steadybit/cli/internal/interrupt" + "github.com/steadybit/cli/v6/internal/interrupt" "golang.org/x/term" ) diff --git a/internal/property/property.go b/internal/property/property.go index 7ec0877..b234d78 100644 --- a/internal/property/property.go +++ b/internal/property/property.go @@ -12,11 +12,11 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // The version is dropped as `service get` drops it: kept in a file, it turns every apply diff --git a/internal/property/property_test.go b/internal/property/property_test.go index 5c55e32..fa5e247 100644 --- a/internal/property/property_test.go +++ b/internal/property/property_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/property" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/property" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/report/report.go b/internal/report/report.go index 5f9c082..19b2124 100644 --- a/internal/report/report.go +++ b/internal/report/report.go @@ -13,10 +13,10 @@ import ( "strings" "time" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" ) // Filter says which filters a report takes beyond the time range. diff --git a/internal/report/report_test.go b/internal/report/report_test.go index 0cc7559..23144ec 100644 --- a/internal/report/report_test.go +++ b/internal/report/report_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/report" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/report" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/resource/list.go b/internal/resource/list.go index 63b9d14..accbd4a 100644 --- a/internal/resource/list.go +++ b/internal/resource/list.go @@ -10,9 +10,9 @@ import ( "os" "strings" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" ) // ListTypeHelp describes the -t flag of listings. diff --git a/internal/resource/list_test.go b/internal/resource/list_test.go index 5d7f1b5..a0b9c14 100644 --- a/internal/resource/list_test.go +++ b/internal/resource/list_test.go @@ -7,9 +7,9 @@ import ( "encoding/json" "testing" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/resource/listed_test.go b/internal/resource/listed_test.go index 4adbb2e..12e3f88 100644 --- a/internal/resource/listed_test.go +++ b/internal/resource/listed_test.go @@ -7,8 +7,8 @@ import ( "context" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/resource" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/resource/resource.go b/internal/resource/resource.go index 2dd9779..17c6ee6 100644 --- a/internal/resource/resource.go +++ b/internal/resource/resource.go @@ -16,10 +16,10 @@ import ( "time" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/prompt" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/prompt" ) // Output writes to the file when one is given and to stdout otherwise, as JSON diff --git a/internal/schedule/schedule.go b/internal/schedule/schedule.go index 0a353ba..741bab0 100644 --- a/internal/schedule/schedule.go +++ b/internal/schedule/schedule.go @@ -13,12 +13,12 @@ import ( "io" "net/http" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // What the platform reports about the last edit and the next run cannot be sent back, diff --git a/internal/schedule/schedule_test.go b/internal/schedule/schedule_test.go index 9464394..00369f5 100644 --- a/internal/schedule/schedule_test.go +++ b/internal/schedule/schedule_test.go @@ -10,9 +10,9 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/schedule" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/schedule" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/service/service.go b/internal/service/service.go index 1150a46..db6c3ea 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -14,13 +14,13 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // Who created and edited a service cannot be sent back. The version is dropped as diff --git a/internal/service/service_test.go b/internal/service/service_test.go index 5e78478..fd4a8cb 100644 --- a/internal/service/service_test.go +++ b/internal/service/service_test.go @@ -11,10 +11,10 @@ import ( "strings" "testing" - "github.com/steadybit/cli/internal/experiment" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/service" + "github.com/steadybit/cli/v6/internal/experiment" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/service" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/serviceprofile/serviceprofile.go b/internal/serviceprofile/serviceprofile.go index 9fc62a1..2afb126 100644 --- a/internal/serviceprofile/serviceprofile.go +++ b/internal/serviceprofile/serviceprofile.go @@ -12,13 +12,13 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/service" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/service" + "github.com/steadybit/cli/v6/internal/table" ) // Only what can be sent back is kept. Whether a profile is the default is changed in the diff --git a/internal/serviceprofile/serviceprofile_test.go b/internal/serviceprofile/serviceprofile_test.go index ee9e914..a0c3dcb 100644 --- a/internal/serviceprofile/serviceprofile_test.go +++ b/internal/serviceprofile/serviceprofile_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/serviceprofile" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/serviceprofile" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/table/table.go b/internal/table/table.go index 52b559d..05a42bb 100644 --- a/internal/table/table.go +++ b/internal/table/table.go @@ -11,7 +11,7 @@ import ( "strings" "github.com/mattn/go-runewidth" - "github.com/steadybit/cli/internal/output" + "github.com/steadybit/cli/v6/internal/output" ) type Alignment int diff --git a/internal/target/target.go b/internal/target/target.go index a3bfa33..e448c32 100644 --- a/internal/target/target.go +++ b/internal/target/target.go @@ -11,12 +11,12 @@ import ( "net/http" "strings" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) func notFoundOr(err error, environment, format string) error { diff --git a/internal/target/target_test.go b/internal/target/target_test.go index 1b6885b..d8e7306 100644 --- a/internal/target/target_test.go +++ b/internal/target/target_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/target" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/target" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/team/team.go b/internal/team/team.go index 542c486..e74b355 100644 --- a/internal/team/team.go +++ b/internal/team/team.go @@ -11,12 +11,12 @@ import ( "net/http" "strings" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // The version is dropped as `service get` drops it. Members are sent back as the platform diff --git a/internal/team/team_test.go b/internal/team/team_test.go index 85f5829..de818d5 100644 --- a/internal/team/team_test.go +++ b/internal/team/team_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/team" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/team" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/template/template.go b/internal/template/template.go index 7e3c0b8..1a0ea10 100644 --- a/internal/template/template.go +++ b/internal/template/template.go @@ -12,12 +12,12 @@ import ( "net/http" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/jsyaml" - "github.com/steadybit/cli/internal/output" - "github.com/steadybit/cli/internal/platform" - "github.com/steadybit/cli/internal/resource" - "github.com/steadybit/cli/internal/table" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/jsyaml" + "github.com/steadybit/cli/v6/internal/output" + "github.com/steadybit/cli/v6/internal/platform" + "github.com/steadybit/cli/v6/internal/resource" + "github.com/steadybit/cli/v6/internal/table" ) // Who created and edited a template cannot be sent back. The version is dropped as diff --git a/internal/template/template_test.go b/internal/template/template_test.go index 093ca2a..39ed8b0 100644 --- a/internal/template/template_test.go +++ b/internal/template/template_test.go @@ -10,8 +10,8 @@ import ( "path/filepath" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/template" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/template" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/tools/npmpkg/main.go b/internal/tools/npmpkg/main.go deleted file mode 100644 index be8f2d2..0000000 --- a/internal/tools/npmpkg/main.go +++ /dev/null @@ -1,193 +0,0 @@ -// SPDX-License-Identifier: MIT -// SPDX-FileCopyrightText: 2026 Steadybit GmbH - -// Command npmpkg turns goreleaser's binaries into the npm packages: one per platform -// holding the binary, and `steadybit`, which depends on all of them optionally and starts -// the one npm installed. npm 12 no longer runs install scripts by default, so downloading -// the binary on install is not an option. -// -// go run ./internal/tools/npmpkg -version 6.0.0 -dist dist -out npm/dist -package main - -import ( - "bytes" - "encoding/json" - "flag" - "fmt" - "io" - "os" - "path/filepath" - "strings" -) - -type platform struct { - goos, goarch, nodeOS, nodeCPU string -} - -var platforms = []platform{ - {"darwin", "arm64", "darwin", "arm64"}, - {"darwin", "amd64", "darwin", "x64"}, - {"linux", "arm64", "linux", "arm64"}, - {"linux", "amd64", "linux", "x64"}, - {"windows", "arm64", "win32", "arm64"}, - {"windows", "amd64", "win32", "x64"}, -} - -type artifact struct { - Type string `json:"type"` - Path string `json:"path"` - Goos string `json:"goos"` - Goarch string `json:"goarch"` -} - -func main() { - version := flag.String("version", "", "the version to publish, without a leading v") - dist := flag.String("dist", "dist", "goreleaser's output directory") - out := flag.String("out", "npm/dist", "where to write the packages") - flag.Parse() - if err := run(strings.TrimPrefix(*version, "v"), *dist, *out); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func run(version, dist, out string) error { - if version == "" { - return fmt.Errorf("-version is required") - } - content, err := os.ReadFile(filepath.Join(dist, "artifacts.json")) - if err != nil { - return err - } - var artifacts []artifact - if err := json.Unmarshal(content, &artifacts); err != nil { - return err - } - binaries := map[string]string{} - for _, a := range artifacts { - if a.Type == "Binary" { - binaries[a.Goos+"/"+a.Goarch] = a.Path - } - } - - if err := os.RemoveAll(out); err != nil { - return err - } - optional := map[string]string{} - for _, p := range platforms { - binary, ok := binaries[p.goos+"/"+p.goarch] - if !ok { - return fmt.Errorf("no %s/%s binary in %s", p.goos, p.goarch, dist) - } - name := fmt.Sprintf("@steadybit/cli-%s-%s", p.nodeOS, p.nodeCPU) - dir := filepath.Join(out, fmt.Sprintf("cli-%s-%s", p.nodeOS, p.nodeCPU)) - executable := "steadybit" - if p.goos == "windows" { - executable += ".exe" - } - if err := copyFile(binary, filepath.Join(dir, "bin", executable), 0o755); err != nil { - return err - } - if err := writeJSON(filepath.Join(dir, "package.json"), map[string]any{ - "name": name, - "version": version, - "description": fmt.Sprintf("The Steadybit CLI binary for %s %s. Install `steadybit` instead.", p.nodeOS, p.nodeCPU), - "license": "MIT", - "repository": map[string]string{"type": "git", "url": "https://github.com/steadybit/cli.git"}, - "os": []string{p.nodeOS}, - "cpu": []string{p.nodeCPU}, - "files": []string{"bin"}, - "preferUnplugged": true, - }); err != nil { - return err - } - optional[name] = version - } - - main := filepath.Join(out, "steadybit") - if err := copyFile("npm/steadybit/bin/steadybit.js", filepath.Join(main, "bin", "steadybit.js"), 0o755); err != nil { - return err - } - for _, f := range []string{"README.md", "LICENSE", "CHANGELOG.md"} { - if err := copyFile(f, filepath.Join(main, f), 0o644); err != nil { - return err - } - } - return writeJSON(filepath.Join(main, "package.json"), mainPackage{ - Name: "steadybit", - Version: version, - Description: "Command-line interface to interact with the Steadybit API", - Keywords: []string{"steadybit", "cli", "chaos engineering", "resilience engineering", "api", "gitops"}, - License: "MIT", - Author: "Steadybit GmbH", - Repository: repo, - Bin: map[string]string{"steadybit": "bin/steadybit.js"}, - Files: []string{"bin", "README.md", "CHANGELOG.md", "LICENSE"}, - Engines: map[string]string{"node": ">=18"}, - OptionalDependencies: optional, - }) -} - -func copyFile(from, to string, mode os.FileMode) error { - if err := os.MkdirAll(filepath.Dir(to), 0o755); err != nil { - return err - } - src, err := os.Open(from) - if err != nil { - return err - } - defer src.Close() - dst, err := os.OpenFile(to, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode) - if err != nil { - return err - } - defer dst.Close() - _, err = io.Copy(dst, src) - return err -} - -// writeJSON writes a package.json without Go's HTML escaping, which would turn ">=" in -// engines into "\u003e=". -func writeJSON(file string, value any) error { - var buf bytes.Buffer - encoder := json.NewEncoder(&buf) - encoder.SetEscapeHTML(false) - encoder.SetIndent("", " ") - if err := encoder.Encode(value); err != nil { - return err - } - return os.WriteFile(file, buf.Bytes(), 0o644) -} - -type repository struct { - Type string `json:"type"` - URL string `json:"url"` -} - -var repo = repository{Type: "git", URL: "https://github.com/steadybit/cli.git"} - -type platformPackage struct { - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description"` - License string `json:"license"` - Repository repository `json:"repository"` - OS []string `json:"os"` - CPU []string `json:"cpu"` - Files []string `json:"files"` - PreferUnplugged bool `json:"preferUnplugged"` -} - -type mainPackage struct { - Name string `json:"name"` - Version string `json:"version"` - Description string `json:"description"` - Keywords []string `json:"keywords"` - License string `json:"license"` - Author string `json:"author"` - Repository repository `json:"repository"` - Bin map[string]string `json:"bin"` - Files []string `json:"files"` - Engines map[string]string `json:"engines"` - OptionalDependencies map[string]string `json:"optionalDependencies"` -} diff --git a/internal/user/user.go b/internal/user/user.go index aaa9c37..1aeecc2 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -12,8 +12,8 @@ import ( "strings" openapi_types "github.com/oapi-codegen/runtime/types" - "github.com/steadybit/cli/api" - "github.com/steadybit/cli/internal/platform" + "github.com/steadybit/cli/v6/api" + "github.com/steadybit/cli/v6/internal/platform" ) type InviteOptions struct { diff --git a/internal/user/user_test.go b/internal/user/user_test.go index 51f9795..eecbfde 100644 --- a/internal/user/user_test.go +++ b/internal/user/user_test.go @@ -8,8 +8,8 @@ import ( "net/http" "testing" - "github.com/steadybit/cli/internal/platformtest" - "github.com/steadybit/cli/internal/user" + "github.com/steadybit/cli/v6/internal/platformtest" + "github.com/steadybit/cli/v6/internal/user" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/npm/steadybit/bin/steadybit.js b/npm/steadybit/bin/steadybit.js deleted file mode 100644 index b50953b..0000000 --- a/npm/steadybit/bin/steadybit.js +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env node -// SPDX-License-Identifier: MIT -// SPDX-FileCopyrightText: 2026 Steadybit GmbH - -// Runs the steadybit binary for this platform, which npm installed as one of the -// optional dependencies. The CLI itself is a Go binary; this only finds and starts it. -'use strict'; - -const { spawn } = require('node:child_process'); -const path = require('node:path'); - -const platforms = { - 'darwin arm64': '@steadybit/cli-darwin-arm64', - 'darwin x64': '@steadybit/cli-darwin-x64', - 'linux arm64': '@steadybit/cli-linux-arm64', - 'linux x64': '@steadybit/cli-linux-x64', - 'win32 arm64': '@steadybit/cli-win32-arm64', - 'win32 x64': '@steadybit/cli-win32-x64', -}; - -function binaryPath() { - const pkg = platforms[`${process.platform} ${process.arch}`]; - if (!pkg) { - fail(`The Steadybit CLI is not available for ${process.platform} ${process.arch}.`); - } - const executable = process.platform === 'win32' ? 'steadybit.exe' : 'steadybit'; - try { - return require.resolve(path.posix.join(pkg, 'bin', executable)); - } catch { - fail( - `The package ${pkg}, which holds the CLI for this platform, is not installed. ` + - 'It is an optional dependency; reinstall without --no-optional / --omit=optional:\n\n npm install -g steadybit' - ); - } -} - -function fail(message) { - console.error(message); - process.exit(1); -} - -const child = spawn(binaryPath(), process.argv.slice(2), { stdio: 'inherit' }); - -// Ctrl-C reaches the CLI directly, as they share the terminal; this process only waits -// for it, so that the CLI decides how to end, and its exit status (130 for Ctrl-C) -// becomes ours. A signal sent to this process alone, as a CI runner does, is passed on. -for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) { - process.on(signal, () => { - if (signal !== 'SIGINT') { - child.kill(signal); - } - }); -} - -child.on('error', error => fail(`Failed to start the Steadybit CLI: ${error.message}`)); -child.on('exit', (code, signal) => { - if (signal) { - process.kill(process.pid, signal); - return; - } - process.exit(code ?? 1); -});