mirror of
https://git.sr.ht/~magic_rb/dotfiles
synced 2024-12-11 09:22:02 +01:00
74 lines
3.1 KiB
Diff
74 lines
3.1 KiB
Diff
|
From 1bc15c644e6e39f268b1d06c343d8a9a4fceab2d Mon Sep 17 00:00:00 2001
|
||
|
From: Magic_RB <magic_rb@redalder.org>
|
||
|
Date: Fri, 31 Mar 2023 23:23:41 +0200
|
||
|
Subject: [PATCH] Allow null in authMountTuneSchema
|
||
|
|
||
|
Signed-off-by: Magic_RB <magic_rb@redalder.org>
|
||
|
---
|
||
|
internal/provider/validators.go | 10 ++++++++++
|
||
|
vault/auth_mount.go | 8 ++++----
|
||
|
2 files changed, 14 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/internal/provider/validators.go b/internal/provider/validators.go
|
||
|
index 15e23212..89a9d7e1 100644
|
||
|
--- a/internal/provider/validators.go
|
||
|
+++ b/internal/provider/validators.go
|
||
|
@@ -39,6 +39,16 @@ func ValidateStringSlug(i interface{}, k string) (s []string, es []error) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
+func ValidateAllowNull(f func(interface{}, string) ([]string, []error)) (func(interface{}, string) ([]string, []error)) {
|
||
|
+ return func(i interface{}, k string) (s []string, es []error) {
|
||
|
+ if i == nil {
|
||
|
+ return
|
||
|
+ } else {
|
||
|
+ return f(i, k)
|
||
|
+ }
|
||
|
+ };
|
||
|
+}
|
||
|
+
|
||
|
func ValidateDuration(i interface{}, k string) (s []string, es []error) {
|
||
|
v, ok := i.(string)
|
||
|
if !ok {
|
||
|
diff --git a/vault/auth_mount.go b/vault/auth_mount.go
|
||
|
index 2e1854f8..9bb77bc2 100644
|
||
|
--- a/vault/auth_mount.go
|
||
|
+++ b/vault/auth_mount.go
|
||
|
@@ -28,13 +28,13 @@ func authMountTuneSchema() *schema.Schema {
|
||
|
Type: schema.TypeString,
|
||
|
Optional: true,
|
||
|
Description: "Specifies the default time-to-live duration. This overrides the global default. A value of 0 is equivalent to the system default TTL",
|
||
|
- ValidateFunc: provider.ValidateDuration,
|
||
|
+ ValidateFunc: provider.ValidateAllowNull(provider.ValidateDuration),
|
||
|
},
|
||
|
"max_lease_ttl": {
|
||
|
Type: schema.TypeString,
|
||
|
Optional: true,
|
||
|
Description: "Specifies the maximum time-to-live duration. This overrides the global default. A value of 0 are equivalent and set to the system max TTL.",
|
||
|
- ValidateFunc: provider.ValidateDuration,
|
||
|
+ ValidateFunc: provider.ValidateAllowNull(provider.ValidateDuration),
|
||
|
},
|
||
|
"audit_non_hmac_request_keys": {
|
||
|
Type: schema.TypeList,
|
||
|
@@ -52,7 +52,7 @@ func authMountTuneSchema() *schema.Schema {
|
||
|
Type: schema.TypeString,
|
||
|
Optional: true,
|
||
|
Description: "Specifies whether to show this mount in the UI-specific listing endpoint. Valid values are \"unauth\" or \"hidden\". If not set, behaves like \"hidden\".",
|
||
|
- ValidateFunc: validation.StringInSlice([]string{"unauth", "hidden"}, false),
|
||
|
+ ValidateFunc: provider.ValidateAllowNull(validation.StringInSlice([]string{"unauth", "hidden"}, false)),
|
||
|
},
|
||
|
"passthrough_request_headers": {
|
||
|
Type: schema.TypeList,
|
||
|
@@ -70,7 +70,7 @@ func authMountTuneSchema() *schema.Schema {
|
||
|
Type: schema.TypeString,
|
||
|
Optional: true,
|
||
|
Description: "Specifies the type of tokens that should be returned by the mount.",
|
||
|
- ValidateFunc: validation.StringInSlice([]string{"default-service", "default-batch", "service", "batch"}, false),
|
||
|
+ ValidateFunc: provider.ValidateAllowNull(validation.StringInSlice([]string{"default-service", "default-batch", "service", "batch"}, false)),
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
--
|
||
|
2.39.1
|
||
|
|