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
20 changes: 9 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module github.com/temporalio/cloud-cli

go 1.26.8
go 1.27

require (
github.com/aws/aws-sdk-go-v2 v1.41.11
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.19.0
github.com/google/go-cmp v0.7.0
github.com/kylelemons/godebug v1.1.0
github.com/mattn/go-isatty v0.0.22
github.com/olekukonko/tablewriter v1.1.4
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/spf13/cobra v1.10.2
Expand All @@ -20,6 +22,7 @@ require (
golang.org/x/oauth2 v0.36.0
golang.org/x/term v0.43.0
google.golang.org/grpc v1.82.1
google.golang.org/protobuf v1.36.11
)

require (
Expand All @@ -28,6 +31,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
Expand All @@ -48,13 +52,16 @@ require (
github.com/knadh/koanf/providers/posflag v1.0.1 // indirect
github.com/knadh/koanf/providers/structs v1.0.0 // indirect
github.com/knadh/koanf/v2 v2.3.2 // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/nexus-rpc/nexus-proto-annotations v0.1.0 // indirect
github.com/nexus-rpc/sdk-go v0.6.0 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.3.0 // indirect
github.com/olekukonko/ll v0.1.8 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rs/zerolog v1.34.0 // indirect
github.com/stretchr/objx v0.5.3 // indirect
Expand All @@ -67,6 +74,7 @@ require (
golang.org/x/mod v0.35.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.37.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/tools v0.44.0 // indirect
Expand All @@ -75,14 +83,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
github.com/mattn/go-isatty v0.0.22
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
golang.org/x/sys v0.45.0 // indirect
google.golang.org/protobuf v1.36.11
)

tool github.com/vektra/mockery/v3
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
go.temporal.io/api v1.63.6-0.20260811224032-89570b10e9e2 h1:VeNTxlOHETym01zX6kSXHIVw4nc2RrX/KVgepQ/dr/8=
go.temporal.io/api v1.63.6-0.20260811224032-89570b10e9e2/go.mod h1:SrlW2JMwVlDP4nRWSNznUFqnSHd+YeMDS1BkYo63HCQ=
go.temporal.io/cloud-sdk v0.18.0 h1:7jGf76PwO6teN/wCkFlrf5yEsJcUrtbMw1hxV/l0a9M=
go.temporal.io/cloud-sdk v0.18.0/go.mod h1:W2O9t9tvo3Q/LhGgYdj8JijWbN5C84os+cz/BadIHYI=
go.temporal.io/cloud-sdk v0.19.0 h1:Vjr8a75hdxbq6VAiZJz7WboqhGA2NhmXl5A6ZFrVt60=
go.temporal.io/cloud-sdk v0.19.0/go.mod h1:W2O9t9tvo3Q/LhGgYdj8JijWbN5C84os+cz/BadIHYI=
go.temporal.io/sdk v1.44.1 h1:Mt2OZLZpqkzDIdg9YyQzO0Rb/HqCDnnqHlIAGAJ5gqM=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package temporalcloudcli_test
import (
"bytes"
"context"
"encoding/json"
"errors"
"testing"

Expand Down Expand Up @@ -440,7 +439,7 @@ func TestValidateAuditLogSinkKinesis_Success(t *testing.T) {
var out struct {
Status string `json:"status"`
}
require.NoError(t, json.Unmarshal(buf.Bytes(), &out))
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Equal(t, "valid", out.Status)
}

Expand Down
11 changes: 7 additions & 4 deletions temporalcloudcli/commands.account.auditlog.sink.pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package temporalcloudcli_test
import (
"bytes"
"context"
"encoding/json"
"errors"
"testing"

Expand Down Expand Up @@ -329,9 +328,13 @@ func TestValidateAuditLogSinkPubSub_Success(t *testing.T) {
})
require.NoError(t, err)

var out struct{ Status string }
require.NoError(t, json.Unmarshal(buf.Bytes(), &out))
assert.Equal(t, struct{ Status string }{Status: "valid"}, out)
var out struct {
Status string `json:"status"`
}
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Equal(t, struct {
Status string `json:"status"`
}{Status: "valid"}, out)
}

// TestValidateAuditLogSinkPubSub_APIError verifies that a ValidateAccountAuditLogSink error is returned.
Expand Down
17 changes: 9 additions & 8 deletions temporalcloudcli/commands.account.auditlog.sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package temporalcloudcli_test
import (
"bytes"
"context"
"encoding/json"
"errors"
"testing"

"github.com/google/go-cmp/cmp"
cloudmock "github.com/temporalio/cloud-cli/internal/cloudservice/mock"
"github.com/temporalio/cloud-cli/temporalcloudcli"
"github.com/temporalio/cloud-cli/temporalcloudcli/internal/printer"
cmdmock "github.com/temporalio/cloud-cli/temporalcloudcli/mock"
accountv1 "go.temporal.io/cloud-sdk/api/account/v1"
cloudservice "go.temporal.io/cloud-sdk/api/cloudservice/v1"
operation "go.temporal.io/cloud-sdk/api/operation/v1"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/testing/protocmp"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -44,7 +44,7 @@ func TestGetAuditLogSink_Success(t *testing.T) {

// Printer uses protojson for proto messages (camelCase output).
var out accountv1.AuditLogSink
require.NoError(t, protojson.Unmarshal(buf.Bytes(), &out))
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Equal(t, sink.Name, out.Name)
assert.Equal(t, sink.ResourceVersion, out.ResourceVersion)
}
Expand Down Expand Up @@ -91,15 +91,16 @@ func TestListAuditLogSinks_Success(t *testing.T) {
require.NoError(t, err)

type listResponse struct {
Sinks []*accountv1.AuditLogSink `json:"sinks"`
NextPageToken string `json:"nextPageToken"`
Sinks []*accountv1.AuditLogSink
NextPageToken string
}
var out listResponse
require.NoError(t, json.Unmarshal(buf.Bytes(), &out))
assert.Equal(t, listResponse{
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Empty(t, cmp.Diff(listResponse{
Sinks: sinks,
NextPageToken: "next-token",
}, out)
}, out,
protocmp.Transform()))
}

func TestListAuditLogSinks_WithPagination(t *testing.T) {
Expand Down
15 changes: 8 additions & 7 deletions temporalcloudcli/commands.account.auditlog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package temporalcloudcli_test
import (
"bytes"
"context"
"encoding/json"
"errors"
"testing"
"time"

"github.com/google/go-cmp/cmp"
cloudmock "github.com/temporalio/cloud-cli/internal/cloudservice/mock"
"github.com/temporalio/cloud-cli/temporalcloudcli"
"github.com/temporalio/cloud-cli/temporalcloudcli/internal/printer"
auditlogv1 "go.temporal.io/cloud-sdk/api/auditlog/v1"
cloudservice "go.temporal.io/cloud-sdk/api/cloudservice/v1"
"google.golang.org/protobuf/testing/protocmp"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/stretchr/testify/assert"
Expand All @@ -23,8 +24,8 @@ func TestListAuditLogs_Success(t *testing.T) {
mockCloud := cloudmock.NewMockCloudServiceClient(t)

expected := struct {
AuditLogs []*auditlogv1.LogRecord `json:"auditLogs"`
NextPageToken string `json:"nextPageToken"`
AuditLogs []*auditlogv1.LogRecord
NextPageToken string
}{
AuditLogs: []*auditlogv1.LogRecord{
{LogId: "log-1", Operation: "CreateNamespace"},
Expand All @@ -47,11 +48,11 @@ func TestListAuditLogs_Success(t *testing.T) {
require.NoError(t, err)

var out struct {
AuditLogs []*auditlogv1.LogRecord `json:"auditLogs"`
NextPageToken string `json:"nextPageToken"`
AuditLogs []*auditlogv1.LogRecord
NextPageToken string
}
require.NoError(t, json.Unmarshal(buf.Bytes(), &out))
assert.Equal(t, expected, out)
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Empty(t, cmp.Diff(expected, out, protocmp.Transform()))
}

func TestGetAuditLogs_WithPagination(t *testing.T) {
Expand Down
16 changes: 8 additions & 8 deletions temporalcloudcli/commands.connectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package temporalcloudcli_test
import (
"bytes"
"context"
"encoding/json"
"errors"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
cloudservice "go.temporal.io/cloud-sdk/api/cloudservice/v1"
connectivityrulev1 "go.temporal.io/cloud-sdk/api/connectivityrule/v1"
operation "go.temporal.io/cloud-sdk/api/operation/v1"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"

cloudmock "github.com/temporalio/cloud-cli/internal/cloudservice/mock"
"github.com/temporalio/cloud-cli/temporalcloudcli"
Expand Down Expand Up @@ -42,12 +42,12 @@ func TestListConnectivityRules_Success(t *testing.T) {
require.NoError(t, err)

type listConnectivityRulesOutput struct {
ConnectivityRules []*connectivityrulev1.ConnectivityRule `json:"connectivityRules"`
NextPageToken string `json:"nextPageToken"`
ConnectivityRules []*connectivityrulev1.ConnectivityRule
NextPageToken string
}
var out listConnectivityRulesOutput
require.NoError(t, json.Unmarshal(buf.Bytes(), &out))
assert.Equal(t, listConnectivityRulesOutput{ConnectivityRules: rules, NextPageToken: ""}, out)
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Empty(t, cmp.Diff(listConnectivityRulesOutput{ConnectivityRules: rules, NextPageToken: ""}, out, protocmp.Transform()))
}

// TestListConnectivityRules_WithNamespace verifies that the namespace filter is passed through.
Expand Down Expand Up @@ -135,8 +135,8 @@ func TestGetConnectivityRule_Success(t *testing.T) {
require.NoError(t, err)

var out connectivityrulev1.ConnectivityRule
require.NoError(t, json.Unmarshal(buf.Bytes(), &out))
assert.True(t, proto.Equal(&connectivityrulev1.ConnectivityRule{Id: "rule-1"}, &out))
require.NoError(t, unmarshalWithProtos(buf.Bytes(), &out))
assert.Empty(t, cmp.Diff(&connectivityrulev1.ConnectivityRule{Id: "rule-1", ResourceVersion: "rv-1"}, &out, protocmp.Transform()))
}

// TestGetConnectivityRule_Error verifies that an API error propagates.
Expand Down
23 changes: 12 additions & 11 deletions temporalcloudcli/commands.namespace.cert_ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (
"crypto/x509"
"crypto/x509/pkix"
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"math/big"
"os"
"testing"
"time"

"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand All @@ -27,6 +27,7 @@ import (
"go.temporal.io/cloud-sdk/api/operation/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/testing/protocmp"
)

func TestCloudNamespaceCertCaCreateCommand_Success(t *testing.T) {
Expand Down Expand Up @@ -80,15 +81,15 @@ func TestCloudNamespaceCertCaCreateCommand_Success(t *testing.T) {
},
assertResult: func(t *testing.T, buf bytes.Buffer) {
var result temporalcloudcli.MutationResult
err := json.Unmarshal(buf.Bytes(), &result)
err := unmarshalWithProtos(buf.Bytes(), &result)
require.NoError(t, err)
expected := temporalcloudcli.MutationResult{
AsyncOp: &operation.AsyncOperation{
Id: "test-operation-id",
},
ID: "test-namespace.test-account",
}
assert.Equal(t, expected, result)
assert.Empty(t, cmp.Diff(expected, result, protocmp.Transform()))
},
},
{
Expand All @@ -113,15 +114,15 @@ func TestCloudNamespaceCertCaCreateCommand_Success(t *testing.T) {
},
assertResult: func(t *testing.T, buf bytes.Buffer) {
var result temporalcloudcli.MutationResult
err := json.Unmarshal(buf.Bytes(), &result)
err := unmarshalWithProtos(buf.Bytes(), &result)
require.NoError(t, err)
expected := temporalcloudcli.MutationResult{
AsyncOp: &operation.AsyncOperation{
Id: "test-operation-id",
},
ID: "test-namespace.test-account",
}
assert.Equal(t, expected, result)
assert.Empty(t, cmp.Diff(expected, result, protocmp.Transform()))
},
},
{
Expand Down Expand Up @@ -313,7 +314,7 @@ func TestCloudNamespaceMtlsCertCaCreateCommand_NothingToChange(t *testing.T) {
var result struct {
Status string `json:"status"`
}
err := json.Unmarshal(buf.Bytes(), &result)
err := unmarshalWithProtos(buf.Bytes(), &result)
require.NoError(t, err)
assert.Equal(t, "unchanged", result.Status)
},
Expand Down Expand Up @@ -574,15 +575,15 @@ func TestCloudNamespaceMtlsCertCaDeleteCommand_Success(t *testing.T) {
},
assertResult: func(t *testing.T, buf bytes.Buffer) {
var result temporalcloudcli.MutationResult
err := json.Unmarshal(buf.Bytes(), &result)
err := unmarshalWithProtos(buf.Bytes(), &result)
require.NoError(t, err)
expected := temporalcloudcli.MutationResult{
AsyncOp: &operation.AsyncOperation{
Id: "test-operation-id",
},
ID: "test-namespace.test-account",
}
assert.Equal(t, expected, result)
assert.Empty(t, cmp.Diff(expected, result, protocmp.Transform()))
},
},
{
Expand All @@ -607,15 +608,15 @@ func TestCloudNamespaceMtlsCertCaDeleteCommand_Success(t *testing.T) {
},
assertResult: func(t *testing.T, buf bytes.Buffer) {
var result temporalcloudcli.MutationResult
err := json.Unmarshal(buf.Bytes(), &result)
err := unmarshalWithProtos(buf.Bytes(), &result)
require.NoError(t, err)
expected := temporalcloudcli.MutationResult{
AsyncOp: &operation.AsyncOperation{
Id: "test-operation-id",
},
ID: "test-namespace.test-account",
}
assert.Equal(t, expected, result)
assert.Empty(t, cmp.Diff(expected, result, protocmp.Transform()))
},
},
{
Expand Down Expand Up @@ -816,7 +817,7 @@ func TestCloudNamespaceMtlsCertCaDeleteCommand_NothingToChange(t *testing.T) {
var result struct {
Status string `json:"status"`
}
err := json.Unmarshal(buf.Bytes(), &result)
err := unmarshalWithProtos(buf.Bytes(), &result)
require.NoError(t, err)
assert.Equal(t, "unchanged", result.Status)
},
Expand Down
Loading
Loading