Skip to content

Commit

Permalink
Bump go-scalr version, update Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
kozliuk committed Apr 24, 2023
2 parents 904b1ba + b8ada94 commit f366fd3
Show file tree
Hide file tree
Showing 16 changed files with 780 additions and 110 deletions.
50 changes: 45 additions & 5 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- `scalr_vcs_provider`: added new attribute `agent_pool_id` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/233))
- `data.scalr_vcs_provider`: added new attribute `agent_pool_id` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/233))
- `scalr_agent_pool`: added new attribute `vcs_enabled` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/233))
- `data.scalr_agent_pool`: added new attribute `vcs_enabled` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/232))

### Fixed

- `data.scalr_module_version`: if there are several module versions with the same version, select the version that has the 'is-root-module' flag set to true. ([#229](https://github.com/Scalr/terraform-provider-scalr/pull/229))

### Required

- scalr-server >= `8.64.0`

## [1.0.5] - 2023-04-21

### Changed

- `data.scalr_workspace`: added new optional `id` argument, `name` became optional, one of or both can be specified ([#228](https://github.com/Scalr/terraform-provider-scalr/pull/228))
- `data.scalr_role`: added new optional `id` argument, `name` became optional, one of or both can be specified ([#228](https://github.com/Scalr/terraform-provider-scalr/pull/228))
- `data.scalr_iam_team`: added new optional `id` argument, `name` became optional, one of or both can be specified ([#228](https://github.com/Scalr/terraform-provider-scalr/pull/228))
Expand All @@ -23,18 +40,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `data.scalr_environment`: optional `id` and `name` arguments can be used together ([#228](https://github.com/Scalr/terraform-provider-scalr/pull/228))
- `data.scalr_endpoint`: optional `id` and `name` arguments can be used together ([#228](https://github.com/Scalr/terraform-provider-scalr/pull/228))
- `data.scalr_service_account`: optional `id` and `email` arguments can be used together ([#228](https://github.com/Scalr/terraform-provider-scalr/pull/228))
- `scalr_vcs_provider`: added new attribute `agent_pool_id` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/233))
- `data.scalr_vcs_provider`: added new attribute `agent_pool_id` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/233))
- `scalr_agent_pool`: added new attribute `vcs_enabled` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/233))
- `data.scalr_agent_pool`: added new attribute `vcs_enabled` ([#233](https://github.com/Scalr/terraform-provider-scalr/pull/232))
- `scalr_workspace_run_schedule`: make `apply-schedule` and `destroy-schedule` attributes nullable ([#231](https://github.com/Scalr/terraform-provider-scalr/pull/231))
- `scalr_webhook`: ([#234](https://github.com/Scalr/terraform-provider-scalr/pull/234))
- endpoint arguments are now included in the webhook resource: `url`, `secret_key`, `timeout` and `max_attempts`
This manifests the new way webhook integration will work further on, deprecating the `endpoint_id` argument
and merging the endpoint information into the webhook. During the deprecation period both old-style and new-style
webhooks are supported. The support for old-style webhooks will be dropped in the next major release.
- added new optional `header` argument (new-style webhooks only) - additional headers to set in the webhook request
- added new optional `environments` argument (new-style webhooks only) - environments that the webhook is shared to
- `data.scalr_webhook`: extended with new attributes from new-style webhook - `url`, `secret_key`, `timeout`,
`max_attempts`, `header`, `environments` ([#234](https://github.com/Scalr/terraform-provider-scalr/pull/234))

### Fixed

- `scalr_account_allowed_ips`: accept /32 suffix ([#224](https://github.com/Scalr/terraform-provider-scalr/pull/224))
- `scalr_vcs_provider`: fix handling resource destroy when resource no longer exists ([#235](https://github.com/Scalr/terraform-provider-scalr/pull/235))
- `scalr_webhook`: fix handling resource destroy when resource no longer exists ([#235](https://github.com/Scalr/terraform-provider-scalr/pull/235))

### Deprecated

- `scalr_endpoint` is deprecated and will be removed in the next major version ([#234](https://github.com/Scalr/terraform-provider-scalr/pull/234))
- `data.scalr_endpoint` is deprecated and will be removed in the next major version ([#234](https://github.com/Scalr/terraform-provider-scalr/pull/234))
- `scalr_webhook`: ([#234](https://github.com/Scalr/terraform-provider-scalr/pull/234))
- attribute `endpoint_id` is deprecated
- attribute `environment_id` is deprecated
- attribute `workspace_id` is deprecated
- `data.scalr_webhook`: ([#234](https://github.com/Scalr/terraform-provider-scalr/pull/234))
- attribute `endpoint_id` is deprecated
- attribute `environment_id` is deprecated
- attribute `workspace_id` is deprecated

### Required

- scalr-server >= `8.63.0`

## [1.0.4] - 2023-03-13

### Fixed
Expand Down Expand Up @@ -621,7 +660,8 @@ Requires Scalr 8.0.1-beta.20200625 at least

- Initial release.

[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.4...HEAD
[Unreleased]: https://github.com/Scalr/terraform-provider-scalr/compare/v1.0.5...HEAD
[1.0.5]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.5
[1.0.4]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.4
[1.0.3]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.3
[1.0.2]: https://github.com/Scalr/terraform-provider-scalr/releases/tag/v1.0.2
Expand Down
2 changes: 2 additions & 0 deletions docs/data-sources/scalr_endpoint.md
Expand Up @@ -3,6 +3,8 @@

Retrieves the details of a webhook endpoint.

> **WARNING:** This datasource is deprecated and will be removed in the next major version.
## Example Usage

```hcl
Expand Down
15 changes: 13 additions & 2 deletions docs/data-sources/scalr_webhook.md
Expand Up @@ -32,7 +32,18 @@ Arguments `id` and `name` are both optional, specify at least one of them to obt
All arguments plus:

* `enabled` - Boolean indicates if the webhook is enabled.
* `endpoint_id` - ID of the endpoint, in the format `ep-<RANDOM STRING>`.
* `environment_id` - ID of the environment, in the format `env-<RANDOM STRING>`.
* `endpoint_id` - (Deprecated) ID of the endpoint, in the format `ep-<RANDOM STRING>`.
* `environment_id` - (Deprecated) ID of the environment, in the format `env-<RANDOM STRING>`.
* `workspace_id` - (Deprecated) ID of the workspace, in the format `ws-<RANDOM STRING>`.
* `events` - List of event IDs.
* `last_triggered_at` - Date/time when webhook was last triggered.
* `url` - Endpoint URL.
* `secret_key` - Secret key to sign the webhook payload.
* `max_attempts` - Max delivery attempts of the payload.
* `timeout` - Endpoint timeout (in seconds).
* `environments` - The list of environment identifiers that the webhook is shared to,
or `["*"]` if shared with all environments.
* `header` - (Set of header objects) Additional headers to set in the webhook request.
The `header` block item contains:
* `name` - The name of the header.
* `value` - The value of the header.
2 changes: 2 additions & 0 deletions docs/resources/scalr_endpoint.md
Expand Up @@ -3,6 +3,8 @@

Manage the state of endpoints in Scalr. Create, update and destroy

> **WARNING:** This resource is deprecated and will be removed in the next major version.
## Example Usage

Basic usage:
Expand Down
17 changes: 14 additions & 3 deletions docs/resources/scalr_webhook.md
Expand Up @@ -21,11 +21,22 @@ resource "scalr_webhook" "example" {
## Argument Reference

* `name` - (Required) Name of the webhook.
* `account_id` - (Optional) ID of the account, in the format `acc-<RANDOM STRING>`.
* `enabled` - (Optional) Set (true/false) to enable/disable the webhook.
* `endpoint_id` - (Required) ID of the endpoint, in the format `ep-<RANDOM STRING>`.
* `workspace_id` - (Optional) ID of the workspace, in the format `ws-<RANDOM STRING>`.
* `environment_id` - (Required if workspace ID is empty) ID of the environment, in the format `env-<RANDOM STRING>`.
* `endpoint_id` - (Deprecated) ID of the endpoint, in the format `ep-<RANDOM STRING>`.
* `workspace_id` - (Deprecated) ID of the workspace, in the format `ws-<RANDOM STRING>`.
* `environment_id` - (Deprecated) ID of the environment, in the format `env-<RANDOM STRING>`.
* `events` - (Required) List of event IDs.
* `url` - (Optional) Endpoint URL. Required if `endpoint_id` is not set.
* `secret_key` - (Optional) Secret key to sign the webhook payload.
* `max_attempts` - (Optional) Max delivery attempts of the payload.
* `timeout` - (Optional) Endpoint timeout (in seconds).
* `environments` - (Optional) The list of environment identifiers that the webhook is shared to.
Use `["*"]` to share with all environments.
* `header` - (Optional, set of header objects) Additional headers to set in the webhook request.
The `header` block item contains:
* `name` - The name of the header.
* `value` - The value of the header.

## Attributes

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -5,7 +5,7 @@ require (
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce
github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.1
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
github.com/scalr/go-scalr v0.0.0-20230419170500-fde618c901e4
github.com/scalr/go-scalr v0.0.0-20230424091123-5437ed6e096e
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -242,8 +242,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/scalr/go-scalr v0.0.0-20230419170500-fde618c901e4 h1:Nqaw2N8N7djvSBK02g4MFTcIo9fUZaLeJS5kZmshhe4=
github.com/scalr/go-scalr v0.0.0-20230419170500-fde618c901e4/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/scalr/go-scalr v0.0.0-20230424091123-5437ed6e096e h1:dnFu7ozDG1exX+KnYqtfStR/nYobB2k1OhqT+jIEVgg=
github.com/scalr/go-scalr v0.0.0-20230424091123-5437ed6e096e/go.mod h1:p34SHb25YRvbgft7SUjSDYESeoQhWzAlxGXId/BbaSE=
github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
Expand Down
3 changes: 3 additions & 0 deletions scalr/data_source_scalr_endpoint.go
Expand Up @@ -12,6 +12,9 @@ import (

func dataSourceScalrEndpoint() *schema.Resource {
return &schema.Resource{
DeprecationMessage: "Datasource `scalr_endpoint` is deprecated, the endpoint information" +
" is included in the `scalr_webhook` resource.",

ReadContext: dataSourceScalrEndpointRead,

Schema: map[string]*schema.Schema{
Expand Down
23 changes: 17 additions & 6 deletions scalr/data_source_scalr_module_version.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/scalr/go-scalr"
)

Expand All @@ -19,8 +20,9 @@ func dataSourceModuleVersion() *schema.Resource {
Required: true,
},
"version": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotWhiteSpace,
},
"id": {
Type: schema.TypeString,
Expand All @@ -46,7 +48,19 @@ func dataSourceModuleVersionRead(ctx context.Context, d *schema.ResourceData, me
var version string
if v, ok := d.GetOk("version"); ok {
version = v.(string)
mv, err = scalrClient.ModuleVersions.ReadBySemanticVersion(ctx, module.ID, version)
ml, err := scalrClient.ModuleVersions.List(ctx, scalr.ModuleVersionListOptions{Module: module.ID, Version: &version})
if err != nil {
return diag.Errorf("Could not find module %s with version %s", module.ID, version)
}
for _, item := range ml.Items {
if item.IsRootModule {
mv = item
break
}
}
if mv == nil {
return diag.Errorf("Could not find module with source %s and version %s", source, version)
}
} else {
if module.ModuleVersion == nil {
return diag.FromErr(errors.New("The module has no version tags"))
Expand All @@ -55,9 +69,6 @@ func dataSourceModuleVersionRead(ctx context.Context, d *schema.ResourceData, me
}

if err != nil {
if errors.Is(err, scalr.ErrResourceNotFound) {
return diag.Errorf("Could not find module with source %s and version %s", source, version)
}
return diag.Errorf("Error retrieving module version: %v", err)
}
log.Printf("[DEBUG] Download module version by source %s version: %s", source, version)
Expand Down

0 comments on commit f366fd3

Please sign in to comment.