-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathsupported_version.rs
145 lines (133 loc) · 7.96 KB
/
supported_version.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
pub(crate) const ALL: &[SupportedVersion] = &[
SupportedVersion::V1_28,
SupportedVersion::V1_29,
SupportedVersion::V1_30,
SupportedVersion::V1_31,
SupportedVersion::V1_32,
];
#[derive(Clone, Copy, Debug)]
pub(crate) enum SupportedVersion {
V1_28,
V1_29,
V1_30,
V1_31,
V1_32,
}
impl SupportedVersion {
pub(crate) fn name(self) -> &'static str {
match self {
SupportedVersion::V1_28 => "1.28",
SupportedVersion::V1_29 => "1.29",
SupportedVersion::V1_30 => "1.30",
SupportedVersion::V1_31 => "1.31",
SupportedVersion::V1_32 => "1.32",
}
}
pub(crate) fn mod_root(self) -> &'static str {
match self {
SupportedVersion::V1_28 => "v1_28",
SupportedVersion::V1_29 => "v1_29",
SupportedVersion::V1_30 => "v1_30",
SupportedVersion::V1_31 => "v1_31",
SupportedVersion::V1_32 => "v1_32",
}
}
pub(crate) fn spec_url(self) -> &'static str {
match self {
SupportedVersion::V1_28 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.28.15/api/openapi-spec/swagger.json",
SupportedVersion::V1_29 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.29.15/api/openapi-spec/swagger.json",
SupportedVersion::V1_30 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.30.11/api/openapi-spec/swagger.json",
SupportedVersion::V1_31 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.31.7/api/openapi-spec/swagger.json",
SupportedVersion::V1_32 => "https://raw.githubusercontent.com/kubernetes/kubernetes/v1.32.3/api/openapi-spec/swagger.json",
}
}
pub(crate) fn fixup(self, spec: &mut crate::swagger20::Spec) -> Result<(), crate::Error> {
#[allow(clippy::match_same_arms, clippy::type_complexity)]
let upstream_bugs_fixups: &[fn(&mut crate::swagger20::Spec) -> Result<(), crate::Error>] = match self {
SupportedVersion::V1_28 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::config_map_env_source,
crate::fixups::upstream_bugs::required_properties::config_map_key_selector,
crate::fixups::upstream_bugs::required_properties::config_map_projection,
crate::fixups::upstream_bugs::required_properties::config_map_volume_source,
crate::fixups::upstream_bugs::required_properties::host_alias,
crate::fixups::upstream_bugs::required_properties::host_ip,
crate::fixups::upstream_bugs::required_properties::local_object_reference,
crate::fixups::upstream_bugs::required_properties::pod_ip,
crate::fixups::upstream_bugs::required_properties::secret_env_source,
crate::fixups::upstream_bugs::required_properties::secret_key_selector,
crate::fixups::upstream_bugs::required_properties::secret_projection,
crate::fixups::upstream_bugs::pod_scheduling_context_spec_potential_nodes_merge_strategy,
crate::fixups::upstream_bugs::status_extra_gvk,
crate::fixups::upstream_bugs::v1alpha2_resource_claim_scheduling_status_unsuitable_nodes_merge_strategy,
],
SupportedVersion::V1_29 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::config_map_env_source,
crate::fixups::upstream_bugs::required_properties::config_map_key_selector,
crate::fixups::upstream_bugs::required_properties::config_map_projection,
crate::fixups::upstream_bugs::required_properties::config_map_volume_source,
crate::fixups::upstream_bugs::required_properties::host_alias,
crate::fixups::upstream_bugs::required_properties::host_ip,
crate::fixups::upstream_bugs::required_properties::local_object_reference,
crate::fixups::upstream_bugs::required_properties::pod_ip,
crate::fixups::upstream_bugs::required_properties::secret_env_source,
crate::fixups::upstream_bugs::required_properties::secret_key_selector,
crate::fixups::upstream_bugs::required_properties::secret_projection,
crate::fixups::upstream_bugs::status_extra_gvk,
],
SupportedVersion::V1_30 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::config_map_env_source,
crate::fixups::upstream_bugs::required_properties::config_map_key_selector,
crate::fixups::upstream_bugs::required_properties::config_map_projection,
crate::fixups::upstream_bugs::required_properties::config_map_volume_source,
crate::fixups::upstream_bugs::required_properties::local_object_reference,
crate::fixups::upstream_bugs::required_properties::secret_env_source,
crate::fixups::upstream_bugs::required_properties::secret_key_selector,
crate::fixups::upstream_bugs::required_properties::secret_projection,
crate::fixups::upstream_bugs::status_extra_gvk,
],
SupportedVersion::V1_31 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::config_map_env_source,
crate::fixups::upstream_bugs::required_properties::config_map_key_selector,
crate::fixups::upstream_bugs::required_properties::config_map_projection,
crate::fixups::upstream_bugs::required_properties::config_map_volume_source,
crate::fixups::upstream_bugs::required_properties::local_object_reference,
crate::fixups::upstream_bugs::required_properties::secret_env_source,
crate::fixups::upstream_bugs::required_properties::secret_key_selector,
crate::fixups::upstream_bugs::required_properties::secret_projection,
],
SupportedVersion::V1_32 => &[
crate::fixups::upstream_bugs::connect_options_gvk,
crate::fixups::upstream_bugs::optional_properties::eventsv1_event,
crate::fixups::upstream_bugs::required_properties::config_map_env_source,
crate::fixups::upstream_bugs::required_properties::config_map_key_selector,
crate::fixups::upstream_bugs::required_properties::config_map_projection,
crate::fixups::upstream_bugs::required_properties::config_map_volume_source,
crate::fixups::upstream_bugs::required_properties::local_object_reference,
crate::fixups::upstream_bugs::required_properties::secret_env_source,
crate::fixups::upstream_bugs::required_properties::secret_key_selector,
crate::fixups::upstream_bugs::required_properties::secret_projection,
],
};
let special_fixups = &[
crate::fixups::special::json_ty::json_schema_props_or_array,
crate::fixups::special::json_ty::json_schema_props_or_bool,
crate::fixups::special::json_ty::json_schema_props_or_string_array,
crate::fixups::special::patch,
crate::fixups::special::watch_event,
crate::fixups::special::list,
crate::fixups::special::resource_metadata_not_optional,
];
for fixup in upstream_bugs_fixups.iter().chain(special_fixups) {
fixup(spec)?;
}
Ok(())
}
}