mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Simplify GroupVersion.Seting()
The old code had special cases that returned the same values as the regular case does. If group is empty, the conditional ```if len(gv.Group) > 0 {``` doesn't apply, and `gv.Version` is returned. In the empty case, the special case was returning `""`, which is exactly what `gv.Version` contains. In the legacy v1 case, the special case was returning `"v1"`, which is exactly what `gv.Version` contains.
This commit is contained in:
parent
a0344973a3
commit
445044db9c
@ -176,15 +176,6 @@ func (gv GroupVersion) Empty() bool {
|
||||
// String puts "group" and "version" into a single "group/version" string. For the legacy v1
|
||||
// it returns "v1".
|
||||
func (gv GroupVersion) String() string {
|
||||
// special case the internal apiVersion for the legacy kube types
|
||||
if gv.Empty() {
|
||||
return ""
|
||||
}
|
||||
|
||||
// special case of "v1" for backward compatibility
|
||||
if len(gv.Group) == 0 && gv.Version == "v1" {
|
||||
return gv.Version
|
||||
}
|
||||
if len(gv.Group) > 0 {
|
||||
return gv.Group + "/" + gv.Version
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user