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. Exposes the `dockerhub[].if:`
45    /// conditional gate; distinct from `skip:` (which expresses "always
46    /// skip") and provides config-import parity.
47    #[serde(rename = "if")]
48    pub if_condition: Option<String>,
49    /// When `true`, a triggered rollback leaves this publisher's work in
50    /// place rather than attempting to undo it. Default `false`.
51    pub retain_on_rollback: Option<bool>,
52}
53
54/// Full description source for DockerHub: either from a URL or a local file.
55#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
56#[serde(default, deny_unknown_fields)]
57pub struct DockerHubFullDescription {
58    /// Fetch full description content from a URL.
59    pub from_url: Option<DockerHubFromUrl>,
60    /// Read full description content from a local file.
61    pub from_file: Option<DockerHubFromFile>,
62}
63
64/// Fetch DockerHub full description content from a URL.
65#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
66#[serde(default, deny_unknown_fields)]
67pub struct DockerHubFromUrl {
68    /// URL to fetch the full description from.
69    pub url: String,
70    /// Optional HTTP headers for the request.
71    pub headers: Option<HashMap<String, String>>,
72}
73
74/// Read DockerHub full description content from a local file.
75#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
76#[serde(default, deny_unknown_fields)]
77pub struct DockerHubFromFile {
78    /// Path to the file containing the full description.
79    pub path: String,
80}