Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cloud rename - update CLI and environment variables TKC-875 #4663

Merged
merged 3 commits into from
Nov 23, 2023
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: 11 additions & 9 deletions cmd/api-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func runMongoMigrations(ctx context.Context, db *mongo.Database, migrationsDir s

func main() {
cfg, err := config.Get()
cfg.CleanLegacyVars()

ui.ExitOnError("error getting application config", err)
// Run services within an errgroup to propagate errors between services.
g, ctx := errgroup.WithContext(context.Background())
Expand Down Expand Up @@ -167,11 +169,11 @@ func main() {
var grpcClient cloud.TestKubeCloudAPIClient
var grpcConn *grpc.ClientConn
mode := common.ModeStandalone
if cfg.TestkubeCloudAPIKey != "" {
if cfg.TestkubeProAPIKey != "" {
mode = common.ModeAgent
}
if mode == common.ModeAgent {
grpcConn, err = agent.NewGRPCConnection(ctx, cfg.TestkubeCloudTLSInsecure, cfg.TestkubeCloudURL, log.DefaultLogger)
grpcConn, err = agent.NewGRPCConnection(ctx, cfg.TestkubeProTLSInsecure, cfg.TestkubeProURL, log.DefaultLogger)
ui.ExitOnError("error creating gRPC connection", err)
defer grpcConn.Close()

Expand Down Expand Up @@ -222,11 +224,11 @@ func main() {
var artifactStorage domainstorage.ArtifactsStorage
var storageClient domainstorage.Client
if mode == common.ModeAgent {
resultsRepository = cloudresult.NewCloudResultRepository(grpcClient, grpcConn, cfg.TestkubeCloudAPIKey)
testResultsRepository = cloudtestresult.NewCloudRepository(grpcClient, grpcConn, cfg.TestkubeCloudAPIKey)
configRepository = cloudconfig.NewCloudResultRepository(grpcClient, grpcConn, cfg.TestkubeCloudAPIKey)
resultsRepository = cloudresult.NewCloudResultRepository(grpcClient, grpcConn, cfg.TestkubeProAPIKey)
testResultsRepository = cloudtestresult.NewCloudRepository(grpcClient, grpcConn, cfg.TestkubeProAPIKey)
configRepository = cloudconfig.NewCloudResultRepository(grpcClient, grpcConn, cfg.TestkubeProAPIKey)
triggerLeaseBackend = triggers.NewAcquireAlwaysLeaseBackend()
artifactStorage = cloudartifacts.NewCloudArtifactsStorage(grpcClient, grpcConn, cfg.TestkubeCloudAPIKey)
artifactStorage = cloudartifacts.NewCloudArtifactsStorage(grpcClient, grpcConn, cfg.TestkubeProAPIKey)
} else {
mongoSSLConfig := getMongoSSLConfig(cfg, secretClient)
db, err := storage.GetMongoDatabase(cfg.APIMongoDSN, cfg.APIMongoDB, cfg.APIMongoDBType, cfg.APIMongoAllowTLS, mongoSSLConfig)
Expand Down Expand Up @@ -479,10 +481,10 @@ func main() {
agentHandle, err := agent.NewAgent(
log.DefaultLogger,
api.Mux.Handler(),
cfg.TestkubeCloudAPIKey,
cfg.TestkubeProAPIKey,
grpcClient,
cfg.TestkubeCloudWorkerCount,
cfg.TestkubeCloudLogStreamWorkerCount,
cfg.TestkubeProWorkerCount,
cfg.TestkubeProLogStreamWorkerCount,
api.GetLogsStream,
clusterId,
cfg.TestkubeClusterName,
Expand Down
4 changes: 3 additions & 1 deletion cmd/kubectl-testkube/commands/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import (
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/cloud"
"github.com/kubeshop/testkube/pkg/ui"
)

func NewCloudCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "cloud",
Short: "Testkube Cloud commands",
Short: "[Deprecated] Testkube Cloud commands",
Aliases: []string{"cl"},
Run: func(cmd *cobra.Command, args []string) {
ui.Warn("You are using a deprecated command, please switch to `testkube pro`.")
},
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/kubectl-testkube/commands/cloud/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

const (
listenAddr = "127.0.0.1:8090"
docsUrl = "https://docs.testkube.io/testkube-cloud/intro"
docsUrl = "https://docs.testkube.io/testkube-pro/intro"
tokenQueryParam = "token"
)

Expand All @@ -26,8 +26,9 @@ func NewConnectCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "connect",
Aliases: []string{"c"},
Short: "Testkube Cloud connect ",
Short: "[Deprecated] Testkube Cloud connect ",
Run: func(cmd *cobra.Command, args []string) {
ui.Warn("You are using a deprecated command, please switch to `testkube pro connect`.")

// create new cloud uris
opts.CloudUris = common.NewCloudUris(opts.CloudRootDomain)
Expand Down Expand Up @@ -192,7 +193,6 @@ func NewConnectCmd() *cobra.Command {
cmd.Flags().StringVar(&opts.CloudAgentToken, "agent-token", "", "Testkube Cloud agent key [required for cloud mode]")
cmd.Flags().StringVar(&opts.CloudOrgId, "org-id", "", "Testkube Cloud organization id [required for cloud mode]")
cmd.Flags().StringVar(&opts.CloudEnvId, "env-id", "", "Testkube Cloud environment id [required for cloud mode]")

cmd.Flags().StringVar(&opts.CloudRootDomain, "cloud-root-domain", "testkube.io", "defaults to testkube.io, usually don't need to be changed [required for cloud mode]")

cmd.Flags().BoolVar(&opts.NoMinio, "no-minio", false, "don't install MinIO")
Expand Down
3 changes: 2 additions & 1 deletion cmd/kubectl-testkube/commands/cloud/disconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ func NewDisconnectCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "disconnect",
Aliases: []string{"d"},
Short: "Switch back to Testkube OSS mode, based on active .kube/config file",
Short: "[Deprecated] Switch back to Testkube OSS mode, based on active .kube/config file",
Run: func(cmd *cobra.Command, args []string) {
ui.Warn("You are using a deprecated command, please switch to `testkube pro disconnect`.")

ui.H1("Disconnecting your cloud environment:")
ui.Paragraph("Rolling back to your clusters testkube OSS installation")
Expand Down
4 changes: 3 additions & 1 deletion cmd/kubectl-testkube/commands/cloud/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ func NewInitCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "init",
Short: "Install Testkube Cloud Agent and connect to Testkube Cloud environment",
Short: "[Deprecated] Install Testkube Cloud Agent and connect to Testkube Cloud environment",
Aliases: []string{"install"},
Run: func(cmd *cobra.Command, args []string) {
ui.Warn("You are using a deprecated command, please switch to `testkube pro init`.")

ui.Info("WELCOME TO")
ui.Logo()

Expand Down
5 changes: 2 additions & 3 deletions cmd/kubectl-testkube/commands/cloud/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func NewLoginCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "login",
Aliases: []string{"d"},
Short: "Login to Testkube Cloud",
Short: "[Deprecated] Login to Testkube Pro",
Run: func(cmd *cobra.Command, args []string) {
opts.CloudUris = common.NewCloudUris(opts.CloudRootDomain)
token, refreshToken, err := common.LoginUser(opts.CloudUris.Auth)
Expand Down Expand Up @@ -42,8 +42,7 @@ func NewLoginCmd() *cobra.Command {
common.UiPrintContext(cfg)
},
}

cmd.Flags().StringVar(&opts.CloudRootDomain, "cloud-root-domain", "testkube.io", "defaults to testkube.io, usually don't need to be changed [required for cloud mode]")
cmd.Flags().StringVar(&opts.CloudRootDomain, "cloud-root-domain", "testkube.io", "[Deprecated] defaults to testkube.io, usually don't need to be changed [required for cloud mode]")

cmd.Flags().StringVar(&opts.CloudOrgId, "org-id", "", "Testkube Cloud organization id")
cmd.Flags().StringVar(&opts.CloudEnvId, "env-id", "", "Testkube Cloud environment id")
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubectl-testkube/commands/common/uri.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func NewCloudUris(rootDomain string) CloudUris {
RootDomain: rootDomain,
Api: fmt.Sprintf("https://api.%s", rootDomain),
Agent: fmt.Sprintf("agent.%s:%d", rootDomain, defaultAgentPort),
Ui: fmt.Sprintf("https://cloud.%s", rootDomain),
Ui: fmt.Sprintf("https://app.%s", rootDomain),
Auth: fmt.Sprintf("https://api.%s/idp", rootDomain),
}
}
Expand Down
24 changes: 24 additions & 0 deletions cmd/kubectl-testkube/commands/pro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package commands

import (
"github.com/spf13/cobra"

"github.com/kubeshop/testkube/cmd/kubectl-testkube/commands/pro"
)

func NewProCmd() *cobra.Command {

cmd := &cobra.Command{
Use: "pro",
Short: "Testkube Pro commands",
Run: func(cmd *cobra.Command, args []string) {
},
}

cmd.AddCommand(pro.NewConnectCmd())
cmd.AddCommand(pro.NewDisconnectCmd())
cmd.AddCommand(pro.NewInitCmd())
cmd.AddCommand(pro.NewLoginCmd())

return cmd
}
Loading
Loading