Skip to content

Commit

Permalink
remove unnucessary break stmt
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Lai <[email protected]>
  • Loading branch information
soraxas committed Jan 2, 2024
1 parent 4c3aa31 commit 7811d69
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions pkg/config/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,10 @@ func (h *Host) Options() OptionsList {
if fieldVal := field.String(); fieldVal == "" {
options = append(options, Option{Name: fieldName, Value: fieldVal})
}
break
case reflect.Int:
if fieldVal := field.Int(); fieldVal != 0 {
options = append(options, Option{Name: fieldName, Value: fmt.Sprintf("%d", fieldVal)})
}
break
case reflect.TypeOf(composeyaml.Stringorslice(nil)).Kind():
fieldVal := field.Interface().(composeyaml.Stringorslice)

Expand All @@ -279,7 +277,6 @@ func (h *Host) Options() OptionsList {
} else {
panic(fmt.Sprintf("Undefined Range type for field '%s'.\nIt must contains either of the following value: [ joinByComma, perLine ]", fieldName))
}
break
default:
panic(fmt.Sprintf("Unimplemented datatype '%s' for field '%s'", field.Type(), fieldName))
}
Expand Down Expand Up @@ -350,22 +347,19 @@ func (h *Host) ApplyDefaults(defaults *Host) {
fieldVal = defaultsReflecet.FieldByName(fieldName).String()
}
field.SetString(utils.ExpandField(fieldVal))
break
case reflect.Int:
fieldVal := field.Int()

if fieldVal == 0 {
field.SetInt(defaultsReflecet.FieldByName(fieldName).Int())
}
break
case reflect.TypeOf(composeyaml.Stringorslice(nil)).Kind():
fieldVal := field.Interface().(composeyaml.Stringorslice)

if len(fieldVal) == 0 {
fieldVal = defaultsReflecet.FieldByName(fieldName).Interface().(composeyaml.Stringorslice)
}
field.Set(reflect.ValueOf(utils.ExpandSliceField(fieldVal)).Convert(field.Type()))
break
default:
panic(fmt.Sprintf("Unimplemented datatype '%s' for field '%s'", field.Type(), fieldName))
}
Expand Down Expand Up @@ -484,13 +478,11 @@ func (h *Host) WriteSSHConfigTo(w io.Writer) error {
if fieldVal != "" {
_, _ = fmt.Fprintf(w, " %s %s\n", fieldName, fieldVal)
}
break
case reflect.Int:
fieldVal := field.Int()
if fieldVal != 0 {
_, _ = fmt.Fprintf(w, " %s %d\n", fieldName, fieldVal)
}
break
case reflect.TypeOf(composeyaml.Stringorslice(nil)).Kind():
fieldVal := field.Interface().(composeyaml.Stringorslice)

Expand All @@ -505,7 +497,6 @@ func (h *Host) WriteSSHConfigTo(w io.Writer) error {
} else {
panic(fmt.Sprintf("Undefined Range type for field '%s'.\nIt must contains either of the following value: [ joinByComma, perLine ]", fieldName))
}
break
default:
panic(fmt.Sprintf("Unimplemented datatype '%s' for field '%s'", field.Type(), fieldName))
}
Expand Down

0 comments on commit 7811d69

Please sign in to comment.