k8s_openapi/v1_35/api/core/v1/
git_repo_volume_source.rs1#[derive(Clone, Debug, Default, PartialEq)]
7pub struct GitRepoVolumeSource {
8 pub directory: Option<std::string::String>,
10
11 pub repository: std::string::String,
13
14 pub revision: Option<std::string::String>,
16}
17
18impl crate::DeepMerge for GitRepoVolumeSource {
19 fn merge_from(&mut self, other: Self) {
20 crate::DeepMerge::merge_from(&mut self.directory, other.directory);
21 crate::DeepMerge::merge_from(&mut self.repository, other.repository);
22 crate::DeepMerge::merge_from(&mut self.revision, other.revision);
23 }
24}
25
26impl<'de> crate::serde::Deserialize<'de> for GitRepoVolumeSource {
27 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
28 #[allow(non_camel_case_types)]
29 enum Field {
30 Key_directory,
31 Key_repository,
32 Key_revision,
33 Other,
34 }
35
36 impl<'de> crate::serde::Deserialize<'de> for Field {
37 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
38 struct Visitor;
39
40 impl crate::serde::de::Visitor<'_> for Visitor {
41 type Value = Field;
42
43 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
44 f.write_str("field identifier")
45 }
46
47 fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
48 Ok(match v {
49 "directory" => Field::Key_directory,
50 "repository" => Field::Key_repository,
51 "revision" => Field::Key_revision,
52 _ => Field::Other,
53 })
54 }
55 }
56
57 deserializer.deserialize_identifier(Visitor)
58 }
59 }
60
61 struct Visitor;
62
63 impl<'de> crate::serde::de::Visitor<'de> for Visitor {
64 type Value = GitRepoVolumeSource;
65
66 fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67 f.write_str("GitRepoVolumeSource")
68 }
69
70 fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
71 let mut value_directory: Option<std::string::String> = None;
72 let mut value_repository: Option<std::string::String> = None;
73 let mut value_revision: Option<std::string::String> = None;
74
75 while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
76 match key {
77 Field::Key_directory => value_directory = crate::serde::de::MapAccess::next_value(&mut map)?,
78 Field::Key_repository => value_repository = crate::serde::de::MapAccess::next_value(&mut map)?,
79 Field::Key_revision => value_revision = crate::serde::de::MapAccess::next_value(&mut map)?,
80 Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
81 }
82 }
83
84 Ok(GitRepoVolumeSource {
85 directory: value_directory,
86 repository: value_repository.unwrap_or_default(),
87 revision: value_revision,
88 })
89 }
90 }
91
92 deserializer.deserialize_struct(
93 "GitRepoVolumeSource",
94 &[
95 "directory",
96 "repository",
97 "revision",
98 ],
99 Visitor,
100 )
101 }
102}
103
104impl crate::serde::Serialize for GitRepoVolumeSource {
105 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
106 let mut state = serializer.serialize_struct(
107 "GitRepoVolumeSource",
108 1 +
109 self.directory.as_ref().map_or(0, |_| 1) +
110 self.revision.as_ref().map_or(0, |_| 1),
111 )?;
112 if let Some(value) = &self.directory {
113 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "directory", value)?;
114 }
115 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "repository", &self.repository)?;
116 if let Some(value) = &self.revision {
117 crate::serde::ser::SerializeStruct::serialize_field(&mut state, "revision", value)?;
118 }
119 crate::serde::ser::SerializeStruct::end(state)
120 }
121}
122
123#[cfg(feature = "schemars")]
124impl crate::schemars::JsonSchema for GitRepoVolumeSource {
125 fn schema_name() -> std::borrow::Cow<'static, str> {
126 "io.k8s.api.core.v1.GitRepoVolumeSource".into()
127 }
128
129 fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
130 crate::schemars::json_schema!({
131 "description": "Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling.\n\nDEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod's container.",
132 "type": "object",
133 "properties": {
134 "directory": {
135 "description": "directory is the target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.",
136 "type": "string",
137 },
138 "repository": {
139 "description": "repository is the URL",
140 "type": "string",
141 },
142 "revision": {
143 "description": "revision is the commit hash for the specified revision.",
144 "type": "string",
145 },
146 },
147 "required": [
148 "repository",
149 ],
150 })
151 }
152}