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)]
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    #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
29    pub skip: Option<StringOrBool>,
30}
31
32/// Full description source for DockerHub: either from a URL or a local file.
33#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
34#[serde(default)]
35pub struct DockerHubFullDescription {
36    /// Fetch full description content from a URL.
37    pub from_url: Option<DockerHubFromUrl>,
38    /// Read full description content from a local file.
39    pub from_file: Option<DockerHubFromFile>,
40}
41
42/// Fetch DockerHub full description content from a URL.
43#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
44#[serde(default)]
45pub struct DockerHubFromUrl {
46    /// URL to fetch the full description from.
47    pub url: String,
48    /// Optional HTTP headers for the request.
49    pub headers: Option<HashMap<String, String>>,
50}
51
52/// Read DockerHub full description content from a local file.
53#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
54#[serde(default)]
55pub struct DockerHubFromFile {
56    /// Path to the file containing the full description.
57    pub path: String,
58}