-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14060 from hashicorp/f/go-azure-helpers-v0.17
dependencies: upgrading to v0.17.0 of github.com/hashicorp/go-azure-helpers
- Loading branch information
Showing
258 changed files
with
2,308 additions
and
942 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
package location | ||
|
||
import "strings" | ||
import ( | ||
"github.com/hashicorp/go-azure-helpers/resourcemanager/location" | ||
) | ||
|
||
// Normalize transforms the human readable Azure Region/Location names (e.g. `West US`) | ||
// into the canonical value to allow comparisons between user-code and API Responses | ||
func Normalize(input string) string { | ||
return strings.ReplaceAll(strings.ToLower(input), " ", "") | ||
return location.Normalize(input) | ||
} | ||
|
||
// NormalizeNilable normalizes the Location field even if it's nil to ensure this field | ||
// can always have a value | ||
func NormalizeNilable(input *string) string { | ||
if input == nil { | ||
return "" | ||
} | ||
|
||
return Normalize(*input) | ||
return location.NormalizeNilable(input) | ||
} |
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 |
---|---|---|
@@ -1,62 +1,38 @@ | ||
package location | ||
|
||
import ( | ||
"github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" | ||
"github.com/hashicorp/go-azure-helpers/resourcemanager/location" | ||
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" | ||
) | ||
|
||
// Schema returns the default Schema which should be used for Location fields | ||
// where these are Required and Cannot be Changed | ||
func Schema() *pluginsdk.Schema { | ||
return &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: EnhancedValidate, | ||
StateFunc: StateFunc, | ||
DiffSuppressFunc: DiffSuppressFunc, | ||
} | ||
return commonschema.LocationSchema() | ||
} | ||
|
||
// SchemaOptional returns the Schema for a Location field where this can be optionally specified | ||
func SchemaOptional() *pluginsdk.Schema { | ||
return &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
StateFunc: StateFunc, | ||
DiffSuppressFunc: DiffSuppressFunc, | ||
} | ||
return commonschema.LocationSchemaOptional() | ||
} | ||
|
||
func SchemaComputed() *pluginsdk.Schema { | ||
return &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
Computed: true, | ||
} | ||
return commonschema.LocationSchemaComputed() | ||
} | ||
|
||
// Schema returns the Schema which should be used for Location fields | ||
// where these are Required and can be changed | ||
func SchemaWithoutForceNew() *pluginsdk.Schema { | ||
return &pluginsdk.Schema{ | ||
Type: pluginsdk.TypeString, | ||
Required: true, | ||
ValidateFunc: EnhancedValidate, | ||
StateFunc: StateFunc, | ||
DiffSuppressFunc: DiffSuppressFunc, | ||
} | ||
return commonschema.LocationSchemaWithoutForceNew() | ||
} | ||
|
||
func DiffSuppressFunc(_, old, new string, _ *pluginsdk.ResourceData) bool { | ||
return Normalize(old) == Normalize(new) | ||
func DiffSuppressFunc(v, old, new string, d *pluginsdk.ResourceData) bool { | ||
return location.DiffSuppressFunc(v, old, new, d) | ||
} | ||
|
||
func HashCode(location interface{}) int { | ||
// NOTE: this is intentionally not present upstream as the only usage is deprecated | ||
// and so this can be removed in 3.0 | ||
loc := location.(string) | ||
return pluginsdk.HashString(Normalize(loc)) | ||
} | ||
|
||
func StateFunc(location interface{}) string { | ||
input := location.(string) | ||
return Normalize(input) | ||
func StateFunc(input interface{}) string { | ||
return location.StateFunc(input) | ||
} |
Oops, something went wrong.