Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
Expand All @@ -74,10 +74,10 @@ jobs:
REPORT_FILE: gl-license-scanning-report.json

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
Expand All @@ -89,7 +89,7 @@ jobs:
run: |
go-licenses report . > licenses.csv
- name: Save license scan report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: license_scanning
path: licenses.csv
Expand All @@ -102,15 +102,15 @@ jobs:
timeout-minutes: 5

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
Expand All @@ -129,10 +129,10 @@ jobs:
timeout-minutes: 10

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
Expand All @@ -155,10 +155,10 @@ jobs:
QUAY_PASSWORD: ${{ secrets.QUAY_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false
Expand All @@ -177,7 +177,7 @@ jobs:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Go releaser publish
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -193,7 +193,7 @@ jobs:
run: mkdir -p dist && printf '%s\n' "${TAG}" > dist/LATEST_VERSION

- name: Authenticate with AWS
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
29 changes: 29 additions & 0 deletions cmd/servicetoken/servicetoken_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ package servicetoken
import (
"testing"

"github.com/gookit/color"

"github.com/stackvista/stackstate-cli/generated/stackstate_api"
"github.com/stackvista/stackstate-cli/internal/di"
"github.com/stretchr/testify/assert"
)

func TestServiceTokenCreate(t *testing.T) {
forceColor(t)
cli := di.NewMockDeps(t)
cmd := CreateCommand(&cli.Deps)

Expand All @@ -25,6 +28,7 @@ func TestServiceTokenCreate(t *testing.T) {
}

func TestServiceTokenCreateExpirationOptional(t *testing.T) {
forceColor(t)
cli := di.NewMockDeps(t)
cmd := CreateCommand(&cli.Deps)

Expand All @@ -41,6 +45,7 @@ func TestServiceTokenCreateExpirationOptional(t *testing.T) {
}

func TestServiceTokenCreateMultipleRoles(t *testing.T) {
forceColor(t)
cli := di.NewMockDeps(t)
cmd := CreateCommand(&cli.Deps)

Expand Down Expand Up @@ -99,3 +104,27 @@ func checkCreateCall(t *testing.T, calls *[]stackstate_api.CreateNewServiceToken
assert.Nil(t, call.PnewServiceTokenRequest.ExpiryDate)
}
}

func TestServiceTokenCreateWithoutColor(t *testing.T) {
colorEnabled := color.Disable()
t.Cleanup(func() { color.Enable = colorEnabled })
cli := di.NewMockDeps(t)
cmd := CreateCommand(&cli.Deps)
cli.MockClient.ApiMocks.ServiceTokenApi.CreateNewServiceTokenResponse.Result = stackstate_api.ServiceTokenCreatedResponse{
Name: "test-token",
Token: "test-token-token",
}
di.ExecuteCommandWithContextUnsafe(&cli.Deps, cmd, "--name", "test-token", "--roles", "test-role")
assert.Equal(t, []string{"Service token created: test-token-token\n"}, *cli.MockPrinter.SuccessCalls)
}

func forceColor(t *testing.T) {
t.Helper()
colorEnabled := color.Enable
colorLevel := color.ForceColor()
color.Enable = true
t.Cleanup(func() {
color.Enable = colorEnabled
color.ForceSetColorLevel(colorLevel)
})
}
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ replace github.com/spf13/pflag => github.com/stackvista/pflag v1.22.0

require (
github.com/alecthomas/chroma v0.10.0
github.com/gookit/color v1.5.4
github.com/jedib0t/go-pretty/v6 v6.5.8
github.com/gookit/color v1.6.0
github.com/jedib0t/go-pretty/v6 v6.5.9
github.com/mitchellh/go-homedir v1.1.0
github.com/pterm/pterm v0.12.79
github.com/pterm/pterm v0.12.84
github.com/rs/zerolog v1.32.0
github.com/spf13/cobra v1.8.0
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.18.2
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.11.1
golang.org/x/oauth2 v0.37.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/blang/semver/v4 v4.0.0
github.com/mattn/go-runewidth v0.0.15
github.com/mattn/go-runewidth v0.0.31
github.com/mcuadros/go-defaults v1.2.0
github.com/spf13/pflag v1.0.5
github.com/spf13/pflag v1.0.10
golang.org/x/text v0.43.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/kubectl v0.29.15
Expand Down Expand Up @@ -80,9 +80,10 @@ require (

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/keyboard v0.2.10 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/containerd/console v1.0.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand All @@ -100,7 +101,6 @@ require (
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand Down
Loading