-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDKQE-3441: Add ability to add external links to Capella Columnar clu…
…sters (#69)
- Loading branch information
1 parent
3c3f333
commit f9da78c
Showing
11 changed files
with
334 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/couchbaselabs/cbdinocluster/deployment/clouddeploy" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var linksCapellaCmd = &cobra.Command{ | ||
Use: "capella", | ||
Short: "Link a capella cluster to a columnar instance. Provide either a capella Cbdino id, or a capella cluster id (i.e. not created by cbdino) ", | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
helper := CmdHelper{} | ||
logger := helper.GetLogger() | ||
ctx := helper.GetContext() | ||
|
||
linkName, _ := cmd.Flags().GetString("link-name") | ||
capellaId, _ := cmd.Flags().GetString("cbd-id") | ||
directId, _ := cmd.Flags().GetString("capella-id") | ||
|
||
if linkName == "" { | ||
logger.Fatal("you must specify a link name") | ||
} | ||
|
||
if capellaId == directId && directId == "" { | ||
logger.Fatal("you must specify only one of a cbd-id or a direct capella-id ") | ||
} | ||
|
||
_, deployer, cluster := helper.IdentifyCluster(ctx, args[0]) | ||
|
||
cloudDeployer, ok := deployer.(*clouddeploy.Deployer) | ||
if !ok { | ||
logger.Fatal("links capella is only supported for cloud deployments") | ||
} | ||
|
||
err := cloudDeployer.CreateCapellaLink(ctx, cluster.GetID(), linkName, capellaId, directId) | ||
if err != nil { | ||
logger.Fatal("failed to link capella cluster", zap.Error(err)) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
linksAddCmd.AddCommand(linksCapellaCmd) | ||
|
||
linksCapellaCmd.Flags().String("link-name", "", "The name of the link to be created") | ||
linksCapellaCmd.Flags().String("cbd-id", "", "The cbdino id of the capella cluster to link") | ||
linksCapellaCmd.Flags().String("capella-id", "", "The direct capella cluster id, if created without cbdino") | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/couchbaselabs/cbdinocluster/deployment/clouddeploy" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var linksS3Cmd = &cobra.Command{ | ||
Use: "s3", | ||
Short: "Link a S3 bucket to a columnar instance.", | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
helper := CmdHelper{} | ||
logger := helper.GetLogger() | ||
ctx := helper.GetContext() | ||
|
||
linkName, _ := cmd.Flags().GetString("link-name") | ||
region, _ := cmd.Flags().GetString("region") | ||
// Optionals | ||
endpoint, _ := cmd.Flags().GetString("endpoint") | ||
accessKey, _ := cmd.Flags().GetString("access-key") | ||
secretKey, _ := cmd.Flags().GetString("secret-key") | ||
|
||
if linkName == "" { | ||
logger.Fatal("you must give the link a name") | ||
} | ||
|
||
if region == "" { | ||
logger.Fatal("you must specify an AWS region") | ||
} | ||
_, deployer, cluster := helper.IdentifyCluster(ctx, args[0]) | ||
|
||
cloudDeployer, ok := deployer.(*clouddeploy.Deployer) | ||
if !ok { | ||
logger.Fatal("links s3 is only supported for cloud deployments") | ||
} | ||
|
||
if accessKey == "" && secretKey == "" { | ||
awsCreds := helper.GetAWSCredentials(ctx) | ||
accessKey = awsCreds.AccessKeyID | ||
secretKey = awsCreds.SecretAccessKey | ||
} | ||
|
||
err := cloudDeployer.CreateS3Link(ctx, cluster.GetID(), linkName, region, endpoint, accessKey, secretKey) | ||
if err != nil { | ||
logger.Fatal("failed to setup S3 link", zap.Error(err)) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
linksAddCmd.AddCommand(linksS3Cmd) | ||
|
||
linksS3Cmd.Flags().String("link-name", "", "The name of the link to be created") | ||
linksS3Cmd.Flags().String("region", "", "The AWS region the S3 bucket is in.") | ||
linksS3Cmd.Flags().String("endpoint", "", "The S3 endpoint. Optional.") | ||
linksS3Cmd.Flags().String("access-key", "", "AWS AccessKeyId to use. Will use the cbdino config values if not flag not provided.") | ||
linksS3Cmd.Flags().String("secret-key", "", "AWS SecretKey to use. Will use the cbdino config values if not flag not provided.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var linksAddCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Add a link to a columnar cluster", | ||
Run: nil, | ||
} | ||
|
||
func init() { | ||
linksCmd.AddCommand(linksAddCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/couchbaselabs/cbdinocluster/deployment/clouddeploy" | ||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
) | ||
|
||
var linksDropCmd = &cobra.Command{ | ||
Use: "drop", | ||
Short: "Drop a link on a columnar instance", | ||
Args: cobra.MinimumNArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
helper := CmdHelper{} | ||
logger := helper.GetLogger() | ||
ctx := helper.GetContext() | ||
_, deployer, cluster := helper.IdentifyCluster(ctx, args[0]) | ||
linkName := args[1] | ||
|
||
cloudDeployer, ok := deployer.(*clouddeploy.Deployer) | ||
if !ok { | ||
logger.Fatal("links is only supported for cloud deployments") | ||
} | ||
|
||
err := cloudDeployer.DropLink(ctx, cluster.GetID(), linkName) | ||
if err != nil { | ||
logger.Fatal("failed to drop link", zap.Error(err)) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
linksCmd.AddCommand(linksDropCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var linksCmd = &cobra.Command{ | ||
Use: "links", | ||
Short: "Provides ability to link data sources to columnar instances", | ||
Run: nil, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(linksCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters