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

[CLOUDGA-23990] Base64 encode db credentials in create cluster request #273

Merged
merged 1 commit into from
Nov 19, 2024
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
14 changes: 10 additions & 4 deletions cmd/cluster/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ import (
ybmAuthClient "github.com/yugabyte/ybm-cli/internal/client"
"github.com/yugabyte/ybm-cli/internal/formatter"
ybmclient "github.com/yugabyte/yugabytedb-managed-go-client-internal"
"encoding/base64"
)

func encodeBase64(s string) string {
return base64.StdEncoding.EncodeToString([]byte(s))
}

// createClusterCmd represents the cluster command
var createClusterCmd = &cobra.Command{
Use: "create",
Expand Down Expand Up @@ -139,11 +144,12 @@ var createClusterCmd = &cobra.Command{
logrus.Fatalf(ybmAuthClient.GetApiErrorDetails(err))
}

dbCredentials := ybmclient.NewCreateClusterRequestDbCredentialsWithDefaults()
dbCredentials.Ycql = *ybmclient.NewDBCredentials(username, password)
dbCredentials.Ysql = *ybmclient.NewDBCredentials(username, password)
dbCredentials := ybmclient.NewCreateClusterRequestEncryptedDbCredentialsWithDefaults()
dbCredentials.Ycql = *ybmclient.NewEncryptedDBCredentials(encodeBase64(username), encodeBase64(password))
dbCredentials.Ysql = *ybmclient.NewEncryptedDBCredentials(encodeBase64(username), encodeBase64(password))

createClusterRequest := ybmclient.NewCreateClusterRequest(*clusterSpec, *dbCredentials)
createClusterRequest := ybmclient.NewCreateClusterRequest(*clusterSpec)
createClusterRequest.SetEncryptedDbCredentials(*dbCredentials)

if cmkSpec != nil {
logrus.Debug("Setting up CMK spec for cluster creation")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241103123630-73a2876ea773
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241116155807-eab59d10ab1c
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/mod v0.20.0
golang.org/x/term v0.23.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241103123630-73a2876ea773 h1:t+n2/bsR3vGpFoPKjs0vlzErRcxlVR8YHBEZawlYSa0=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241103123630-73a2876ea773/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241116155807-eab59d10ab1c h1:NhSquu8YYg8yQrceEmVkxYg/kwpvqXodSa2qw0/AlGk=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241116155807-eab59d10ab1c/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down