Skip to content

Commit 5027f4d

Browse files
authored
routes: update data source (#33)
Update the routes data source, which was missing some fields. Also add the additional list parameters supported by the API.
1 parent fdbacb7 commit 5027f4d

File tree

2 files changed

+206
-182
lines changed

2 files changed

+206
-182
lines changed

internal/provider/route_data_source.go

+154-150
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,159 @@ import (
1515

1616
var _ datasource.DataSource = &RouteDataSource{}
1717

18+
func getRouteDataSourceAttributes(idRequired bool) map[string]schema.Attribute {
19+
return map[string]schema.Attribute{
20+
"id": schema.StringAttribute{
21+
Description: "Unique identifier for the route.",
22+
Required: idRequired,
23+
Computed: !idRequired,
24+
},
25+
"name": schema.StringAttribute{
26+
Computed: true,
27+
Description: "Name of the route.",
28+
},
29+
"from": schema.StringAttribute{
30+
Computed: true,
31+
Description: "From URL.",
32+
},
33+
"to": schema.ListAttribute{
34+
Computed: true,
35+
ElementType: types.StringType,
36+
Description: "To URLs.",
37+
},
38+
"namespace_id": schema.StringAttribute{
39+
Computed: true,
40+
Description: "ID of the namespace the route belongs to.",
41+
},
42+
"policies": schema.ListAttribute{
43+
Computed: true,
44+
ElementType: types.StringType,
45+
Description: "List of policy IDs associated with the route.",
46+
},
47+
"stat_name": schema.StringAttribute{
48+
Computed: true,
49+
Description: "Name of the stat.",
50+
},
51+
"prefix": schema.StringAttribute{
52+
Computed: true,
53+
Description: "Prefix.",
54+
},
55+
"path": schema.StringAttribute{
56+
Computed: true,
57+
Description: "Path.",
58+
},
59+
"regex": schema.StringAttribute{
60+
Computed: true,
61+
Description: "Regex.",
62+
},
63+
"prefix_rewrite": schema.StringAttribute{
64+
Computed: true,
65+
Description: "Prefix rewrite.",
66+
},
67+
"regex_rewrite_pattern": schema.StringAttribute{
68+
Computed: true,
69+
Description: "Regex rewrite pattern.",
70+
},
71+
"regex_rewrite_substitution": schema.StringAttribute{
72+
Computed: true,
73+
Description: "Regex rewrite substitution.",
74+
},
75+
"host_rewrite": schema.StringAttribute{
76+
Computed: true,
77+
Description: "Host rewrite.",
78+
},
79+
"host_rewrite_header": schema.StringAttribute{
80+
Computed: true,
81+
Description: "Host rewrite header.",
82+
},
83+
"host_path_regex_rewrite_pattern": schema.StringAttribute{
84+
Computed: true,
85+
Description: "Host path regex rewrite pattern.",
86+
},
87+
"host_path_regex_rewrite_substitution": schema.StringAttribute{
88+
Computed: true,
89+
Description: "Host path regex rewrite substitution.",
90+
},
91+
"regex_priority_order": schema.Int64Attribute{
92+
Computed: true,
93+
Description: "Regex priority order.",
94+
},
95+
"timeout": schema.StringAttribute{
96+
Computed: true,
97+
Description: "Timeout.",
98+
CustomType: timetypes.GoDurationType{},
99+
},
100+
"idle_timeout": schema.StringAttribute{
101+
Computed: true,
102+
Description: "Idle timeout.",
103+
CustomType: timetypes.GoDurationType{},
104+
},
105+
"allow_websockets": schema.BoolAttribute{
106+
Computed: true,
107+
Description: "Allow websockets.",
108+
},
109+
"allow_spdy": schema.BoolAttribute{
110+
Computed: true,
111+
Description: "Allow SPDY.",
112+
},
113+
"tls_skip_verify": schema.BoolAttribute{
114+
Computed: true,
115+
Description: "TLS skip verify.",
116+
},
117+
"tls_upstream_server_name": schema.StringAttribute{
118+
Computed: true,
119+
Description: "TLS upstream server name.",
120+
},
121+
"tls_downstream_server_name": schema.StringAttribute{
122+
Computed: true,
123+
Description: "TLS downstream server name.",
124+
},
125+
"tls_upstream_allow_renegotiation": schema.BoolAttribute{
126+
Computed: true,
127+
Description: "TLS upstream allow renegotiation.",
128+
},
129+
"set_request_headers": schema.MapAttribute{
130+
Computed: true,
131+
ElementType: types.StringType,
132+
Description: "Set request headers.",
133+
},
134+
"remove_request_headers": schema.ListAttribute{
135+
Computed: true,
136+
ElementType: types.StringType,
137+
Description: "Remove request headers.",
138+
},
139+
"set_response_headers": schema.MapAttribute{
140+
Computed: true,
141+
ElementType: types.StringType,
142+
Description: "Set response headers.",
143+
},
144+
"preserve_host_header": schema.BoolAttribute{
145+
Computed: true,
146+
Description: "Preserve host header.",
147+
},
148+
"pass_identity_headers": schema.BoolAttribute{
149+
Computed: true,
150+
Description: "Pass identity headers.",
151+
},
152+
"kubernetes_service_account_token": schema.StringAttribute{
153+
Computed: true,
154+
Description: "Kubernetes service account token.",
155+
},
156+
"idp_client_id": schema.StringAttribute{
157+
Computed: true,
158+
Description: "IDP client ID.",
159+
},
160+
"idp_client_secret": schema.StringAttribute{
161+
Computed: true,
162+
Description: "IDP client secret.",
163+
},
164+
"show_error_details": schema.BoolAttribute{
165+
Computed: true,
166+
Description: "Show error details.",
167+
},
168+
}
169+
}
170+
18171
func NewRouteDataSource() datasource.DataSource {
19172
return &RouteDataSource{}
20173
}
@@ -30,156 +183,7 @@ func (d *RouteDataSource) Metadata(_ context.Context, req datasource.MetadataReq
30183
func (d *RouteDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
31184
resp.Schema = schema.Schema{
32185
MarkdownDescription: "Route data source",
33-
34-
Attributes: map[string]schema.Attribute{
35-
"id": schema.StringAttribute{
36-
Required: true,
37-
Description: "Unique identifier for the route.",
38-
},
39-
"name": schema.StringAttribute{
40-
Computed: true,
41-
Description: "Name of the route.",
42-
},
43-
"from": schema.StringAttribute{
44-
Computed: true,
45-
Description: "From URL.",
46-
},
47-
"to": schema.ListAttribute{
48-
Computed: true,
49-
ElementType: types.StringType,
50-
Description: "To URLs.",
51-
},
52-
"namespace_id": schema.StringAttribute{
53-
Computed: true,
54-
Description: "ID of the namespace the route belongs to.",
55-
},
56-
"policies": schema.ListAttribute{
57-
Computed: true,
58-
ElementType: types.StringType,
59-
Description: "List of policy IDs associated with the route.",
60-
},
61-
"stat_name": schema.StringAttribute{
62-
Computed: true,
63-
Description: "Name of the stat.",
64-
},
65-
"prefix": schema.StringAttribute{
66-
Computed: true,
67-
Description: "Prefix.",
68-
},
69-
"path": schema.StringAttribute{
70-
Computed: true,
71-
Description: "Path.",
72-
},
73-
"regex": schema.StringAttribute{
74-
Computed: true,
75-
Description: "Regex.",
76-
},
77-
"prefix_rewrite": schema.StringAttribute{
78-
Computed: true,
79-
Description: "Prefix rewrite.",
80-
},
81-
"regex_rewrite_pattern": schema.StringAttribute{
82-
Computed: true,
83-
Description: "Regex rewrite pattern.",
84-
},
85-
"regex_rewrite_substitution": schema.StringAttribute{
86-
Computed: true,
87-
Description: "Regex rewrite substitution.",
88-
},
89-
"host_rewrite": schema.StringAttribute{
90-
Computed: true,
91-
Description: "Host rewrite.",
92-
},
93-
"host_rewrite_header": schema.StringAttribute{
94-
Computed: true,
95-
Description: "Host rewrite header.",
96-
},
97-
"host_path_regex_rewrite_pattern": schema.StringAttribute{
98-
Computed: true,
99-
Description: "Host path regex rewrite pattern.",
100-
},
101-
"host_path_regex_rewrite_substitution": schema.StringAttribute{
102-
Computed: true,
103-
Description: "Host path regex rewrite substitution.",
104-
},
105-
"regex_priority_order": schema.Int64Attribute{
106-
Computed: true,
107-
Description: "Regex priority order.",
108-
},
109-
"timeout": schema.StringAttribute{
110-
Computed: true,
111-
Description: "Timeout.",
112-
CustomType: timetypes.GoDurationType{},
113-
},
114-
"idle_timeout": schema.StringAttribute{
115-
Computed: true,
116-
Description: "Idle timeout.",
117-
CustomType: timetypes.GoDurationType{},
118-
},
119-
"allow_websockets": schema.BoolAttribute{
120-
Computed: true,
121-
Description: "Allow websockets.",
122-
},
123-
"allow_spdy": schema.BoolAttribute{
124-
Computed: true,
125-
Description: "Allow SPDY.",
126-
},
127-
"tls_skip_verify": schema.BoolAttribute{
128-
Computed: true,
129-
Description: "TLS skip verify.",
130-
},
131-
"tls_upstream_server_name": schema.StringAttribute{
132-
Computed: true,
133-
Description: "TLS upstream server name.",
134-
},
135-
"tls_downstream_server_name": schema.StringAttribute{
136-
Computed: true,
137-
Description: "TLS downstream server name.",
138-
},
139-
"tls_upstream_allow_renegotiation": schema.BoolAttribute{
140-
Computed: true,
141-
Description: "TLS upstream allow renegotiation.",
142-
},
143-
"set_request_headers": schema.MapAttribute{
144-
Computed: true,
145-
ElementType: types.StringType,
146-
Description: "Set request headers.",
147-
},
148-
"remove_request_headers": schema.ListAttribute{
149-
Computed: true,
150-
ElementType: types.StringType,
151-
Description: "Remove request headers.",
152-
},
153-
"set_response_headers": schema.MapAttribute{
154-
Computed: true,
155-
ElementType: types.StringType,
156-
Description: "Set response headers.",
157-
},
158-
"preserve_host_header": schema.BoolAttribute{
159-
Computed: true,
160-
Description: "Preserve host header.",
161-
},
162-
"pass_identity_headers": schema.BoolAttribute{
163-
Computed: true,
164-
Description: "Pass identity headers.",
165-
},
166-
"kubernetes_service_account_token": schema.StringAttribute{
167-
Computed: true,
168-
Description: "Kubernetes service account token.",
169-
},
170-
"idp_client_id": schema.StringAttribute{
171-
Computed: true,
172-
Description: "IDP client ID.",
173-
},
174-
"idp_client_secret": schema.StringAttribute{
175-
Computed: true,
176-
Description: "IDP client secret.",
177-
},
178-
"show_error_details": schema.BoolAttribute{
179-
Computed: true,
180-
Description: "Show error details.",
181-
},
182-
},
186+
Attributes: getRouteDataSourceAttributes(true),
183187
}
184188
}
185189

0 commit comments

Comments
 (0)