Skip to content

Commit

Permalink
feat: secrets - add new events
Browse files Browse the repository at this point in the history
  • Loading branch information
Kichiyaki committed Mar 31, 2024
1 parent b728dee commit b8e8f46
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 21 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
env:
GITEA_IMAGE: gitea/gitea:1.21
WOODPECKER_IMAGE: woodpeckerci/woodpecker-server:v2.0
- name: Forgejo 1.20 & Woodpecker 2.0
WOODPECKER_IMAGE: woodpeckerci/woodpecker-server:v2.4.1
- name: Forgejo 1.21 & Woodpecker 2.0
run: go test -race -coverprofile=coverage.txt -covermode=atomic ./...
env:
GITEA_IMAGE: codeberg.org/forgejo/forgejo:1.20
WOODPECKER_IMAGE: woodpeckerci/woodpecker-server:v2.0
GITEA_IMAGE: codeberg.org/forgejo/forgejo:1.21
WOODPECKER_IMAGE: woodpeckerci/woodpecker-server:v2.4.1
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.5.0
rev: v9.13.0
hooks:
- id: commitlint
stages: [commit-msg]
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/repository_secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ data "woodpecker_repository_secret" "test_secret" {

### Read-Only

- `events` (Set of String) events for which the secret is available (push, tag, pull_request, deployment, cron, manual)
- `events` (Set of String) events for which the secret is available (push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)
- `id` (Number) the secret's id
- `images` (Set of String) list of Docker images for which this secret is available
2 changes: 1 addition & 1 deletion docs/data-sources/secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ data "woodpecker_secret" "test_secret" {

### Read-Only

- `events` (Set of String) events for which the secret is available (push, tag, pull_request, deployment, cron, manual)
- `events` (Set of String) events for which the secret is available (push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)
- `id` (Number) the secret's id
- `images` (Set of String) list of Docker images for which this secret is available
2 changes: 1 addition & 1 deletion docs/resources/repository_secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "woodpecker_repository_secret" "test" {

### Required

- `events` (Set of String) events for which the secret is available (push, tag, pull_request, deployment, cron, manual)
- `events` (Set of String) events for which the secret is available (push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)
- `name` (String) the name of the secret
- `repository_id` (Number) the ID of the repository
- `value` (String, Sensitive) the value of the secret
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "woodpecker_secret" "test" {

### Required

- `events` (Set of String) events for which the secret is available (push, tag, pull_request, deployment, cron, manual)
- `events` (Set of String) events for which the secret is available (push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)
- `name` (String) the name of the secret
- `value` (String, Sensitive) the value of the secret

Expand Down
3 changes: 2 additions & 1 deletion internal/data_source_repository_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (d *repositorySecretDataSource) Schema(
"events": schema.SetAttribute{
ElementType: types.StringType,
Computed: true,
Description: "events for which the secret is available (push, tag, pull_request, deployment, cron, manual)",
Description: "events for which the secret is available " +
"(push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)",
},
"images": schema.SetAttribute{
ElementType: types.StringType,
Expand Down
3 changes: 2 additions & 1 deletion internal/data_source_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ func (d *secretDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
"events": schema.SetAttribute{
ElementType: types.StringType,
Computed: true,
Description: "events for which the secret is available (push, tag, pull_request, deployment, cron, manual)",
Description: "events for which the secret is available " +
"(push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)",
},
"images": schema.SetAttribute{
ElementType: types.StringType,
Expand Down
2 changes: 1 addition & 1 deletion internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (r woodpeckerResource) Close() error {
return r.docker.Close()
}

const defaultWoodpeckerImage = "woodpeckerci/woodpecker-server:v2.0.0"
const defaultWoodpeckerImage = "woodpeckerci/woodpecker-server:v2.4.1.0"

//nolint:nonamedreturns
func getWoodpeckerRepoTag() (repo string, tag string) {
Expand Down
28 changes: 24 additions & 4 deletions internal/resource_repository_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,20 @@ func (r *repositorySecretResource) Schema(_ context.Context, _ resource.SchemaRe
"events": schema.SetAttribute{
ElementType: types.StringType,
Required: true,
Description: "events for which the secret is available (push, tag, pull_request, deployment, cron, manual)",
Description: "events for which the secret is available " +
"(push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.OneOfCaseInsensitive("push", "tag", "pull_request", "deployment", "cron", "manual"),
stringvalidator.OneOfCaseInsensitive(
"push",
"tag",
"pull_request",
"pull_request_closed",
"deployment",
"cron",
"manual",
"release",
),
),
},
PlanModifiers: []planmodifier.Set{
Expand Down Expand Up @@ -300,10 +310,20 @@ func (r *repositorySecretResource) UpgradeState(_ context.Context) map[int64]res
"events": schema.SetAttribute{
ElementType: types.StringType,
Required: true,
Description: "events for which the secret is available (push, tag, pull_request, deployment, cron, manual)",
Description: "events for which the secret is available " +
"(push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.OneOfCaseInsensitive("push", "tag", "pull_request", "deployment", "cron", "manual"),
stringvalidator.OneOfCaseInsensitive(
"push",
"tag",
"pull_request",
"pull_request_closed",
"deployment",
"cron",
"manual",
"release",
),
),
},
PlanModifiers: []planmodifier.Set{
Expand Down
4 changes: 3 additions & 1 deletion internal/resource_repository_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "woodpecker_repository_secret" "test_secret" {
repository_id = %d
name = "%s"
value = "test123123"
events = ["push", "deployment"]
events = ["push", "deployment", "release", "pull_request_closed"]
images = ["testimage"]
}
`, repo.ID, name),
Expand All @@ -77,6 +77,8 @@ resource "woodpecker_repository_secret" "test_secret" {
resource.TestCheckResourceAttr("woodpecker_repository_secret.test_secret", "value", "test123123"),
resource.TestCheckTypeSetElemAttr("woodpecker_repository_secret.test_secret", "events.*", "push"),
resource.TestCheckTypeSetElemAttr("woodpecker_repository_secret.test_secret", "events.*", "deployment"),
resource.TestCheckTypeSetElemAttr("woodpecker_repository_secret.test_secret", "events.*", "release"),
resource.TestCheckTypeSetElemAttr("woodpecker_repository_secret.test_secret", "events.*", "pull_request_closed"),
resource.TestCheckTypeSetElemAttr("woodpecker_repository_secret.test_secret", "images.*", "testimage"),
),
},
Expand Down
28 changes: 24 additions & 4 deletions internal/resource_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,20 @@ func (r *secretResource) Schema(_ context.Context, _ resource.SchemaRequest, res
"events": schema.SetAttribute{
ElementType: types.StringType,
Required: true,
Description: "events for which the secret is available (push, tag, pull_request, deployment, cron, manual)",
Description: "events for which the secret is available " +
"(push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.OneOfCaseInsensitive("push", "tag", "pull_request", "deployment", "cron", "manual"),
stringvalidator.OneOfCaseInsensitive(
"push",
"tag",
"pull_request",
"pull_request_closed",
"deployment",
"cron",
"manual",
"release",
),
),
},
PlanModifiers: []planmodifier.Set{
Expand Down Expand Up @@ -246,10 +256,20 @@ func (r *secretResource) UpgradeState(_ context.Context) map[int64]resource.Stat
"events": schema.SetAttribute{
ElementType: types.StringType,
Required: true,
Description: "events for which the secret is available (push, tag, pull_request, deployment, cron, manual)",
Description: "events for which the secret is available " +
"(push, tag, pull_request, pull_request_closed, deployment, cron, manual, release)",
Validators: []validator.Set{
setvalidator.ValueStringsAre(
stringvalidator.OneOfCaseInsensitive("push", "tag", "pull_request", "deployment", "cron", "manual"),
stringvalidator.OneOfCaseInsensitive(
"push",
"tag",
"pull_request",
"pull_request_closed",
"deployment",
"cron",
"manual",
"release",
),
),
},
PlanModifiers: []planmodifier.Set{
Expand Down

0 comments on commit b8e8f46

Please sign in to comment.