Skip to content

Commit

Permalink
Fix hashicorp#2302 Add hugepages support to emptyDir
Browse files Browse the repository at this point in the history
  • Loading branch information
trunet committed Sep 28, 2023
1 parent 32a58d2 commit 5b747c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kubernetes/schema_pod_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,11 +669,11 @@ func volumeSchema(isUpdatable bool) *schema.Resource {
Schema: map[string]*schema.Schema{
"medium": {
Type: schema.TypeString,
Description: `What type of storage medium should back this directory. The default is "" which means to use the node's default medium. Must be an empty string (default) or Memory. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir`,
Description: `What type of storage medium should back this directory. The default is "" which means to use the node's default medium. Must be an empty string (default), Memory, HugePages-<hugepagesize>. More info: https://kubernetes.io/docs/concepts/storage/volumes#emptydir`,
Optional: true,
Default: "",
ForceNew: !isUpdatable,
ValidateFunc: validateAttributeValueIsIn([]string{"", "Memory"}),
ValidateFunc: validateAttributeValueIsInAndContain([]string{"", "Memory", "HugePages-"}),
},
"size_limit": {
Type: schema.TypeString,
Expand Down
20 changes: 20 additions & 0 deletions kubernetes/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,26 @@ func validateAttributeValueIsIn(validValues []string) schema.SchemaValidateFunc
}
}

func validateAttributeValueIsInAndContain(validValues []string) schema.SchemaValidateFunc {
return func(v interface{}, k string) (ws []string, errors []error) {
input := v.(string)
isValid := false
for _, s := range validValues {
if strings.Contains(input, s) {
isValid = true
break
}
}
if !isValid {
errors = append(errors, fmt.Errorf(
"%q must contain a value containing %#v, got %q",
k, validValues, input))
}
return

}
}

func validateTypeStringNullableIntOrPercent(v interface{}, key string) (ws []string, es []error) {
value, ok := v.(string)
if !ok {
Expand Down

0 comments on commit 5b747c8

Please sign in to comment.