Skip to main content

anodizer_core/config/
dockerhub.rs

1use std::collections::HashMap;
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use super::{StringOrBool, deserialize_string_or_bool_opt};
7
8// ---------------------------------------------------------------------------
9// DockerHub description sync
10// ---------------------------------------------------------------------------
11
12/// DockerHub description sync configuration.
13/// Pushes image descriptions and README content to DockerHub repositories.
14#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
15#[serde(default, deny_unknown_fields)]
16pub struct DockerHubConfig {
17    /// DockerHub username for authentication.
18    pub username: Option<String>,
19    /// Environment variable name containing the DockerHub token.
20    pub secret_name: Option<String>,
21    /// DockerHub image names to update (e.g. `myorg/myapp`).
22    pub images: Option<Vec<String>>,
23    /// Short description for the DockerHub repository (max 100 chars).
24    pub description: Option<String>,
25    /// Full description (README) source for the DockerHub repository.
26    pub full_description: Option<DockerHubFullDescription>,
27    /// Skip this publisher. Accepts bool or template string.
28    /// Accepts the legacy `disable:` spelling via serde alias for back-compat
29    /// with imported configs (the legacy `disable:` spelling).
30    #[serde(
31        deserialize_with = "deserialize_string_or_bool_opt",
32        default,
33        alias = "disable"
34    )]
35    pub skip: Option<StringOrBool>,
36    /// Override whether this publisher failing should fail the overall release.
37    ///
38    /// Default: `false` — a failure here is logged but does not abort the release.
39    /// Set to `true` to fail the release on any error.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub required: Option<bool>,
42    /// Template-conditional gate: when the rendered result is falsy
43    /// (`"false"` / `"0"` / `"no"` / empty), the DockerHub publisher is
44    /// skipped. Render failure hard-errors. The
45    /// `dockerhub[].if:`.
46    #[serde(rename = "if")]
47    pub if_condition: Option<String>,
48}
49
50/// Full description source for DockerHub: either from a URL or a local file.
51#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
52#[serde(default, deny_unknown_fields)]
53pub struct DockerHubFullDescription {
54    /// Fetch full description content from a URL.
55    pub from_url: Option<DockerHubFromUrl>,
56    /// Read full description content from a local file.
57    pub from_file: Option<DockerHubFromFile>,
58}
59
60/// Fetch DockerHub full description content from a URL.
61#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
62#[serde(default, deny_unknown_fields)]
63pub struct DockerHubFromUrl {
64    /// URL to fetch the full description from.
65    pub url: String,
66    /// Optional HTTP headers for the request.
67    pub headers: Option<HashMap<String, String>>,
68}
69
70/// Read DockerHub full description content from a local file.
71#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
72#[serde(default, deny_unknown_fields)]
73pub struct DockerHubFromFile {
74    /// Path to the file containing the full description.
75    pub path: String,
76}