Skip to content

Commit

Permalink
Fix incorrect header name for api key in alerting client. (#633)
Browse files Browse the repository at this point in the history
* Fix incorrect header name for api key in alerting client.

* Fix null pointer deref in case of 4xx responses

* Fix acc tests for alerting for < 8.8.2

Kibana doesn't support api key prior to that version.

* Changelog

---------

Co-authored-by: Toby Brain <[email protected]>
  • Loading branch information
dimuon and tobio authored May 15, 2024
1 parent a74ccf6 commit 69e7b29
Show file tree
Hide file tree
Showing 7 changed files with 2,447 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Prevent a provider panic in `elasticstack_kibana_data_view` when a `field_format` does not include a `pattern`. ([#619](https://github.com/elastic/terraform-provider-elasticstack/pull/619/files))
- Fixed a bug where the `id` attribute for `elasticstack_kibana_slo` resources was ignored by renaming the attribute to `slo_id`. ([#622](https://github.com/elastic/terraform-provider-elasticstack/pull/622))
- Fixed a bug where the `rule_id` attribute for `elasticstack_kibana_alerting_rule` was ignored. ([#626](https://github.com/elastic/terraform-provider-elasticstack/pull/626))
- Fixed a bug with incorrect HTTP header name for API key for alerting client. ([#633](https://github.com/elastic/terraform-provider-elasticstack/pull/633))
- Fix provider crash when running against Serverless projects ([#630](https://github.com/elastic/terraform-provider-elasticstack/pull/630))

### Added
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ help: ## this help
.PHONY: generate-alerting-client
generate-alerting-client: ## generate Kibana alerting client
@ docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v7.0.1 generate \
-i https://raw.githubusercontent.com/elastic/kibana/$(SWAGGER_VERSION)/x-pack/plugins/alerting/docs/openapi/bundled.json \
-i /local/generated/alerting/bundled.yaml \
--skip-validate-spec \
--git-repo-id terraform-provider-elasticstack \
--git-user-id elastic \
Expand Down
6 changes: 3 additions & 3 deletions generated/alerting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ r, err := client.Service.Operation(auth, args)
### apiKeyAuth

- **Type**: API key
- **API key parameter name**: ApiKey
- **API key parameter name**: Authorization
- **Location**: HTTP header

Note, each API key must be added to a map of `map[string]APIKey` where the key is: ApiKey and passed in as the auth context for each request.
Note, each API key must be added to a map of `map[string]APIKey` where the key is: Authorization and passed in as the auth context for each request.

Example

Expand All @@ -190,7 +190,7 @@ auth := context.WithValue(
context.Background(),
sw.ContextAPIKeys,
map[string]sw.APIKey{
"ApiKey": {Key: "API_KEY_STRING"},
"Authorization": {Key: "API_KEY_STRING"},
},
)
r, err := client.Service.Operation(auth, args)
Expand Down
3 changes: 2 additions & 1 deletion generated/alerting/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3618,6 +3618,7 @@ components:
scheme: basic
type: http
apiKeyAuth:
description: "e.g. Authorization: ApiKey base64AccessApiKey"
in: header
name: ApiKey
name: Authorization
type: apiKey
52 changes: 26 additions & 26 deletions generated/alerting/api_alerting.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 69e7b29

Please sign in to comment.