11package aquasec
22
33import (
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
1012func 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
0 commit comments