Adding SkipVerify to Secrets

This commit is contained in:
Don 2016-10-19 11:50:09 -07:00
parent 2d90155d5a
commit dfcaa78e85
8 changed files with 77 additions and 26 deletions

View file

@ -20,25 +20,30 @@ type RepoSecret struct {
// the secret is restricted to this list of events.
Events []string `json:"event,omitempty" meddler:"secret_events,json"`
// whether the secret requires verification
SkipVerify bool `json:"skip_verify" meddler:"secret_skip_verify"`
}
// Secret transforms a repo secret into a simple secret.
func (s *RepoSecret) Secret() *Secret {
return &Secret{
Name: s.Name,
Value: s.Value,
Images: s.Images,
Events: s.Events,
Name: s.Name,
Value: s.Value,
Images: s.Images,
Events: s.Events,
SkipVerify: s.SkipVerify,
}
}
// Clone provides a repo secrets clone without the value.
func (s *RepoSecret) Clone() *RepoSecret {
return &RepoSecret{
ID: s.ID,
Name: s.Name,
Images: s.Images,
Events: s.Events,
ID: s.ID,
Name: s.Name,
Images: s.Images,
Events: s.Events,
SkipVerify: s.SkipVerify,
}
}

View file

@ -18,6 +18,9 @@ type Secret struct {
// the secret is restricted to this list of events.
Events []string `json:"event,omitempty"`
// whether the secret requires verification
SkipVerify bool `json:"skip_verify"`
}
// Match returns true if an image and event match the restricted list.

View file

@ -20,25 +20,30 @@ type TeamSecret struct {
// the secret is restricted to this list of events.
Events []string `json:"event,omitempty" meddler:"team_secret_events,json"`
// whether the secret requires verification
SkipVerify bool `json:"skip_verify" meddler:"team_secret_skip_verify"`
}
// Secret transforms a repo secret into a simple secret.
func (s *TeamSecret) Secret() *Secret {
return &Secret{
Name: s.Name,
Value: s.Value,
Images: s.Images,
Events: s.Events,
Name: s.Name,
Value: s.Value,
Images: s.Images,
Events: s.Events,
SkipVerify: s.SkipVerify,
}
}
// Clone provides a repo secrets clone without the value.
func (s *TeamSecret) Clone() *TeamSecret {
return &TeamSecret{
ID: s.ID,
Name: s.Name,
Images: s.Images,
Events: s.Events,
ID: s.ID,
Name: s.Name,
Images: s.Images,
Events: s.Events,
SkipVerify: s.SkipVerify,
}
}

View file

@ -0,0 +1,12 @@
-- +migrate Up
ALTER TABLE secrets ADD COLUMN secret_skip_verify BOOLEAN;
ALTER TABLE team_secrets ADD COLUMN team_secret_skip_verify BOOLEAN;
UPDATE secrets SET secret_skip_verify = false;
UPDATE team_secrets SET team_secret_skip_verify = false;
-- +migrate Down
ALTER TABLE secrets DROP COLUMN secret_skip_verify;
ALTER TABLE team_secrets DROP COLUMN team_secret_skip_verify;

View file

@ -0,0 +1,12 @@
-- +migrate Up
ALTER TABLE secrets ADD COLUMN secret_skip_verify BOOLEAN;
ALTER TABLE team_secrets ADD COLUMN team_secret_skip_verify BOOLEAN;
UPDATE secrets SET secret_skip_verify = false;
UPDATE team_secrets SET team_secret_skip_verify = false;
-- +migrate Down
ALTER TABLE secrets DROP COLUMN secret_skip_verify;
ALTER TABLE team_secrets DROP COLUMN team_secret_skip_verify;

View file

@ -0,0 +1,12 @@
-- +migrate Up
ALTER TABLE secrets ADD COLUMN secret_skip_verify BOOLEAN;
ALTER TABLE team_secrets ADD COLUMN team_secret_skip_verify BOOLEAN;
UPDATE secrets SET secret_skip_verify = 0;
UPDATE team_secrets SET team_secret_skip_verify = 0;
-- +migrate Down
ALTER TABLE secrets DROP COLUMN secret_skip_verify;
ALTER TABLE team_secrets DROP COLUMN team_secret_skip_verify;

View file

@ -23,11 +23,12 @@ func TestRepoSecrets(t *testing.T) {
g.It("Should set and get a secret", func() {
secret := &model.RepoSecret{
RepoID: 1,
Name: "foo",
Value: "bar",
Images: []string{"docker", "gcr"},
Events: []string{"push", "tag"},
RepoID: 1,
Name: "foo",
Value: "bar",
Images: []string{"docker", "gcr"},
Events: []string{"push", "tag"},
SkipVerify: false,
}
err := s.SetSecret(secret)
g.Assert(err == nil).IsTrue()

View file

@ -23,11 +23,12 @@ func TestTeamSecrets(t *testing.T) {
g.It("Should set and get a secret", func() {
secret := &model.TeamSecret{
Key: "octocat",
Name: "foo",
Value: "bar",
Images: []string{"docker", "gcr"},
Events: []string{"push", "tag"},
Key: "octocat",
Name: "foo",
Value: "bar",
Images: []string{"docker", "gcr"},
Events: []string{"push", "tag"},
SkipVerify: false,
}
err := s.SetTeamSecret(secret)
g.Assert(err == nil).IsTrue()