Skip to content

Commit 6eb5d01

Browse files
committed
Removing comments from enum files
Signed-off-by: Dawid Nowak <[email protected]>
1 parent b1f8ecd commit 6eb5d01

File tree

5 files changed

+14
-75
lines changed

5 files changed

+14
-75
lines changed

gateway-api/src/apis/experimental/common.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,13 @@ mod prelude {
99
pub use std::collections::BTreeMap;
1010
}
1111
use self::prelude::*;
12-
/// GRPCRouteFilter defines processing steps that must be completed during the
13-
/// request or response lifecycle. GRPCRouteFilters are meant as an extension
14-
/// point to express processing that may be done in Gateway implementations. Some
15-
/// examples include request or response modification, implementing
16-
/// authentication strategies, rate-limiting, and traffic shaping. API
17-
/// guarantee/conformance is defined based on the type of the filter.
1812
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1913
pub enum GRPCFilterType {
2014
ResponseHeaderModifier,
2115
RequestHeaderModifier,
2216
RequestMirror,
2317
ExtensionRef,
2418
}
25-
/// HTTPRouteFilter defines processing steps that must be completed during the
26-
/// request or response lifecycle. HTTPRouteFilters are meant as an extension
27-
/// point to express processing that may be done in Gateway implementations. Some
28-
/// examples include request or response modification, implementing
29-
/// authentication strategies, rate-limiting, and traffic shaping. API
30-
/// guarantee/conformance is defined based on the type of the filter.
3119
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3220
pub enum HTTPFilterType {
3321
RequestHeaderModifier,
@@ -38,60 +26,35 @@ pub enum HTTPFilterType {
3826
UrlRewrite,
3927
ExtensionRef,
4028
}
41-
/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
42-
/// headers.
4329
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
4430
pub enum HeaderMatchType {
4531
Exact,
4632
RegularExpression,
4733
}
48-
/// CookieConfig provides configuration settings that are specific
49-
/// to cookie-based session persistence.
50-
///
51-
/// Support: Core
5234
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
5335
pub enum PersistenceCookieConfigLifetime {
5436
Permanent,
5537
Session,
5638
}
57-
/// RequestRedirect defines a schema for a filter that responds to the
58-
/// request with an HTTP redirection.
59-
///
60-
/// Support: Core
6139
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
6240
pub enum RedirectStatusCode {
6341
#[serde(rename = "301")]
6442
r#_301,
6543
#[serde(rename = "302")]
6644
r#_302,
6745
}
68-
/// Path defines parameters used to modify the path of the incoming request.
69-
/// The modified path is then used to construct the `Location` header. When
70-
/// empty, the request path is used as-is.
71-
///
72-
/// Support: Extended
7346
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
7447
pub enum RequestOperationType {
7548
ReplaceFullPath,
7649
ReplacePrefixMatch,
7750
}
78-
/// RequestRedirect defines a schema for a filter that responds to the
79-
/// request with an HTTP redirection.
80-
///
81-
/// Support: Core
8251
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
8352
pub enum RequestRedirectScheme {
8453
#[serde(rename = "http")]
8554
Http,
8655
#[serde(rename = "https")]
8756
Https,
8857
}
89-
/// SessionPersistence defines and configures session persistence
90-
/// for the route rule.
91-
///
92-
/// Support: Extended
93-
///
94-
///
9558
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
9659
pub enum SessionPersistenceType {
9760
Cookie,

gateway-api/src/apis/standard/common.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,13 @@ mod prelude {
99
pub use std::collections::BTreeMap;
1010
}
1111
use self::prelude::*;
12-
/// GRPCRouteFilter defines processing steps that must be completed during the
13-
/// request or response lifecycle. GRPCRouteFilters are meant as an extension
14-
/// point to express processing that may be done in Gateway implementations. Some
15-
/// examples include request or response modification, implementing
16-
/// authentication strategies, rate-limiting, and traffic shaping. API
17-
/// guarantee/conformance is defined based on the type of the filter.
1812
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
1913
pub enum GRPCFilterType {
2014
ResponseHeaderModifier,
2115
RequestHeaderModifier,
2216
RequestMirror,
2317
ExtensionRef,
2418
}
25-
/// HTTPRouteFilter defines processing steps that must be completed during the
26-
/// request or response lifecycle. HTTPRouteFilters are meant as an extension
27-
/// point to express processing that may be done in Gateway implementations. Some
28-
/// examples include request or response modification, implementing
29-
/// authentication strategies, rate-limiting, and traffic shaping. API
30-
/// guarantee/conformance is defined based on the type of the filter.
3119
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
3220
pub enum HTTPFilterType {
3321
RequestHeaderModifier,
@@ -38,38 +26,23 @@ pub enum HTTPFilterType {
3826
UrlRewrite,
3927
ExtensionRef,
4028
}
41-
/// GRPCHeaderMatch describes how to select a gRPC route by matching gRPC request
42-
/// headers.
4329
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
4430
pub enum HeaderMatchType {
4531
Exact,
4632
RegularExpression,
4733
}
48-
/// RequestRedirect defines a schema for a filter that responds to the
49-
/// request with an HTTP redirection.
50-
///
51-
/// Support: Core
5234
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
5335
pub enum RedirectStatusCode {
5436
#[serde(rename = "301")]
5537
r#_301,
5638
#[serde(rename = "302")]
5739
r#_302,
5840
}
59-
/// Path defines parameters used to modify the path of the incoming request.
60-
/// The modified path is then used to construct the `Location` header. When
61-
/// empty, the request path is used as-is.
62-
///
63-
/// Support: Extended
6441
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
6542
pub enum RequestOperationType {
6643
ReplaceFullPath,
6744
ReplacePrefixMatch,
6845
}
69-
/// RequestRedirect defines a schema for a filter that responds to the
70-
/// request with an HTTP redirection.
71-
///
72-
/// Support: Core
7346
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq)]
7447
pub enum RequestRedirectScheme {
7548
#[serde(rename = "http")]

type-reducer/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub fn write_type_names_to_file(
9595
Ok(())
9696
}
9797

98-
pub fn delete_replaced_structs(file: File, type_names: Vec<String>) -> File {
98+
pub fn delete_replaced_types(file: File, type_names: Vec<String>) -> File {
9999
let File {
100100
shebang,
101101
attrs,
@@ -179,7 +179,7 @@ pub fn find_similar_types(
179179
}
180180
}
181181

182-
pub fn prune_replaced_structs(
182+
pub fn prune_replaced_types(
183183
renaming_visitor: &mut StructEnumFieldsRenamer,
184184
visitors: Vec<(String, File)>,
185185
) -> Vec<(String, String, bool)> {
@@ -189,7 +189,7 @@ pub fn prune_replaced_structs(
189189
renaming_visitor.changed = false;
190190
renaming_visitor.visit_file_mut(&mut f);
191191
let new_file =
192-
delete_replaced_structs(f, renaming_visitor.names.keys().cloned().collect());
192+
delete_replaced_types(f, renaming_visitor.names.keys().cloned().collect());
193193
(
194194
name,
195195
prettyplease::unparse(&new_file),
@@ -303,5 +303,11 @@ pub fn create_common_type_struct(s: &ItemStruct, type_new_name: &str) -> ItemStr
303303
pub fn create_common_type_enum(s: &ItemEnum, type_new_name: &str) -> ItemEnum {
304304
let mut new_enum = s.clone();
305305
new_enum.ident = Ident::new(type_new_name, Span::call_site());
306+
new_enum.attrs = s
307+
.attrs
308+
.iter()
309+
.filter(|&a| a.meta.path().get_ident() != Some(&Ident::new("doc", Span::call_site())))
310+
.cloned()
311+
.collect();
306312
new_enum
307313
}

type-reducer/src/main.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ fn handle_reduce_types(
140140
return None;
141141
}
142142

143-
// let type_new_name =
144-
// create_struct_type_name_substitute(&current_pass_type_name_substitutes, v);
145-
146143
if let Some((i, s)) = v.first() {
147144
let new_struct = create_common_type_struct(
148145
s,
@@ -176,9 +173,6 @@ fn handle_reduce_types(
176173
);
177174
let mapped_type_names = v.iter().map(|v| v.0.to_string()).collect::<Vec<_>>();
178175

179-
// let type_new_name =
180-
// create_enum_type_name_substitute(&current_pass_type_name_substitutes, v);
181-
182176
if let Some((i, s)) = v.first() {
183177
let new_enum = create_common_type_enum(
184178
s,
@@ -212,7 +206,7 @@ fn handle_reduce_types(
212206

213207
write_type_names_to_file(&renaming_visitor.names)?;
214208

215-
let unparsed_files = prune_replaced_structs(&mut renaming_visitor, visitors);
209+
let unparsed_files = prune_replaced_types(&mut renaming_visitor, visitors);
216210

217211
recreate_project_files(
218212
out_dir,

update.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,7 @@ sed -i '/#\[kube(status = "GRPCRouteStatus")\]/c\#\[kube(status = "RouteStatus")
201201
sed -i '/#\[kube(status = "HTTPRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/httproutes.rs
202202
sed -i '/#\[kube(status = "TLSRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tlsroutes.rs
203203
sed -i '/#\[kube(status = "UDPRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/udproutes.rs
204-
sed -i '/#\[kube(status = "TCPRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs
204+
sed -i '/#\[kube(status = "TCPRouteStatus")\]/c\#\[kube(status = "RouteStatus")\]' $APIS_DIR/experimental/tcproutes.rs
205+
206+
207+
cargo fmt

0 commit comments

Comments
 (0)