get returns a resource from the catalog. Unlike other catalog functions, it is safe to call get concurrently with calls to list and flush (i.e. under a read lock).
(n *runtimev1.ResourceName, withDeleted, clone bool)
| 137 | // get returns a resource from the catalog. |
| 138 | // Unlike other catalog functions, it is safe to call get concurrently with calls to list and flush (i.e. under a read lock). |
| 139 | func (c *catalogCache) get(n *runtimev1.ResourceName, withDeleted, clone bool) (*runtimev1.Resource, error) { |
| 140 | rs := c.resources[n.Kind] |
| 141 | if rs == nil { |
| 142 | return nil, drivers.ErrResourceNotFound |
| 143 | } |
| 144 | r, ok := rs[strings.ToLower(n.Name)] |
| 145 | if !ok { |
| 146 | return nil, drivers.ErrResourceNotFound |
| 147 | } |
| 148 | if r.Meta.DeletedOn != nil && !withDeleted { |
| 149 | return nil, drivers.ErrResourceNotFound |
| 150 | } |
| 151 | if clone { |
| 152 | return c.clone(r), nil |
| 153 | } |
| 154 | return r, nil |
| 155 | } |
| 156 | |
| 157 | // list returns a list of resources in the catalog. |
| 158 | // It optionally supports filtering by kind, path, and soft-deleted status. |
no test coverage detected