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

Deprecate Redis-Named Fields #495

Merged
merged 2 commits into from
Nov 22, 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
70 changes: 35 additions & 35 deletions cmd/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
return fmt.Errorf("error parsing flag 'mysql-long-query-time' for database create : %v", errMt)
}

redisEvictionPolicy, errEe := cmd.Flags().GetString("redis-eviction-policy")
evictionPolicy, errEe := cmd.Flags().GetString("eviction-policy")
if errEe != nil {
return fmt.Errorf("error parsing flag 'redis-eviction-policy' for database create : %v", errEe)
return fmt.Errorf("error parsing flag 'eviction-policy' for database create : %v", errEe)
}

o.CreateReq = &govultr.DatabaseCreateReq{
Expand All @@ -222,7 +222,7 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
MySQLRequirePrimaryKey: &mysqlRequirePrimaryKey,
MySQLSlowQueryLog: &mySQLSlowQueryLog,
MySQLLongQueryTime: mySQLLongQueryTime,
RedisEvictionPolicy: redisEvictionPolicy,
EvictionPolicy: evictionPolicy,
}

db, err := o.create()
Expand Down Expand Up @@ -296,7 +296,7 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
0,
"long query time for the new mysql managed database when slow query logging is enabled",
)
create.Flags().String("redis-eviction-policy", "", "eviction policy for the new redis managed database")
create.Flags().String("eviction-policy", "", "eviction policy for the new caching managed database")

// Update
update := &cobra.Command{
Expand Down Expand Up @@ -362,9 +362,9 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
return fmt.Errorf("error parsing flag 'mysql-long-query-time' for database update : %v", errMt)
}

redisEvictionPolicy, errEe := cmd.Flags().GetString("redis-eviction-policy")
evictionPolicy, errEe := cmd.Flags().GetString("eviction-policy")
if errEe != nil {
return fmt.Errorf("error parsing flag 'redis-eviction-policy' for database update : %v", errEe)
return fmt.Errorf("error parsing flag 'eviction-policy' for database update : %v", errEe)
}

o.UpdateReq = &govultr.DatabaseUpdateReq{}
Expand Down Expand Up @@ -409,8 +409,8 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
o.UpdateReq.MySQLLongQueryTime = mySQLLongQueryTime
}

if cmd.Flags().Changed("redis-eviction-policy") {
o.UpdateReq.RedisEvictionPolicy = redisEvictionPolicy
if cmd.Flags().Changed("eviction-policy") {
o.UpdateReq.EvictionPolicy = evictionPolicy
}

db, err := o.update()
Expand Down Expand Up @@ -454,7 +454,7 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
0,
"long query time for the mysql managed database when slow query logging is enabled",
)
update.Flags().String("redis-eviction-policy", "", "eviction policy for the redis managed database")
update.Flags().String("eviction-policy", "", "eviction policy for the caching managed database")

// Delete
del := &cobra.Command{
Expand Down Expand Up @@ -675,7 +675,7 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
// User ACL
userACL := &cobra.Command{
Use: "acl",
Short: "Commands to manage database user access control (Redis only)",
Short: "Commands to manage database user access control (Caching only)",
}

// User ACL Update
Expand All @@ -689,24 +689,24 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
categories, errCa := cmd.Flags().GetStringSlice("redis-acl-categories")
categories, errCa := cmd.Flags().GetStringSlice("acl-categories")
if errCa != nil {
return fmt.Errorf("error parsing flag 'redis-acl-categories' for database user ACL update : %v", errCa)
return fmt.Errorf("error parsing flag 'acl-categories' for database user ACL update : %v", errCa)
}

channels, errCh := cmd.Flags().GetStringSlice("redis-acl-channels")
channels, errCh := cmd.Flags().GetStringSlice("acl-channels")
if errCh != nil {
return fmt.Errorf("error parsing flag 'redis-acl-channels' for database user ACL update : %v", errCh)
return fmt.Errorf("error parsing flag 'acl-channels' for database user ACL update : %v", errCh)
}

commands, errCo := cmd.Flags().GetStringSlice("redis-acl-commands")
commands, errCo := cmd.Flags().GetStringSlice("acl-commands")
if errCo != nil {
return fmt.Errorf("error parsing flag 'redis-acl-commands' for database user ACL update : %v", errCo)
return fmt.Errorf("error parsing flag 'acl-commands' for database user ACL update : %v", errCo)
}

keys, errKe := cmd.Flags().GetStringSlice("redis-acl-keys")
keys, errKe := cmd.Flags().GetStringSlice("acl-keys")
if errKe != nil {
return fmt.Errorf("error parsing flag 'redis-acl-keys' for database user ACL update : %v", errKe)
return fmt.Errorf("error parsing flag 'acl-keys' for database user ACL update : %v", errKe)
}

permission, errPe := cmd.Flags().GetString("permission")
Expand All @@ -716,20 +716,20 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo

o.UserUpdateACLReq = &govultr.DatabaseUserACLReq{}

if cmd.Flags().Changed("redis-acl-categories") {
o.UserUpdateACLReq.RedisACLCategories = &categories
if cmd.Flags().Changed("acl-categories") {
o.UserUpdateACLReq.ACLCategories = &categories
}

if cmd.Flags().Changed("redis-acl-channels") {
o.UserUpdateACLReq.RedisACLChannels = &channels
if cmd.Flags().Changed("acl-channels") {
o.UserUpdateACLReq.ACLChannels = &channels
}

if cmd.Flags().Changed("redis-acl-commands") {
o.UserUpdateACLReq.RedisACLCommands = &commands
if cmd.Flags().Changed("acl-commands") {
o.UserUpdateACLReq.ACLCommands = &commands
}

if cmd.Flags().Changed("redis-acl-keys") {
o.UserUpdateACLReq.RedisACLKeys = &keys
if cmd.Flags().Changed("acl-keys") {
o.UserUpdateACLReq.ACLKeys = &keys
}

if cmd.Flags().Changed("permission") {
Expand All @@ -749,32 +749,32 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
}

userACLUpdate.Flags().StringSlice(
"redis-acl-categories",
"acl-categories",
[]string{},
"list of rules for command categories",
)
userACLUpdate.Flags().StringSlice(
"redis-acl-channels",
"acl-channels",
[]string{},
"list of publish/subscribe channel patterns",
)
userACLUpdate.Flags().StringSlice(
"redis-acl-commands",
"acl-commands",
[]string{},
"list of rules for individual commands",
)
userACLUpdate.Flags().StringSlice(
"redis-acl-keys",
"acl-keys",
[]string{},
"list of key access rules",
)
userACLUpdate.Flags().String("permission", "", "the kafka permission level")

userACLUpdate.MarkFlagsOneRequired(
"redis-acl-categories",
"redis-acl-channels",
"redis-acl-commands",
"redis-acl-keys",
"acl-categories",
"acl-channels",
"acl-commands",
"acl-keys",
"permission",
)

Expand Down Expand Up @@ -1457,7 +1457,7 @@ func NewCmdDatabase(base *cli.Base) *cobra.Command { //nolint:funlen,gocyclo
migrationStart.Flags().String(
"username",
"",
"source username for the managed database migration (uses `default` for Redis if omitted)",
"source username for the managed database migration (uses `default` for caching databases if omitted)",
)
migrationStart.Flags().String("password", "", "source password for the managed database migration")
migrationStart.Flags().String(
Expand Down
32 changes: 16 additions & 16 deletions cmd/database/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func (d *DBsPrinter) Data() [][]string { //nolint:funlen,gocyclo
data = append(data, []string{" "})
}

if d.DBs[i].DatabaseEngine == "redis" {
data = append(data, []string{"REDIS EVICTION POLICY", d.DBs[i].RedisEvictionPolicy})
if d.DBs[i].DatabaseEngine == "redis" || d.DBs[i].DatabaseEngine == "valkey" {
data = append(data, []string{"EVICTION POLICY", d.DBs[i].EvictionPolicy})
}

data = append(data, []string{"CLUSTER TIME ZONE", d.DBs[i].ClusterTimeZone})
Expand Down Expand Up @@ -249,8 +249,8 @@ func (d *DBsPrinter) Data() [][]string { //nolint:funlen,gocyclo
data = append(data, []string{" "})
}

if d.DBs[i].ReadReplicas[j].DatabaseEngine == "redis" {
data = append(data, []string{"REDIS EVICTION POLICY", d.DBs[i].ReadReplicas[j].RedisEvictionPolicy})
if d.DBs[i].ReadReplicas[j].DatabaseEngine == "redis" || d.DBs[i].ReadReplicas[j].DatabaseEngine == "valkey" {
data = append(data, []string{"EVICTION POLICY", d.DBs[i].ReadReplicas[j].EvictionPolicy})
}

data = append(data, []string{"CLUSTER TIME ZONE", d.DBs[i].ReadReplicas[j].ClusterTimeZone})
Expand Down Expand Up @@ -404,8 +404,8 @@ func (d *DBPrinter) Data() [][]string { //nolint:funlen,gocyclo
data = append(data, []string{" "})
}

if d.DB.DatabaseEngine == "redis" {
data = append(data, []string{"REDIS EVICTION POLICY", d.DB.RedisEvictionPolicy})
if d.DB.DatabaseEngine == "redis" || d.DB.DatabaseEngine == "valkey" {
data = append(data, []string{"EVICTION POLICY", d.DB.EvictionPolicy})
}

data = append(data, []string{"CLUSTER TIME ZONE", d.DB.ClusterTimeZone})
Expand Down Expand Up @@ -505,8 +505,8 @@ func (d *DBPrinter) Data() [][]string { //nolint:funlen,gocyclo
data = append(data, []string{" "})
}

if d.DB.ReadReplicas[i].DatabaseEngine == "redis" {
data = append(data, []string{"REDIS EVICTION POLICY", d.DB.ReadReplicas[i].RedisEvictionPolicy})
if d.DB.ReadReplicas[i].DatabaseEngine == "redis" || d.DB.ReadReplicas[i].DatabaseEngine == "valkey" {
data = append(data, []string{"EVICTION POLICY", d.DB.ReadReplicas[i].EvictionPolicy})
}

data = append(data, []string{"CLUSTER TIME ZONE", d.DB.ReadReplicas[i].ClusterTimeZone})
Expand Down Expand Up @@ -778,10 +778,10 @@ func (u *UsersPrinter) Data() [][]string {
if u.Users[i].AccessControl != nil {
data = append(data,
[]string{"ACCESS CONTROL"},
[]string{"REDIS ACL CATEGORIES", printer.ArrayOfStringsToString(u.Users[i].AccessControl.RedisACLCategories)},
[]string{"REDIS ACL CHANNELS", printer.ArrayOfStringsToString(u.Users[i].AccessControl.RedisACLChannels)},
[]string{"REDIS ACL COMMANDS", printer.ArrayOfStringsToString(u.Users[i].AccessControl.RedisACLCommands)},
[]string{"REDIS ACL KEYS", printer.ArrayOfStringsToString(u.Users[i].AccessControl.RedisACLKeys)},
[]string{"ACL CATEGORIES", printer.ArrayOfStringsToString(u.Users[i].AccessControl.ACLCategories)},
[]string{"ACL CHANNELS", printer.ArrayOfStringsToString(u.Users[i].AccessControl.ACLChannels)},
[]string{"ACL COMMANDS", printer.ArrayOfStringsToString(u.Users[i].AccessControl.ACLCommands)},
[]string{"ACL KEYS", printer.ArrayOfStringsToString(u.Users[i].AccessControl.ACLKeys)},
)
}

Expand Down Expand Up @@ -846,10 +846,10 @@ func (u *UserPrinter) Data() [][]string {
if u.User.AccessControl != nil {
data = append(data,
[]string{"ACCESS CONTROL"},
[]string{"REDIS ACL CATEGORIES", printer.ArrayOfStringsToString(u.User.AccessControl.RedisACLCategories)},
[]string{"REDIS ACL CHANNELS", printer.ArrayOfStringsToString(u.User.AccessControl.RedisACLChannels)},
[]string{"REDIS ACL COMMANDS", printer.ArrayOfStringsToString(u.User.AccessControl.RedisACLCommands)},
[]string{"REDIS ACL KEYS", printer.ArrayOfStringsToString(u.User.AccessControl.RedisACLKeys)},
[]string{"ACL CATEGORIES", printer.ArrayOfStringsToString(u.User.AccessControl.ACLCategories)},
[]string{"ACL CHANNELS", printer.ArrayOfStringsToString(u.User.AccessControl.ACLChannels)},
[]string{"ACL COMMANDS", printer.ArrayOfStringsToString(u.User.AccessControl.ACLCommands)},
[]string{"ACL KEYS", printer.ArrayOfStringsToString(u.User.AccessControl.ACLKeys)},
)
}

Expand Down
Loading