// SplitResource splits the Resource section of an ARN into its type and id
// components.
762132
func SplitResource(r string) (resource, id string, err error) {
	p := strings.Split(r, "/")

	if len(p) != 2 {
		err = ErrInvalidResource
		return
	}

	resource = p[0]
	id = p[1]

	return
}
3897
func (rm *StateResourceManager) RedefineResource(id, desc string, rsrcCfg interface{}) error {

	rsrc, alreadyExists, err := rm.findResource(id, desc)
	if err != nil {
		return err
	}

	if !alreadyExists {
		return core.Errorf("No resource found for description: %q and id: %q",
			desc, id)
	}

	rsrc.Reinit(rsrcCfg)
	return nil

}
1328090
func Parse(arn string) (*ARN, error) {
	p := strings.SplitN(arn, delimiter, 6)

	// Ensure that we have all the components that make up an ARN.
	if len(p) < 6 {
		return nil, ErrInvalidARN
	}

	a := &ARN{
		ARN:      p[0],
		AWS:      p[1],
		Service:  p[2],
		Region:   p[3],
		Account:  p[4],
		Resource: p[5],
	}

	// ARN's always start with "arn:aws" (hopefully).
	if a.ARN != "arn" || a.AWS != "aws" {
		return nil, ErrInvalidARN
	}

	return a, nil
}
581851
func (s *TaskStartFailedEventDetails) SetResource(v string) *TaskStartFailedEventDetails {
	s.Resource = &v
	return s
}
945200
func (s *AwsSecurityFindingFilters) SetResourcePartition(v []*StringFilter) *AwsSecurityFindingFilters {
	s.ResourcePartition = v
	return 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)
}
886120
func validateResource(v, collection string) error {
	// A resource must contain exactly three forward slashes.
	parts := splitResource(v)
	switch len(parts) {
	case 0:
		return errors.New("missing project component")
	case 1:
		return errors.New("missing project name")
	case 2:
		return errors.New("missing collection type")
	case 3:
		return errors.New("missing resource name")
	case 4:
		break
	default:
		return fmt.Errorf("too many components (%d) in resource name", len(parts))
	}

	switch {
	case parts[0] != "projects":
		return errors.New("first resource component must be 'projects'")
	case parts[2] != collection:
		return fmt.Errorf("third resource component must be '%s'", collection)
	}

	// Validate the resource name.
	if err := validateResourceName(parts[3]); err != nil {
		return err
	}
	return nil
}
1044912
func resourceProjectName(v string) (p, n string, err error) {
	parts := splitResource(v)
	if len(parts) != 4 {
		err = errors.New("malformed resource")
		return
	}
	p, n = parts[1], parts[3]
	return
}
319070
func (s *TaskStartedEventDetails) SetResource(v string) *TaskStartedEventDetails {
	s.Resource = &v
	return s
}
1143605
func GetResource(kind string, resources []*api.GenericResource) []*api.GenericResource {
	var res []*api.GenericResource

	for _, r := range resources {
		if Kind(r) != kind {
			continue
		}

		res = append(res, r)
	}

	return res
}
1264138
func splitPath(path string) ([]fileInfo, error) {
	var mode os.FileMode
	fi, err := os.Stat(path)

	// If the path is not present in the host then we respond with the most
	// flexible permission.
	uid, gid := idUnsupported, idUnsupported
	if err != nil {
		mode = os.ModePerm
	} else {
		uid, gid = getOwner(fi)
		mode = fi.Mode()
	}
	var dirs []fileInfo
	dirs = append(dirs, fileInfo{Name: path, Perm: mode, Uid: uid, Gid: gid})
	currentDir := path
	for {
		dir := filepath.Dir(filepath.Clean(currentDir))
		if dir == currentDir {
			break
		}

		// We try to find the permission of the file in the host. If the path is not
		// present in the host then we respond with the most flexible permission.
		uid, gid := idUnsupported, idUnsupported
		fi, err := os.Stat(dir)
		if err != nil {
			mode = os.ModePerm
		} else {
			uid, gid = getOwner(fi)
			mode = fi.Mode()
		}
		dirs = append(dirs, fileInfo{Name: dir, Perm: mode, Uid: uid, Gid: gid})
		currentDir = dir
	}
	return dirs, nil
}
520584
func ComponentResources(cpu string) v1.ResourceRequirements {
	return v1.ResourceRequirements{
		Requests: v1.ResourceList{
			v1.ResourceName(v1.ResourceCPU): resource.MustParse(cpu),
		},
	}
}
29235
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
	switch resource {
	// Group=argoproj.io, Version=v1alpha1
	case v1alpha1.SchemeGroupVersion.WithResource("appprojects"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Argoproj().V1alpha1().AppProjects().Informer()}, nil
	case v1alpha1.SchemeGroupVersion.WithResource("applications"):
		return &genericInformer{resource: resource.GroupResource(), informer: f.Argoproj().V1alpha1().Applications().Informer()}, nil

	}

	return nil, fmt.Errorf("no informer found for %v", resource)
}
329259
func (r V3Resource) ToV2Resource() Resource {
	return Resource{
		Filename: r.FilePath,
		Mode:     r.Mode,
		SHA1:     r.Checksum.Value,
		Size:     r.SizeInBytes,
	}
}
120323
func NewResource(init ...*Resource) *Resource {
	var o *Resource
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(Resource)
	}
	return o.Init()
}
1196733
func NewResource(rl v1.ResourceList) *Resource {
	r := &Resource{}
	r.Add(rl)
	return r
}
1146439
func SplitPathDirEntry(path string) (dir, base string) {
	cleanedPath := filepath.Clean(filepath.FromSlash(path))

	if specifiesCurrentDir(path) {
		cleanedPath += string(os.PathSeparator) + "."
	}

	return filepath.Dir(cleanedPath), filepath.Base(cleanedPath)
}