Skip to content

Commit 3d7b491

Browse files
authored
Add Namespace Support (MySQL)
Signed-off-by: Rudro-25 <rudro@appscode.com>
1 parent 65b12c1 commit 3d7b491

File tree

7 files changed

+43
-12
lines changed

7 files changed

+43
-12
lines changed

api/openapi-spec/swagger.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14246,6 +14246,10 @@
1424614246
"mysql": {
1424714247
"$ref": "#/definitions/dev.kubevault.apimachinery.apis.engine.v1alpha1.MySQLConfiguration"
1424814248
},
14249+
"namespace": {
14250+
"description": "Namespace specifies the OpenBao namespace for this SecretEngine. Only applicable when using OpenBao distribution. If specified, overrides the namespace from VaultServer. Empty string means use VaultServer's namespace (or root if VaultServer has none). Supports hierarchical namespaces (e.g., \"tenant-1/project-a\").",
14251+
"type": "string"
14252+
},
1424914253
"pki": {
1425014254
"$ref": "#/definitions/dev.kubevault.apimachinery.apis.engine.v1alpha1.PKIConfiguration"
1425114255
},

apis/engine/v1alpha1/openapi_generated.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/engine/v1alpha1/secret_engine_helpers.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@ func GetDBNameFromAppBindingRef(dbAppRef *appcat.AppReference) string {
5555
}
5656

5757
func (se SecretEngine) GetSecretEnginePath() string {
58-
// Todo: update SecretEngine path
59-
// - k8s.{cluster-name or -}.{se-type}.se-ns.se-name
6058
cluster := "-"
6159
if clustermeta.ClusterName() != "" {
6260
cluster = clustermeta.ClusterName()
6361
}
62+
63+
// Format: k8s.{cluster-name}.{se-type}.{se-ns}.{se-name}
64+
// The difference is WHERE this path exists in OpenBao:
65+
// - Root approach: path lives in OpenBao root namespace "/"
66+
// - Namespace approach: path lives in OpenBao namespace (e.g., "tenant-1")
6467
return fmt.Sprintf("k8s.%s.%s.%s.%s", cluster, se.GetSecretEngineType(), se.Namespace, se.Name)
6568
}
6669

apis/engine/v1alpha1/secret_engine_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ type SecretEngine struct {
5353
type SecretEngineSpec struct {
5454
VaultRef kmapi.ObjectReference `json:"vaultRef"`
5555

56+
// Namespace specifies the OpenBao namespace for this SecretEngine.
57+
// Only applicable when using OpenBao distribution.
58+
// If specified, overrides the namespace from VaultServer.
59+
// Empty string means use VaultServer's namespace (or root if VaultServer has none).
60+
// Supports hierarchical namespaces (e.g., "tenant-1/project-a").
61+
// +optional
62+
Namespace string `json:"namespace,omitempty"`
63+
5664
SecretEngineConfiguration `json:",inline"`
5765

5866
DefaultLeaseTTL string `json:"defaultLeaseTTL,omitempty"`

apis/kubevault/v1alpha1/conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,12 @@ func Convert_v1alpha1_AuthMethod_To_v1alpha2_AuthMethod(in *AuthMethod, out *v1a
505505
return nil
506506
}
507507

508+
func Convert_v1alpha1_VaultServerSpec_To_v1alpha2_VaultServerSpec(in *VaultServerSpec, out *v1alpha2.VaultServerSpec, s conversion.Scope) error {
509+
// WARNING: in.Namespace requires manual conversion: does not exist in peer-type
510+
// The Namespace field is intentionally not converted as it doesn't exist in v1alpha2
511+
return autoConvert_v1alpha1_VaultServerSpec_To_v1alpha2_VaultServerSpec(in, out, s)
512+
}
513+
508514
func Convert_v1alpha2_VaultServerSpec_To_v1alpha1_VaultServerSpec(in *v1alpha2.VaultServerSpec, out *VaultServerSpec, s conversion.Scope) error {
509515
return autoConvert_v1alpha2_VaultServerSpec_To_v1alpha1_VaultServerSpec(in, out, s)
510516
}

apis/kubevault/v1alpha1/zz_generated.conversion.go

Lines changed: 5 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crds/engine.kubevault.com_secretengines.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,14 @@ spec:
434434
required:
435435
- databaseRef
436436
type: object
437+
namespace:
438+
description: |-
439+
Namespace specifies the OpenBao namespace for this SecretEngine.
440+
Only applicable when using OpenBao distribution.
441+
If specified, overrides the namespace from VaultServer.
442+
Empty string means use VaultServer's namespace (or root if VaultServer has none).
443+
Supports hierarchical namespaces (e.g., "tenant-1/project-a").
444+
type: string
437445
pki:
438446
description: |-
439447
https://developer.hashicorp.com/vault/api-docs/secret/pki#generate-root

0 commit comments

Comments
 (0)