Add class to repository scope
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)master
							parent
							
								
									e10634f8c3
								
							
						
					
					
						commit
						01509db714
					
				|  | @ -66,8 +66,9 @@ type UserInfo struct { | ||||||
| 
 | 
 | ||||||
| // Resource describes a resource by type and name.
 | // Resource describes a resource by type and name.
 | ||||||
| type Resource struct { | type Resource struct { | ||||||
| 	Type string | 	Type  string | ||||||
| 	Name string | 	Class string | ||||||
|  | 	Name  string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Access describes a specific action that is
 | // Access describes a specific action that is
 | ||||||
|  |  | ||||||
|  | @ -34,6 +34,7 @@ var ( | ||||||
| // ResourceActions stores allowed actions on a named and typed resource.
 | // ResourceActions stores allowed actions on a named and typed resource.
 | ||||||
| type ResourceActions struct { | type ResourceActions struct { | ||||||
| 	Type    string   `json:"type"` | 	Type    string   `json:"type"` | ||||||
|  | 	Class   string   `json:"class"` | ||||||
| 	Name    string   `json:"name"` | 	Name    string   `json:"name"` | ||||||
| 	Actions []string `json:"actions"` | 	Actions []string `json:"actions"` | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -147,13 +147,18 @@ type Scope interface { | ||||||
| // to a repository.
 | // to a repository.
 | ||||||
| type RepositoryScope struct { | type RepositoryScope struct { | ||||||
| 	Repository string | 	Repository string | ||||||
|  | 	Class      string | ||||||
| 	Actions    []string | 	Actions    []string | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // String returns the string representation of the repository
 | // String returns the string representation of the repository
 | ||||||
| // using the scope grammar
 | // using the scope grammar
 | ||||||
| func (rs RepositoryScope) String() string { | func (rs RepositoryScope) String() string { | ||||||
| 	return fmt.Sprintf("repository:%s:%s", rs.Repository, strings.Join(rs.Actions, ",")) | 	repoType := "repository" | ||||||
|  | 	if rs.Class != "" { | ||||||
|  | 		repoType = fmt.Sprintf("%s(%s)", repoType, rs.Class) | ||||||
|  | 	} | ||||||
|  | 	return fmt.Sprintf("%s:%s:%s", repoType, rs.Repository, strings.Join(rs.Actions, ",")) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // RegistryScope represents a token scope for access
 | // RegistryScope represents a token scope for access
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue