aboutsummaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg/runtime/scheme.go')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/scheme.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go b/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
index 697dd4ed7..ae47ab3ab 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
@@ -129,12 +129,6 @@ func (s *Scheme) nameFunc(t reflect.Type) string {
return gvks[0].Kind
}
-// fromScope gets the input version, desired output version, and desired Scheme
-// from a conversion.Scope.
-func (s *Scheme) fromScope(scope conversion.Scope) *Scheme {
- return s
-}
-
// Converter allows access to the converter for the scheme
func (s *Scheme) Converter() *conversion.Converter {
return s.converter
@@ -235,6 +229,32 @@ func (s *Scheme) KnownTypes(gv schema.GroupVersion) map[string]reflect.Type {
return types
}
+// VersionsForGroupKind returns the versions that a particular GroupKind can be converted to within the given group.
+// A GroupKind might be converted to a different group. That information is available in EquivalentResourceMapper.
+func (s *Scheme) VersionsForGroupKind(gk schema.GroupKind) []schema.GroupVersion {
+ availableVersions := []schema.GroupVersion{}
+ for gvk := range s.gvkToType {
+ if gk != gvk.GroupKind() {
+ continue
+ }
+
+ availableVersions = append(availableVersions, gvk.GroupVersion())
+ }
+
+ // order the return for stability
+ ret := []schema.GroupVersion{}
+ for _, version := range s.PrioritizedVersionsForGroup(gk.Group) {
+ for _, availableVersion := range availableVersions {
+ if version != availableVersion {
+ continue
+ }
+ ret = append(ret, availableVersion)
+ }
+ }
+
+ return ret
+}
+
// AllKnownTypes returns the all known types.
func (s *Scheme) AllKnownTypes() map[schema.GroupVersionKind]reflect.Type {
return s.gvkToType