Skip to content

Commit

Permalink
chore: update missing boolean fields (#170)
Browse files Browse the repository at this point in the history
* chore: update edge-firewall and rawlogs

* chore: update WebApplicationFirewall fields

* chore: destroy before and after running tests, to make sure

* chore: destroy before and after running tests, to make sure

* chore: if slice is empty, set it with zero elements

* chore: remove edge-firewall mentions
  • Loading branch information
PatrickMenoti authored Jan 15, 2025
1 parent c705f9d commit 06c444a
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ jobs:
run: |
sed -i 's/test-func/test-func-action-003/g' func-tests/main.tf
- name: destroy before run func tests
if: ${{ always() }}
run: |
make func-init && make func-destroy
- name: run func tests
run: |
make func-init && make func-plan && make func-apply
Expand Down
2 changes: 0 additions & 2 deletions docs/data-sources/edge_application_main_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ Read-Only:
- `debug_rules` (Boolean) Indicates whether debug rules are enabled for the Edge Application.
- `delivery_protocol` (String) The delivery protocol of the Edge Application.
- `device_detection` (Boolean) Indicates whether device detection is enabled for the Edge Application.
- `edge_firewall` (Boolean) Indicates whether the Edge Application has an edge firewall enabled.
- `edge_functions` (Boolean) Indicates whether edge functions are enabled for the Edge Application.
- `http3` (Boolean) Indicates whether HTTP/3 is enabled for the Edge Application.
- `http_port` (List of Number) The HTTP port(s) for the Edge Application.
Expand All @@ -54,4 +53,3 @@ Read-Only:
- `name` (String) The name of the Edge Application.
- `raw_logs` (Boolean) Indicates whether raw logs are enabled for the Edge Application.
- `supported_ciphers` (String) The supported ciphers for the Edge Application.
- `web_application_firewall` (Boolean) Indicates whether a web application firewall is enabled for the Edge Application.
4 changes: 0 additions & 4 deletions docs/resources/edge_application_main_setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ resource "azion_edge_application_main_setting" "example" {
minimum_tls_version = ""
debug_rules = false
caching = true
edge_firewall = false
edge_functions = false
image_optimization = false
http3 = false
Expand All @@ -32,7 +31,6 @@ resource "azion_edge_application_main_setting" "example" {
load_balancer = false
raw_logs = true
device_detection = false
web_application_firewall = false
}
}
Expand Down Expand Up @@ -104,15 +102,13 @@ Optional:
- `caching` (Boolean) Indicates whether caching is enabled for the Edge Application.
- `debug_rules` (Boolean) Indicates whether debug rules are enabled for the Edge Application.
- `device_detection` (Boolean) Indicates whether device detection is enabled for the Edge Application.
- `edge_firewall` (Boolean) Indicates whether the Edge Application has an edge firewall enabled.
- `edge_functions` (Boolean) Indicates whether edge functions are enabled for the Edge Application.
- `http3` (Boolean) Indicates whether HTTP/3 is enabled for the Edge Application.
- `image_optimization` (Boolean) Indicates whether image optimization is enabled for the Edge Application.
- `l2_caching` (Boolean) Indicates whether l2 caching is enabled for the Edge Application.
- `load_balancer` (Boolean) Indicates whether load balancing is enabled for the Edge Application.
- `minimum_tls_version` (String) The minimum TLS version supported by the Edge Application.
- `raw_logs` (Boolean) Indicates whether raw logs are enabled for the Edge Application.
- `web_application_firewall` (Boolean) Indicates whether a web application firewall is enabled for the Edge Application.

Read-Only:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ resource "azion_edge_application_main_setting" "example" {
minimum_tls_version = ""
debug_rules = false
caching = true
edge_firewall = false
edge_functions = false
image_optimization = false
http3 = false
Expand All @@ -17,7 +16,6 @@ resource "azion_edge_application_main_setting" "example" {
load_balancer = false
raw_logs = true
device_detection = false
web_application_firewall = false
}
}

Expand Down
2 changes: 0 additions & 2 deletions func-tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ resource "azion_edge_application_main_setting" "testfunc" {
https_port : [443]
minimum_tls_version : ""
debug_rules : false
edge_firewall : false
edge_functions : var.edge_functions_module
image_optimization : false
http3 : false
Expand All @@ -33,7 +32,6 @@ resource "azion_edge_application_main_setting" "testfunc" {
load_balancer : false
raw_logs : true
device_detection : false
web_application_firewall : false
raw_logs : false
}
}
Expand Down
12 changes: 0 additions & 12 deletions internal/data_source_edge_application_main_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ type EdgeApplicationResult struct {
ApplicationAcceleration types.Bool `tfsdk:"application_acceleration"`
Caching types.Bool `tfsdk:"caching"`
DeviceDetection types.Bool `tfsdk:"device_detection"`
EdgeFirewall types.Bool `tfsdk:"edge_firewall"`
EdgeFunctions types.Bool `tfsdk:"edge_functions"`
ImageOptimization types.Bool `tfsdk:"image_optimization"`
LoadBalancer types.Bool `tfsdk:"load_balancer"`
L2Caching types.Bool `tfsdk:"l2_caching"`
RawLogs types.Bool `tfsdk:"raw_logs"`
WebApplicationFirewall types.Bool `tfsdk:"web_application_firewall"`
}

func (e *EdgeApplicationDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
Expand Down Expand Up @@ -132,10 +130,6 @@ func (e *EdgeApplicationDataSource) Schema(_ context.Context, _ datasource.Schem
Computed: true,
Description: "Indicates whether device detection is enabled for the Edge Application.",
},
"edge_firewall": schema.BoolAttribute{
Computed: true,
Description: "Indicates whether the Edge Application has an edge firewall enabled.",
},
"edge_functions": schema.BoolAttribute{
Computed: true,
Description: "Indicates whether edge functions are enabled for the Edge Application.",
Expand All @@ -156,10 +150,6 @@ func (e *EdgeApplicationDataSource) Schema(_ context.Context, _ datasource.Schem
Computed: true,
Description: "Indicates whether raw logs are enabled for the Edge Application.",
},
"web_application_firewall": schema.BoolAttribute{
Computed: true,
Description: "Indicates whether a web application firewall is enabled for the Edge Application.",
},
},
},
},
Expand Down Expand Up @@ -215,13 +205,11 @@ func (e *EdgeApplicationDataSource) Read(ctx context.Context, req datasource.Rea
ApplicationAcceleration: types.BoolValue(edgeApplicationsResponse.Results.GetApplicationAcceleration()),
Caching: types.BoolValue(edgeApplicationsResponse.Results.GetCaching()),
DeviceDetection: types.BoolValue(edgeApplicationsResponse.Results.GetDeviceDetection()),
EdgeFirewall: types.BoolValue(edgeApplicationsResponse.Results.GetEdgeFirewall()),
EdgeFunctions: types.BoolValue(edgeApplicationsResponse.Results.GetEdgeFunctions()),
ImageOptimization: types.BoolValue(edgeApplicationsResponse.Results.GetImageOptimization()),
LoadBalancer: types.BoolValue(edgeApplicationsResponse.Results.GetLoadBalancer()),
L2Caching: types.BoolValue(edgeApplicationsResponse.Results.GetL2Caching()),
RawLogs: types.BoolValue(edgeApplicationsResponse.Results.GetRawLogs()),
WebApplicationFirewall: types.BoolValue(edgeApplicationsResponse.Results.GetWebApplicationFirewall()),
},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/resource_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *domainResource) Create(ctx context.Context, req resource.CreateRequest,
}

plan.SchemaVersion = types.Int64Value(createDomain.SchemaVersion)
var slice []types.String
var slice []types.String = []types.String{}
for _, Cnames := range createDomain.Results.Cnames {
slice = append(slice, types.StringValue(Cnames))
}
Expand All @@ -179,7 +179,7 @@ func (r *domainResource) Create(ctx context.Context, req resource.CreateRequest,
IsActive: types.BoolValue(createDomain.Results.GetIsActive()),
EdgeApplicationId: types.Int64Value(createDomain.Results.GetEdgeApplicationId()),
DomainName: types.StringValue(createDomain.Results.GetDomainName()),
Cnames: utils.SliceStringTypeToSet(slice),
Cnames: utils.SliceStringTypeToSetOrNull(slice),
}

if createDomain.Results.Environment != nil {
Expand Down Expand Up @@ -310,7 +310,7 @@ func (r *domainResource) Update(ctx context.Context, req resource.UpdateRequest,
}

plan.SchemaVersion = types.Int64Value(updateDomain.SchemaVersion)
var slice []types.String
var slice []types.String = []types.String{}
for _, Cnames := range updateDomain.Results.Cnames {
slice = append(slice, types.StringValue(Cnames))
}
Expand All @@ -321,7 +321,7 @@ func (r *domainResource) Update(ctx context.Context, req resource.UpdateRequest,
IsActive: types.BoolValue(updateDomain.Results.GetIsActive()),
EdgeApplicationId: types.Int64Value(updateDomain.Results.GetEdgeApplicationId()),
DomainName: types.StringValue(updateDomain.Results.GetDomainName()),
Cnames: utils.SliceStringTypeToSet(slice),
Cnames: utils.SliceStringTypeToSetOrNull(slice),
}

if updateDomain.Results.Environment != nil {
Expand Down
53 changes: 21 additions & 32 deletions internal/resource_edge_application_main_setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ type EdgeApplicationResults struct {
ApplicationAcceleration types.Bool `tfsdk:"application_acceleration"`
Caching types.Bool `tfsdk:"caching"`
DeviceDetection types.Bool `tfsdk:"device_detection"`
EdgeFirewall types.Bool `tfsdk:"edge_firewall"`
EdgeFunctions types.Bool `tfsdk:"edge_functions"`
ImageOptimization types.Bool `tfsdk:"image_optimization"`
LoadBalancer types.Bool `tfsdk:"load_balancer"`
L2Caching types.Bool `tfsdk:"l2_caching"`
RawLogs types.Bool `tfsdk:"raw_logs"`
WebApplicationFirewall types.Bool `tfsdk:"web_application_firewall"`
}

func (r *edgeApplicationResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
Expand Down Expand Up @@ -146,11 +144,6 @@ func (r *edgeApplicationResource) Schema(_ context.Context, _ resource.SchemaReq
Computed: true,
Description: "Indicates whether device detection is enabled for the Edge Application.",
},
"edge_firewall": schema.BoolAttribute{
Optional: true,
Computed: true,
Description: "Indicates whether the Edge Application has an edge firewall enabled.",
},
"edge_functions": schema.BoolAttribute{
Optional: true,
Computed: true,
Expand All @@ -176,11 +169,6 @@ func (r *edgeApplicationResource) Schema(_ context.Context, _ resource.SchemaReq
Computed: true,
Description: "Indicates whether raw logs are enabled for the Edge Application.",
},
"web_application_firewall": schema.BoolAttribute{
Optional: true,
Computed: true,
Description: "Indicates whether a web application firewall is enabled for the Edge Application.",
},
},
},
},
Expand Down Expand Up @@ -278,6 +266,10 @@ func (r *edgeApplicationResource) Create(ctx context.Context, req resource.Creat
requestUpdate.ImageOptimization = plan.EdgeApplication.ImageOptimization.ValueBoolPointer()
}

if plan.EdgeApplication.RawLogs.ValueBool() {
requestUpdate.RawLogs = plan.EdgeApplication.RawLogs.ValueBoolPointer()
}

ID := strconv.Itoa(int(createEdgeApplication.Results.GetId()))

updateEdgeApplication, response, err := r.client.edgeApplicationsApi.
Expand All @@ -301,20 +293,17 @@ func (r *edgeApplicationResource) Create(ctx context.Context, req resource.Creat
}

edgeAppResults := &EdgeApplicationResults{
ApplicationID: types.Int64Value(createEdgeApplication.Results.GetId()),
Name: types.StringValue(createEdgeApplication.Results.GetName()),
DeliveryProtocol: types.StringValue(createEdgeApplication.Results.GetDeliveryProtocol()),
HTTPPort: utils.ConvertInterfaceToFloat64List(createEdgeApplication.Results.HttpPort),
HTTPSPort: utils.ConvertInterfaceToFloat64List(createEdgeApplication.Results.HttpsPort),
MinimumTLSVersion: types.StringValue(createEdgeApplication.Results.GetMinimumTlsVersion()),
Active: types.BoolValue(createEdgeApplication.Results.GetActive()),
DebugRules: types.BoolValue(createEdgeApplication.Results.GetDebugRules()),
HTTP3: types.BoolValue(createEdgeApplication.Results.GetHttp3()),
SupportedCiphers: types.StringValue(createEdgeApplication.Results.GetSupportedCiphers()),
Caching: types.BoolValue(createEdgeApplication.Results.GetCaching()),
EdgeFirewall: types.BoolValue(createEdgeApplication.Results.GetEdgeFirewall()),
RawLogs: types.BoolValue(createEdgeApplication.Results.GetRawLogs()),
WebApplicationFirewall: types.BoolValue(createEdgeApplication.Results.GetWebApplicationFirewall()),
ApplicationID: types.Int64Value(createEdgeApplication.Results.GetId()),
Name: types.StringValue(createEdgeApplication.Results.GetName()),
DeliveryProtocol: types.StringValue(createEdgeApplication.Results.GetDeliveryProtocol()),
HTTPPort: utils.ConvertInterfaceToFloat64List(createEdgeApplication.Results.HttpPort),
HTTPSPort: utils.ConvertInterfaceToFloat64List(createEdgeApplication.Results.HttpsPort),
MinimumTLSVersion: types.StringValue(createEdgeApplication.Results.GetMinimumTlsVersion()),
Active: types.BoolValue(createEdgeApplication.Results.GetActive()),
DebugRules: types.BoolValue(createEdgeApplication.Results.GetDebugRules()),
HTTP3: types.BoolValue(createEdgeApplication.Results.GetHttp3()),
SupportedCiphers: types.StringValue(createEdgeApplication.Results.GetSupportedCiphers()),
Caching: types.BoolValue(createEdgeApplication.Results.GetCaching()),
}

if requestUpdate.L2Caching == nil {
Expand Down Expand Up @@ -353,6 +342,12 @@ func (r *edgeApplicationResource) Create(ctx context.Context, req resource.Creat
edgeAppResults.ImageOptimization = types.BoolValue(updateEdgeApplication.Results.GetImageOptimization())
}

if requestUpdate.RawLogs == nil {
edgeAppResults.RawLogs = types.BoolValue(createEdgeApplication.Results.GetRawLogs())
} else {
edgeAppResults.RawLogs = types.BoolValue(updateEdgeApplication.Results.GetRawLogs())
}

plan.EdgeApplication = edgeAppResults
plan.SchemaVersion = types.Int64Value(createEdgeApplication.SchemaVersion)
plan.ID = types.StringValue(strconv.FormatInt(createEdgeApplication.Results.Id, 10))
Expand Down Expand Up @@ -414,13 +409,11 @@ func (r *edgeApplicationResource) Read(ctx context.Context, req resource.ReadReq
ApplicationAcceleration: types.BoolValue(stateEdgeApplication.Results.GetApplicationAcceleration()),
Caching: types.BoolValue(stateEdgeApplication.Results.GetCaching()),
DeviceDetection: types.BoolValue(stateEdgeApplication.Results.GetDeviceDetection()),
EdgeFirewall: types.BoolValue(stateEdgeApplication.Results.GetEdgeFirewall()),
EdgeFunctions: types.BoolValue(stateEdgeApplication.Results.GetEdgeFunctions()),
ImageOptimization: types.BoolValue(stateEdgeApplication.Results.GetImageOptimization()),
LoadBalancer: types.BoolValue(stateEdgeApplication.Results.GetLoadBalancer()),
RawLogs: types.BoolValue(stateEdgeApplication.Results.GetRawLogs()),
L2Caching: types.BoolValue(stateEdgeApplication.Results.GetL2Caching()),
WebApplicationFirewall: types.BoolValue(stateEdgeApplication.Results.GetWebApplicationFirewall()),
}
state.ID = types.StringValue(strconv.FormatInt(stateEdgeApplication.Results.GetId(), 10))
state.SchemaVersion = types.Int64Value(stateEdgeApplication.SchemaVersion)
Expand Down Expand Up @@ -465,12 +458,10 @@ func (r *edgeApplicationResource) Update(ctx context.Context, req resource.Updat
SupportedCiphers: edgeapplications.PtrString(plan.EdgeApplication.SupportedCiphers.ValueString()),
ApplicationAcceleration: edgeapplications.PtrBool(plan.EdgeApplication.ApplicationAcceleration.ValueBool()),
DeviceDetection: edgeapplications.PtrBool(plan.EdgeApplication.DeviceDetection.ValueBool()),
EdgeFirewall: edgeapplications.PtrBool(plan.EdgeApplication.EdgeFirewall.ValueBool()),
EdgeFunctions: edgeapplications.PtrBool(plan.EdgeApplication.EdgeFunctions.ValueBool()),
ImageOptimization: edgeapplications.PtrBool(plan.EdgeApplication.ImageOptimization.ValueBool()),
LoadBalancer: edgeapplications.PtrBool(plan.EdgeApplication.LoadBalancer.ValueBool()),
RawLogs: edgeapplications.PtrBool(plan.EdgeApplication.RawLogs.ValueBool()),
WebApplicationFirewall: edgeapplications.PtrBool(plan.EdgeApplication.WebApplicationFirewall.ValueBool()),
DeliveryProtocol: edgeapplications.PtrString(plan.EdgeApplication.DeliveryProtocol.ValueString()),
L2Caching: edgeapplications.PtrBool(plan.EdgeApplication.L2Caching.ValueBool()),
}
Expand Down Expand Up @@ -513,13 +504,11 @@ func (r *edgeApplicationResource) Update(ctx context.Context, req resource.Updat
ApplicationAcceleration: types.BoolValue(updateEdgeApplication.Results.GetApplicationAcceleration()),
Caching: types.BoolValue(updateEdgeApplication.Results.GetCaching()),
DeviceDetection: types.BoolValue(updateEdgeApplication.Results.GetDeviceDetection()),
EdgeFirewall: types.BoolValue(updateEdgeApplication.Results.GetEdgeFirewall()),
EdgeFunctions: types.BoolValue(updateEdgeApplication.Results.GetEdgeFunctions()),
ImageOptimization: types.BoolValue(updateEdgeApplication.Results.GetImageOptimization()),
LoadBalancer: types.BoolValue(updateEdgeApplication.Results.GetLoadBalancer()),
RawLogs: types.BoolValue(updateEdgeApplication.Results.GetRawLogs()),
L2Caching: types.BoolValue(updateEdgeApplication.Results.GetL2Caching()),
WebApplicationFirewall: types.BoolValue(updateEdgeApplication.Results.GetWebApplicationFirewall()),
}

plan.SchemaVersion = types.Int64Value(updateEdgeApplication.SchemaVersion)
Expand Down

0 comments on commit 06c444a

Please sign in to comment.