// ToV2Resource converts a V3 Resource to V2 Resource format
329259
func (r V3Resource) ToV2Resource() Resource {
	return Resource{
		Filename: r.FilePath,
		Mode:     r.Mode,
		SHA1:     r.Checksum.Value,
		Size:     r.SizeInBytes,
	}
}
1096940
func (t *Template) GetAllAWSEC2VPNConnectionRouteResources() map[string]*resources.AWSEC2VPNConnectionRoute {
	results := map[string]*resources.AWSEC2VPNConnectionRoute{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2VPNConnectionRoute:
			results[name] = resource
		}
	}
	return results
}
675632
func (t *Template) GetAllAWSEC2NetworkInterfaceResources() map[string]*resources.AWSEC2NetworkInterface {
	results := map[string]*resources.AWSEC2NetworkInterface{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2NetworkInterface:
			results[name] = resource
		}
	}
	return results
}
749796
func (c *Client) GetResource(ctx context.Context, project *string, res *primitives.Resource) (*manifold.Resource, error) {
	rs, err := c.GetResources(ctx, project, []*primitives.Resource{res})
	if err != nil {
		return nil, err
	}

	if len(rs) > 1 {
		// Names are unique per project. If no project is specified it could be
		// that there are multiple resources.
		// TODO: figure out if we can setup a test for this.
		return nil, ErrMultipleResourcesFound
	}

	return rs[0], nil
}
1090342
func (t *Template) GetAllAWSEC2TransitGatewayRouteTableResources() map[string]*resources.AWSEC2TransitGatewayRouteTable {
	results := map[string]*resources.AWSEC2TransitGatewayRouteTable{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2TransitGatewayRouteTable:
			results[name] = resource
		}
	}
	return results
}
1272483
func (t *Template) GetAllAWSApiGatewayV2ApiResources() map[string]*resources.AWSApiGatewayV2Api {
	results := map[string]*resources.AWSApiGatewayV2Api{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSApiGatewayV2Api:
			results[name] = resource
		}
	}
	return results
}
1289841
func (t *Template) GetAllAWSEC2RouteResources() map[string]*resources.AWSEC2Route {
	results := map[string]*resources.AWSEC2Route{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2Route:
			results[name] = resource
		}
	}
	return results
}
239819
func doc2resource(doc resourceDoc) (storedResource, error) {
	res, err := doc2basicResource(doc)
	if err != nil {
		return storedResource{}, errors.Trace(err)
	}

	stored := storedResource{
		Resource:    res,
		storagePath: doc.StoragePath,
	}
	return stored, nil
}
1251279
func (t *Template) GetAllAWSEC2TransitGatewayRouteResources() map[string]*resources.AWSEC2TransitGatewayRoute {
	results := map[string]*resources.AWSEC2TransitGatewayRoute{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2TransitGatewayRoute:
			results[name] = resource
		}
	}
	return results
}
218791
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
	switch resource {
	// Group=example.apiserver.code-generator.k8s.io, Version=internalVersion
	case example.SchemeGroupVersion.WithResource("testtypes"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Example().InternalVersion().TestTypes().Informer()}, nil

		// Group=example.test.apiserver.code-generator.k8s.io, Version=internalVersion
	case example2.SchemeGroupVersion.WithResource("testtypes"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.SecondExample().InternalVersion().TestTypes().Informer()}, nil

	}

	return nil, fmt.Errorf("no informer found for %v", resource)
}
1213721
func doc2basicResource(doc resourceDoc) (resource.Resource, error) {
	var res resource.Resource

	resType, err := charmresource.ParseType(doc.Type)
	if err != nil {
		return res, errors.Annotate(err, "got invalid data from DB")
	}

	origin, err := charmresource.ParseOrigin(doc.Origin)
	if err != nil {
		return res, errors.Annotate(err, "got invalid data from DB")
	}

	fp, err := resource.DeserializeFingerprint(doc.Fingerprint)
	if err != nil {
		return res, errors.Annotate(err, "got invalid data from DB")
	}

	res = resource.Resource{
		Resource: charmresource.Resource{
			Meta: charmresource.Meta{
				Name:        doc.Name,
				Type:        resType,
				Path:        doc.Path,
				Description: doc.Description,
			},
			Origin:      origin,
			Revision:    doc.Revision,
			Fingerprint: fp,
			Size:        doc.Size,
		},
		ID:            doc.ID,
		PendingID:     doc.PendingID,
		ApplicationID: doc.ApplicationID,
		Username:      doc.Username,
		Timestamp:     doc.Timestamp,
	}
	if err := res.Validate(); err != nil {
		return res, errors.Annotate(err, "got invalid data from DB")
	}
	return res, nil
}
271505
func (o *ResourceBuilderFlags) ToBuilder(restClientGetter RESTClientGetter, resources []string) ResourceFinder {
	namespace, enforceNamespace, namespaceErr := restClientGetter.ToRawKubeConfigLoader().Namespace()

	builder := resource.NewBuilder(restClientGetter).
		NamespaceParam(namespace).DefaultNamespace()

	if o.Scheme != nil {
		builder.WithScheme(o.Scheme, o.Scheme.PrioritizedVersionsAllGroups()...)
	} else {
		builder.Unstructured()
	}

	if o.FileNameFlags != nil {
		opts := o.FileNameFlags.ToOptions()
		builder.FilenameParam(enforceNamespace, &opts)
	}

	if o.Local == nil || !*o.Local {
		// resource type/name tuples only work non-local
		if o.All != nil {
			builder.ResourceTypeOrNameArgs(*o.All, resources...)
		} else {
			builder.ResourceTypeOrNameArgs(false, resources...)
		}
		// label selectors only work non-local (for now)
		if o.LabelSelector != nil {
			builder.LabelSelectorParam(*o.LabelSelector)
		}
		// field selectors only work non-local (forever)
		if o.FieldSelector != nil {
			builder.FieldSelectorParam(*o.FieldSelector)
		}
		// latest only works non-local (forever)
		if o.Latest {
			builder.Latest()
		}

	} else {
		builder.Local()

		if len(resources) > 0 {
			builder.AddError(resource.LocalResourceError)
		}
	}

	if !o.StopOnFirstError {
		builder.ContinueOnError()
	}

	return &ResourceFindBuilderWrapper{
		builder: builder.
			Flatten(). // I think we're going to recommend this everywhere
			AddError(namespaceErr),
	}
}
671670
func (t *Template) GetAllAWSApiGatewayV2StageResources() map[string]*resources.AWSApiGatewayV2Stage {
	results := map[string]*resources.AWSApiGatewayV2Stage{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSApiGatewayV2Stage:
			results[name] = resource
		}
	}
	return results
}
55964
func (t *Template) GetAllAWSEC2VPCEndpointResources() map[string]*resources.AWSEC2VPCEndpoint {
	results := map[string]*resources.AWSEC2VPCEndpoint{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2VPCEndpoint:
			results[name] = resource
		}
	}
	return results
}
153445
func Convert_core_RBDPersistentVolumeSource_To_v1_RBDPersistentVolumeSource(in *core.RBDPersistentVolumeSource, out *v1.RBDPersistentVolumeSource, s conversion.Scope) error {
	return autoConvert_core_RBDPersistentVolumeSource_To_v1_RBDPersistentVolumeSource(in, out, s)
}
1191858
func (c *Client) Resource(resource *metav1.APIResource, namespace string) ResourceInterface {
	resourceTokens := strings.SplitN(resource.Name, "/", 2)
	subresources := []string{}
	if len(resourceTokens) > 1 {
		subresources = strings.Split(resourceTokens[1], "/")
	}

	if len(namespace) == 0 {
		return oldResourceShim(c.delegate.Resource(c.version.WithResource(resourceTokens[0])), subresources)
	}
	return oldResourceShim(c.delegate.Resource(c.version.WithResource(resourceTokens[0])).Namespace(namespace), subresources)
}
1023815
func (t *Template) AddResource(resource NamedResource) {
	if _, ok := t.Resources[resource.Name]; ok {
		panic(fmt.Sprintf("%s is already defined in the template", resource.Name))
	}
	t.Resources[resource.Name] = resource.Resource
}