mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-18 07:54:28 +00:00
Integrated org secrets into client
This commit is contained in:
parent
606ca93881
commit
86e4e53e77
2 changed files with 55 additions and 24 deletions
|
@ -61,6 +61,15 @@ type Client interface {
|
||||||
// SecretDel deletes a named repository secret.
|
// SecretDel deletes a named repository secret.
|
||||||
SecretDel(string, string, string) error
|
SecretDel(string, string, string) error
|
||||||
|
|
||||||
|
// TeamSecretList returns a list of all team secrets.
|
||||||
|
TeamSecretList(string) ([]*model.Secret, error)
|
||||||
|
|
||||||
|
// TeamSecretPost create or updates a team secret.
|
||||||
|
TeamSecretPost(string, *model.Secret) error
|
||||||
|
|
||||||
|
// TeamSecretDel deletes a named team secret.
|
||||||
|
TeamSecretDel(string, string) error
|
||||||
|
|
||||||
// Build returns a repository build by number.
|
// Build returns a repository build by number.
|
||||||
Build(string, string, int) (*model.Build, error)
|
Build(string, string, int) (*model.Build, error)
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,10 @@ const (
|
||||||
pathLog = "%s/api/repos/%s/%s/logs/%d/%d"
|
pathLog = "%s/api/repos/%s/%s/logs/%d/%d"
|
||||||
pathKey = "%s/api/repos/%s/%s/key"
|
pathKey = "%s/api/repos/%s/%s/key"
|
||||||
pathSign = "%s/api/repos/%s/%s/sign"
|
pathSign = "%s/api/repos/%s/%s/sign"
|
||||||
pathSecrets = "%s/api/repos/%s/%s/secrets"
|
pathRepoSecrets = "%s/api/repos/%s/%s/secrets"
|
||||||
pathSecret = "%s/api/repos/%s/%s/secrets/%s"
|
pathRepoSecret = "%s/api/repos/%s/%s/secrets/%s"
|
||||||
|
pathTeamSecrets = "%s/api/teams/%s/secrets"
|
||||||
|
pathTeamSecret = "%s/api/teams/%s/secrets/%s"
|
||||||
pathNodes = "%s/api/nodes"
|
pathNodes = "%s/api/nodes"
|
||||||
pathNode = "%s/api/nodes/%d"
|
pathNode = "%s/api/nodes/%d"
|
||||||
pathUsers = "%s/api/users"
|
pathUsers = "%s/api/users"
|
||||||
|
@ -265,20 +267,40 @@ func (c *client) Deploy(owner, name string, num int, env string, params map[stri
|
||||||
// SecretList returns a list of a repository secrets.
|
// SecretList returns a list of a repository secrets.
|
||||||
func (c *client) SecretList(owner, name string) ([]*model.Secret, error) {
|
func (c *client) SecretList(owner, name string) ([]*model.Secret, error) {
|
||||||
var out []*model.Secret
|
var out []*model.Secret
|
||||||
uri := fmt.Sprintf(pathSecrets, c.base, owner, name)
|
uri := fmt.Sprintf(pathRepoSecrets, c.base, owner, name)
|
||||||
err := c.get(uri, &out)
|
err := c.get(uri, &out)
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecretPost create or updates a repository secret.
|
// SecretPost create or updates a repository secret.
|
||||||
func (c *client) SecretPost(owner, name string, secret *model.Secret) error {
|
func (c *client) SecretPost(owner, name string, secret *model.Secret) error {
|
||||||
uri := fmt.Sprintf(pathSecrets, c.base, owner, name)
|
uri := fmt.Sprintf(pathRepoSecrets, c.base, owner, name)
|
||||||
return c.post(uri, secret, nil)
|
return c.post(uri, secret, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecretDel deletes a named repository secret.
|
// SecretDel deletes a named repository secret.
|
||||||
func (c *client) SecretDel(owner, name, secret string) error {
|
func (c *client) SecretDel(owner, name, secret string) error {
|
||||||
uri := fmt.Sprintf(pathSecret, c.base, owner, name, secret)
|
uri := fmt.Sprintf(pathRepoSecret, c.base, owner, name, secret)
|
||||||
|
return c.delete(uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TeamSecretList returns a list of a repository secrets.
|
||||||
|
func (c *client) TeamSecretList(team string) ([]*model.Secret, error) {
|
||||||
|
var out []*model.Secret
|
||||||
|
uri := fmt.Sprintf(pathTeamSecrets, c.base, team)
|
||||||
|
err := c.get(uri, &out)
|
||||||
|
return out, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TeamSecretPost create or updates a repository secret.
|
||||||
|
func (c *client) TeamSecretPost(team string, secret *model.Secret) error {
|
||||||
|
uri := fmt.Sprintf(pathTeamSecrets, c.base, team)
|
||||||
|
return c.post(uri, secret, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TeamSecretDel deletes a named repository secret.
|
||||||
|
func (c *client) TeamSecretDel(team, secret string) error {
|
||||||
|
uri := fmt.Sprintf(pathTeamSecret, c.base, team, secret)
|
||||||
return c.delete(uri)
|
return c.delete(uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue