Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/crazy-max/ghaction…
Browse files Browse the repository at this point in the history
…-import-gpg-6
  • Loading branch information
jschoombee authored Dec 12, 2023
2 parents 02bd6ce + c8f1ed3 commit 9e090db
Show file tree
Hide file tree
Showing 16 changed files with 824 additions and 21 deletions.
53 changes: 41 additions & 12 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
timeout-minutes: 5
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand All @@ -25,8 +25,8 @@ jobs:
name: go-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: danhunsaker/[email protected]
Expand All @@ -36,8 +36,8 @@ jobs:
name: go-fmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: danhunsaker/[email protected]
Expand All @@ -47,8 +47,8 @@ jobs:
name: go-imports
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: check
Expand All @@ -61,9 +61,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand All @@ -78,11 +78,40 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
id: go
- run: go test -v -cover ./internal/provider/... ./internal/client/... ./internal/config/... ./internal/utils/...
codeowners:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Check for CODEOWNERS file
uses: andstor/file-existence-action@v2
id: check_codeowners_1
with:
files: CODEOWNERS
- name: Check for CODEOWNERS file
uses: andstor/file-existence-action@v2
id: check_codeowners_2
with:
files: docs/CODEOWNERS
- name: Check for CODEOWNERS file
uses: andstor/file-existence-action@v2
id: check_codeowners_3
with:
files: .github/CODEOWNERS
- name: Validate CODEOWNERS
uses: mszostok/[email protected]
if: steps.check_codeowners_1.outputs.files_exists || steps.check_codeowners_2.outputs.files_exists ||steps.check_codeowners_3.outputs.files_exists
with:
checks: "files,owners,duppatterns,syntax"
github_access_token: ${{ secrets.CODEOWNERS_PAT}}
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
Expand All @@ -41,7 +41,7 @@ jobs:
passphrase: ${{ secrets.PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4.4.0
uses: goreleaser/goreleaser-action@v5.0.0
with:
version: latest
args: release --rm-dist
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @axtongrams/reviewers
78 changes: 78 additions & 0 deletions docs/resources/report_graph_query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wiz_report_graph_query Resource - terraform-provider-wiz"
subcategory: ""
description: |-
A GraphQL Query Report is an automated query that can be scheduled to run at hourly intervals.
---

# wiz_report_graph_query (Resource)

A GraphQL Query Report is an automated query that can be scheduled to run at hourly intervals.

## Example Usage

```terraform
# A simple example
resource "wiz_report_graph_query" "foo" {
name = "foo"
project_id = "2c38b8fa-c315-57ea-9de4-e3a19592d796"
query = <<EOF
{
"select": true,
"type": [
"CONTAINER_IMAGE"
],
"where": {
"name": {
"CONTAINS": [
"foo"
]
}
}
}
EOF
}
# Scheduling enabled (both run_interval_hours and run_starts_at must be set)
resource "wiz_report_graph_query" "foo" {
name = "foo"
project_id = "2c38b8fa-c315-57ea-9de4-e3a19592d796"
run_interval_hours = 24
run_starts_at = "2023-12-06 16:00:00 +0000 UTC"
query = <<EOF
{
"select": true,
"type": [
"CONTAINER_IMAGE"
],
"where": {
"name": {
"CONTAINS": [
"foo"
]
}
}
}
EOF
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Name of the Report.
- `query` (String) The query that the report will run. Required by the GRAPH_QUERY report type.

### Optional

- `project_id` (String) The ID of the project that this report belongs to (changing this requires re-creatting the report). Defaults to all projects.
- Defaults to `*`.
- `run_interval_hours` (Number) Run interval for scheduled reports (in hours).
- `run_starts_at` (String) String representing the time and date when the scheduling should start (required when run_interval_hours is set). Must be in the following format: 2006-01-02 15:04:05 +0000 UTC. Also, Wiz will always round this down by the hour.

### Read-Only

- `id` (String) The ID of this resource.
43 changes: 43 additions & 0 deletions examples/resources/wiz_report_graph_query/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# A simple example
resource "wiz_report_graph_query" "foo" {
name = "foo"
project_id = "2c38b8fa-c315-57ea-9de4-e3a19592d796"
query = <<EOF
{
"select": true,
"type": [
"CONTAINER_IMAGE"
],
"where": {
"name": {
"CONTAINS": [
"foo"
]
}
}
}
EOF
}

# Scheduling enabled (both run_interval_hours and run_starts_at must be set)
resource "wiz_report_graph_query" "foo" {
name = "foo"
project_id = "2c38b8fa-c315-57ea-9de4-e3a19592d796"
run_interval_hours = 24
run_starts_at = "2023-12-06 16:00:00 +0000 UTC"
query = <<EOF
{
"select": true,
"type": [
"CONTAINER_IMAGE"
],
"where": {
"name": {
"CONTAINS": [
"foo"
]
}
}
}
EOF
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module wiz.io/hashicorp/terraform-provider-wiz
go 1.18

require (
github.com/google/uuid v1.3.0
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/google/uuid v1.4.0
github.com/hashicorp/go-retryablehttp v0.7.5
github.com/hashicorp/terraform-plugin-docs v0.16.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand All @@ -66,8 +66,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk=
github.com/hashicorp/go-plugin v1.4.10/go.mod h1:6/1TEzT0eQznvI/gV2CM29DLSkAK/e58mUWKVsPaph0=
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
Expand Down
2 changes: 2 additions & 0 deletions internal/acceptance/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
TcSubscriptionResourceGroups TestCase = "SUBSCRIPTION_RESOURCE_GROUPS"
// TcProject test case
TcProject TestCase = "PROJECT"
// TcReportGraphQuery test case
TcReportGraphQuery TestCase = "REPORT_GRAPH_QUERY"
// TcCloudConfigRule test case
TcCloudConfigRule TestCase = "CLOUD_CONFIG_RULE"
)
2 changes: 2 additions & 0 deletions internal/acceptance/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func testAccPreCheck(t *testing.T, tc TestCase) {
envVars = append(commonEnvVars, "WIZ_SUBSCRIPTION_ID")
case TcCloudConfigRule:
envVars = append(commonEnvVars, "WIZ_SUBSCRIPTION_ID")
case TcReportGraphQuery:
envVars = append(commonEnvVars, "WIZ_PROJECT_ID")
default:
t.Fatalf("unknown testCase: %s", tc)
}
Expand Down
64 changes: 64 additions & 0 deletions internal/acceptance/resource_report_graph_query_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package acceptance

import (
"fmt"
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

func TestAccResourceWizReportGraphQuery_basic(t *testing.T) {
rName := acctest.RandomWithPrefix(ResourcePrefix)
projectID := os.Getenv("WIZ_PROJECT_ID")

resource.UnitTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t, TestCase(TcReportGraphQuery)) },
ProviderFactories: providerFactories,
Steps: []resource.TestStep{
{
Config: testResourceWizReportGraphQueryBasic(rName, projectID),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"wiz_report_graph_query.foo",
"name",
rName,
),
resource.TestCheckResourceAttr(
"wiz_report_graph_query.foo",
"project_id",
projectID,
),
resource.TestCheckResourceAttr(
"wiz_report_graph_query.foo",
"query",
"{\"select\": true, \"type\": [\"CONTAINER_IMAGE\"], \"where\": {\"name\": {\"CONTAINS\": [\"foo\"]}}}",
),
resource.TestCheckResourceAttr(
"wiz_report_graph_query.foo",
"run_interval_hours",
"48",
),
resource.TestCheckResourceAttr(
"wiz_report_graph_query.foo",
"run_starts_at",
"2023-12-06 16:00:00 +0000 UTC",
),
),
},
},
})
}

func testResourceWizReportGraphQueryBasic(rName, projectID string) string {
return fmt.Sprintf(`
resource "wiz_report_graph_query" "foo" {
name = "%s"
project_id = "%s"
run_interval_hours = 48
run_starts_at = "2023-12-06 16:00:00 +0000 UTC"
query = "{\"select\": true, \"type\": [\"CONTAINER_IMAGE\"], \"where\": {\"name\": {\"CONTAINS\": [\"foo\"]}}}"
}
`, rName, projectID)
}
1 change: 1 addition & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ yLyKQXhw2W2Xs0qLeC1etA+jTGDK4UfLeC0SF7FSi8o5LL21L8IzApar2pR/
"wiz_integration_aws_sns": resourceWizIntegrationAwsSNS(),
"wiz_integration_servicenow": resourceWizIntegrationServiceNow(),
"wiz_integration_jira": resourceWizIntegrationJira(),
"wiz_report_graph_query": resourceWizReportGraphQuery(),
"wiz_project": resourceWizProject(),
"wiz_saml_idp": resourceWizSAMLIdP(),
"wiz_security_framework": resourceWizSecurityFramework(),
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/resource_cloud_config_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ func resourceWizCloudConfigurationRuleRead(ctx context.Context, d *schema.Resour
if err != nil {
return append(diags, diag.FromErr(err)...)
}
err = d.Set("opa_policy", data.CloudConfigurationRule.OPAPolicy)
if err != nil {
return append(diags, diag.FromErr(err)...)
}
err = d.Set("severity", data.CloudConfigurationRule.Severity)
if err != nil {
return append(diags, diag.FromErr(err)...)
Expand Down
Loading

0 comments on commit 9e090db

Please sign in to comment.