// GetDefinitionVersionKind returns the api version and kind for the spec.  This is the primary key of a Definition.
194870
func GetDefinitionVersionKind(s spec.Schema) (string, string, string) {
	// Get the reference for complex types
	if IsDefinition(s) {
		s := fmt.Sprintf("%s", s.SchemaProps.Ref.GetPointer())
		s = strings.Replace(s, "/definitions/", "", -1)
		name := strings.Split(s, ".")

		var group, version, kind string
		if name[len(name)-3] == "api" {
			// e.g. "io.k8s.apimachinery.pkg.api.resource.Quantity"
			group = "core"
			version = name[len(name)-2]
			kind = name[len(name)-1]
		} else if name[len(name)-4] == "api" {
			// e.g. "io.k8s.api.core.v1.Pod"
			group = name[len(name)-3]
			version = name[len(name)-2]
			kind = name[len(name)-1]
		} else if name[len(name)-4] == "apis" {
			// e.g. "io.k8s.apimachinery.pkg.apis.meta.v1.Status"
			group = name[len(name)-3]
			version = name[len(name)-2]
			kind = name[len(name)-1]
		} else if name[len(name)-3] == "util" || name[len(name)-3] == "pkg" {
			// e.g. io.k8s.apimachinery.pkg.util.intstr.IntOrString
			// e.g. io.k8s.apimachinery.pkg.runtime.RawExtension
			return "", "", ""
		} else {
			panic(errors.New(fmt.Sprintf("Could not locate group for %s", name)))
		}
		return group, version, kind
	}
	// Recurse if type is array
	if IsArray(s) {
		return GetDefinitionVersionKind(*s.Items.Schema)
	}
	return "", "", ""
}
711615
func (t *Template) GetAllAWSGreengrassDeviceDefinitionVersionResources() map[string]*resources.AWSGreengrassDeviceDefinitionVersion {
	results := map[string]*resources.AWSGreengrassDeviceDefinitionVersion{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSGreengrassDeviceDefinitionVersion:
			results[name] = resource
		}
	}
	return results
}
405731
func (g *KubeVersionGetter) VersionFromCILabel(ciVersionLabel, description string) (string, *versionutil.Version, error) {
	versionStr, err := kubeadmutil.KubernetesReleaseVersion(ciVersionLabel)
	if err != nil {
		return "", nil, errors.Wrapf(err, "Couldn't fetch latest %s from the internet", description)
	}

	if description != "" {
		fmt.Fprintf(g.w, "[upgrade/versions] Latest %s: %s\n", description, versionStr)
	}

	ver, err := versionutil.ParseSemantic(versionStr)
	if err != nil {
		return "", nil, errors.Wrapf(err, "Couldn't parse latest %s", description)
	}
	return versionStr, ver, nil
}
526791
func (s *Snapshot) GetVersion(typ string) string {
	if s == nil {
		return ""
	}
	switch typ {
	case EndpointType:
		return s.Endpoints.Version
	case ClusterType:
		return s.Clusters.Version
	case RouteType:
		return s.Routes.Version
	case ListenerType:
		return s.Listeners.Version
	case SecretType:
		return s.Secrets.Version
	}
	return ""
}
534954
func GetSchemaForVersion(crd *CustomResourceDefinition, version string) (*CustomResourceValidation, error) {
	if !HasPerVersionSchema(crd.Spec.Versions) {
		return crd.Spec.Validation, nil
	}
	if crd.Spec.Validation != nil {
		return nil, fmt.Errorf("malformed CustomResourceDefinition %s version %s: top-level and per-version schemas must be mutual exclusive", crd.Name, version)
	}
	for _, v := range crd.Spec.Versions {
		if version == v.Name {
			return v.Schema, nil
		}
	}
	return nil, fmt.Errorf("version %s not found in CustomResourceDefinition: %v", version, crd.Name)
}
1008204
func (f *Registry) GetType(name string, version int) (reflect.Type, error) {
	record, err := f.lookup(name, version)
	if err != nil {
		return nil, err
	}
	return record.facadeType, nil
}
162656
func (gvs GroupVersioners) KindForGroupVersionKinds(kinds []schema.GroupVersionKind) (schema.GroupVersionKind, bool) {
	for _, gv := range gvs {
		target, ok := gv.KindForGroupVersionKinds(kinds)
		if !ok {
			continue
		}
		return target, true
	}
	return schema.GroupVersionKind{}, false
}
683418
func (t *Template) GetAWSGreengrassDeviceDefinitionVersionWithName(name string) (*resources.AWSGreengrassDeviceDefinitionVersion, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSGreengrassDeviceDefinitionVersion:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSGreengrassDeviceDefinitionVersion not found", name)
}
326024
func hasIdenticalPerVersionSchema(versions []apiextensions.CustomResourceDefinitionVersion) bool {
	if len(versions) == 0 {
		return false
	}
	value := versions[0].Schema
	for _, v := range versions {
		if v.Schema == nil || !apiequality.Semantic.DeepEqual(v.Schema, value) {
			return false
		}
	}
	return true
}
37030
func (c *Client) GetVersion() (string, error) {
	var clusterVersion string

	versions, err := c.GetClusterVersions()
	if err != nil {
		return "", err
	}
	for _, v := range versions {
		if clusterVersion != "" && clusterVersion != v {
			return "", errors.Errorf("etcd cluster contains endpoints with mismatched versions: %v", versions)
		}
		clusterVersion = v
	}
	if clusterVersion == "" {
		return "", errors.New("could not determine cluster etcd version")
	}
	return clusterVersion, nil
}
1345594
func getGroupVersionKind(config map[string]interface{}) (schema.GroupVersionKind, error) {
	gvk := schema.GroupVersionKind{}
	if gv, found := config["apiVersion"]; found {
		casted, ok := gv.(string)
		if !ok {
			return gvk, fmt.Errorf("Expected string for apiVersion, found %T", gv)
		}
		s := strings.Split(casted, "/")
		if len(s) != 1 {
			gvk.Group = s[0]
		}
		gvk.Version = s[len(s)-1]
	} else {
		return gvk, fmt.Errorf("Missing apiVersion in Kind %v", config)
	}
	if k, found := config["kind"]; found {
		casted, ok := k.(string)
		if !ok {
			return gvk, fmt.Errorf("Expected string for kind, found %T", k)
		}
		gvk.Kind = casted
	} else {
		return gvk, fmt.Errorf("Missing kind in Kind %v", config)
	}
	return gvk, nil
}
445543
func objectMetaAndKind(typer runtime.ObjectTyper, obj runtime.Object) (*api.ObjectMeta, unversioned.GroupVersionKind, error) {
	objectMeta, err := api.ObjectMetaFor(obj)
	if err != nil {
		return nil, unversioned.GroupVersionKind{}, errors.NewInternalError(err)
	}
	kind, err := typer.ObjectKind(obj)
	if err != nil {
		return nil, unversioned.GroupVersionKind{}, errors.NewInternalError(err)
	}
	return objectMeta, kind, nil
}
743524
func MinVersionFromContext(ctx context.Context) (int, bool) {
	minVersion, ok := ctx.Value(minVersionKey).(int)
	return minVersion, ok
}
995336
func (f *Function) GetVersionFromAlias(alias string) (string, error) {
	var version string = alias
	aliases, err := f.GetAliases()
	if err != nil {
		return version, err
	}

	for _, fnAlias := range aliases.Aliases {
		if strings.Compare(version, *fnAlias.Name) == 0 {
			version = *fnAlias.FunctionVersion
			break
		}
	}
	return version, nil
}
234003
func (obj *TypeMeta) GroupVersionKind() *unversioned.GroupVersionKind {
	return unversioned.FromAPIVersionAndKind(obj.APIVersion, obj.Kind)
}
1261551
func getVersion(mts map[int]*metricType, ver int) (*metricType, error) {
	if len(mts) == 0 {
		return nil, errMetricNotFound
	}
	if ver > 0 {
		// a version IS given
		if mt, exist := mts[ver]; exist {
			return mt, nil
		}
		return nil, errMetricNotFound
	}
	// or get the latest
	return getLatest(mts), nil
}
4456
func hasIdenticalPerVersionColumns(versions []apiextensions.CustomResourceDefinitionVersion) bool {
	if len(versions) == 0 {
		return false
	}
	value := versions[0].AdditionalPrinterColumns
	for _, v := range versions {
		if len(v.AdditionalPrinterColumns) == 0 || !apiequality.Semantic.DeepEqual(v.AdditionalPrinterColumns, value) {
			return false
		}
	}
	return true
}