Skip to content

Commit 80d0582

Browse files
lincolnzhoukumfo
authored andcommitted
feat: cache-redis add username field
1 parent bca2b20 commit 80d0582

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

cache-redis/i18n/en_US.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ plugin:
2929
other: Endpoint
3030
description:
3131
other: Redis connection address, such as 127.0.0.1:6379
32+
username:
33+
title:
34+
other: Username
35+
description:
36+
other: Redis username
3237
password:
3338
title:
3439
other: Password

cache-redis/i18n/translation.go

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const (
2525

2626
ConfigEndpointTitle = "plugin.redis_cache.backend.config.endpoint.title"
2727
ConfigEndpointDescription = "plugin.redis_cache.backend.config.endpoint.description"
28+
ConfigUsernameTitle = "plugin.redis_cache.backend.config.username.title"
29+
ConfigUsernameDescription = "plugin.redis_cache.backend.config.username.description"
2830
ConfigPasswordTitle = "plugin.redis_cache.backend.config.password.title"
2931
ConfigPasswordDescription = "plugin.redis_cache.backend.config.password.description"
3032
)

cache-redis/i18n/zh_CN.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ plugin:
2929
other: Endpoint
3030
description:
3131
other: Redis的链接地址,如:127.0.0.1:6379
32+
username:
33+
title:
34+
other: 用户名
35+
description:
36+
other: Redis 用户名
3237
password:
3338
title:
3439
other: 密码

cache-redis/redis.go

+13
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Cache struct {
4242

4343
type CacheConfig struct {
4444
Endpoint string `json:"endpoint"`
45+
Username string `json:"username"`
4546
Password string `json:"password"`
4647
}
4748

@@ -145,6 +146,17 @@ func (c *Cache) ConfigFields() []plugin.ConfigField {
145146
},
146147
Value: c.Config.Endpoint,
147148
},
149+
{
150+
Name: "username",
151+
Type: plugin.ConfigTypeInput,
152+
Title: plugin.MakeTranslator(i18n.ConfigUsernameTitle),
153+
Description: plugin.MakeTranslator(i18n.ConfigUsernameDescription),
154+
Required: false,
155+
UIOptions: plugin.ConfigFieldUIOptions{
156+
InputType: plugin.InputTypeText,
157+
},
158+
Value: c.Config.Username,
159+
},
148160
{
149161
Name: "password",
150162
Type: plugin.ConfigTypeInput,
@@ -166,6 +178,7 @@ func (c *Cache) ConfigReceiver(config []byte) error {
166178

167179
c.RedisClient = redis.NewClient(&redis.Options{
168180
Addr: conf.Endpoint,
181+
Username: conf.Username,
169182
Password: conf.Password,
170183
})
171184
return nil

0 commit comments

Comments
 (0)