feat: secrets - add new events (#26)
This commit is contained in:
parent
b728dee457
commit
fbc3b39840
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -33,6 +33,5 @@ data "woodpecker_repository_secret" "test_secret" {
|
|||
|
||||
### Read-Only
|
||||
|
||||
- `email` (String) email used for authentication
|
||||
- `id` (Number) the id of the registry
|
||||
- `username` (String) username used for authentication
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -37,10 +37,6 @@ resource "woodpecker_repository_secret" "test" {
|
|||
- `repository_id` (Number) the ID of the repository
|
||||
- `username` (String) username used for authentication
|
||||
|
||||
### Optional
|
||||
|
||||
- `email` (String) email used for authentication
|
||||
|
||||
### Read-Only
|
||||
|
||||
- `id` (Number) the id of the registry
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -53,10 +53,6 @@ func (d *repositoryRegistryDataSource) Schema(
|
|||
Computed: true,
|
||||
Description: "username used for authentication",
|
||||
},
|
||||
"email": schema.StringAttribute{
|
||||
Computed: true,
|
||||
Description: "email used for authentication",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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"
|
||||
|
||||
//nolint:nonamedreturns
|
||||
func getWoodpeckerRepoTag() (repo string, tag string) {
|
||||
|
|
|
@ -268,14 +268,12 @@ type repositoryRegistryResourceModel struct {
|
|||
Address types.String `tfsdk:"address"`
|
||||
Username types.String `tfsdk:"username"`
|
||||
Password types.String `tfsdk:"password"`
|
||||
Email types.String `tfsdk:"email"`
|
||||
}
|
||||
|
||||
func (m *repositoryRegistryResourceModel) setValues(_ context.Context, registry *woodpecker.Registry) diag.Diagnostics {
|
||||
m.ID = types.Int64Value(registry.ID)
|
||||
m.Address = types.StringValue(registry.Address)
|
||||
m.Username = types.StringValue(registry.Username)
|
||||
m.Email = types.StringValue(registry.Email)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -287,7 +285,6 @@ func (m *repositoryRegistryResourceModel) toWoodpeckerModel(
|
|||
Address: m.Address.ValueString(),
|
||||
Username: m.Username.ValueString(),
|
||||
Password: m.Password.ValueString(),
|
||||
Email: m.Email.ValueString(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -296,7 +293,6 @@ type repositoryRegistryDataSourceModel struct {
|
|||
RepositoryID types.Int64 `tfsdk:"repository_id"`
|
||||
Address types.String `tfsdk:"address"`
|
||||
Username types.String `tfsdk:"username"`
|
||||
Email types.String `tfsdk:"email"`
|
||||
}
|
||||
|
||||
func (m *repositoryRegistryDataSourceModel) setValues(
|
||||
|
@ -306,6 +302,5 @@ func (m *repositoryRegistryDataSourceModel) setValues(
|
|||
m.ID = types.Int64Value(registry.ID)
|
||||
m.Address = types.StringValue(registry.Address)
|
||||
m.Username = types.StringValue(registry.Username)
|
||||
m.Email = types.StringValue(registry.Email)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -76,14 +76,6 @@ func (r *repositoryRegistryResource) Schema(
|
|||
Description: "password used for authentication",
|
||||
Sensitive: true,
|
||||
},
|
||||
"email": schema.StringAttribute{
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
Description: "email used for authentication",
|
||||
PlanModifiers: []planmodifier.String{
|
||||
stringplanmodifier.UseStateForUnknown(),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ resource "woodpecker_repository_registry" "test_registry" {
|
|||
address = "%s"
|
||||
username = "test2"
|
||||
password = "test2"
|
||||
email = "test@localhost"
|
||||
}
|
||||
`, repo.ID, address),
|
||||
Check: resource.ComposeAggregateTestCheckFunc(
|
||||
|
@ -73,7 +72,6 @@ resource "woodpecker_repository_registry" "test_registry" {
|
|||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "address", address),
|
||||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "username", "test2"),
|
||||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "password", "test2"),
|
||||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "email", "test@localhost"),
|
||||
),
|
||||
},
|
||||
{ // update registry
|
||||
|
@ -95,7 +93,6 @@ resource "woodpecker_repository_registry" "test_registry" {
|
|||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "address", address),
|
||||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "username", "test"),
|
||||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "password", "test"),
|
||||
resource.TestCheckResourceAttr("woodpecker_repository_registry.test_registry", "email", "test@localhost"),
|
||||
),
|
||||
},
|
||||
{ // import
|
||||
|
|
|
@ -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{
|
||||
|
@ -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{
|
||||
|
|
|
@ -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),
|
||||
|
@ -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"),
|
||||
),
|
||||
},
|
||||
|
|
|
@ -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{
|
||||
|
@ -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{
|
||||
|
|
|
@ -134,8 +134,10 @@ type (
|
|||
Address string `json:"address"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Email string `json:"email"`
|
||||
Token string `json:"token"`
|
||||
// Deprecated
|
||||
Email string `json:"email"` // TODO remove in 3.x
|
||||
// Deprecated
|
||||
Token string `json:"token"` // TODO remove in 3.x
|
||||
}
|
||||
|
||||
// Secret represents a secret variable, such as a password or token.
|
||||
|
|
Loading…
Reference in New Issue