Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POR-32339 CPS Documentation & Rules Engine Diff Correction #180

Merged
merged 7 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: build --rm-dist --snapshot
args: build --clean --snapshot
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 4 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.

version: 2

before:
hooks:
# this is just an example and not a requirement for provider building/publishing
Expand Down Expand Up @@ -51,4 +54,4 @@ release:
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
disable: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ HOSTNAME=github.com
NAMESPACE=terraform-providers
NAME=edgecast
BINARY=terraform-provider-${NAME}
VERSION=1.3.4
VERSION=1.3.5
OS_ARCH=darwin_amd64

default: install
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Reference this provider in a Terraform Configuration file (e.g. `main.tf`):
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ Example:
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vars:
NAMESPACE: terraform-providers
NAME: edgecast
BINARY: terraform-provider-{{.NAME}}
VERSION: 1.3.4
VERSION: 1.3.5


includes:
Expand Down
5 changes: 2 additions & 3 deletions docs/resources/cps_certificate.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,11 @@ Manage an existing TLS certificate through Terraform by importing it as a resour
}
1. Run the following command to attach a TLS certificate request to your resource configuration.

terraform import edgecast_cps_certificate.<RESOURCE> <ACCOUNT_NUMBER>:<CERTIFICATE_REQUEST_ID>
terraform import edgecast_cps_certificate.<RESOURCE> <CERTIFICATE_REQUEST_ID>
* `<RESOURCE>` - Replace this term with the name of the resource defined in step 1.
* `<ACCOUNT_NUMBER>` - Replace this term with your customer account number. Find your account number in the upper right-hand corner of the MCC.
* `<CERTIFICATE_REQUEST_ID>` - Replace this term with the system-defined ID assigned to the desired TLS certificate request. You may retrieve a list of TLS certificate requests and their system-defined IDs through our [REST API](https://developer.edgecast.com/cdn/api/index.html#CPS/Get-All-Certificate-Requests.htm).

**Example:**

terraform import edgecast_cps_certificate.sample_certificate 0001:123456
terraform import edgecast_cps_certificate.sample_certificate 123456
-> Upon running the above command, a resource for that TLS certificate request will be recorded in the state file.
2 changes: 1 addition & 1 deletion edgecast/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
idsURLProd string = "https://id.vdms.io"

// Version indicates the current version of this provider
Version string = "1.3.4"
Version string = "1.3.5"

userAgentFormat = "edgecast/terraform-provider:%s"
)
Expand Down
7 changes: 7 additions & 0 deletions edgecast/resources/rulesengine/v4policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ func cleanMatches(matches []interface{}) ([]map[string]interface{}, error) {
}

delete(cleanedMatch, "ordinal")
delete(cleanedMatch, "raw_value")

err := standardizeMatchFeature(cleanedMatch)
if err != nil {
return nil, fmt.Errorf("error standardizing match: %w", err)
Expand All @@ -301,7 +303,12 @@ func cleanMatches(matches []interface{}) ([]map[string]interface{}, error) {
cleanedFeatures := make([]map[string]interface{}, 0)
for _, feature := range features {
cleanedFeature := feature.(map[string]interface{})

delete(cleanedFeature, "ordinal")
delete(cleanedFeature, "raw_source")
delete(cleanedFeature, "raw_destination")
delete(cleanedFeature, "raw_value")

err := standardizeMatchFeature(cleanedFeature)
if err != nil {
return nil, fmt.Errorf("error standardizing features: %w", err)
Expand Down
105 changes: 104 additions & 1 deletion edgecast/resources/rulesengine/v4policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package rulesengine

import (
"encoding/json"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"reflect"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

type JSONMap map[string]any
Expand Down Expand Up @@ -104,3 +106,104 @@ func Test_policyDiffSuppress(t *testing.T) {
})
}
}

func Test_cleanPolicy(t *testing.T) {

policy := map[string]any{
"@type": "Policy",
"name": "tf--staging-http_large-1727827247",
"policy_type": "customer",
"state": "locked",
"created_at": "2024-10-02T00:00:47Z",
"rules": []any{
map[string]interface{}{
"name": "CustOriginMatch",
"description": "Rule to match origin to test raw values",
"ordinal": 1,
"created_at": "2024-10-02T00:00:47Z",
"@id": "/rules-engine/v1.1/policies/4409533/rules/33753446",
"@type": "Rule",
"id": "33753446",
"updated_at": "2024-10-02T00:00:47Z",
"matches": []any{
map[string]any{
"type": "match.origin.customer-origin.literal",
"ordinal": 1,
"value": "/804FDBB/test/",
"raw_value": "/804FDBB/test/",
"features": []any{
map[string]any{
"type": "feature.url.url-redirect",
"ordinal": 1,
"code": "301",
"destination": "/804FDBB/test/testdest",
"raw_destination": "/804FDBB/test/testdest",
"source": "/804FDBB/test/testsource",
"raw_source": "/804FDBB/test/testsource",
"value": "Good test value",
"raw_value": "Good test value",
},
},
},
},
},
},
"@id": "/rules-engine/v1.1/policies/4409533",
"id": "4409533",
"description": "This is a test policy of PolicyCreate.",
"platform": "http_large",
"updated_at": "2024-10-02T00:00:47Z",
"history": []any{},
}

cleanedPolicy := map[string]any{
"name": "tf--staging-http_large-1727827247",
"rules": []map[string]interface{}{
{
"name": "CustOriginMatch",
"description": "Rule to match origin to test raw values",
"matches": []map[string]interface{}{
{
"type": "match.origin.customer-origin.literal",
"value": "/804FDBB/test/",
"features": []map[string]interface{}{
{
"type": "feature.url.url-redirect",
"code": "301",
"destination": "/804FDBB/test/testdest",
"source": "/804FDBB/test/testsource",
"value": "Good test value",
},
},
},
},
},
},
"description": "This is a test policy of PolicyCreate.",
"platform": "http_large",
}

tests := []struct {
name string
originalPolicy map[string]any
expectedPolicy map[string]any
}{
{
name: "Unneeded Values Removed",
originalPolicy: policy,
expectedPolicy: cleanedPolicy,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := cleanPolicy(tt.originalPolicy)
if err != nil {
t.Errorf("cleanPolicy() function call errored unexpectedly %v", err)
}

if !reflect.DeepEqual(tt.originalPolicy, tt.expectedPolicy) {
t.Errorf("cleanPolicy() = got %v, want %v", tt.originalPolicy, tt.expectedPolicy)
}
})
}
}
2 changes: 1 addition & 1 deletion examples/data-sources/edgecast_cps_dns_txt_token/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/data-sources/edgecast_cps_full_workflow/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/data-sources/edgecast_cps_target_cname/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_cps_appendix/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_cps_certificate/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_customer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_customer_user/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_dns_group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_dns_masterservergroup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_dns_secondaryzonegroup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_dns_tsig/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_dns_zone/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_edgecname/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_origin/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_originv3_httplarge/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/resources/edgecast_rules_engine_policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
terraform {
required_providers {
edgecast = {
version = "1.3.4"
version = "1.3.5"
source = "Edgio/edgecast"
}
}
Expand Down
Loading
Loading