Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/names/names.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ var (
{"Bgp", "BGP", "bgp", nil},
{"Cors", "CORS", "cors", nil},
{"Cidr", "CIDR", "cidr", nil},
{"Cname", "CNAME", "cname", nil},
{"Cpu", "CPU", "cpu", nil},
{"Crl", "CRL", "crl", nil},
{"Cps", "CPS", "cps", nil},
{"Csr", "CSR", "csr", nil},
{"Dhcp", "DHCP", "dhcp", nil},
{"Dns", "DNS", "dns", nil},
{"Dpd", "DPD", "dpd", nil},
{"Ebs", "EBS", "ebs", nil},
{"Ec2", "EC2", "ec2", nil},
{"Ecr", "ECR", "ecr", nil},
// Prevent "Edit" from becoming "EDIt"
{"Edi", "EDI", "edi", regexp.MustCompile("Edi(?!t)", regexp.None)},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding a quick unit test that verifies this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added! And sorted all tests because their ordering was annoying me

{"Efs", "EFS", "efs", nil},
{"Eks", "EKS", "eks", nil},
// Prevent "Enable" and "Enabling" from becoming "ENAble"
Expand All @@ -112,6 +118,8 @@ var (
// Prevent "Native" from becoming "NATive"
{"Nat", "NAT", "nat", regexp.MustCompile("Nat(?!i)", regexp.None)},
{"Oidc", "OIDC", "oidc", nil},
{"Ocsp", "OCSP", "ocsp", nil},
{"Rfc", "RFC", "rfc", nil},
{"Sdk", "SDK", "sdk", nil},
{"Sha256", "SHA256", "sha256", nil},
{"Sqs", "SQS", "sns", nil},
Expand Down
54 changes: 28 additions & 26 deletions pkg/names/names_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,46 @@ func TestNames(t *testing.T) {
expectSnake string
}{
{"Ami", "AMI", "ami", "ami"},
{"Identifier", "Identifier", "identifier", "identifier"},
{"Id", "ID", "id", "id"},
{"ID", "ID", "id", "id"},
{"Family", "Family", "family", "family"},
{"Examine", "Examine", "examine", "examine"},
{"Dynamic", "Dynamic", "dynamic", "dynamic"},
{"Camila", "Camila", "camila", "camila"},
{"AmiLaunchIndex", "AMILaunchIndex", "amiLaunchIndex", "ami_launch_index"},
{"Amis", "AMIs", "amis", "amis"},
{"AmiType", "AMIType", "amiType", "ami_type"},
{"AmiLaunchIndex", "AMILaunchIndex", "amiLaunchIndex", "ami_launch_index"},
{"NumberOfAmiToKeep", "NumberOfAMIToKeep", "numberOfAMIToKeep", "number_of_ami_to_keep"},
{"RequestedAmiVersion", "RequestedAMIVersion", "requestedAMIVersion", "requested_ami_version"},
{"KeyIdentifier", "KeyIdentifier", "keyIdentifier", "key_identifier"},
{"KeyId", "KeyID", "keyID", "key_id"},
{"KeyID", "KeyID", "keyID", "key_id"},
{"SSEKMSKeyID", "SSEKMSKeyID", "sseKMSKeyID", "sse_kms_key_id"},
{"DbiResourceId", "DBIResourceID", "dbiResourceID", "dbi_resource_id"},
{"CacheSecurityGroup", "CacheSecurityGroup", "cacheSecurityGroup", "cache_security_group"},
{"Camila", "Camila", "camila", "camila"},
{"DbInstanceId", "DBInstanceID", "dbInstanceID", "db_instance_id"},
{"DBInstanceId", "DBInstanceID", "dbInstanceID", "db_instance_id"},
{"DBInstanceID", "DBInstanceID", "dbInstanceID", "db_instance_id"},
{"DBInstanceIdentifier", "DBInstanceIdentifier", "dbInstanceIdentifier", "db_instance_identifier"},
{"MaxIdleConnectionsPercent", "MaxIdleConnectionsPercent", "maxIdleConnectionsPercent", "max_idle_connections_percent"},
{"CacheSecurityGroup", "CacheSecurityGroup", "cacheSecurityGroup", "cache_security_group"},
{"RepositoryUriTest", "RepositoryURITest", "repositoryURITest", "repository_uri_test"},
{"Ip", "IP", "ip", "ip"},
{"MultipartUpload", "MultipartUpload", "multipartUpload", "multipart_upload"},
{"Package", "Package", "package_", "package_"},
{"LdapServerMetadata", "LDAPServerMetadata", "ldapServerMetadata", "ldap_server_metadata"},
{"DbiResourceId", "DBIResourceID", "dbiResourceID", "dbi_resource_id"},
{"DpdTimeoutAction", "DPDTimeoutAction", "dpdTimeoutAction", "dpd_timeout_action"},
{"Iops", "IOPS", "iops", "iops"},
{"IoPerformance", "IOPerformance", "ioPerformance", "io_performance"},
{"Vlan", "VLAN", "vlan", "vlan"},
{"Dynamic", "Dynamic", "dynamic", "dynamic"},
{"Ecmp", "ECMP", "ecmp", "ecmp"},
{"EdiPartyName", "EDIPartyName", "ediPartyName", "edi_party_name"},
{"Editable", "Editable", "editable", "editable"},
Comment on lines +48 to +49
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My new additions

{"Ena", "ENA", "ena", "ena"},
{"UUID", "UUID", "uuid", "uuid"},
{"Examine", "Examine", "examine", "examine"},
{"Family", "Family", "family", "family"},
{"Id", "ID", "id", "id"},
{"ID", "ID", "id", "id"},
{"Identifier", "Identifier", "identifier", "identifier"},
{"IoPerformance", "IOPerformance", "ioPerformance", "io_performance"},
{"Iops", "IOPS", "iops", "iops"},
{"Ip", "IP", "ip", "ip"},
{"KeyId", "KeyID", "keyID", "key_id"},
{"KeyID", "KeyID", "keyID", "key_id"},
{"KeyIdentifier", "KeyIdentifier", "keyIdentifier", "key_identifier"},
{"LdapServerMetadata", "LDAPServerMetadata", "ldapServerMetadata", "ldap_server_metadata"},
{"MaxIdleConnectionsPercent", "MaxIdleConnectionsPercent", "maxIdleConnectionsPercent", "max_idle_connections_percent"},
{"MultipartUpload", "MultipartUpload", "multipartUpload", "multipart_upload"},
{"Nat", "NAT", "nat", "nat"},
{"NatGateway", "NATGateway", "natGateway", "nat_gateway"},
{"NativeAuditFieldsIncluded", "NativeAuditFieldsIncluded", "nativeAuditFieldsIncluded", "native_audit_fields_included"},
{"NumberOfAmiToKeep", "NumberOfAMIToKeep", "numberOfAMIToKeep", "number_of_ami_to_keep"},
{"Package", "Package", "package_", "package_"},
{"RepositoryUriTest", "RepositoryURITest", "repositoryURITest", "repository_uri_test"},
{"RequestedAmiVersion", "RequestedAMIVersion", "requestedAMIVersion", "requested_ami_version"},
{"SSEKMSKeyID", "SSEKMSKeyID", "sseKMSKeyID", "sse_kms_key_id"},
{"UUID", "UUID", "uuid", "uuid"},
{"Vlan", "VLAN", "vlan", "vlan"},
}
for _, tc := range testCases {
n := names.New(tc.original)
Expand Down