Skip to content

Commit f14b434

Browse files
authored
Merge pull request #334 from aquasecurity/test_coverage
fix: Increase acceptance test coverage
2 parents 44be1b3 + 9de8063 commit f14b434

32 files changed

+1851
-443
lines changed

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ git clone https://github.com/aquasecurity/terraform-provider-aquasec.git
3232
3333
cd terraform-provider-aquasec
3434
35-
git checkout v0.9.0
35+
git checkout v0.10.0
3636
```
3737

3838
**Build and install the provider**

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ HOSTNAME := github.com
66
NAMESPACE := aquasec
77
NAME := aquasec
88
BINARY := terraform-provider-${NAME}
9-
VERSION := 0.9.0
9+
VERSION := 0.10.0
1010
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
1111

1212
default: build

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ To quickly get started using the Aquasec provider for Terraform, configure the p
4343
terraform {
4444
required_providers {
4545
aquasec = {
46-
version = "0.9.0"
46+
version = "0.10.0"
4747
source = "aquasecurity/aquasec"
4848
}
4949
}

aquasec/data_enforcer_group_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func testAccCheckAquasecEnforcerGroupDataSource(enforcerGroup client.EnforcerGro
5757
schedule_scan_settings {
5858
disabled = %v
5959
is_custom = %v
60-
days = [0, 1, 2, 3, 4, 5, 6]
60+
days = [0,1,2,3,4,5,6]
6161
time = [3, 0]
6262
}
6363
}

aquasec/data_gateway.go

Lines changed: 69 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,109 @@
11
package aquasec
22

33
import (
4+
"context"
45
"log"
56

67
"github.com/aquasecurity/terraform-provider-aquasec/client"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
79
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
810
)
911

1012
func dataSourceGateways() *schema.Resource {
1113
return &schema.Resource{
1214
Description: "The data source `aquasec_gateways` provides a method to query all gateways within the Aqua ",
13-
Read: dataGatewayRead,
15+
ReadContext: dataGatewayRead,
1416
Schema: map[string]*schema.Schema{
1517
"gateways": {
16-
Type: schema.TypeList,
18+
Type: schema.TypeList,
1719
Description: "A list of existing gateways' parameters.",
18-
Computed: true,
20+
Computed: true,
1921
Elem: &schema.Resource{
2022
Schema: map[string]*schema.Schema{
2123
"id": {
22-
Type: schema.TypeString,
24+
Type: schema.TypeString,
2325
Description: "The ID of the gateway (for example: 8522744b25e2_gateway)",
24-
Computed: true,
26+
Computed: true,
2527
},
2628
"logicalname": {
27-
Type: schema.TypeString,
29+
Type: schema.TypeString,
2830
Description: "The logical name of the gateway (for example: 8522744b25e2)",
29-
Computed: true,
31+
Computed: true,
3032
},
3133
"description": {
32-
Type: schema.TypeString,
34+
Type: schema.TypeString,
3335
Description: "The description of the gateway.",
34-
Computed: true,
36+
Computed: true,
3537
},
3638
"version": {
37-
Type: schema.TypeString,
39+
Type: schema.TypeString,
3840
Description: "The version of the gateway.",
39-
Computed: true,
41+
Computed: true,
4042
},
4143
"hostname": {
42-
Type: schema.TypeString,
44+
Type: schema.TypeString,
4345
Description: "The name of the gateway's host.",
44-
Computed: true,
46+
Computed: true,
4547
},
4648
"public_address": {
47-
Type: schema.TypeString,
49+
Type: schema.TypeString,
4850
Description: "The public IP address of the gateway.",
49-
Computed: true,
51+
Computed: true,
5052
},
5153
"grpc_address": {
52-
Type: schema.TypeString,
54+
Type: schema.TypeString,
5355
Description: "The GRPC address of the gateway.",
54-
Computed: true,
56+
Computed: true,
5557
},
5658
"status": {
57-
Type: schema.TypeString,
59+
Type: schema.TypeString,
5860
Description: "The status of the gateway.",
59-
Computed: true,
61+
Computed: true,
62+
},
63+
"project_id": {
64+
Type: schema.TypeInt,
65+
Description: "",
66+
Computed: true,
67+
},
68+
"type": {
69+
Type: schema.TypeString,
70+
Description: "",
71+
Computed: true,
72+
},
73+
"commit": {
74+
Type: schema.TypeString,
75+
Description: "",
76+
Computed: true,
77+
},
78+
"address": {
79+
Type: schema.TypeString,
80+
Description: "",
81+
Computed: true,
82+
},
83+
"last_update": {
84+
Type: schema.TypeInt,
85+
Description: "",
86+
Computed: true,
87+
},
88+
"server_id": {
89+
Type: schema.TypeString,
90+
Description: "",
91+
Computed: true,
92+
},
93+
"server_name": {
94+
Type: schema.TypeString,
95+
Description: "",
96+
Computed: true,
97+
},
98+
"docker_version": {
99+
Type: schema.TypeString,
100+
Description: "",
101+
Computed: true,
102+
},
103+
"host_os": {
104+
Type: schema.TypeString,
105+
Description: "",
106+
Computed: true,
60107
},
61108
},
62109
},
@@ -65,18 +112,18 @@ func dataSourceGateways() *schema.Resource {
65112
}
66113
}
67114

68-
func dataGatewayRead(d *schema.ResourceData, m interface{}) error {
115+
func dataGatewayRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
69116
log.Println("[DEBUG] inside dataGateway")
70117
c := m.(*client.Client)
71118
result, err := c.GetGateways()
72119
if err == nil {
73120
gateways, id := flattenGatewaysData(&result)
74121
d.SetId(id)
75122
if err := d.Set("gateways", gateways); err != nil {
76-
return err
123+
return diag.FromErr(err)
77124
}
78125
} else {
79-
return err
126+
return diag.FromErr(err)
80127
}
81128

82129
return nil

aquasec/data_image_assurance_policy.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,22 @@ func dataImageAssurancePolicy() *schema.Resource {
403403
Type: schema.TypeString,
404404
Computed: true,
405405
},
406+
"imageid": {
407+
Type: schema.TypeInt,
408+
Computed: true,
409+
},
410+
"imagedigest": {
411+
Type: schema.TypeString,
412+
Computed: true,
413+
},
414+
"author": {
415+
Type: schema.TypeString,
416+
Computed: true,
417+
},
418+
"lastupdated": {
419+
Type: schema.TypeInt,
420+
Computed: true,
421+
},
406422
},
407423
},
408424
},
@@ -743,7 +759,7 @@ func dataImageAssurancePolicyRead(ctx context.Context, d *schema.ResourceData, m
743759
d.Set("malware_action", iap.MalwareAction)
744760
d.Set("partial_results_image_fail", iap.PartialResultsImageFail)
745761
d.Set("maximum_score_exclude_no_fix", iap.MaximumScoreExcludeNoFix)
746-
d.Set("aggregated_vulnerability", flattenAggregatedVulnerability(iap.AggregatedVulnerability))
762+
d.Set("aggregated_vulnerability", flattenAggregatedVulnerability(iap.AggregatedVulnerability))
747763
d.SetId(name)
748764
} else {
749765
return diag.FromErr(err)

aquasec/data_integration_state.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package aquasec
22

33
import (
4+
"context"
45
"fmt"
6+
57
"github.com/aquasecurity/terraform-provider-aquasec/client"
8+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
69
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
710
)
811

912
func dataIntegrationState() *schema.Resource {
1013
return &schema.Resource{
11-
Read: dataIntegrationStateRead,
14+
ReadContext: dataIntegrationStateRead,
1215
Schema: map[string]*schema.Schema{
1316
"oidc_settings": {
1417
Type: schema.TypeBool,
@@ -29,7 +32,7 @@ func dataIntegrationState() *schema.Resource {
2932
}
3033
}
3134

32-
func dataIntegrationStateRead(d *schema.ResourceData, m interface{}) error {
35+
func dataIntegrationStateRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
3336
ac := m.(*client.Client)
3437

3538
iap, err := ac.GetIntegrationState()
@@ -40,7 +43,7 @@ func dataIntegrationStateRead(d *schema.ResourceData, m interface{}) error {
4043
_, id := flattenIntegrationEnablesStateData(iap)
4144
d.SetId(id)
4245
} else {
43-
return err
46+
return diag.FromErr(err)
4447
}
4548
return nil
4649
}

0 commit comments

Comments
 (0)