Skip to content

Commit

Permalink
feat(policies): Support wildcard and dynamic_tag (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Moran-k authored Nov 12, 2024
1 parent dcd0f10 commit be6fcc2
Show file tree
Hide file tree
Showing 17 changed files with 287 additions and 232 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=github.com
NAMESPACE=komodorio
NAME=komodor
BINARY=terraform-provider-${NAME}
VERSION=1.0.10
VERSION=1.0.11
OS_ARCH?=darwin_amd64

default: install
Expand All @@ -23,4 +23,7 @@ test:
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

testacc:
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

generate-docs:
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
2 changes: 0 additions & 2 deletions docs/data-sources/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ description: |-
### Read-Only

- `id` (String) The id and api key of the cluster integration


2 changes: 0 additions & 2 deletions docs/data-sources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ description: |-
- `id` (String) The id of the policy
- `statements` (String) The policy's statements
- `updated_at` (String) The date and time of when the Policy was last updated


2 changes: 0 additions & 2 deletions docs/data-sources/role.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ description: |-
- `id` (String) The id of the role
- `is_default` (Boolean) Is default role
- `updated_at` (String) The date and time of when the Role was last updated


1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ variable "komodor_api_key" {
```

<!-- schema generated by tfplugindocs -->

## Schema

### Optional
Expand Down
2 changes: 0 additions & 2 deletions docs/resources/action.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,3 @@ description: |-
- `created_at` (String)
- `id` (String) The ID of this resource.
- `updated_at` (String)


2 changes: 0 additions & 2 deletions docs/resources/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ description: |-
### Read-Only

- `id` (String) The id and api key of the cluster integration


2 changes: 0 additions & 2 deletions docs/resources/monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ description: |-
### Read-Only

- `id` (String) The ID of this resource.


7 changes: 5 additions & 2 deletions docs/resources/policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ description: |-
- `name` (String)
- `statements` (String)

### Optional

- `tags` (Map of String)
- `type` (String)

### Read-Only

- `created_at` (String)
- `id` (String) The ID of this resource.
- `updated_at` (String)


2 changes: 0 additions & 2 deletions docs/resources/policy_role_attachment.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ description: |-
### Read-Only

- `id` (String) The ID of this resource.


2 changes: 0 additions & 2 deletions docs/resources/role.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ description: |-
- `id` (String) The ID of this resource.
- `is_default` (Boolean)
- `updated_at` (String)


19 changes: 19 additions & 0 deletions examples/policy_dynamic_tags.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This example shows how to create a policy with dynamic tags.
# Dynamic tags feature is not available by default.
# When the feature is disabled, applying this policy will fail with error: `400 Bad Request`

resource "komodor_policy" "komo-example-dynamic-tags-policy" {
name = "komo-example-dynamic-tags-policy"
type = "dynamic_tag"
tags = {
"team": "super-heroes"
}
statements = <<EOF
[{
"actions": [
"view:all"
],
"resources": []
}]
EOF
}
19 changes: 19 additions & 0 deletions examples/policy_wildcard_namespace.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This example shows how to create a policy with a wildcard namespace pattern.
# wildcard policy type is not available by default.
# When the feature is disabled, applying this policy will fail with error: `400 Bad Request`

resource "komodor_policy" "komo-example-wildcard-policy" {
name = "komo-example-wildcard-policy"
type = "wildcard"
statements = <<EOF
[{
"actions": [
"view:all"
],
"resources": [{
"cluster": "komo-example-cluster",
"namespacePattern": "prod-*"
}]
}]
EOF
}
89 changes: 52 additions & 37 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,68 +1,83 @@
module github.com/komodorio/terraform-provider-komodor

go 1.19
go 1.23.3

require (
github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hashicorp/terraform-plugin-docs v0.20.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
)

require (
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/cli v1.1.6 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.2.1 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.6 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.4.0 // indirect
github.com/hashicorp/hcl/v2 v2.15.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hc-install v0.9.0 // indirect
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.17.3 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.14.1 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.25.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/huandu/xstrings v1.3.3 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mitchellh/cli v1.1.4 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.12.1 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.6 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yuin/goldmark v1.7.7 // indirect
github.com/yuin/goldmark-meta v1.1.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.22.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d // indirect
google.golang.org/grpc v1.50.1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit be6fcc2

Please sign in to comment.