-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent equivalent disk_size values from causing cluster replacement (#…
…177)
- Loading branch information
1 parent
ac9ee40
commit 1e63fe9
Showing
7 changed files
with
108 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package state_utils | ||
|
||
import ( | ||
"errors" | ||
"strconv" | ||
|
||
"github.com/hashicorp/go-cty/cty" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
||
pkgutil "k8s.io/minikube/pkg/util" | ||
) | ||
|
||
func ResourceSizeConverter() schema.SchemaStateFunc { | ||
return func(val interface{}) string { | ||
size, ok := val.(string) | ||
if !ok { | ||
panic(errors.New("resource size is not a string")) | ||
} | ||
sizeMb, err := pkgutil.CalculateSizeInMB(size) | ||
if err != nil { | ||
panic(errors.New("invalid resource size value")) | ||
} | ||
|
||
return strconv.Itoa(sizeMb) + "mb" | ||
} | ||
} | ||
|
||
func ResourceSizeValidator() schema.SchemaValidateDiagFunc { | ||
return schema.SchemaValidateDiagFunc(func(val interface{}, path cty.Path) diag.Diagnostics { | ||
size, ok := val.(string) | ||
if !ok { | ||
diag := diag.FromErr(errors.New("resource size is not a string")) | ||
return diag | ||
} | ||
_, err := pkgutil.CalculateSizeInMB(size) | ||
if err != nil { | ||
diag := diag.FromErr(errors.New("invalid resource size value")) | ||
return diag | ||
} | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters