diff --git a/.github/workflows/release-beta.yml b/.github/workflows/release-beta.yml index 0541ce077..015792031 100644 --- a/.github/workflows/release-beta.yml +++ b/.github/workflows/release-beta.yml @@ -28,9 +28,9 @@ jobs: go-version-file: auth0-cli/go.mod check-latest: true - # GoReleaser automatically marks SemVer prerelease tags (those with a - # "-suffix") as GitHub prereleases. Homebrew and Scoop PRs are - # intentionally omitted so beta builds never reach package managers. + # GoReleaser marks SemVer prerelease tags (those with a "-suffix") as GitHub + # prereleases. The beta formula and manifest are separate from the stable + # auth0 package, so the stable formula and manifest are not touched. - name: Run GoReleaser uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3 with: @@ -38,4 +38,142 @@ jobs: args: release --clean workdir: 'auth0-cli' env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file + GITHUB_TOKEN: ${{ github.token }} + + # The tap jobs run on their own so a failed tap PR can be re-run + # without publishing the release again. + - name: Upload Homebrew formula + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: homebrew-formula + path: auth0-cli/dist/homebrew/auth0-beta.rb + if-no-files-found: error + overwrite: true + retention-days: 5 + + - name: Upload Scoop manifest + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: scoop-manifest + path: auth0-cli/dist/scoop/auth0-beta.json + if-no-files-found: error + overwrite: true + retention-days: 5 + + # Scan every published archive. Nothing depends on this job, so a failed scan fails + # its own run but does not block the release or the Homebrew and Scoop updates. + rl-scan: + name: RL Scan + needs: goreleaser + strategy: + fail-fast: false + matrix: + asset-suffix: + - Darwin_arm64.tar.gz + - Darwin_x86_64.tar.gz + - Linux_arm64.tar.gz + - Linux_x86_64.tar.gz + - Windows_arm64.zip + - Windows_x86_64.zip + permissions: + contents: read + id-token: write + uses: ./.github/workflows/rl.yml + with: + tag: ${{ github.ref_name }} + asset-suffix: ${{ matrix.asset-suffix }} + secrets: inherit + + homebrew: + name: Homebrew Tap + needs: goreleaser + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Download Homebrew formula + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: homebrew-formula + path: homebrew-formula + + - name: Generate Homebrew app token + id: app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + client-id: ${{ secrets.RELEASE_APP_CLIENT_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + owner: auth0 + repositories: homebrew-auth0-cli + permission-contents: write + permission-pull-requests: write + + - name: Checkout Homebrew Tap Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: auth0/homebrew-auth0-cli + token: ${{ steps.app-token.outputs.token }} + path: homebrew-auth0-cli + + - name: Copy Brew Formula + run: | + cp homebrew-formula/*.rb homebrew-auth0-cli/ + + - name: Create Homebrew Pull Request + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + token: ${{ steps.app-token.outputs.token }} + commit-message: "Beta brew formula update for auth0-cli version ${{ github.ref_name }}" + branch: ${{ github.ref_name }} + title: "Beta brew formula update for auth0-cli version ${{ github.ref_name }}" + body: "This PR updates the beta Homebrew formula (auth0-beta) for version ${{ github.ref_name }}." + base: main + sign-commits: true + path: homebrew-auth0-cli + + scoop: + name: Scoop Bucket + needs: goreleaser + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Download Scoop manifest + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: scoop-manifest + path: scoop-manifest + + - name: Generate Scoop app token + id: app-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + client-id: ${{ secrets.RELEASE_APP_CLIENT_ID }} + private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} + owner: auth0 + repositories: scoop-auth0-cli + permission-contents: write + permission-pull-requests: write + + - name: Checkout Scoop Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: auth0/scoop-auth0-cli + token: ${{ steps.app-token.outputs.token }} + path: scoop-auth0-cli + + - name: Copy Scoop Manifest + run: | + cp scoop-manifest/*.json scoop-auth0-cli/ + + - name: Create Scoop Pull Request + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + token: ${{ steps.app-token.outputs.token }} + commit-message: "Beta scoop manifest update for auth0-cli version ${{ github.ref_name }}" + branch: ${{ github.ref_name }} + title: "Beta scoop manifest update for auth0-cli version ${{ github.ref_name }}" + body: "This PR updates the beta Scoop manifest (auth0-beta) for version ${{ github.ref_name }}." + base: main + sign-commits: true + path: scoop-auth0-cli diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 377506f7c..00412ea9c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: homebrew-formula - path: auth0-cli/dist/homebrew/*.rb + path: auth0-cli/dist/homebrew/auth0.rb if-no-files-found: error overwrite: true retention-days: 5 @@ -53,7 +53,7 @@ jobs: uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: scoop-manifest - path: auth0-cli/dist/scoop/*.json + path: auth0-cli/dist/scoop/auth0.json if-no-files-found: error overwrite: true retention-days: 5 diff --git a/.goreleaser.yml b/.goreleaser.yml index 33d3e69dd..def7d6f9e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -55,6 +55,26 @@ brews: (fish_completion/"auth0.fish").write `#{bin}/auth0 completion fish` (zsh_completion/"_auth0").write `#{bin}/auth0 completion zsh` caveats: "Thanks for installing the Auth0 CLI\n\nTip: run 'auth0 agent skills install' to install the Auth0 skill for your AI coding assistants." + - name: auth0-beta + repository: + owner: auth0 + name: homebrew-auth0-cli + token: "{{ .Env.GITHUB_TOKEN }}" + commit_author: + name: auth0 + email: auth0-cli-cd-sa@okta.com + commit_msg_template: "Beta brew formula update for {{ .ProjectName }} version {{ .Tag }}" + homepage: https://auth0.github.io/auth0-cli + description: Build, manage and test your Auth0 integrations from the command line + license: MIT + skip_upload: true + install: | + bin.install "auth0" + + (bash_completion/"auth0").write `#{bin}/auth0 completion bash` + (fish_completion/"auth0.fish").write `#{bin}/auth0 completion fish` + (zsh_completion/"_auth0").write `#{bin}/auth0 completion zsh` + caveats: "Thanks for installing the Auth0 CLI (beta)\n\nTip: run 'auth0 agent skills install' to install the Auth0 skill for your AI coding assistants." scoops: - name: auth0 @@ -71,3 +91,17 @@ scoops: license: MIT skip_upload: true post_install: ["Write-Host 'Thanks for installing the Auth0 CLI'", "Write-Host \"Tip: run 'auth0 agent skills install' to install the Auth0 skill for your AI coding assistants.\""] + - name: auth0-beta + repository: + owner: auth0 + name: scoop-auth0-cli + token: "{{ .Env.GITHUB_TOKEN }}" + commit_author: + name: auth0 + email: auth0-cli-cd-sa@okta.com + commit_msg_template: "Beta scoop manifest update for {{ .ProjectName }} version {{ .Tag }}" + homepage: https://auth0.github.io/auth0-cli + description: Build, manage and test your Auth0 integrations from the command line + license: MIT + skip_upload: true + post_install: ["Write-Host 'Thanks for installing the Auth0 CLI (beta)'", "Write-Host \"Tip: run 'auth0 agent skills install' to install the Auth0 skill for your AI coding assistants.\""] diff --git a/docs/Gemfile b/docs/Gemfile index d24312b1c..44c58dc2f 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -13,7 +13,7 @@ source "https://rubygems.org" # gem "github-pages", group: :jekyll_plugins # If you have any plugins, put them here! group :jekyll_plugins do - gem "jekyll-feed", "~> 0.17" + gem "jekyll-feed", "~> 0.18" end # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem @@ -23,4 +23,4 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do gem "tzinfo-data" end -gem "github-pages", "~> 232", group: :jekyll_plugins +gem "github-pages", "~> 233", group: :jekyll_plugins diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 8a1116fe4..47fde30e6 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -1,61 +1,65 @@ GEM remote: https://rubygems.org/ specs: - activesupport (7.2.3.1) + activesupport (8.1.4.1) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) - minitest (>= 5.1, < 6) + minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) - addressable (2.9.0) + uri (>= 0.13.1) + addressable (2.9.2) public_suffix (>= 2.0.2, < 8.0) base64 (0.3.0) - benchmark (0.5.0) - bigdecimal (4.0.1) + bigdecimal (4.1.3) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) colorator (1.1.0) - commonmarker (0.23.10) - concurrent-ruby (1.3.7) + commonmarker (0.23.12) + concurrent-ruby (1.3.8) connection_pool (3.0.2) - csv (3.3.0) - dnsruby (1.72.2) + csv (3.3.7) + dnsruby (1.74.0) + base64 (>= 0.2) + logger (~> 1.6) simpleidn (~> 0.2.1) drb (2.2.3) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - ethon (0.16.0) + ethon (0.19.1) ffi (>= 1.15.0) + logger eventmachine (1.2.7) - execjs (2.9.1) - faraday (2.14.3) - faraday-net_http (>= 2.0, < 3.5) + execjs (2.10.2) + json (>= 2) + faraday (2.15.1) + faraday-net_http (>= 2.0, < 3.6) json logger - faraday-net_http (3.4.4) + faraday-net_http (3.5.0) net-http (~> 0.5) - ffi (1.17.0) - ffi (1.17.0-x86_64-darwin) - ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.4) + ffi (1.17.4-x86_64-darwin) + ffi (1.17.4-x86_64-linux-gnu) forwardable-extended (2.6.0) gemoji (4.1.0) - github-pages (232) + github-pages (233) github-pages-health-check (= 1.18.2) jekyll (= 3.10.0) jekyll-avatar (= 0.8.0) jekyll-coffeescript (= 1.2.2) jekyll-commonmark-ghpages (= 0.5.1) jekyll-default-layout (= 0.1.5) - jekyll-feed (= 0.17.0) + jekyll-feed (= 0.18.0) jekyll-gist (= 1.5.0) jekyll-github-metadata (= 2.16.1) jekyll-include-cache (= 0.2.1) @@ -63,11 +67,11 @@ GEM jekyll-optional-front-matter (= 0.3.2) jekyll-paginate (= 1.1.0) jekyll-readme-index (= 0.3.0) - jekyll-redirect-from (= 0.16.0) + jekyll-redirect-from (= 0.17.0) jekyll-relative-links (= 0.6.1) - jekyll-remote-theme (= 0.4.3) + jekyll-remote-theme (= 0.6.2) jekyll-sass-converter (= 1.5.2) - jekyll-seo-tag (= 2.8.0) + jekyll-seo-tag (= 2.9.1) jekyll-sitemap (= 1.4.0) jekyll-swiss (= 1.0.0) jekyll-theme-architect (= 0.2.0) @@ -103,8 +107,8 @@ GEM html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) - http_parser.rb (0.8.0) - i18n (1.14.8) + http_parser.rb (0.8.1) + i18n (1.15.2) concurrent-ruby (~> 1.0) jekyll (3.10.0) addressable (~> 2.4) @@ -135,7 +139,7 @@ GEM rouge (>= 2.0, < 5.0) jekyll-default-layout (0.1.5) jekyll (>= 3.0, < 5.0) - jekyll-feed (0.17.0) + jekyll-feed (0.18.0) jekyll (>= 3.7, < 5.0) jekyll-gist (1.5.0) octokit (~> 4.2) @@ -152,18 +156,19 @@ GEM jekyll-paginate (1.1.0) jekyll-readme-index (0.3.0) jekyll (>= 3.0, < 5.0) - jekyll-redirect-from (0.16.0) + jekyll-redirect-from (0.17.0) jekyll (>= 3.3, < 5.0) jekyll-relative-links (0.6.1) jekyll (>= 3.3, < 5.0) - jekyll-remote-theme (0.4.3) + jekyll-remote-theme (0.6.2) addressable (~> 2.0) jekyll (>= 3.5, < 5.0) - jekyll-sass-converter (>= 1.0, <= 3.0.0, != 2.0.0) - rubyzip (>= 1.3.0, < 3.0) + jekyll-sass-converter (>= 1.0, < 4.0, != 2.0.0) + openssl (>= 3.1.2) + rubyzip (>= 1.3.0, < 4.0) jekyll-sass-converter (1.5.2) sass (~> 3.4) - jekyll-seo-tag (2.8.0) + jekyll-seo-tag (2.9.1) jekyll (>= 3.8, < 5.0) jekyll-sitemap (1.4.0) jekyll (>= 3.7, < 5.0) @@ -216,13 +221,14 @@ GEM gemoji (>= 3, < 5) html-pipeline (~> 2.2) jekyll (>= 3.0, < 5.0) - json (2.19.9) + json (3.1.0) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) liquid (4.0.4) - listen (3.9.0) + listen (3.10.1) + logger rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) @@ -232,49 +238,57 @@ GEM jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - minitest (5.27.0) - net-http (0.9.1) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) + net-http (0.10.0) + net-protocol (>= 0.3.0) uri (>= 0.11.1) - nokogiri (1.19.4) + net-protocol (0.4.0) + timeout + nokogiri (1.19.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.19.4-x86_64-darwin) + nokogiri (1.19.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.19.4-x86_64-linux-gnu) + nokogiri (1.19.7-x86_64-linux-gnu) racc (~> 1.4) octokit (4.25.1) faraday (>= 1, < 3) sawyer (~> 0.9) + openssl (4.0.2) pathutil (0.16.2) forwardable-extended (~> 2.6) + prism (1.9.0) public_suffix (5.1.1) racc (1.8.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rexml (3.4.2) + rexml (3.4.4) rouge (3.30.0) - rubyzip (2.3.2) + rubyzip (3.7.0) safe_yaml (1.0.5) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sawyer (0.9.2) + sawyer (0.9.3) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) securerandom (0.4.1) simpleidn (0.2.3) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) - typhoeus (1.4.1) - ethon (>= 0.9.0) + timeout (0.6.1) + typhoeus (1.7.1) + ethon (>= 0.19.1, < 0.20.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (1.8.0) - uri (1.1.1) - webrick (1.8.2) + uri (1.1.2) + webrick (1.9.2) PLATFORMS ruby @@ -284,8 +298,8 @@ PLATFORMS x86_64-linux DEPENDENCIES - github-pages (~> 232) - jekyll-feed (~> 0.17) + github-pages (~> 233) + jekyll-feed (~> 0.18) tzinfo (~> 1.2) tzinfo-data diff --git a/go.mod b/go.mod index bac29182c..b48ed2e07 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/briandowns/spinner v1.23.2 github.com/charmbracelet/glamour v1.0.0 github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e - github.com/dlclark/regexp2 v1.11.5 + github.com/dlclark/regexp2 v1.12.0 github.com/fsnotify/fsnotify v1.10.1 github.com/getkin/kin-openapi v0.152.0 github.com/getsentry/sentry-go v0.50.0 @@ -20,7 +20,7 @@ require ( github.com/gorilla/websocket v1.5.3 github.com/hashicorp/go-version v1.9.0 github.com/hashicorp/hc-install v0.10.0 - github.com/hashicorp/terraform-exec v0.25.3 + github.com/hashicorp/terraform-exec v0.26.0 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/lestrrat-go/jwx/v2 v2.1.7 github.com/lestrrat-go/jwx/v3 v3.4.0 @@ -70,7 +70,7 @@ require ( github.com/gorilla/css v1.0.1 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-retryablehttp v0.7.8 // indirect - github.com/hashicorp/terraform-json v0.28.0 // indirect + github.com/hashicorp/terraform-json v0.29.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/lestrrat-go/blackmagic v1.0.4 // indirect github.com/lestrrat-go/dsig v1.4.0 // indirect diff --git a/go.sum b/go.sum index 2eedac152..583b13975 100644 --- a/go.sum +++ b/go.sum @@ -75,8 +75,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 h1:5RVFMOWjMyRy8cARdy79nAmgYw3hK/4HUq48LQ6Wwqo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40= -github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= -github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.12.0 h1:0j4c5qQmnC6XOWNjP3PIXURXN2gWx76rd3KvgdPkCz8= +github.com/dlclark/regexp2 v1.12.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= @@ -126,10 +126,10 @@ github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaX github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hc-install v0.10.0 h1:uIxUzTXNIm3O36cERJZikxUwbCacDUOhjZ9UKpm3oCQ= github.com/hashicorp/hc-install v0.10.0/go.mod h1:5kfh7dISJeGaGA1OuETooZsk6p9LVctKt3Hq5RM6oMU= -github.com/hashicorp/terraform-exec v0.25.3 h1:Xr9DBt2LX4deJnahlbhw7N25MFPDMxzj/VzE7cdFBoc= -github.com/hashicorp/terraform-exec v0.25.3/go.mod h1:NeE9+ss4hLaLuVlOIr+M6FK7Bqyy+JLZUHo5kQph+ME= -github.com/hashicorp/terraform-json v0.28.0 h1:dOkJT55rWfU6T1/VklHde51ym4LfNP+9xYR3ZizAJe4= -github.com/hashicorp/terraform-json v0.28.0/go.mod h1:PJIRf+Yzu5iLb52c/xYp1tUOL4jzMzfIAB5gvWWKIWE= +github.com/hashicorp/terraform-exec v0.26.0 h1:0h8YOfbKHWfCLUsvn24QVKCD9lEyjE/9VjV1fGDApRE= +github.com/hashicorp/terraform-exec v0.26.0/go.mod h1:AzXiGH+CZQvpzfubB5reUaN4D0xOfCh3prGGFrhPUo8= +github.com/hashicorp/terraform-json v0.29.0 h1:ZggVL0YzGj5zdbafX4+rDcROM7EvVU0eXlIMkHieptI= +github.com/hashicorp/terraform-json v0.29.0/go.mod h1:PJIRf+Yzu5iLb52c/xYp1tUOL4jzMzfIAB5gvWWKIWE= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog= diff --git a/internal/cli/logs_test.go b/internal/cli/logs_test.go index 520d64a2f..9bff2f0df 100644 --- a/internal/cli/logs_test.go +++ b/internal/cli/logs_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "sync" "testing" "time" @@ -17,6 +18,18 @@ import ( "github.com/auth0/auth0-cli/internal/display" ) +// syncBuffer is a bytes.Buffer safe for the tail goroutine and renderer to write concurrently. +type syncBuffer struct { + mu sync.Mutex + buf bytes.Buffer +} + +func (b *syncBuffer) Write(p []byte) (int, error) { + b.mu.Lock() + defer b.mu.Unlock() + return b.buf.Write(p) +} + func TestTailLogsCommand(t *testing.T) { t.Run("it returns an error when it fails to get the logs on the first request", func(t *testing.T) { ctrl := gomock.NewController(t) @@ -123,8 +136,8 @@ API Operation Update branding settings cli := &cli{ renderer: &display.Renderer{ - MessageWriter: &bytes.Buffer{}, - ResultWriter: &bytes.Buffer{}, + MessageWriter: &syncBuffer{}, + ResultWriter: &syncBuffer{}, }, api: &auth0.API{Log: logsAPI}, }