cdl_openapi/
model_user.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
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[cfg_attr(feature = "k8s", derive(::kube::CustomResource))]
#[cfg_attr(
    feature = "k8s",
    kube(
        group = "cdl.ulagbulag.io",
        version = "v1alpha1",
        kind = "ModelUser",
        root = "ModelUserCrd",
        shortname = "mu",
        namespaced,
        printcolumn = r#"{
            "name": "created-at",
            "type": "date",
            "description": "created time",
            "jsonPath": ".metadata.creationTimestamp"
        }"#,
        printcolumn = r#"{
            "name": "version",
            "type": "integer",
            "description": "model user version",
            "jsonPath": ".metadata.generation"
        }"#,
    )
)]
#[serde(rename_all = "camelCase")]
pub struct ModelUserSpec {
    #[serde(default)]
    pub access_token: Option<ModelUserAccessTokenSpec>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub enum ModelUserAccessTokenSpec {
    SecretRef(ModelUserAccessTokenSecretRefSpec),
}

impl Default for ModelUserAccessTokenSpec {
    fn default() -> Self {
        Self::SecretRef(ModelUserAccessTokenSecretRefSpec::default())
    }
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub struct ModelUserAccessTokenSecretRefSpec {
    #[serde(default = "ModelUserAccessTokenSecretRefSpec::default_map_access_key")]
    pub map_access_key: String,
    #[serde(default = "ModelUserAccessTokenSecretRefSpec::default_map_secret_key")]
    pub map_secret_key: String,

    #[serde(default = "ModelUserAccessTokenSecretRefSpec::default_name")]
    pub name: String,
}

impl Default for ModelUserAccessTokenSecretRefSpec {
    fn default() -> Self {
        Self {
            map_access_key: Self::default_map_access_key(),
            map_secret_key: Self::default_map_secret_key(),
            name: Self::default_name(),
        }
    }
}

impl ModelUserAccessTokenSecretRefSpec {
    fn default_map_access_key() -> String {
        "CONSOLE_ACCESS_KEY".into()
    }

    fn default_map_secret_key() -> String {
        "CONSOLE_SECRET_KEY".into()
    }

    fn default_name() -> String {
        "object-storage-user-0".into()
    }
}