Add class to repository scope

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2016-11-15 17:14:31 -08:00
parent f982e05861
commit 07d2f1aac7
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB
3 changed files with 10 additions and 3 deletions

View file

@ -67,6 +67,7 @@ type UserInfo struct {
// Resource describes a resource by type and name.
type Resource struct {
Type string
Class string
Name string
}

View file

@ -34,6 +34,7 @@ var (
// ResourceActions stores allowed actions on a named and typed resource.
type ResourceActions struct {
Type string `json:"type"`
Class string `json:"class"`
Name string `json:"name"`
Actions []string `json:"actions"`
}

View file

@ -147,13 +147,18 @@ type Scope interface {
// to a repository.
type RepositoryScope struct {
Repository string
Class string
Actions []string
}
// String returns the string representation of the repository
// using the scope grammar
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