Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a0d8723
Kibana action connectors
dimuon Apr 12, 2023
e6a8853
Acc test for Kibana action connector
dimuon Apr 12, 2023
dc54742
make secrets optional
dimuon Apr 12, 2023
926cb61
Fixes and improvements
dimuon Apr 13, 2023
999c7fc
Improve code generation for kibana action connectors
dimuon Apr 14, 2023
f948faa
Using swagger-codegen for kibana actions connectors
dimuon Apr 19, 2023
6b6c9d0
Switch to ogen for kibana connectors generation
dimuon Apr 20, 2023
5a55d4e
add 400 http error to specs
dimuon Apr 20, 2023
5a74dfb
Fixes for connectors specs
dimuon Apr 20, 2023
59fbfa1
fixes
dimuon May 1, 2023
8202acd
Code generation based on ogen and modified bundled.yaml
dimuon May 1, 2023
e3d7055
Switch code generation for Kibana connectors to oapi-codegen.
dimuon May 4, 2023
5b947df
fix lint errors
dimuon May 4, 2023
8ee5134
suppress diff for configs when the only diff is default values
dimuon May 5, 2023
c05c7af
fix acc test
dimuon May 5, 2023
4e011c1
fix test
dimuon May 5, 2023
880c57f
support all types of connectors in create
dimuon May 5, 2023
b793928
customizeDiff for connector config
dimuon May 5, 2023
886efe6
WIP: email connector
dimuon May 5, 2023
5c80f4c
remove commented out code from bundled.yaml
dimuon May 8, 2023
24b1690
email connector
dimuon May 8, 2023
a58626f
remove obsolete comment
dimuon May 8, 2023
1437742
update for the remaining connector types
dimuon May 8, 2023
dae146e
response => model and config defaults (WIP)
dimuon May 9, 2023
29039ac
default configs
dimuon May 10, 2023
e8389ae
Merge remote-tracking branch 'upstream/main' into kibana-action-conne…
dimuon May 10, 2023
90f923d
update test
dimuon May 10, 2023
f4f3985
renaming
dimuon May 10, 2023
d90f5fe
refactoring
dimuon May 10, 2023
c21091b
acc test for cases-webhook
dimuon May 11, 2023
858af1e
acc test for email
dimuon May 11, 2023
5d5ec6d
improve acc test for cases-webhook
dimuon May 11, 2023
0bbbe6d
improve acc tests
dimuon May 11, 2023
9a44455
acc test for jira
dimuon May 11, 2023
bbbe713
acc tests for opsgenie and pagerduty
dimuon May 11, 2023
4940790
acc test for resilient
dimuon May 11, 2023
db32a5d
increase minimum supported version for opsgenie
dimuon May 11, 2023
41415e7
acc tests refactoring
dimuon May 11, 2023
0b4127f
acc test for server-log
dimuon May 11, 2023
3acaa4a
acc test for servicenow
dimuon May 11, 2023
8540413
acc test for servicenow-itom
dimuon May 11, 2023
731f216
fix acc test
dimuon May 11, 2023
e78c67d
fix acc test
dimuon May 11, 2023
90ee63a
fix acc test
dimuon May 11, 2023
dff0e60
acc test for servicenow-sir
dimuon May 11, 2023
60c7dfc
acc test for slack
dimuon May 11, 2023
91d81bb
acc test for swimlane
dimuon May 12, 2023
b758fd8
acc test for teams
dimuon May 12, 2023
130c95c
acc test for tines
dimuon May 12, 2023
6241ddd
acc test for webhook
dimuon May 12, 2023
938172c
acc test for xmatters
dimuon May 12, 2023
175bc13
fix matrix acc test
dimuon May 12, 2023
7cbc45d
unit test for connectorResponseToModel
dimuon May 16, 2023
824fe3f
Merge remote-tracking branch 'upstream/main' into kibana-action-conne…
dimuon May 16, 2023
58eac4c
update go.mod
dimuon May 16, 2023
ec39434
Merge remote-tracking branch 'upstream/main' into kibana-action-conne…
dimuon May 22, 2023
fa07370
address PR review
dimuon May 22, 2023
d12e73f
readme for modified specs
dimuon May 22, 2023
baec3cc
readme for the modified specs
dimuon May 22, 2023
5e9f87f
fix Makefile
dimuon May 22, 2023
9a1c1dc
move connectors client generation to tools
dimuon May 22, 2023
c076b83
formatting
dimuon May 22, 2023
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
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ retry = until [ $$(if [ -z "$$attempt" ]; then echo -n "0"; else echo -n "$$atte
backoff=$$((backoff * 2)); \
done

# To run specific test (e.g. TestAccResourceActionConnector) execute `make docker-testacc TESTARGS='-run ^TestAccResourceActionConnector$$'`
# To enable tracing (or debugging), execute `make docker-testacc TFLOG=TRACE`
.PHONY: docker-testacc
docker-testacc: docker-elasticsearch docker-kibana ## Run acceptance tests in the docker container
@ docker run --rm \
-e ELASTICSEARCH_ENDPOINTS="$(ELASTICSEARCH_ENDPOINTS)" \
-e KIBANA_ENDPOINT="$(KIBANA_ENDPOINT)" \
-e ELASTICSEARCH_USERNAME="$(ELASTICSEARCH_USERNAME)" \
-e ELASTICSEARCH_PASSWORD="$(ELASTICSEARCH_PASSWORD)" \
-e TF_LOG="$(TF_LOG)" \
--network $(ELASTICSEARCH_NETWORK) \
-w "/provider" \
-v "$(SOURCE_LOCATION):/provider" \
golang:$(GOVERSION) make testacc
golang:$(GOVERSION) make testacc TESTARGS="$(TESTARGS)"

.PHONY: docker-elasticsearch
docker-elasticsearch: docker-network ## Start Elasticsearch single node cluster in docker container
Expand Down Expand Up @@ -159,7 +162,6 @@ tools: $(GOBIN) ## Install useful tools for linting, docs generation and develop
@ cd tools && go install github.com/goreleaser/goreleaser
@ cd tools && go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen


.PHONY: misspell
misspell:
@ $(GOBIN)/misspell -error -source go ./internal/
Expand Down Expand Up @@ -247,11 +249,15 @@ generate-alerting-client: ## generate Kibana alerting client
-g go \
-o /local/generated/alerting
@ rm -rf generated/alerting/go.mod generated/alerting/go.sum generated/alerting/test
@ go fmt ./generated/...
@ go fmt ./generated/alerting/...

.PHONY: generate-connectors-client
generate-connectors-client: tools ## generate Kibana connectors client
@ cd tools && go generate
@ go fmt ./generated/connectors/...

.PHONY: generate-slo-client
generate-slo-client: ## generate Kibana slo client
generate-slo-client: tools ## generate Kibana slo client
@ docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/observability/docs/openapi/slo/bundled.yaml \
--skip-validate-spec \
Expand All @@ -266,4 +272,4 @@ generate-slo-client: ## generate Kibana slo client
@ go fmt ./generated/...

.PHONY: generate-clients
generate-clients: generate-alerting-client generate-slo-client ## generate all clients
generate-clients: generate-alerting-client generate-slo-client generate-connectors-client ## generate all clients
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,8 @@ go mod tidy
```

Then commit the changes to `go.mod` and `go.sum`.

### Generating Kibana clients

Kibana clients for some APIs are generated based on Kibana OpenAPI specs.
Please see [Makefile](./Makefile) tasks for more details.
58 changes: 58 additions & 0 deletions docs/resources/kibana_action_connector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "elasticstack_kibana_action_connector Resource - terraform-provider-elasticstack"
subcategory: ""
description: |-
Creates a Kibana action connector. See https://www.elastic.co/guide/en/kibana/8.7/action-types.html
---

# elasticstack_kibana_action_connector (Resource)

Creates a Kibana action connector. See https://www.elastic.co/guide/en/kibana/8.7/action-types.html

## Example Usage

```terraform
provider "elasticstack" {
elasticsearch {}
}

resource "elasticstack_kibana_action_connector" "example" {
name = "%s"
config = jsonencode({
index = ".kibana"
refresh = true
})
connector_type_id = ".index"
}
```

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

### Required

- `connector_type_id` (String) The ID of the connector type, e.g. `.index`.
- `name` (String) The name of the connector. While this name does not have to be unique, a distinctive name can help you identify a connector.

### Optional

- `config` (String) The configuration for the connector. Configuration properties vary depending on the connector type.
- `connector_id` (String) A UUID v1 or v4 to use instead of a randomly generated ID.
- `secrets` (String) The secrets configuration for the connector. Secrets configuration properties vary depending on the connector type.
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.

### Read-Only

- `id` (String) The ID of this resource.
- `is_deprecated` (Boolean) Indicates whether the connector type is deprecated.
- `is_missing_secrets` (Boolean) Indicates whether secrets are missing for the connector.
- `is_preconfigured` (Boolean) Indicates whether it is a preconfigured connector.

## Import

Import is supported using the following syntax:

```shell
terraform import elasticstack_kibana_action_connector.my_connector <space id>/<connector id>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import elasticstack_kibana_action_connector.my_connector <space id>/<connector id>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
provider "elasticstack" {
elasticsearch {}
}

resource "elasticstack_kibana_action_connector" "example" {
name = "%s"
config = jsonencode({
index = ".kibana"
refresh = true
})
connector_type_id = ".index"
}
39 changes: 39 additions & 0 deletions generated/connectors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[OpenAPI specs](./bundled.yaml) is copied from [Kibana repo](https://raw.githubusercontent.com/elastic/kibana/8.7/x-pack/plugins/actions/docs/openapi/bundled.yaml) with some modifications:

- added mapping section for discriminator field in `POST` `/s/{spaceId}/api/actions/connector`;
- added explicit object definitions for `400`, `401` and `404` errors (`oapi-codegen` doesn't generate proper code for embedded anonymous objects in some cases) - `bad_request_error`, `authorization_error` and `object_not_found_error`;
- added missing `oneOf` types in `requestBody` for `PUT` `/s/{spaceId}/api/actions/connector/{connectorId}` - the original `bundled.yaml` misses some connector types in the `PUT` `requestBody` defintion:
- `update_connector_request_email`;
- `update_connector_request_pagerduty`;
- `update_connector_request_servicenow_sir`;
- `update_connector_request_slack`;
- `update_connector_request_teams`;
- `update_connector_request_tines`;
- `update_connector_request_webhook`;
- `update_connector_request_xmatters`.
- response definitions of `/s/{spaceId}/api/actions/connector/{connectorId}/_execute` and `/s/{spaceId}/api/actions/action/{actionId}/_execute` are modified from embedded object definitions to named ones `run_connector_general_response` and `legacy_run_connector_general_response`;
- specified properties for following types. The original `bundled.yaml` defines them as dynamic objects (`additionalProperties: true`):
- `config_propeties_email`;
- `config_properties_pagerduty`;
- `config_properties_tines`;
- `config_properties_webhook`;
- `config_properties_xmatters`;
- `is_deprecated` is marked as optional field (it's required field in the vanilla `bundled.yaml`) in the following objects (Kibana responses may omit it):
- `connector_response_properties_cases_webhook`;
- `connector_response_properties_email`;
- `connector_response_properties_index`;
- `connector_response_properties_jira`;
- `connector_response_properties_opsgenie`;
- `connector_response_properties_pagerduty`;
- `connector_response_properties_resilient`;
- `connector_response_properties_serverlog`;
- `connector_response_properties_servicenow`;
- `connector_response_properties_servicenow_itom`;
- `connector_response_properties_servicenow_sir`;
- `connector_response_properties_slack`;
- `connector_response_properties_swimlane`;
- `connector_response_properties_teams`;
- `connector_response_properties_tines`;
- `connector_response_properties_webhook`;
- `connector_response_properties_xmatters`.
- added mapping section for discriminator field in `connector_response_properties`.
Loading