Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for patch to vault_policy_document #1238

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.1.0 (Unreleased)

IMPROVEMENTS:
* `data/policy_document`: Add support for `patch` capability for vault-1.9+. ([#1238](https://github.com/hashicorp/terraform-provider-vault/pull/1238))

## 3.0.1 (November 23, 2021)

BUGS:
Expand Down
13 changes: 11 additions & 2 deletions vault/data_source_policy_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ type PolicyRule struct {
DeniedParameters map[string][]string
}

var allowedCapabilities = []string{"create", "read", "update", "delete", "list", "sudo", "deny"}
var allowedCapabilities = []string{
"create",
"read",
"update",
"delete",
"list",
"sudo",
"deny",
"patch",
}

func policyDocumentDataSource() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -136,7 +145,7 @@ func policyDocumentDataSourceRead(d *schema.ResourceData, meta interface{}) erro
policy := &Policy{}

if rawRules, hasRawRules := d.GetOk("rule"); hasRawRules {
var rawRuleIntfs = rawRules.([]interface{})
rawRuleIntfs := rawRules.([]interface{})
rules := make([]*PolicyRule, len(rawRuleIntfs))

for i, ruleI := range rawRuleIntfs {
Expand Down
5 changes: 2 additions & 3 deletions vault/data_source_policy_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ func TestDataSourcePolicyDocument(t *testing.T) {
},
},
})

}

var testDataSourcePolicyDocument_config = `
data "vault_policy_document" "test" {
rule {
path = "secret/test1/*"
capabilities = ["create", "read", "update", "delete", "list"]
capabilities = ["create", "read", "update", "delete", "list", "patch"]
description = "test rule 1"
required_parameters = ["test_param1"]

Expand Down Expand Up @@ -86,7 +85,7 @@ data "vault_policy_document" "test" {

var testResultPolicyHCLDocument = `# test rule 1
path "secret/test1/*" {
capabilities = ["create", "read", "update", "delete", "list"]
capabilities = ["create", "read", "update", "delete", "list", "patch"]
required_parameters = ["test_param1"]
allowed_parameters = {
"eggs" = ["foo", "bar"]
Expand Down