Skip to content

Commit 5578023

Browse files
committed
kubedb: correct Memcached and Milvus auth hints
Review against apimachinery: Memcached has an auth secret by default (GetMemcachedAuthSecretName) so it is username/password, not none; Milvus has no GetAPIKey (only Qdrant and Weaviate do) so it is username/password, not apikey. Add known-coordinates and auth-type spot-check tests. Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 70a35af commit 5578023

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

kubedb/engines.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type Engine struct {
2020
Resource string
2121
// Ports are the engine's default client service ports (informational).
2222
Ports []int
23-
// AuthType hints how connection credentials are shaped: "password", "apikey"
24-
// or "none".
23+
// AuthType hints how connection credentials in the {name}-auth secret are shaped:
24+
// "password" (username/password) or "apikey" (Qdrant/Weaviate).
2525
AuthType string
2626
}
2727

@@ -34,7 +34,7 @@ var engines = map[string]Engine{
3434
"elasticsearch": {Name: "elasticsearch", Group: group, Version: "v1", Kind: "Elasticsearch", Resource: "elasticsearches", Ports: []int{9200}, AuthType: "password"},
3535
"kafka": {Name: "kafka", Group: group, Version: "v1", Kind: "Kafka", Resource: "kafkas", Ports: []int{9092}, AuthType: "password"},
3636
"mariadb": {Name: "mariadb", Group: group, Version: "v1", Kind: "MariaDB", Resource: "mariadbs", Ports: []int{3306}, AuthType: "password"},
37-
"memcached": {Name: "memcached", Group: group, Version: "v1", Kind: "Memcached", Resource: "memcacheds", Ports: []int{11211}, AuthType: "none"},
37+
"memcached": {Name: "memcached", Group: group, Version: "v1", Kind: "Memcached", Resource: "memcacheds", Ports: []int{11211}, AuthType: "password"},
3838
"mongodb": {Name: "mongodb", Group: group, Version: "v1", Kind: "MongoDB", Resource: "mongodbs", Ports: []int{27017}, AuthType: "password"},
3939
"mysql": {Name: "mysql", Group: group, Version: "v1", Kind: "MySQL", Resource: "mysqls", Ports: []int{3306}, AuthType: "password"},
4040
"perconaxtradb": {Name: "perconaxtradb", Group: group, Version: "v1", Kind: "PerconaXtraDB", Resource: "perconaxtradbs", Ports: []int{3306}, AuthType: "password"},
@@ -53,7 +53,7 @@ var engines = map[string]Engine{
5353
"hanadb": {Name: "hanadb", Group: group, Version: "v1alpha2", Kind: "HanaDB", Resource: "hanadbs", Ports: []int{39017}, AuthType: "password"},
5454
"hazelcast": {Name: "hazelcast", Group: group, Version: "v1alpha2", Kind: "Hazelcast", Resource: "hazelcasts", Ports: []int{5701}, AuthType: "password"},
5555
"ignite": {Name: "ignite", Group: group, Version: "v1alpha2", Kind: "Ignite", Resource: "ignites", Ports: []int{10800}, AuthType: "password"},
56-
"milvus": {Name: "milvus", Group: group, Version: "v1alpha2", Kind: "Milvus", Resource: "milvuses", Ports: []int{19530}, AuthType: "apikey"},
56+
"milvus": {Name: "milvus", Group: group, Version: "v1alpha2", Kind: "Milvus", Resource: "milvuses", Ports: []int{19530}, AuthType: "password"},
5757
"mssqlserver": {Name: "mssqlserver", Group: group, Version: "v1alpha2", Kind: "MSSQLServer", Resource: "mssqlservers", Ports: []int{1433}, AuthType: "password"},
5858
"oracle": {Name: "oracle", Group: group, Version: "v1alpha2", Kind: "Oracle", Resource: "oracles", Ports: []int{1521}, AuthType: "password"},
5959
"pgpool": {Name: "pgpool", Group: group, Version: "v1alpha2", Kind: "Pgpool", Resource: "pgpools", Ports: []int{9999}, AuthType: "password"},

kubedb/engines_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,42 @@ func TestEngines_Complete(t *testing.T) {
2626
}
2727
}
2828

29+
func TestEngines_KnownCoordinates(t *testing.T) {
30+
// Spot-check a sample against kubedb.dev/apimachinery to catch registry typos.
31+
want := map[string]struct {
32+
version, kind, resource, auth string
33+
}{
34+
"postgres": {"v1", "Postgres", "postgreses", "password"},
35+
"redis": {"v1", "Redis", "redises", "password"},
36+
"mysql": {"v1", "MySQL", "mysqls", "password"},
37+
"memcached": {"v1", "Memcached", "memcacheds", "password"}, // has auth by default
38+
"mssqlserver": {"v1alpha2", "MSSQLServer", "mssqlservers", "password"},
39+
"qdrant": {"v1alpha2", "Qdrant", "qdrants", "apikey"},
40+
"weaviate": {"v1alpha2", "Weaviate", "weaviates", "apikey"},
41+
"milvus": {"v1alpha2", "Milvus", "milvuses", "password"}, // no API key
42+
"perconaxtradb": {"v1", "PerconaXtraDB", "perconaxtradbs", "password"},
43+
}
44+
for name, w := range want {
45+
e, err := Lookup(name)
46+
if err != nil {
47+
t.Fatalf("Lookup(%q): %v", name, err)
48+
}
49+
if e.Version != w.version || e.Kind != w.kind || e.Resource != w.resource || e.AuthType != w.auth {
50+
t.Errorf("%s = {%s %s %s %s}, want {%s %s %s %s}",
51+
name, e.Version, e.Kind, e.Resource, e.AuthType, w.version, w.kind, w.resource, w.auth)
52+
}
53+
}
54+
}
55+
56+
func TestEngines_AuthTypeValues(t *testing.T) {
57+
for _, name := range SupportedEngines() {
58+
e, _ := Lookup(name)
59+
if e.AuthType != "password" && e.AuthType != "apikey" {
60+
t.Errorf("%s: unexpected AuthType %q", name, e.AuthType)
61+
}
62+
}
63+
}
64+
2965
func TestLookup_CaseInsensitiveAndUnknown(t *testing.T) {
3066
if e, err := Lookup("PostGres"); err != nil || e.Kind != "Postgres" {
3167
t.Fatalf("case-insensitive lookup failed: %+v, %v", e, err)

0 commit comments

Comments
 (0)