From 6eb80ed2ff68a98f2ca13e1297fd57ae9d0ac2d6 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 15 Feb 2024 01:12:10 +0000
Subject: [PATCH 01/13] chore: Update module golang.org/x/vuln/cmd/govulncheck
to v1.0.4 (#159)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| golang.org/x/vuln/cmd/govulncheck | `v1.0.3` -> `v1.0.4` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fvuln%2fcmd%2fgovulncheck/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fvuln%2fcmd%2fgovulncheck/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fvuln%2fcmd%2fgovulncheck/v1.0.3/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fvuln%2fcmd%2fgovulncheck/v1.0.3/v1.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
---
### Configuration
📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
every weekday,every weekend" (UTC), Automerge - At any time (no schedule
defined).
🚦 **Automerge**: Enabled.
â™» **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] If you want to rebase/retry this PR, check
this box
---
This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/nobl9/terraform-provider-nobl9).
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 8074656b..beb9b4c1 100644
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@ GOSEC_VERSION := v2.18.2
# renovate datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION := v1.55.2
# renovate datasource=go depName=golang.org/x/vuln/cmd/govulncheck
-GOVULNCHECK_VERSION := v1.0.3
+GOVULNCHECK_VERSION := v1.0.4
# renovate datasource=go depName=golang.org/x/tools/cmd/goimports
GOIMPORTS_VERSION := v0.17.0
# renovate datasource=github-releases depName=segmentio/golines
From 3ca9a904783e97fbf47918926411acfacde9b218 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 15 Feb 2024 03:12:52 +0000
Subject: [PATCH 02/13] chore: Update module golang.org/x/tools/cmd/goimports
to v0.18.0 (#164)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| golang.org/x/tools/cmd/goimports | `v0.17.0` -> `v0.18.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftools%2fcmd%2fgoimports/v0.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2ftools%2fcmd%2fgoimports/v0.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2ftools%2fcmd%2fgoimports/v0.17.0/v0.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftools%2fcmd%2fgoimports/v0.17.0/v0.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
---
### Configuration
📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
every weekday,every weekend" (UTC), Automerge - At any time (no schedule
defined).
🚦 **Automerge**: Enabled.
â™» **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] If you want to rebase/retry this PR, check
this box
---
This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/nobl9/terraform-provider-nobl9).
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index beb9b4c1..9b63eb73 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ GOLANGCI_LINT_VERSION := v1.55.2
# renovate datasource=go depName=golang.org/x/vuln/cmd/govulncheck
GOVULNCHECK_VERSION := v1.0.4
# renovate datasource=go depName=golang.org/x/tools/cmd/goimports
-GOIMPORTS_VERSION := v0.17.0
+GOIMPORTS_VERSION := v0.18.0
# renovate datasource=github-releases depName=segmentio/golines
GOLINES_VERSION := v0.9.0
From d7d754574695e3f16ff7038138aa7397e006575c Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 15 Feb 2024 08:51:28 +0000
Subject: [PATCH 03/13] chore: Update dependency segmentio/golines to v0.12.2
(#163)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [segmentio/golines](https://togithub.com/segmentio/golines) | minor |
`v0.9.0` -> `v0.12.2` |
---
### Release Notes
segmentio/golines (segmentio/golines)
###
[`v0.12.2`](https://togithub.com/segmentio/golines/releases/tag/v0.12.2)
[Compare
Source](https://togithub.com/segmentio/golines/compare/v0.12.1...v0.12.2)
#### What's Changed
- build: build and release on ubuntu-20.04 for older glibc versions by
[@asaf-erlich](https://togithub.com/asaf-erlich) in
[https://github.com/segmentio/golines/pull/121](https://togithub.com/segmentio/golines/pull/121)
#### New Contributors
- [@asaf-erlich](https://togithub.com/asaf-erlich) made their
first contribution in
[https://github.com/segmentio/golines/pull/121](https://togithub.com/segmentio/golines/pull/121)
**Full Changelog**:
https://github.com/segmentio/golines/compare/v0.12.1...v0.12.2
###
[`v0.12.1`](https://togithub.com/segmentio/golines/releases/tag/v0.12.1)
[Compare
Source](https://togithub.com/segmentio/golines/compare/v0.12.0...v0.12.1)
#### Changelog
-
[`22903f7`](https://togithub.com/segmentio/golines/commit/22903f7af571b45339b1ccd3c64f6d41ad0740a3):
Fix version formatting
([#118](https://togithub.com/segmentio/golines/issues/118))
([@mckern](https://togithub.com/mckern))
###
[`v0.12.0`](https://togithub.com/segmentio/golines/releases/tag/v0.12.0)
[Compare
Source](https://togithub.com/segmentio/golines/compare/v0.11.0...v0.12.0)
#### Changelog
-
[`833265d`](https://togithub.com/segmentio/golines/commit/833265ddea58d67d7322ec0fbba7c8a86c03bc30):
Update README to reflect 1.19
([#81](https://togithub.com/segmentio/golines/issues/81))
([@yolken](https://togithub.com/yolken))
-
[`08b576a`](https://togithub.com/segmentio/golines/commit/08b576a44b8f0510a9614ae0af6c0b97cc002b8c):
Fix circleci job
([#82](https://togithub.com/segmentio/golines/issues/82))
([@yolken](https://togithub.com/yolken))
-
[`d7d11e6`](https://togithub.com/segmentio/golines/commit/d7d11e6ae11721865229b1d55b8862c8bd4ca719):
GH Actions updates, remove CircleCI
([#84](https://togithub.com/segmentio/golines/issues/84))
([@wdbetts](https://togithub.com/wdbetts))
-
[`fe1c9ae`](https://togithub.com/segmentio/golines/commit/fe1c9aefd95932088fab00cb0753095778c6ce01):
Q1 2024: deferred updates
([#117](https://togithub.com/segmentio/golines/issues/117))
([@mckern](https://togithub.com/mckern))
###
[`v0.11.0`](https://togithub.com/segmentio/golines/compare/v0.10.0...v0.11.0)
[Compare
Source](https://togithub.com/segmentio/golines/compare/v0.10.0...v0.11.0)
###
[`v0.10.0`](https://togithub.com/segmentio/golines/compare/v0.9.0...v0.10.0)
[Compare
Source](https://togithub.com/segmentio/golines/compare/v0.9.0...v0.10.0)
---
### Configuration
📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
every weekday,every weekend" (UTC), Automerge - At any time (no schedule
defined).
🚦 **Automerge**: Enabled.
â™» **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] If you want to rebase/retry this PR, check
this box
---
This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/nobl9/terraform-provider-nobl9).
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 9b63eb73..37f4c811 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ GOVULNCHECK_VERSION := v1.0.4
# renovate datasource=go depName=golang.org/x/tools/cmd/goimports
GOIMPORTS_VERSION := v0.18.0
# renovate datasource=github-releases depName=segmentio/golines
-GOLINES_VERSION := v0.9.0
+GOLINES_VERSION := v0.12.2
# Check if the program is present in $PATH and install otherwise.
# ${1} - oneOf{binary,yarn}
From 3aad7c24e2a8d7772d0290afa0fa608c5bb8859e Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Thu, 15 Feb 2024 09:55:12 +0100
Subject: [PATCH 04/13] chore: Update pr-title.yml (#158)
## Motivation
Subscribe to synchronize events in order to alleviate pr-title workflow
problems (it won't trigger sometimes).
---
.github/workflows/pr-title.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml
index 2d55ebfe..2a77da50 100644
--- a/.github/workflows/pr-title.yml
+++ b/.github/workflows/pr-title.yml
@@ -1,6 +1,6 @@
on:
pull_request:
- types: [opened, reopened, edited]
+ types: [opened, reopened, edited, synchronize]
merge_group:
name: pr-title
jobs:
From 4afffd3548e376bab4e1b82ee46a99894e834197 Mon Sep 17 00:00:00 2001
From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com>
Date: Thu, 15 Feb 2024 08:56:52 +0000
Subject: [PATCH 05/13] chore: Update dependency securego/gosec to v2.19.0
(#162)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)
This PR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [securego/gosec](https://togithub.com/securego/gosec) | minor |
`v2.18.2` -> `v2.19.0` |
---
### Release Notes
securego/gosec (securego/gosec)
###
[`v2.19.0`](https://togithub.com/securego/gosec/releases/tag/v2.19.0)
[Compare
Source](https://togithub.com/securego/gosec/compare/v2.18.2...v2.19.0)
#### Changelog
- [`26e57d6`](https://togithub.com/securego/gosec/commit/26e57d6) Update
CI to go version 1.22
- [`e60b8d8`](https://togithub.com/securego/gosec/commit/e60b8d8)
chore(deps): update all dependencies
- [`1285eb7`](https://togithub.com/securego/gosec/commit/1285eb7)
chore(deps): update all dependencies
- [`cf4ab3e`](https://togithub.com/securego/gosec/commit/cf4ab3e)
chore(deps): update all dependencies
- [`277553c`](https://togithub.com/securego/gosec/commit/277553c)
chore(deps): update all dependencies
- [`57ec76b`](https://togithub.com/securego/gosec/commit/57ec76b)
chore(deps): update all dependencies
- [`8fa46c1`](https://togithub.com/securego/gosec/commit/8fa46c1)
chore(deps): update dependency babel-standalone to v7.23.7
- [`53aa3f7`](https://togithub.com/securego/gosec/commit/53aa3f7)
chore(deps): update module golang.org/x/crypto to v0.17.0 \[security]
- [`187adab`](https://togithub.com/securego/gosec/commit/187adab)
chore(deps): update all dependencies
- [`e1f27ba`](https://togithub.com/securego/gosec/commit/e1f27ba)
chore(deps): update actions/setup-go action to v5
- [`2aad3f0`](https://togithub.com/securego/gosec/commit/2aad3f0) Fix
lint warnings by properly formatting the files
- [`0e2a618`](https://togithub.com/securego/gosec/commit/0e2a618) chore:
Refactor Sample Code to Separate Files
- [`bc03d1c`](https://togithub.com/securego/gosec/commit/bc03d1c) Update
go version to 1.21.5 and 1.20.12
([#1084](https://togithub.com/securego/gosec/issues/1084))
- [`79a6b47`](https://togithub.com/securego/gosec/commit/79a6b47)
chore(deps): update all dependencies
([#1080](https://togithub.com/securego/gosec/issues/1080))
- [`eb256a7`](https://togithub.com/securego/gosec/commit/eb256a7) Ignore
the issues from generated files when using the analysis framework
([#1079](https://togithub.com/securego/gosec/issues/1079))
- [`43b7cbf`](https://togithub.com/securego/gosec/commit/43b7cbf) Update
README with upload-sarif v2
([#1078](https://togithub.com/securego/gosec/issues/1078))
- [`fece498`](https://togithub.com/securego/gosec/commit/fece498)
chore(deps): update dependency babel-standalone to v7.23.4
- [`24c614b`](https://togithub.com/securego/gosec/commit/24c614b) Added
ppc64le support
- [`c736581`](https://togithub.com/securego/gosec/commit/c736581)
chore(deps): update all dependencies
- [`3188e3f`](https://togithub.com/securego/gosec/commit/3188e3f) Ensure
ignores are handled properly for multi-line issues
- [`6d56592`](https://togithub.com/securego/gosec/commit/6d56592) Update
Go to version 1.21.4 and 1.20.11
- [`870103b`](https://togithub.com/securego/gosec/commit/870103b)
chore(deps): update module golang.org/x/text to v0.14.0
- [`b50e493`](https://togithub.com/securego/gosec/commit/b50e493)
chore(deps): update all dependencies
- [`2f9965b`](https://togithub.com/securego/gosec/commit/2f9965b) Remove
the hardcoded GOOS value when building the Linux binary to enable
support for container image for ARM
- [`fa1b74d`](https://togithub.com/securego/gosec/commit/fa1b74d) Avoid
allocations with `(*regexp.Regexp).MatchString`
- [`64bbe90`](https://togithub.com/securego/gosec/commit/64bbe90) Fix
some typos
- [`d9071e3`](https://togithub.com/securego/gosec/commit/d9071e3) Update
local installation instructions by removing the details for Go 1.16
- [`5d837bc`](https://togithub.com/securego/gosec/commit/5d837bc) Update
gosec version to 2.18.2 in the action
---
### Configuration
📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
every weekday,every weekend" (UTC), Automerge - At any time (no schedule
defined).
🚦 **Automerge**: Enabled.
â™» **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] If you want to rebase/retry this PR, check
this box
---
This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/nobl9/terraform-provider-nobl9).
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 37f4c811..717682a8 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ BUILD_FLAGS="-X github.com/nobl9/terraform-provider-nobl9/nobl9.Version=$(VERSIO
OS_ARCH?=linux_amd64
# renovate datasource=github-releases depName=securego/gosec
-GOSEC_VERSION := v2.18.2
+GOSEC_VERSION := v2.19.0
# renovate datasource=github-releases depName=golangci/golangci-lint
GOLANGCI_LINT_VERSION := v1.55.2
# renovate datasource=go depName=golang.org/x/vuln/cmd/govulncheck
From 8bdf82055d98a7da874dc63408b59d39c5a0f810 Mon Sep 17 00:00:00 2001
From: Nikodem Rafalski
Date: Thu, 15 Feb 2024 13:01:18 +0100
Subject: [PATCH 06/13] feat: Azure Monitor Logs SLOs support [PC-11534] (#143)
Co-authored-by: bsski
---
Makefile | 2 +-
README.md | 2 +-
cspell.yaml | 1 +
docs/index.md | 2 +-
docs/resources/slo.md | 88 ++++++++++++++++++------
examples/provider/provider.tf | 2 +-
nobl9/resource_slo.go | 125 +++++++++++++++++++++++-----------
nobl9/resource_slo_test.go | 72 +++++++++++++++++++-
8 files changed, 229 insertions(+), 65 deletions(-)
diff --git a/Makefile b/Makefile
index 717682a8..90bd722a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ NAMESPACE=nobl9
NAME=nobl9
BIN_DIR=./bin
BINARY=$(BIN_DIR)/terraform-provider-$(NAME)
-VERSION=0.23.0-beta
+VERSION=0.24.0
BUILD_FLAGS="-X github.com/nobl9/terraform-provider-nobl9/nobl9.Version=$(VERSION)"
OS_ARCH?=linux_amd64
diff --git a/README.md b/README.md
index 977fa496..994128a4 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
- version = "0.23.0-beta"
+ version = "0.24.0"
}
}
}
diff --git a/cspell.yaml b/cspell.yaml
index 30c911c9..3e22713d 100644
--- a/cspell.yaml
+++ b/cspell.yaml
@@ -36,6 +36,7 @@ words:
- gopath
- gosec
- govulncheck
+ - kusto
- ldflags
- logql
- msteams
diff --git a/docs/index.md b/docs/index.md
index 9e25428f..2c2a3115 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -37,7 +37,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
- version = "0.23.0-beta"
+ version = "0.24.0"
}
}
}
diff --git a/docs/resources/slo.md b/docs/resources/slo.md
index 8f86481d..20d05a6d 100644
--- a/docs/resources/slo.md
+++ b/docs/resources/slo.md
@@ -261,15 +261,17 @@ Required:
Required:
-- `aggregation` (String) Aggregation type
- `data_type` (String) Specifies source: 'metrics' or 'logs'
-- `metric_name` (String) Name of the metric
-- `resource_id` (String) Name of the added application
Optional:
-- `dimensions` (Block Set) Dimensions of the metric (see [below for nested schema](#nestedblock--objective--count_metrics--total--azure_monitor--dimensions))
-- `metric_namespace` (String) Namespace of the metric
+- `aggregation` (String) Aggregation type [Required for metrics]
+- `dimensions` (Block Set) Dimensions of the metric [Optional for metrics] (see [below for nested schema](#nestedblock--objective--count_metrics--total--azure_monitor--dimensions))
+- `kql_query` (String) Logs query in Kusto Query Language [Required for logs]
+- `metric_name` (String) Name of the metric [Required for metrics]
+- `metric_namespace` (String) Namespace of the metric [Optional for metrics]
+- `resource_id` (String) Identifier of the Azure Cloud resource [Required for metrics]
+- `workspace` (Block Set) Log analytics workspace [Required for logs] (see [below for nested schema](#nestedblock--objective--count_metrics--total--azure_monitor--workspace))
### Nested Schema for `objective.count_metrics.total.azure_monitor.dimensions`
@@ -280,6 +282,16 @@ Required:
- `value` (String) Value
+
+### Nested Schema for `objective.count_metrics.total.azure_monitor.workspace`
+
+Required:
+
+- `resource_group` (String) Resource group of the workspace
+- `subscription_id` (String) Subscription ID of the workspace
+- `workspace_id` (String) ID of the workspace
+
+
### Nested Schema for `objective.count_metrics.total.bigquery`
@@ -598,15 +610,17 @@ Required:
Required:
-- `aggregation` (String) Aggregation type
- `data_type` (String) Specifies source: 'metrics' or 'logs'
-- `metric_name` (String) Name of the metric
-- `resource_id` (String) Name of the added application
Optional:
-- `dimensions` (Block Set) Dimensions of the metric (see [below for nested schema](#nestedblock--objective--count_metrics--bad--azure_monitor--dimensions))
-- `metric_namespace` (String) Namespace of the metric
+- `aggregation` (String) Aggregation type [Required for metrics]
+- `dimensions` (Block Set) Dimensions of the metric [Optional for metrics] (see [below for nested schema](#nestedblock--objective--count_metrics--bad--azure_monitor--dimensions))
+- `kql_query` (String) Logs query in Kusto Query Language [Required for logs]
+- `metric_name` (String) Name of the metric [Required for metrics]
+- `metric_namespace` (String) Namespace of the metric [Optional for metrics]
+- `resource_id` (String) Identifier of the Azure Cloud resource [Required for metrics]
+- `workspace` (Block Set) Log analytics workspace [Required for logs] (see [below for nested schema](#nestedblock--objective--count_metrics--bad--azure_monitor--workspace))
### Nested Schema for `objective.count_metrics.bad.azure_monitor.dimensions`
@@ -617,6 +631,16 @@ Required:
- `value` (String) Value
+
+### Nested Schema for `objective.count_metrics.bad.azure_monitor.workspace`
+
+Required:
+
+- `resource_group` (String) Resource group of the workspace
+- `subscription_id` (String) Subscription ID of the workspace
+- `workspace_id` (String) ID of the workspace
+
+
### Nested Schema for `objective.count_metrics.bad.bigquery`
@@ -935,15 +959,17 @@ Required:
Required:
-- `aggregation` (String) Aggregation type
- `data_type` (String) Specifies source: 'metrics' or 'logs'
-- `metric_name` (String) Name of the metric
-- `resource_id` (String) Name of the added application
Optional:
-- `dimensions` (Block Set) Dimensions of the metric (see [below for nested schema](#nestedblock--objective--count_metrics--good--azure_monitor--dimensions))
-- `metric_namespace` (String) Namespace of the metric
+- `aggregation` (String) Aggregation type [Required for metrics]
+- `dimensions` (Block Set) Dimensions of the metric [Optional for metrics] (see [below for nested schema](#nestedblock--objective--count_metrics--good--azure_monitor--dimensions))
+- `kql_query` (String) Logs query in Kusto Query Language [Required for logs]
+- `metric_name` (String) Name of the metric [Required for metrics]
+- `metric_namespace` (String) Namespace of the metric [Optional for metrics]
+- `resource_id` (String) Identifier of the Azure Cloud resource [Required for metrics]
+- `workspace` (Block Set) Log analytics workspace [Required for logs] (see [below for nested schema](#nestedblock--objective--count_metrics--good--azure_monitor--workspace))
### Nested Schema for `objective.count_metrics.good.azure_monitor.dimensions`
@@ -954,6 +980,16 @@ Required:
- `value` (String) Value
+
+### Nested Schema for `objective.count_metrics.good.azure_monitor.workspace`
+
+Required:
+
+- `resource_group` (String) Resource group of the workspace
+- `subscription_id` (String) Subscription ID of the workspace
+- `workspace_id` (String) ID of the workspace
+
+
### Nested Schema for `objective.count_metrics.good.bigquery`
@@ -1280,15 +1316,17 @@ Required:
Required:
-- `aggregation` (String) Aggregation type
- `data_type` (String) Specifies source: 'metrics' or 'logs'
-- `metric_name` (String) Name of the metric
-- `resource_id` (String) Name of the added application
Optional:
-- `dimensions` (Block Set) Dimensions of the metric (see [below for nested schema](#nestedblock--objective--raw_metric--query--azure_monitor--dimensions))
-- `metric_namespace` (String) Namespace of the metric
+- `aggregation` (String) Aggregation type [Required for metrics]
+- `dimensions` (Block Set) Dimensions of the metric [Optional for metrics] (see [below for nested schema](#nestedblock--objective--raw_metric--query--azure_monitor--dimensions))
+- `kql_query` (String) Logs query in Kusto Query Language [Required for logs]
+- `metric_name` (String) Name of the metric [Required for metrics]
+- `metric_namespace` (String) Namespace of the metric [Optional for metrics]
+- `resource_id` (String) Identifier of the Azure Cloud resource [Required for metrics]
+- `workspace` (Block Set) Log analytics workspace [Required for logs] (see [below for nested schema](#nestedblock--objective--raw_metric--query--azure_monitor--workspace))
### Nested Schema for `objective.raw_metric.query.azure_monitor.dimensions`
@@ -1299,6 +1337,16 @@ Required:
- `value` (String) Value
+
+### Nested Schema for `objective.raw_metric.query.azure_monitor.workspace`
+
+Required:
+
+- `resource_group` (String) Resource group of the workspace
+- `subscription_id` (String) Subscription ID of the workspace
+- `workspace_id` (String) ID of the workspace
+
+
### Nested Schema for `objective.raw_metric.query.bigquery`
diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf
index 13d14e40..13d692d2 100644
--- a/examples/provider/provider.tf
+++ b/examples/provider/provider.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
- version = "0.23.0-beta"
+ version = "0.24.0"
}
}
}
diff --git a/nobl9/resource_slo.go b/nobl9/resource_slo.go
index 6a891b60..f588c7b3 100644
--- a/nobl9/resource_slo.go
+++ b/nobl9/resource_slo.go
@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
v1alphaSLO "github.com/nobl9/nobl9-go/manifest/v1alpha/slo"
v1Objects "github.com/nobl9/nobl9-go/sdk/endpoints/objects/v1"
@@ -1078,34 +1079,40 @@ func schemaMetricAzureMonitor() map[string]*schema.Schema {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"data_type": {
- Type: schema.TypeString,
- Required: true,
+ Type: schema.TypeString,
+ Required: true,
+ ValidateDiagFunc: validation.ToDiagFunc(
+ validation.StringInSlice([]string{
+ v1alphaSLO.AzureMonitorDataTypeMetrics,
+ v1alphaSLO.AzureMonitorDataTypeLogs,
+ }, false),
+ ),
Description: "Specifies source: 'metrics' or 'logs'",
},
"resource_id": {
Type: schema.TypeString,
- Required: true,
- Description: "Name of the added application",
+ Optional: true,
+ Description: "Identifier of the Azure Cloud resource [Required for metrics]",
},
"metric_namespace": {
Type: schema.TypeString,
Optional: true,
- Description: "Namespace of the metric",
+ Description: "Namespace of the metric [Optional for metrics]",
},
"metric_name": {
Type: schema.TypeString,
- Required: true,
- Description: "Name of the metric",
+ Optional: true,
+ Description: "Name of the metric [Required for metrics]",
},
"aggregation": {
Type: schema.TypeString,
- Required: true,
- Description: "Aggregation type",
+ Optional: true,
+ Description: "Aggregation type [Required for metrics]",
},
"dimensions": {
Type: schema.TypeSet,
Optional: true,
- Description: "Dimensions of the metric",
+ Description: "Dimensions of the metric [Optional for metrics]",
MinItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
@@ -1122,6 +1129,35 @@ func schemaMetricAzureMonitor() map[string]*schema.Schema {
},
},
},
+ "workspace": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Log analytics workspace [Required for logs]",
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "subscription_id": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: "Subscription ID of the workspace",
+ },
+ "resource_group": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: "Resource group of the workspace",
+ },
+ "workspace_id": {
+ Type: schema.TypeString,
+ Required: true,
+ Description: "ID of the workspace",
+ },
+ },
+ },
+ },
+ "kql_query": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: "Logs query in Kusto Query Language [Required for logs]",
+ },
},
},
},
@@ -1134,38 +1170,41 @@ func marshalAzureMonitorMetric(s *schema.Set) *v1alphaSLO.AzureMonitorMetric {
}
metric := s.List()[0].(map[string]interface{})
-
dataType := metric["data_type"].(string)
- resourceID := metric["resource_id"].(string)
- metricNamespace := metric["metric_namespace"].(string)
- metricName := metric["metric_name"].(string)
- aggregation := metric["aggregation"].(string)
-
- dimensions := metric["dimensions"].(*schema.Set)
- var metricDimensions []v1alphaSLO.AzureMonitorMetricDimension
-
- if dimensions.Len() > 0 {
- metricDimensions = make([]v1alphaSLO.AzureMonitorMetricDimension, dimensions.Len())
- }
-
- for idx, dimension := range dimensions.List() {
- n9Dimension := dimension.(map[string]interface{})
- name := n9Dimension["name"].(string)
- value := n9Dimension["value"].(string)
- metricDimensions[idx] = v1alphaSLO.AzureMonitorMetricDimension{
- Name: &name,
- Value: &value,
+ result := v1alphaSLO.AzureMonitorMetric{DataType: dataType}
+ if dataType == v1alphaSLO.AzureMonitorDataTypeMetrics {
+ result.ResourceID = metric["resource_id"].(string)
+ result.MetricNamespace = metric["metric_namespace"].(string)
+ result.MetricName = metric["metric_name"].(string)
+ result.Aggregation = metric["aggregation"].(string)
+ dimensions := metric["dimensions"].(*schema.Set)
+ var metricDimensions []v1alphaSLO.AzureMonitorMetricDimension
+ if dimensions.Len() > 0 {
+ metricDimensions = make([]v1alphaSLO.AzureMonitorMetricDimension, dimensions.Len())
+ }
+ for idx, dimension := range dimensions.List() {
+ n9Dimension := dimension.(map[string]interface{})
+ name := n9Dimension["name"].(string)
+ value := n9Dimension["value"].(string)
+ metricDimensions[idx] = v1alphaSLO.AzureMonitorMetricDimension{
+ Name: &name,
+ Value: &value,
+ }
+ }
+ result.Dimensions = metricDimensions
+ } else if dataType == v1alphaSLO.AzureMonitorDataTypeLogs {
+ result.KQLQuery = metric["kql_query"].(string)
+ wsList := metric["workspace"].(*schema.Set).List()
+ if len(wsList) > 0 {
+ workspace := wsList[0].(map[string]interface{})
+ result.Workspace = &v1alphaSLO.AzureMonitorMetricLogAnalyticsWorkspace{
+ SubscriptionID: workspace["subscription_id"].(string),
+ ResourceGroup: workspace["resource_group"].(string),
+ WorkspaceID: workspace["workspace_id"].(string),
+ }
}
}
-
- return &v1alphaSLO.AzureMonitorMetric{
- DataType: dataType,
- ResourceID: resourceID,
- MetricNamespace: metricNamespace,
- MetricName: metricName,
- Aggregation: aggregation,
- Dimensions: metricDimensions,
- }
+ return &result
}
func unmarshalAzureMonitorMetric(metric interface{}) map[string]interface{} {
@@ -1183,6 +1222,14 @@ func unmarshalAzureMonitorMetric(metric interface{}) map[string]interface{} {
var dimensions any
_ = json.Unmarshal(dim, &dimensions)
res["dimensions"] = dimensions
+ res["kql_query"] = amMetric.KQLQuery
+ if amMetric.Workspace != nil {
+ res["workspace"] = schema.NewSet(oneElementSet, []interface{}{map[string]interface{}{
+ "subscription_id": amMetric.Workspace.SubscriptionID,
+ "resource_group": amMetric.Workspace.ResourceGroup,
+ "workspace_id": amMetric.Workspace.WorkspaceID,
+ }})
+ }
return res
}
diff --git a/nobl9/resource_slo_test.go b/nobl9/resource_slo_test.go
index 03420662..4bcabd43 100644
--- a/nobl9/resource_slo_test.go
+++ b/nobl9/resource_slo_test.go
@@ -19,7 +19,8 @@ func TestAcc_Nobl9SLO(t *testing.T) {
}{
{"test-amazonprometheus", testAmazonPrometheusSLO},
{"test-appdynamics", testAppdynamicsSLO},
- {"test-azure-monitor", testAzureMonitorSLO},
+ {"test-azure-monitor-metrics", testAzureMonitorMetricsSLO},
+ {"test-azure-monitor-logs", testAzureMonitorLogsSLO},
{"test-bigquery", testBigQuerySLO},
{"test-cloudwatch-with-json", testCloudWatchWithJSON},
{"test-cloudwatch-with-sql", testCloudWatchWithSQL},
@@ -233,7 +234,7 @@ resource "nobl9_slo" ":name" {
}
// nolint: lll
-func testAzureMonitorSLO(name string) string {
+func testAzureMonitorMetricsSLO(name string) string {
var serviceName = name + "-tf-service"
var agentName = name + "-tf-agent"
config :=
@@ -301,6 +302,73 @@ resource "nobl9_slo" ":name" {
return config
}
+// nolint: lll
+func testAzureMonitorLogsSLO(name string) string {
+ var serviceName = name + "-tf-service"
+ var agentName = name + "-tf-agent"
+ config :=
+ testService(serviceName) +
+ testAzureMonitorAgent(agentName) + `
+resource "nobl9_slo" ":name" {
+ name = ":name"
+ display_name = ":name"
+ project = ":project"
+ service = nobl9_service.:serviceName.name
+
+ label {
+ key = "team"
+ values = ["green","sapphire"]
+ }
+
+ label {
+ key = "env"
+ values = ["dev", "staging", "prod"]
+ }
+
+ budgeting_method = "Occurrences"
+
+ objective {
+ display_name = "obj1"
+ name = "tf-objective-1"
+ target = 0.7
+ value = 1
+ op = "lt"
+ raw_metric {
+ query {
+ azure_monitor {
+ data_type = "logs"
+ workspace {
+ subscription_id = "9c26f90e-24bb-4d20-a648-c6e3e1cde26a"
+ resource_group = "azure-monitor-test-sources"
+ workspace_id = "e5da9ba8-cb8f-437e-aec0-61d21aab2bcd"
+ }
+ kql_query = "AppRequests | where AppRoleName == \"n9-web-app\" | summarize n9_value = avg(DurationMs) by bin(TimeGenerated, 15s) | project n9_time = TimeGenerated, n9_value"
+ }
+ }
+ }
+ }
+
+ time_window {
+ count = 10
+ is_rolling = true
+ unit = "Minute"
+ }
+
+ indicator {
+ name = nobl9_agent.:agentName.name
+ project = ":project"
+ kind = "Agent"
+ }
+}
+`
+ config = strings.ReplaceAll(config, ":name", name)
+ config = strings.ReplaceAll(config, ":serviceName", serviceName)
+ config = strings.ReplaceAll(config, ":agentName", agentName)
+ config = strings.ReplaceAll(config, ":project", testProject)
+
+ return config
+}
+
func testBigQuerySLO(name string) string {
var serviceName = name + "-tf-service"
var agentName = name + "-tf-agent"
From 194820bd94c08c32ff00c5fc3063aef28883c671 Mon Sep 17 00:00:00 2001
From: Nikodem Rafalski
Date: Thu, 15 Feb 2024 13:32:16 +0100
Subject: [PATCH 07/13] chore: adjust version to 0.23.0 (#165)
Co-authored-by: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
---
.github/scripts/release-notes.sh | 2 +-
Makefile | 2 +-
README.md | 2 +-
docs/index.md | 2 +-
examples/provider/provider.tf | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/.github/scripts/release-notes.sh b/.github/scripts/release-notes.sh
index 88915977..3c9e4886 100755
--- a/.github/scripts/release-notes.sh
+++ b/.github/scripts/release-notes.sh
@@ -55,7 +55,7 @@ while IFS= read -r line; do
continue
fi
commit_msg="${BASH_REMATCH[1]}"
- commit_body=$(git log --grep "$commit_msg" -n1 --pretty="%b")
+ commit_body=$(git log -F --grep "$commit_msg" -n1 --pretty="%b")
add_notes() {
local notes="$1"
diff --git a/Makefile b/Makefile
index 90bd722a..12cb9c04 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ NAMESPACE=nobl9
NAME=nobl9
BIN_DIR=./bin
BINARY=$(BIN_DIR)/terraform-provider-$(NAME)
-VERSION=0.24.0
+VERSION=0.23.0
BUILD_FLAGS="-X github.com/nobl9/terraform-provider-nobl9/nobl9.Version=$(VERSION)"
OS_ARCH?=linux_amd64
diff --git a/README.md b/README.md
index 994128a4..367f82d9 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
- version = "0.24.0"
+ version = "0.23.0"
}
}
}
diff --git a/docs/index.md b/docs/index.md
index 2c2a3115..1a6a8a06 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -37,7 +37,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
- version = "0.24.0"
+ version = "0.23.0"
}
}
}
diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf
index 13d692d2..7d308732 100644
--- a/examples/provider/provider.tf
+++ b/examples/provider/provider.tf
@@ -2,7 +2,7 @@ terraform {
required_providers {
nobl9 = {
source = "nobl9/nobl9"
- version = "0.24.0"
+ version = "0.23.0"
}
}
}
From 1b63496e9863867f95d9b4d265f6b56a42c895f8 Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Thu, 15 Feb 2024 15:49:16 +0100
Subject: [PATCH 08/13] chore: Rewrite Codefresh pipeline to GH workflow for
acceptance tests (#166)
## Motivation
Rewrite Codefresh pipeline in GitHub workflow for acceptance tests.
The tests are now a reusable workflow and we can call them against main
environment from n9 repository.
---
.github/workflows/acc-tests.yml | 43 +++++++++++++++++++
.github/workflows/release.yml | 6 +++
.../workflows/{tests.yml => unit-tests.yml} | 4 +-
Makefile | 14 +++---
codefresh.yml | 41 ------------------
nobl9/data_source_test.go | 1 -
nobl9/provider.go | 8 ++--
nobl9/provider_test.go | 27 ++----------
nobl9/resource_agent_test.go | 1 -
nobl9/resource_alert_policy_test.go | 1 -
nobl9/resource_alertmethod_test.go | 1 -
nobl9/resource_direct_test.go | 1 -
nobl9/resource_project_test.go | 2 -
nobl9/resource_role_binding_test.go | 1 -
nobl9/resource_service_test.go | 1 -
nobl9/resource_slo_test.go | 2 -
16 files changed, 66 insertions(+), 88 deletions(-)
create mode 100644 .github/workflows/acc-tests.yml
rename .github/workflows/{tests.yml => unit-tests.yml} (88%)
delete mode 100644 codefresh.yml
diff --git a/.github/workflows/acc-tests.yml b/.github/workflows/acc-tests.yml
new file mode 100644
index 00000000..b9de93b2
--- /dev/null
+++ b/.github/workflows/acc-tests.yml
@@ -0,0 +1,43 @@
+name: Acceptance tests
+on:
+ workflow_call:
+ inputs:
+ clientId:
+ description: Client ID to use for authentication
+ required: true
+ type: string
+ oktaOrgUrl:
+ description: Okta organization URL
+ required: false
+ type: string
+ oktaAuthServer:
+ description: Okta authentication server identifier
+ required: false
+ type: string
+ project:
+ description: Project name to create the tested objects in
+ required: false
+ type: string
+ secrets:
+ clientSecret:
+ description: Client secret to use for authentication
+ required: true
+jobs:
+ test:
+ name: Run acceptance tests
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+ cache: false
+ - name: Run acceptance tests
+ env:
+ TERRAFORM_NOBL9_CLIENT_ID: "${{ secrets.clientId }}"
+ TERRAFORM_NOBL9_CLIENT_SECRET: "${{ secrets.clientSecret }}"
+ TERRAFORM_NOBL9_OKTA_ORG_URL: "${{ inputs.oktaOrgUrl }}"
+ TERRAFORM_NOBL9_OKTA_AUTH_SERVER: "${{ inputs.oktaAuthServer }}"
+ TERRAFORM_NOBL9_PROJECT: "${{ inputs.project }}"
+ run: make test/acc
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 48a9aaad..f281bce1 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -35,6 +35,12 @@ jobs:
passphrase: ${{ secrets.PASSPHRASE }}
- name: setup github
run: git config --global url."https://n9-machine-user:${{ secrets.GH_TOKEN }}@github.com".insteadOf "https://github.com"
+ - name: Run acceptance tests
+ uses: ./.github/workflows/acc-tests.yml
+ with:
+ clientId: ${{ vars.TERRAFORM_NOBL9_CLIENT_ID }}
+ clientSecret: ${{ secrets.TERRAFORM_NOBL9_CLIENT_SECRET }}
+ project: ${{ vars.TERRAFORM_NOBL9_PROJECT }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5.0.0
with:
diff --git a/.github/workflows/tests.yml b/.github/workflows/unit-tests.yml
similarity index 88%
rename from .github/workflows/tests.yml
rename to .github/workflows/unit-tests.yml
index 15acc2d8..578150fc 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/unit-tests.yml
@@ -1,4 +1,4 @@
-name: Tests
+name: Unit tests
on:
push:
branches:
@@ -18,4 +18,4 @@ jobs:
go-version-file: go.mod
cache: false
- name: Run unit tests
- run: make test
+ run: make test/unit
diff --git a/Makefile b/Makefile
index 12cb9c04..72e4f335 100644
--- a/Makefile
+++ b/Makefile
@@ -53,16 +53,18 @@ install: build
build:
go build -ldflags $(BUILD_FLAGS) -o $(BINARY)
-.PHONY: test
+.PHONY: test test/unit test/acc
+## Run all tests.
+test: test/unit test/acc
+
## Run Go unit tests.
-test:
+test/unit:
go test -i $(TEST) || exit 1
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
-.PHONY: testacc
-## Run acceptance tests.
-testacc:
- cd nobl9 && TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
+## Run Terraform acceptance tests.
+test/acc:
+ TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m nobl9/
.PHONY: release-dry-run
## Run Goreleaser in dry-run mode.
diff --git a/codefresh.yml b/codefresh.yml
deleted file mode 100644
index 26f5f499..00000000
--- a/codefresh.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-version: "1.0"
-
-hooks:
- on_fail:
- steps:
- # Notify about pipeline failure only for main
- notify:
- when:
- branch:
- only:
- - main
- image: codefresh/slacknotifier
- environment:
- - 'SLACK_HOOK_URL=${{SLACK_WEBHOOK}}'
- - 'SLACK_TEXT=Pipeline failed for Nobl9 Terraform Provider repository'
- - 'SLACK_ATTACHMENTS=[{ "color":"#d00000", "blocks":[{"type":"context", "elements":[ { "type":"plain_text","text":"Pipeline failed for Nobl9 Terraform Provider repository", "emoji":true }]}]}]'
- - 'SLACK_USER_NAME=Nobl9 Terraform Provider'
- - 'SLACK_ICON_EMOJI=:terraform:'
-
-stages:
- - "clone"
- - "test"
-
-steps:
- clone:
- title: "Cloning repository"
- type: "git-clone"
- repo: "nobl9/terraform-provider-nobl9"
- revision: "${{CF_REVISION}}"
- git: "github"
- stage: "clone"
-
- test:
- title: "Running test"
- type: "freestyle"
- image: "hashicorp/terraform:1.2.5"
- working_directory: "${{clone}}"
- commands:
- - "apk add go make"
- - "make testacc"
- stage: "test"
diff --git a/nobl9/data_source_test.go b/nobl9/data_source_test.go
index dbb995d8..3e73e2ab 100644
--- a/nobl9/data_source_test.go
+++ b/nobl9/data_source_test.go
@@ -18,7 +18,6 @@ func TestAcc_Nobl9DataSource(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
Steps: []resource.TestStep{
{
diff --git a/nobl9/provider.go b/nobl9/provider.go
index 1cb1ce77..260c7ac0 100644
--- a/nobl9/provider.go
+++ b/nobl9/provider.go
@@ -22,7 +22,7 @@ func Provider() *schema.Provider {
"ingest_url": {
Type: schema.TypeString,
Optional: true,
- DefaultFunc: schema.EnvDefaultFunc("NOBL9_URL", "https://app.nobl9.com/api"),
+ DefaultFunc: schema.EnvDefaultFunc("NOBL9_URL", nil),
Description: "Nobl9 API URL.",
},
@@ -36,7 +36,7 @@ func Provider() *schema.Provider {
"project": {
Type: schema.TypeString,
Optional: true,
- DefaultFunc: schema.EnvDefaultFunc("NOBL9_PROJECT", sdk.DefaultProject),
+ DefaultFunc: schema.EnvDefaultFunc("NOBL9_PROJECT", nil),
Description: "Nobl9 project used when importing resources.",
},
@@ -58,7 +58,7 @@ func Provider() *schema.Provider {
"okta_org_url": {
Type: schema.TypeString,
Optional: true,
- DefaultFunc: schema.EnvDefaultFunc("NOBL9_OKTA_URL", "https://accounts.nobl9.com"),
+ DefaultFunc: schema.EnvDefaultFunc("NOBL9_OKTA_URL", nil),
Description: "Authorization service URL.",
},
@@ -66,7 +66,7 @@ func Provider() *schema.Provider {
Type: schema.TypeString,
Optional: true,
//cspell:ignore auseg9kiegWKEtJZC416
- DefaultFunc: schema.EnvDefaultFunc("NOBL9_OKTA_AUTH", "auseg9kiegWKEtJZC416"),
+ DefaultFunc: schema.EnvDefaultFunc("NOBL9_OKTA_AUTH", nil),
Description: "Authorization service configuration.",
},
},
diff --git a/nobl9/provider_test.go b/nobl9/provider_test.go
index 8e2cb371..921bc0d2 100644
--- a/nobl9/provider_test.go
+++ b/nobl9/provider_test.go
@@ -26,6 +26,9 @@ var (
//nolint:gochecknoinits
func init() {
testProject = os.Getenv("NOBL9_PROJECT")
+ if testProject == "" {
+ testProject = "default"
+ }
}
func ProviderFactory() map[string]func() (*schema.Provider, error) {
@@ -43,30 +46,6 @@ func TestProvider(t *testing.T) {
}
}
-func testAccPreCheck(t *testing.T) {
- if err := os.Getenv("NOBL9_URL"); err == "" {
- t.Fatal("NOBL9_URL must be set for acceptance tests")
- }
- if err := os.Getenv("NOBL9_ORG"); err == "" {
- t.Fatal("NOBL9_ORG must be set for acceptance tests")
- }
- if err := os.Getenv("NOBL9_PROJECT"); err == "" {
- t.Fatal("NOBL9_PROJECT must be set for acceptance tests")
- }
- if err := os.Getenv("NOBL9_CLIENT_ID"); err == "" {
- t.Fatal("NOBL9_CLIENT_ID must be set for acceptance tests")
- }
- if err := os.Getenv("NOBL9_CLIENT_SECRET"); err == "" {
- t.Fatal("NOBL9_CLIENT_SECRET must be set for acceptance tests")
- }
- if err := os.Getenv("NOBL9_OKTA_URL"); err == "" {
- t.Fatal("NOBL9_OKTA_URL must be set for acceptance tests")
- }
- if err := os.Getenv("NOBL9_OKTA_AUTH"); err == "" {
- t.Fatal("NOBL9_OKTA_AUTH must be set for acceptance tests")
- }
-}
-
func CheckObjectCreated(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[name]
diff --git a/nobl9/resource_agent_test.go b/nobl9/resource_agent_test.go
index 495fe859..b0809f68 100644
--- a/nobl9/resource_agent_test.go
+++ b/nobl9/resource_agent_test.go
@@ -45,7 +45,6 @@ func TestAcc_Nobl9Agent(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_agent", manifest.KindAgent),
Steps: []resource.TestStep{
diff --git a/nobl9/resource_alert_policy_test.go b/nobl9/resource_alert_policy_test.go
index 5e7c60ed..ca1e574a 100644
--- a/nobl9/resource_alert_policy_test.go
+++ b/nobl9/resource_alert_policy_test.go
@@ -26,7 +26,6 @@ func TestAcc_Nobl9AlertPolicy(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: destroyMultiple(
[]string{"nobl9_alert_policy", "nobl9_alert_method_webhook"},
diff --git a/nobl9/resource_alertmethod_test.go b/nobl9/resource_alertmethod_test.go
index 2d066be1..7d143d98 100644
--- a/nobl9/resource_alertmethod_test.go
+++ b/nobl9/resource_alertmethod_test.go
@@ -33,7 +33,6 @@ func TestAcc_Nobl9AlertMethod(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_alert_method_"+tc.resourceSuffix, manifest.KindAlertMethod),
Steps: []resource.TestStep{
diff --git a/nobl9/resource_direct_test.go b/nobl9/resource_direct_test.go
index d7c93c90..3d46e7bc 100644
--- a/nobl9/resource_direct_test.go
+++ b/nobl9/resource_direct_test.go
@@ -39,7 +39,6 @@ func TestAcc_Nobl9Direct(t *testing.T) {
t.Run(tc.directType, func(t *testing.T) {
testName := strings.ReplaceAll("test-"+tc.directType, "_", "")
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_direct_%s", manifest.KindDirect),
Steps: []resource.TestStep{
diff --git a/nobl9/resource_project_test.go b/nobl9/resource_project_test.go
index 5183cb51..22283b8c 100644
--- a/nobl9/resource_project_test.go
+++ b/nobl9/resource_project_test.go
@@ -13,7 +13,6 @@ func TestAcc_Nobl9Project(t *testing.T) {
name := "test-project"
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_project", manifest.KindProject),
Steps: []resource.TestStep{
@@ -33,7 +32,6 @@ func TestAcc_NewNobl9ProjectReference(t *testing.T) {
name := "test-project"
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: resource.ComposeTestCheckFunc(
CheckDestroy("nobl9_agent", manifest.KindAgent),
diff --git a/nobl9/resource_role_binding_test.go b/nobl9/resource_role_binding_test.go
index d1e8e044..c91fecf7 100644
--- a/nobl9/resource_role_binding_test.go
+++ b/nobl9/resource_role_binding_test.go
@@ -26,7 +26,6 @@ func TestAcc_Nobl9RoleBinding(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.ParallelTest(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_role_binding", manifest.KindRoleBinding),
Steps: []resource.TestStep{
diff --git a/nobl9/resource_service_test.go b/nobl9/resource_service_test.go
index 129a716d..0db64b2f 100644
--- a/nobl9/resource_service_test.go
+++ b/nobl9/resource_service_test.go
@@ -12,7 +12,6 @@ import (
func TestAcc_Nobl9Service(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_service", manifest.KindService),
Steps: []resource.TestStep{
diff --git a/nobl9/resource_slo_test.go b/nobl9/resource_slo_test.go
index 4bcabd43..ff8793d3 100644
--- a/nobl9/resource_slo_test.go
+++ b/nobl9/resource_slo_test.go
@@ -63,7 +63,6 @@ func TestAcc_Nobl9SLO(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_slo", manifest.KindSLO),
Steps: []resource.TestStep{
@@ -98,7 +97,6 @@ func TestAcc_Nobl9SLOErrors(t *testing.T) {
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
resource.Test(t, resource.TestCase{
- PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: ProviderFactory(),
CheckDestroy: CheckDestroy("nobl9_slo.", manifest.KindSLO),
Steps: []resource.TestStep{
From 0d02d75be414335bf276e28eaf2420b794dc32fd Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Thu, 15 Feb 2024 16:36:10 +0100
Subject: [PATCH 09/13] chore: Add release candidate workflow (#167)
## Motivation
In order to mimic the release flow of sloctl we should be able to create
release candidate which would not be pushed to Terraform registry but
would still trigger acceptance tests.
---
.github/workflows/release-candidate.yml | 11 +++++++++++
.github/workflows/release.yml | 6 ++++--
2 files changed, 15 insertions(+), 2 deletions(-)
create mode 100644 .github/workflows/release-candidate.yml
diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml
new file mode 100644
index 00000000..6e0986e4
--- /dev/null
+++ b/.github/workflows/release-candidate.yml
@@ -0,0 +1,11 @@
+name: Release candidate
+on:
+ push:
+ tags:
+ - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
+jobs:
+ test:
+ uses: ./.github/workflows/acc-tests.yml
+ with:
+ clientId: "${{ vars.TERRAFORM_NOBL9_CLIENT_ID }}"
+ clientSecret: "${{ secrets.TERRAFORM_NOBL9_CLIENT_SECRET }}"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index f281bce1..60638897 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,11 +9,13 @@
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
-name: release
+name: Release
on:
push:
tags:
- - "v*"
+ - "v[0-9]+.[0-9]+.[0-9]+"
+ - "v[0-9]+.[0-9]+.[0-9]+-beta"
+ - "v[0-9]+.[0-9]+.[0-9]+-alpha"
jobs:
goreleaser:
runs-on: ubuntu-latest
From bee64e6bf65d7bbe1b1c6635461de4757670e166 Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Thu, 15 Feb 2024 17:06:48 +0100
Subject: [PATCH 10/13] chore: Fix release workflow (#168)
## Motivation
Turns out reusable workflow cannot be called from the step level but
instead must be be called from job level.
---
.github/workflows/release-candidate.yml | 2 ++
.github/workflows/release.yml | 14 ++++++++------
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml
index 6e0986e4..08b11295 100644
--- a/.github/workflows/release-candidate.yml
+++ b/.github/workflows/release-candidate.yml
@@ -8,4 +8,6 @@ jobs:
uses: ./.github/workflows/acc-tests.yml
with:
clientId: "${{ vars.TERRAFORM_NOBL9_CLIENT_ID }}"
+ project: "${{ vars.TERRAFORM_NOBL9_PROJECT }}"
+ secrets:
clientSecret: "${{ secrets.TERRAFORM_NOBL9_CLIENT_SECRET }}"
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 60638897..3dc04688 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -17,8 +17,16 @@ on:
- "v[0-9]+.[0-9]+.[0-9]+-beta"
- "v[0-9]+.[0-9]+.[0-9]+-alpha"
jobs:
+ test:
+ uses: ./.github/workflows/acc-tests.yml
+ with:
+ clientId: "${{ vars.TERRAFORM_NOBL9_CLIENT_ID }}"
+ project: "${{ vars.TERRAFORM_NOBL9_PROJECT }}"
+ secrets:
+ clientSecret: "${{ secrets.TERRAFORM_NOBL9_CLIENT_SECRET }}"
goreleaser:
runs-on: ubuntu-latest
+ needs: test
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
@@ -37,12 +45,6 @@ jobs:
passphrase: ${{ secrets.PASSPHRASE }}
- name: setup github
run: git config --global url."https://n9-machine-user:${{ secrets.GH_TOKEN }}@github.com".insteadOf "https://github.com"
- - name: Run acceptance tests
- uses: ./.github/workflows/acc-tests.yml
- with:
- clientId: ${{ vars.TERRAFORM_NOBL9_CLIENT_ID }}
- clientSecret: ${{ secrets.TERRAFORM_NOBL9_CLIENT_SECRET }}
- project: ${{ vars.TERRAFORM_NOBL9_PROJECT }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5.0.0
with:
From 6964452f6811643741d18622165db16ef71a06ec Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Thu, 15 Feb 2024 17:19:05 +0100
Subject: [PATCH 11/13] chore: Fix acceptance tests (#169)
## Motivation
Correct wrong context name.
---
.github/workflows/acc-tests.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/acc-tests.yml b/.github/workflows/acc-tests.yml
index b9de93b2..0522f1f3 100644
--- a/.github/workflows/acc-tests.yml
+++ b/.github/workflows/acc-tests.yml
@@ -35,7 +35,7 @@ jobs:
cache: false
- name: Run acceptance tests
env:
- TERRAFORM_NOBL9_CLIENT_ID: "${{ secrets.clientId }}"
+ TERRAFORM_NOBL9_CLIENT_ID: "${{ inputs.clientId }}"
TERRAFORM_NOBL9_CLIENT_SECRET: "${{ secrets.clientSecret }}"
TERRAFORM_NOBL9_OKTA_ORG_URL: "${{ inputs.oktaOrgUrl }}"
TERRAFORM_NOBL9_OKTA_AUTH_SERVER: "${{ inputs.oktaAuthServer }}"
From 07a2c7e937cb26ade94347ebaeb9cd72469c5648 Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Thu, 15 Feb 2024 17:38:58 +0100
Subject: [PATCH 12/13] chore: Fix acceptance tests env variable names (#170)
## Motivation
Set empty string instead of nil to "cheat" Terraform into thinking we
did provide required variable (even though we didn't).
---
.github/workflows/acc-tests.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/acc-tests.yml b/.github/workflows/acc-tests.yml
index 0522f1f3..9953c5f7 100644
--- a/.github/workflows/acc-tests.yml
+++ b/.github/workflows/acc-tests.yml
@@ -35,8 +35,8 @@ jobs:
cache: false
- name: Run acceptance tests
env:
- TERRAFORM_NOBL9_CLIENT_ID: "${{ inputs.clientId }}"
- TERRAFORM_NOBL9_CLIENT_SECRET: "${{ secrets.clientSecret }}"
+ NOBL9_CLIENT_ID: "${{ inputs.clientId }}"
+ NOBL9_CLIENT_SECRET: "${{ secrets.clientSecret }}"
TERRAFORM_NOBL9_OKTA_ORG_URL: "${{ inputs.oktaOrgUrl }}"
TERRAFORM_NOBL9_OKTA_AUTH_SERVER: "${{ inputs.oktaAuthServer }}"
TERRAFORM_NOBL9_PROJECT: "${{ inputs.project }}"
From 975ba7f9fca560ac9bf1b509d01ff27d1bb1f22d Mon Sep 17 00:00:00 2001
From: Mateusz Hawrus <48822818+nieomylnieja@users.noreply.github.com>
Date: Fri, 16 Feb 2024 10:20:22 +0100
Subject: [PATCH 13/13] chore: Adjust acceptance tests workflow (#172)
## Motivation
When calling this reusable workflow from an external repository it is
required to explicitly set the right repository and reference name in
order to make sure the terraform-provider-nobl9 is checked out, instead
of the calling repository.
Ref: https://github.com/actions/checkout.
---
.github/workflows/acc-tests.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.github/workflows/acc-tests.yml b/.github/workflows/acc-tests.yml
index 9953c5f7..665fee22 100644
--- a/.github/workflows/acc-tests.yml
+++ b/.github/workflows/acc-tests.yml
@@ -29,6 +29,9 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v4
+ with:
+ repository: nobl9/terraform-provider-nobl9
+ ref: main
- uses: actions/setup-go@v5
with:
go-version-file: go.mod