feat: kubesphere 4.0 (#6115)

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
KubeSphere CI Bot
2024-09-06 11:05:52 +08:00
committed by GitHub
parent b5015ec7b9
commit 447a51f08b
8557 changed files with 546695 additions and 1146174 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package restmapper
import (
"fmt"
"strings"
"k8s.io/klog/v2"
@@ -32,13 +33,15 @@ type shortcutExpander struct {
RESTMapper meta.RESTMapper
discoveryClient discovery.DiscoveryInterface
warningHandler func(string)
}
var _ meta.ResettableRESTMapper = shortcutExpander{}
// NewShortcutExpander wraps a restmapper in a layer that expands shortcuts found via discovery
func NewShortcutExpander(delegate meta.RESTMapper, client discovery.DiscoveryInterface) meta.RESTMapper {
return shortcutExpander{RESTMapper: delegate, discoveryClient: client}
func NewShortcutExpander(delegate meta.RESTMapper, client discovery.DiscoveryInterface, warningHandler func(string)) meta.RESTMapper {
return shortcutExpander{RESTMapper: delegate, discoveryClient: client, warningHandler: warningHandler}
}
// KindFor fulfills meta.RESTMapper
@@ -145,16 +148,37 @@ func (e shortcutExpander) expandResourceShortcut(resource schema.GroupVersionRes
}
}
found := false
var rsc schema.GroupVersionResource
warnedAmbiguousShortcut := make(map[schema.GroupResource]bool)
for _, item := range shortcutResources {
if len(resource.Group) != 0 && resource.Group != item.ShortForm.Group {
continue
}
if resource.Resource == item.ShortForm.Resource {
resource.Resource = item.LongForm.Resource
resource.Group = item.LongForm.Group
return resource
if found {
if item.LongForm.Group == rsc.Group && item.LongForm.Resource == rsc.Resource {
// It is common and acceptable that group/resource has multiple
// versions registered in cluster. This does not introduce ambiguity
// in terms of shortname usage.
continue
}
if !warnedAmbiguousShortcut[item.LongForm] {
if e.warningHandler != nil {
e.warningHandler(fmt.Sprintf("short name %q could also match lower priority resource %s", resource.Resource, item.LongForm.String()))
}
warnedAmbiguousShortcut[item.LongForm] = true
}
continue
}
rsc.Resource = item.LongForm.Resource
rsc.Group = item.LongForm.Group
found = true
}
}
if found {
return rsc
}
// we didn't find exact match so match on group prefixing. This allows autoscal to match autoscaling
if len(resource.Group) == 0 {