-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add generic rename processor for fields
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
tools/importer-rest-api-specs/components/schema/processors/field_name_generic_rename.go
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,26 @@ | ||
package processors | ||
|
||
import ( | ||
"github.com/hashicorp/go-azure-helpers/lang/pointer" | ||
"strings" | ||
) | ||
|
||
var _ FieldNameProcessor = fieldNameGenericRename{} | ||
|
||
type fieldNameGenericRename struct{} | ||
|
||
func (fieldNameGenericRename) ProcessField(fieldName string, metadata FieldMetadata) (*string, error) { | ||
// some simple and flat resources that should be easily generated are blocked because of property names | ||
// that don't follow the naming guidelines we have in the provider. This field processor is a temporary | ||
// means of renaming fields to enable generation of the resource but may want some modifying in future | ||
// e.g. specifying name overrides in the terraform resource configuration (like in devcenter.hcl) instead | ||
// of being hard-coded here | ||
|
||
if strings.EqualFold(metadata.TerraformDetails.ResourceName, "dev_center_gallery") { | ||
if strings.EqualFold(strings.ToLower(fieldName), "galleryResourceId") { | ||
return pointer.To("sharedGalleryId"), nil | ||
} | ||
} | ||
|
||
return nil, 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