Skip to content

Commit

Permalink
CLI Unification: Reset config file to v1 (#1015)
Browse files Browse the repository at this point in the history
* remove CLIName from config

* remove further references to confluent and ccloud

* remove cliName references from goreleaser and login/logout

* remove last remaining ccloud and confluent references

* ps1 refactor

* remove extra confluent folder from autogenerated docs

* trigger build

* reset config back to v1

* fix inappropriately named package

* fix lint

* switch version number

* trigger build
  • Loading branch information
brianstrauch committed Sep 30, 2021
1 parent 0a5c703 commit 5b0e49e
Show file tree
Hide file tree
Showing 115 changed files with 1,059 additions and 3,498 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ root = true
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=true
indent_style=space
indent_size=4

Expand Down
8 changes: 4 additions & 4 deletions cmd/docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"

"github.com/confluentinc/cli/internal/cmd"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
"github.com/confluentinc/cli/internal/pkg/docs"
"github.com/confluentinc/cli/internal/pkg/version"
)
Expand All @@ -21,13 +21,13 @@ func main() {
}

// Auto-generate documentation for cloud and on-prem commands.
configs := []*v3.Config{
configs := []*v1.Config{
{
Contexts: map[string]*v3.Context{"Cloud": {PlatformName: v3.CCloudHostnames[0]}},
Contexts: map[string]*v1.Context{"Cloud": {PlatformName: v1.CCloudHostnames[0]}},
CurrentContext: "Cloud",
},
{
Contexts: map[string]*v3.Context{"On-Prem": {PlatformName: "https://example.com"}},
Contexts: map[string]*v1.Context{"On-Prem": {PlatformName: "https://example.com"}},
CurrentContext: "On-Prem",
},
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/client9/gospell"

"github.com/confluentinc/cli/internal/cmd"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
linter "github.com/confluentinc/cli/internal/pkg/lint-cli"
"github.com/confluentinc/cli/internal/pkg/version"
)
Expand Down Expand Up @@ -220,16 +220,16 @@ func main() {
}

// Lint all three subsets of commands: no context, cloud, and on-prem
configs := []*v3.Config{
configs := []*v1.Config{
{
CurrentContext: "no context",
},
{
Contexts: map[string]*v3.Context{"cloud": {PlatformName: v3.CCloudHostnames[0]}},
Contexts: map[string]*v1.Context{"cloud": {PlatformName: v1.CCloudHostnames[0]}},
CurrentContext: "cloud",
},
{
Contexts: map[string]*v3.Context{"on-prem": {PlatformName: "https://example.com"}},
Contexts: map[string]*v1.Context{"on-prem": {PlatformName: "https://example.com"}},
CurrentContext: "on-prem",
},
}
Expand Down
9 changes: 3 additions & 6 deletions internal/cmd/admin/command_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import (
"context"
"testing"

v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
v2 "github.com/confluentinc/cli/internal/pkg/config/v2"

billingv1 "github.com/confluentinc/cc-structs/kafka/billing/v1"
orgv1 "github.com/confluentinc/cc-structs/kafka/org/v1"
"github.com/confluentinc/ccloud-sdk-go-v1"
Expand All @@ -16,7 +13,7 @@ import (
"github.com/stretchr/testify/require"

pcmd "github.com/confluentinc/cli/internal/pkg/cmd"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
"github.com/confluentinc/cli/internal/pkg/mock"
climock "github.com/confluentinc/cli/mock"
)
Expand Down Expand Up @@ -140,7 +137,7 @@ func getCommand() (c *command) {
Version: nil,
},
Client: mockClient(),
State: &v2.ContextState{
State: &v1.ContextState{
Auth: &v1.AuthConfig{
User: &orgv1.User{},
Organization: &orgv1.Organization{
Expand All @@ -156,7 +153,7 @@ func getCommand() (c *command) {

func mockAdminCommand() *cobra.Command {
client := mockClient()
cfg := v3.AuthenticatedCloudConfigMock()
cfg := v1.AuthenticatedCloudConfigMock()
return New(climock.NewPreRunnerMock(client, nil, nil, cfg), true)
}

Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/admin/command_promo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
ccloudmock "github.com/confluentinc/ccloud-sdk-go-v1/mock"

pcmd "github.com/confluentinc/cli/internal/pkg/cmd"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
climock "github.com/confluentinc/cli/mock"
)

Expand All @@ -26,7 +26,7 @@ func TestPromoAdd(t *testing.T) {
},
}

cfg := v3.AuthenticatedCloudConfigMock()
cfg := v1.AuthenticatedCloudConfigMock()
cmd := New(climock.NewPreRunnerMock(client, nil, nil, cfg), true)

out, err := pcmd.ExecuteCommand(cmd, "promo", "add", "XXXXX")
Expand All @@ -44,7 +44,7 @@ func TestPromoListEmpty(t *testing.T) {
},
}

cfg := v3.AuthenticatedCloudConfigMock()
cfg := v1.AuthenticatedCloudConfigMock()
cmd := New(climock.NewPreRunnerMock(client, nil, nil, cfg), true)

out, err := pcmd.ExecuteCommand(cmd, "promo", "list")
Expand Down
25 changes: 12 additions & 13 deletions internal/cmd/api-key/apikey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

v1 "github.com/confluentinc/cc-structs/kafka/org/v1"
orgv1 "github.com/confluentinc/cc-structs/kafka/org/v1"
schedv1 "github.com/confluentinc/cc-structs/kafka/scheduler/v1"
"github.com/confluentinc/ccloud-sdk-go-v1"
ccsdkmock "github.com/confluentinc/ccloud-sdk-go-v1/mock"

"github.com/confluentinc/cli/internal/cmd/utils"
"github.com/confluentinc/cli/internal/pkg/analytics"
pcmd "github.com/confluentinc/cli/internal/pkg/cmd"
v0 "github.com/confluentinc/cli/internal/pkg/config/v0"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
"github.com/confluentinc/cli/internal/pkg/mock"
cliMock "github.com/confluentinc/cli/mock"
)
Expand Down Expand Up @@ -78,7 +77,7 @@ var (

type APITestSuite struct {
suite.Suite
conf *v3.Config
conf *v1.Config
apiMock *ccsdkmock.APIKey
keystore *mock.KeyStore
kafkaCluster *schedv1.KafkaCluster
Expand All @@ -95,14 +94,14 @@ type APITestSuite struct {

//Require
func (suite *APITestSuite) SetupTest() {
suite.conf = v3.AuthenticatedCloudConfigMock()
suite.conf = v1.AuthenticatedCloudConfigMock()
ctx := suite.conf.Context()

srCluster := ctx.SchemaRegistryClusters[ctx.State.Auth.Account.Id]
srCluster.SrCredentials = &v0.APIKeyPair{Key: apiKeyVal, Secret: apiSecretVal}
srCluster.SrCredentials = &v1.APIKeyPair{Key: apiKeyVal, Secret: apiSecretVal}
cluster := ctx.KafkaClusterContext.GetActiveKafkaClusterConfig()
// Set up audit logs
ctx.State.Auth.Organization.AuditLog = &v1.AuditLog{
ctx.State.Auth.Organization.AuditLog = &orgv1.AuditLog{
ClusterId: cluster.ID,
AccountId: "env-zy987",
ServiceAccountId: auditLogServiceAccountId,
Expand Down Expand Up @@ -180,22 +179,22 @@ func (suite *APITestSuite) SetupTest() {
},
}
suite.userMock = &ccsdkmock.User{
DescribeFunc: func(arg0 context.Context, arg1 *v1.User) (user *v1.User, e error) {
return &v1.User{
DescribeFunc: func(arg0 context.Context, arg1 *orgv1.User) (user *orgv1.User, e error) {
return &orgv1.User{
Email: "csreesangkom@confluent.io",
}, nil
},
GetServiceAccountsFunc: func(arg0 context.Context) (users []*v1.User, e error) {
return []*v1.User{
GetServiceAccountsFunc: func(arg0 context.Context) (users []*orgv1.User, e error) {
return []*orgv1.User{
{
Id: serviceAccountId,
ResourceId: userResourceId,
ServiceName: serviceAccountName,
},
}, nil
},
ListFunc: func(_ context.Context) ([]*v1.User, error) {
return []*v1.User{
ListFunc: func(_ context.Context) ([]*orgv1.User, error) {
return []*orgv1.User{
{
Id: serviceAccountId,
ResourceId: userResourceId,
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/api-key/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

"github.com/confluentinc/cli/internal/pkg/analytics"
pcmd "github.com/confluentinc/cli/internal/pkg/cmd"
configv1 "github.com/confluentinc/cli/internal/pkg/config/v1"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
"github.com/confluentinc/cli/internal/pkg/errors"
"github.com/confluentinc/cli/internal/pkg/examples"
"github.com/confluentinc/cli/internal/pkg/keystore"
Expand Down Expand Up @@ -457,7 +457,7 @@ func (c *command) delete(cmd *cobra.Command, args []string) error {
func (c *command) store(cmd *cobra.Command, args []string) error {
c.setKeyStoreIfNil()

var cluster *configv1.KafkaClusterConfig
var cluster *v1.KafkaClusterConfig

// Attempt to get cluster from --resource flag if set; if that doesn't work,
// attempt to fall back to the currently active Kafka cluster
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/audit-log/command_describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"

pcmd "github.com/confluentinc/cli/internal/pkg/cmd"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
climock "github.com/confluentinc/cli/mock"
)

Expand All @@ -32,7 +32,7 @@ func TestAuditLogDescribeUnconfigured(t *testing.T) {

func mockAuditLogCommand(configured bool) *cobra.Command {
client := &ccloud.Client{}
cfg := v3.AuthenticatedCloudConfigMock()
cfg := v1.AuthenticatedCloudConfigMock()
if configured {
cfg.Context().State.Auth.Organization.AuditLog = &orgv1.AuditLog{
ClusterId: "lkc-ab123",
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/audit-log/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
cliMock "github.com/confluentinc/cli/mock"
)

Expand Down Expand Up @@ -84,7 +84,7 @@ var (

type AuditConfigTestSuite struct {
suite.Suite
conf *v3.Config
conf *v1.Config
mockApi mds.AuditLogConfigurationApi
}

Expand All @@ -104,7 +104,7 @@ type MockCall struct {
}

func (suite *AuditConfigTestSuite) SetupSuite() {
suite.conf = v3.AuthenticatedOnPremConfigMock()
suite.conf = v1.AuthenticatedOnPremConfigMock()
}

func (suite *AuditConfigTestSuite) TearDownSuite() {
Expand Down
14 changes: 7 additions & 7 deletions internal/cmd/cloud-signup/command_signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

"github.com/spf13/cobra"

v1 "github.com/confluentinc/cc-structs/kafka/org/v1"
orgv1 "github.com/confluentinc/cc-structs/kafka/org/v1"
"github.com/confluentinc/ccloud-sdk-go-v1"

pauth "github.com/confluentinc/cli/internal/pkg/auth"
Expand Down Expand Up @@ -122,17 +122,17 @@ func (c *command) Signup(cmd *cobra.Command, prompt form.Prompt, client *ccloud.
return err
}

req := &v1.SignupRequest{
Organization: &v1.Organization{
req := &orgv1.SignupRequest{
Organization: &orgv1.Organization{
Name: fOrgPswdTosPri.Responses["organization"].(string),
Plan: &v1.Plan{AcceptTos: &types.BoolValue{Value: fOrgPswdTosPri.Responses["tos"].(bool)}},
Plan: &orgv1.Plan{AcceptTos: &types.BoolValue{Value: fOrgPswdTosPri.Responses["tos"].(bool)}},
},
User: &v1.User{
User: &orgv1.User{
Email: fEmailName.Responses["email"].(string),
FirstName: fEmailName.Responses["first"].(string),
LastName: fEmailName.Responses["last"].(string),
},
Credentials: &v1.Credentials{
Credentials: &orgv1.Credentials{
Password: fOrgPswdTosPri.Responses["password"].(string),
},
CountryCode: countryCode,
Expand All @@ -155,7 +155,7 @@ func (c *command) Signup(cmd *cobra.Command, prompt form.Prompt, client *ccloud.
}

if !v.Responses["verified"].(bool) {
if err := client.Signup.SendVerificationEmail(context.Background(), &v1.User{Email: fEmailName.Responses["email"].(string)}); err != nil {
if err := client.Signup.SendVerificationEmail(context.Background(), &orgv1.User{Email: fEmailName.Responses["email"].(string)}); err != nil {
return err
}

Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/cloud-signup/command_signup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
ccloudmock "github.com/confluentinc/ccloud-sdk-go-v1/mock"

cmdPkg "github.com/confluentinc/cli/internal/pkg/cmd"
v3 "github.com/confluentinc/cli/internal/pkg/config/v3"
v1 "github.com/confluentinc/cli/internal/pkg/config/v1"
"github.com/confluentinc/cli/internal/pkg/form"
"github.com/confluentinc/cli/internal/pkg/mock"
cliMock "github.com/confluentinc/cli/mock"
Expand Down Expand Up @@ -150,9 +150,9 @@ func testCloudSignup(t *testing.T, prompt form.Prompt, expected ...string) {
buf := new(bytes.Buffer)
cmd.SetOut(buf)

cloudSignupCmd := newCmd(v3.AuthenticatedCloudConfigMock())
cloudSignupCmd := newCmd(v1.AuthenticatedCloudConfigMock())
cloudSignupCmd.Config = &cmdPkg.DynamicConfig{
Config: v3.UnauthenticatedCloudConfigMock(),
Config: v1.UnauthenticatedCloudConfigMock(),
}

err := cloudSignupCmd.Signup(cmd, prompt, mockCcloudClient())
Expand All @@ -163,7 +163,7 @@ func testCloudSignup(t *testing.T, prompt form.Prompt, expected ...string) {
}
}

func newCmd(conf *v3.Config) *command {
func newCmd(conf *v1.Config) *command {
client := mockCcloudClient()
prerunner := cliMock.NewPreRunnerMock(client, nil, nil, conf)
auth := &ccloudmock.Auth{
Expand Down
Loading

0 comments on commit 5b0e49e

Please sign in to comment.