Skip to content

Commit fbcb301

Browse files
committed
make enum untagged: corrected
1 parent d14cc6a commit fbcb301

3 files changed

Lines changed: 36 additions & 56 deletions

File tree

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,38 +89,28 @@ spec:
8989
nullable: true
9090
oneOf:
9191
- required:
92-
- basicAuth
92+
- basicAuthSecretName
9393
- required:
94-
- ssh
94+
- sshPrivateKeySecretName
9595
properties:
96-
basicAuth:
97-
properties:
98-
basicAuthSecretName:
99-
description: |-
100-
The name of the Secret used to access the repository via Basic Authentication if it is not public.
96+
basicAuthSecretName:
97+
description: |-
98+
The name of the Secret used to access the repository via Basic Authentication if it is not public.
10199
102-
The referenced Secret must include two fields: `user` and `password`.
103-
The `password` field can either be an actual password (not recommended) or a GitHub token,
104-
as described in the git-sync [documentation].
100+
The referenced Secret must include two fields: `user` and `password`.
101+
The `password` field can either be an actual password (not recommended) or a GitHub token,
102+
as described in the git-sync [documentation].
105103
106-
[documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
107-
type: string
108-
required:
109-
- basicAuthSecretName
110-
type: object
111-
ssh:
112-
properties:
113-
sshPrivateKeySecretName:
114-
description: |-
115-
The name of the Secret used for SSH access to the repository.
104+
[documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
105+
type: string
106+
sshPrivateKeySecretName:
107+
description: |-
108+
The name of the Secret used for SSH access to the repository.
116109
117-
The referenced Secret must include two fields: `key` and `knownHosts`.
110+
The referenced Secret must include two fields: `key` and `knownHosts`.
118111
119-
[documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
120-
type: string
121-
required:
122-
- sshPrivateKeySecretName
123-
type: object
112+
[documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
113+
type: string
124114
type: object
125115
depth:
126116
default: 1

crates/stackable-operator/src/crd/git_sync/mod.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,19 @@ pub mod versioned {
6363
#[serde(rename_all = "camelCase")]
6464
#[schemars(rename_all = "camelCase")]
6565
pub enum Credentials {
66-
BasicAuth {
67-
/// The name of the Secret used to access the repository via Basic Authentication if it is not public.
68-
///
69-
/// The referenced Secret must include two fields: `user` and `password`.
70-
/// The `password` field can either be an actual password (not recommended) or a GitHub token,
71-
/// as described in the git-sync [documentation].
72-
///
73-
/// [documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
74-
#[serde(rename = "basicAuthSecretName")]
75-
#[schemars(rename = "basicAuthSecretName")]
76-
basic_auth_secret_name: String,
77-
},
78-
Ssh {
79-
/// The name of the Secret used for SSH access to the repository.
80-
///
81-
/// The referenced Secret must include two fields: `key` and `knownHosts`.
82-
///
83-
/// [documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
84-
#[serde(rename = "sshPrivateKeySecretName")]
85-
#[schemars(rename = "sshPrivateKeySecretName")]
86-
ssh_private_key_secret_name: String,
87-
},
66+
/// The name of the Secret used to access the repository via Basic Authentication if it is not public.
67+
///
68+
/// The referenced Secret must include two fields: `user` and `password`.
69+
/// The `password` field can either be an actual password (not recommended) or a GitHub token,
70+
/// as described in the git-sync [documentation].
71+
///
72+
/// [documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
73+
BasicAuthSecretName(String),
74+
/// The name of the Secret used for SSH access to the repository.
75+
///
76+
/// The referenced Secret must include two fields: `key` and `knownHosts`.
77+
///
78+
/// [documentation]: https://github.com/kubernetes/git-sync/tree/v4.2.4?tab=readme-ov-file#manual
79+
SshPrivateKeySecretName(String),
8880
}
8981
}

crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ impl GitSyncResources {
116116
for (i, git_sync) in git_syncs.iter().enumerate() {
117117
let mut env_vars = vec![];
118118

119-
if let Some(Credentials::BasicAuth {
120-
basic_auth_secret_name,
121-
}) = &git_sync.credentials
119+
if let Some(Credentials::BasicAuthSecretName(basic_auth_secret_name)) =
120+
&git_sync.credentials
122121
{
123122
env_vars.push(GitSyncResources::env_var_from_secret(
124123
"GITSYNC_USERNAME",
@@ -131,7 +130,7 @@ impl GitSyncResources {
131130
"password",
132131
));
133132
}
134-
if let Some(Credentials::Ssh { .. }) = git_sync.credentials {
133+
if let Some(Credentials::SshPrivateKeySecretName { .. }) = git_sync.credentials {
135134
env_vars.push(EnvVar {
136135
name: "GITSYNC_SSH_KEY_FILE".to_owned(),
137136
value: Some(format!("{SSH_MOUNT_PATH_PREFIX}-{i}/key").to_owned()),
@@ -166,7 +165,7 @@ impl GitSyncResources {
166165

167166
git_sync_container_volume_mounts.extend_from_slice(extra_volume_mounts);
168167

169-
if matches!(git_sync.credentials, Some(Credentials::Ssh { .. })) {
168+
if let Some(Credentials::SshPrivateKeySecretName(_)) = git_sync.credentials {
170169
let ssh_mount_path = format!("{SSH_MOUNT_PATH_PREFIX}-{i}");
171170
let ssh_volume_name = format!("{SSH_VOLUME_NAME_PREFIX}-{i}");
172171

@@ -221,9 +220,8 @@ impl GitSyncResources {
221220
.push(git_content_volume_mount);
222221
resources.git_content_folders.push(git_content_folder);
223222

224-
if let Some(Credentials::Ssh {
225-
ssh_private_key_secret_name,
226-
}) = &git_sync.credentials
223+
if let Some(Credentials::SshPrivateKeySecretName(ssh_private_key_secret_name)) =
224+
&git_sync.credentials
227225
{
228226
let ssh_volume_name = format!("{SSH_VOLUME_NAME_PREFIX}-{i}");
229227

0 commit comments

Comments
 (0)