@@ -10,11 +10,37 @@ import (
1010 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1111)
1212
13+ const (
14+ // GKEPoliciesResourceName is the name of the resource
15+ GKEPoliciesResourceName = "policy"
16+ // GKELoadBalancersNetworkEndpointGroupPoliciesResourceName is the name of the resource
17+ GKELoadBalancersNetworkEndpointGroupPoliciesResourceName = "castai_gke_load_balancers_network_endpoint_group_policies"
18+ // GKELoadBalancersTargetBackendPoolsPoliciesResourceName is the name of the resource
19+ GKELoadBalancersTargetBackendPoolsPoliciesResourceName = "castai_gke_load_balancers_target_backend_pools_policies"
20+ // GKELoadBalancersUnmanagedInstanceGroupsPoliciesResourceName is the name of the resource
21+ GKELoadBalancersUnmanagedInstanceGroupsPoliciesResourceName = "castai_gke_load_balancers_unmanaged_instance_groups_policies"
22+ )
23+
1324func dataSourceGKEPolicies () * schema.Resource {
1425 return & schema.Resource {
1526 ReadContext : dataSourceGKEPoliciesRead ,
1627 Schema : map [string ]* schema.Schema {
17- "policy" : {
28+ GKEPoliciesResourceName : {
29+ Type : schema .TypeList ,
30+ Computed : true ,
31+ Elem : & schema.Schema {Type : schema .TypeString },
32+ },
33+ GKELoadBalancersNetworkEndpointGroupPoliciesResourceName : {
34+ Type : schema .TypeList ,
35+ Computed : true ,
36+ Elem : & schema.Schema {Type : schema .TypeString },
37+ },
38+ GKELoadBalancersTargetBackendPoolsPoliciesResourceName : {
39+ Type : schema .TypeList ,
40+ Computed : true ,
41+ Elem : & schema.Schema {Type : schema .TypeString },
42+ },
43+ GKELoadBalancersUnmanagedInstanceGroupsPoliciesResourceName : {
1844 Type : schema .TypeList ,
1945 Computed : true ,
2046 Elem : & schema.Schema {Type : schema .TypeString },
@@ -26,7 +52,37 @@ func dataSourceGKEPolicies() *schema.Resource {
2652func dataSourceGKEPoliciesRead (ctx context.Context , data * schema.ResourceData , meta interface {}) diag.Diagnostics {
2753 policies , _ := gke .GetUserPolicy ()
2854 data .SetId ("gke" )
29- if err := data .Set ("policy" , policies ); err != nil {
55+ if err := data .Set (GKEPoliciesResourceName , policies ); err != nil {
56+ return diag .FromErr (fmt .Errorf ("setting gke policy: %w" , err ))
57+ }
58+
59+ return nil
60+ }
61+
62+ func dataSourceGKELoadBalancersNetworkEndpointGroupPoliciesRead (ctx context.Context , data * schema.ResourceData , meta interface {}) diag.Diagnostics {
63+ policies , _ := gke .GetLoadBalancersNetworkEndpointGroupPolicy ()
64+ data .SetId ("gke" )
65+ if err := data .Set (GKELoadBalancersNetworkEndpointGroupPoliciesResourceName , policies ); err != nil {
66+ return diag .FromErr (fmt .Errorf ("setting gke policy: %w" , err ))
67+ }
68+
69+ return nil
70+ }
71+
72+ func dataSourceGKELoadBalancersTargetBackendPoolsPoliciesRead (ctx context.Context , data * schema.ResourceData , meta interface {}) diag.Diagnostics {
73+ policies , _ := gke .GetLoadBalancersTargetBackendPoolsPolicy ()
74+ data .SetId ("gke" )
75+ if err := data .Set (GKELoadBalancersTargetBackendPoolsPoliciesResourceName , policies ); err != nil {
76+ return diag .FromErr (fmt .Errorf ("setting gke policy: %w" , err ))
77+ }
78+
79+ return nil
80+ }
81+
82+ func dataSourceGKELoadBalancersUnmanagedInstanceGroupsPoliciesRead (ctx context.Context , data * schema.ResourceData , meta interface {}) diag.Diagnostics {
83+ policies , _ := gke .GetLoadBalancersUnmanagedInstanceGroupsPolicy ()
84+ data .SetId ("gke" )
85+ if err := data .Set (GKELoadBalancersUnmanagedInstanceGroupsPoliciesResourceName , policies ); err != nil {
3086 return diag .FromErr (fmt .Errorf ("setting gke policy: %w" , err ))
3187 }
3288
0 commit comments