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