github.com/crossplane/upjet@v1.3.0/pkg/types/name/reference.go (about) 1 // SPDX-FileCopyrightText: 2023 The Crossplane Authors <https://crossplane.io> 2 // 3 // SPDX-License-Identifier: Apache-2.0 4 5 package name 6 7 // NOTE(muvaf): We try to rely on snake for name calculations because it is more 8 // accurate in cases where two words are all acronyms and full capital, i.e. 9 // APIID would be converted to apiid when you convert it to lower camel computed 10 // but if you start with api_id, then it becomes apiId as lower camel computed 11 // and APIID as camel, which is what we want. 12 13 // ReferenceFieldName returns the field name for a reference field whose 14 // value field name is given. 15 func ReferenceFieldName(n Name, plural bool, camelOverride string) Name { 16 if camelOverride != "" { 17 return NewFromCamel(camelOverride) 18 } 19 temp := n.Snake + "_ref" 20 if plural { 21 temp += "s" 22 } 23 return NewFromSnake(temp) 24 } 25 26 // SelectorFieldName returns the field name for a selector field whose 27 // value field name is given. 28 func SelectorFieldName(n Name, camelOverride string) Name { 29 if camelOverride != "" { 30 return NewFromCamel(camelOverride) 31 } 32 return NewFromSnake(n.Snake + "_selector") 33 }