Skip to content

Commit

Permalink
fix (kubernetes-model-generator/pkg/schemagen) : Remove check to conv…
Browse files Browse the repository at this point in the history
…ert integer array to string

Kubernetes Model Generator script currently converted all byte, integer
lists to string (since there is no byte reflect.type in GoLang , it's
alias to `uint8`). This seems to be incorrectly generating
PodFailurePolicyOnExitCodesRequirement.values field as String.

Add a switch case in `javaType()` to treat `reflect.Uint8` to byte. Limit
`javaTypeArrayList()` to only convert byte array/ `reflect.Uint8` array
to string.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia authored and manusa committed Sep 21, 2022
1 parent c81c937 commit 6498e28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kubernetes-model-generator/pkg/schemagen/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (g *schemaGenerator) generateReference(t reflect.Type) string {
func (g *schemaGenerator) javaTypeArrayList(t reflect.Type) string {
typeName := g.javaTypeWrapPrimitive(t)
switch typeName {
case "Byte", "Integer":
case "Byte":
return "String"
default:
return "java.util.ArrayList<" + typeName + ">"
Expand Down Expand Up @@ -193,9 +193,11 @@ func (g *schemaGenerator) javaType(t reflect.Type) string {
switch t.Kind() {
case reflect.Bool:
return "bool"
case reflect.Uint8:
return "Byte"
case reflect.Int, reflect.Int8, reflect.Int16,
reflect.Int32, reflect.Uint,
reflect.Uint8, reflect.Uint16, reflect.Uint32:
reflect.Uint16, reflect.Uint32:
return "int"
case reflect.Int64, reflect.Uint64:
return "Long"
Expand Down

0 comments on commit 6498e28

Please sign in to comment.