forked from gboddin/drone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1866ab3
commit 4569b60
Showing
21 changed files
with
394 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
package model | ||
|
||
// Config defines system configuration parameters. | ||
type Config struct { | ||
Open bool // Enables open registration | ||
Secret string // Secret token used to authenticate agents | ||
Admins map[string]bool // Administrative users | ||
Orgs map[string]bool // Organization whitelist | ||
} | ||
|
||
// IsAdmin returns true if the user is a member of the administrator list. | ||
func (c *Config) IsAdmin(user *User) bool { | ||
return c.Admins[user.Login] | ||
// ConfigStore persists pipeline configuration to storage. | ||
type ConfigStore interface { | ||
ConfigLoad(int64) (*Config, error) | ||
ConfigFind(*Repo, string) (*Config, error) | ||
ConfigUpdate(*Config) error | ||
ConfigInsert(*Config) error | ||
} | ||
|
||
// IsMember returns true if the user is a member of the whitelisted teams. | ||
func (c *Config) IsMember(teams []*Team) bool { | ||
for _, team := range teams { | ||
if c.Orgs[team.Login] { | ||
return true | ||
} | ||
} | ||
return false | ||
// Config represents a pipeline configuration. | ||
type Config struct { | ||
ID int64 `json:"-" meddler:"config_id,pk"` | ||
RepoID int64 `json:"-" meddler:"config_repo_id"` | ||
Data string `json:"data" meddler:"config_data"` | ||
Hash string `json:"hash" meddler:"config_hash"` | ||
Approved bool `json:"approved" meddler:"config_approved"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package model | ||
|
||
// Settings defines system configuration parameters. | ||
type Settings struct { | ||
Open bool // Enables open registration | ||
Secret string // Secret token used to authenticate agents | ||
Admins map[string]bool // Administrative users | ||
Orgs map[string]bool // Organization whitelist | ||
} | ||
|
||
// IsAdmin returns true if the user is a member of the administrator list. | ||
func (c *Settings) IsAdmin(user *User) bool { | ||
return c.Admins[user.Login] | ||
} | ||
|
||
// IsMember returns true if the user is a member of the whitelisted teams. | ||
func (c *Settings) IsMember(teams []*Team) bool { | ||
for _, team := range teams { | ||
if c.Orgs[team.Login] { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package datastore | ||
|
||
import ( | ||
"github.com/drone/drone/model" | ||
"github.com/drone/drone/store/datastore/sql" | ||
"github.com/russross/meddler" | ||
) | ||
|
||
func (db *datastore) ConfigLoad(id int64) (*model.Config, error) { | ||
stmt := sql.Lookup(db.driver, "config-find-repo-id") | ||
conf := new(model.Config) | ||
err := meddler.QueryRow(db, conf, stmt, id) | ||
return conf, err | ||
} | ||
|
||
func (db *datastore) ConfigFind(repo *model.Repo, hash string) (*model.Config, error) { | ||
stmt := sql.Lookup(db.driver, "config-find-repo-hash") | ||
conf := new(model.Config) | ||
err := meddler.QueryRow(db, conf, stmt, repo.ID, hash) | ||
return conf, err | ||
} | ||
|
||
func (db *datastore) ConfigUpdate(config *model.Config) error { | ||
return meddler.Update(db, "config", config) | ||
} | ||
|
||
func (db *datastore) ConfigInsert(config *model.Config) error { | ||
return meddler.Insert(db, "config", config) | ||
} |
Oops, something went wrong.