Skip to main content

anodizer_core/config/
upload.rs

1use std::collections::HashMap;
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use super::{ExtraFileSpec, StringOrBool, deserialize_string_or_bool_opt};
7
8// ---------------------------------------------------------------------------
9// UploadConfig (generic HTTP upload)
10// ---------------------------------------------------------------------------
11
12#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
13#[serde(default, deny_unknown_fields)]
14pub struct UploadConfig {
15    /// Human-readable name for this upload config.
16    pub name: Option<String>,
17    /// Build IDs filter: only upload artifacts whose `id` is in this list.
18    pub ids: Option<Vec<String>>,
19    /// File extension filter: only upload artifacts with these extensions.
20    pub exts: Option<Vec<String>>,
21    /// Target URL template (supports template variables like {{ ProjectName }}, {{ Version }}).
22    pub target: String,
23    /// Username for HTTP basic auth.
24    /// Resolution order: rendered `username` template → env `UPLOAD_{NAME}_USERNAME`.
25    /// Set this to a literal value or a `{{ Env.X }}` template.
26    pub username: Option<String>,
27    /// Password for HTTP basic auth.
28    ///
29    /// Strongly prefer `{{ Env.UPLOAD_PASSWORD }}` (or any other env-var
30    /// template) over an in-config literal — plaintext values here are NOT
31    /// redacted from dry-run output and will land in `dist/config.yaml`
32    /// when the pipeline runs with `--dry-run` / `--snapshot`. Resolution
33    /// order: rendered `password` template → env `UPLOAD_{NAME}_SECRET`.
34    /// Password-resolution cascade.
35    pub password: Option<String>,
36    /// HTTP method: PUT or POST (default: PUT).
37    pub method: Option<String>,
38    /// Upload mode: "archive" (default) or "binary".
39    pub mode: Option<String>,
40    /// Header name for the SHA256 checksum of the artifact.
41    pub checksum_header: Option<String>,
42    /// Path to PEM-encoded trusted CA certificates.
43    pub trusted_certificates: Option<String>,
44    /// Path to PEM-encoded client X.509 certificate for mTLS.
45    pub client_x509_cert: Option<String>,
46    /// Path to PEM-encoded client X.509 key for mTLS.
47    pub client_x509_key: Option<String>,
48    /// Include checksums in uploaded artifacts.
49    pub checksum: Option<bool>,
50    /// Include signatures in uploaded artifacts.
51    pub signature: Option<bool>,
52    /// Include metadata artifacts in uploaded artifacts.
53    pub meta: Option<bool>,
54    /// Custom HTTP headers (each value is template-expanded).
55    pub custom_headers: Option<HashMap<String, String>>,
56    /// When true, use the artifact name as-is (don't append to target URL).
57    pub custom_artifact_name: Option<bool>,
58    /// Extra files to include in uploading.
59    pub extra_files: Option<Vec<ExtraFileSpec>>,
60    /// Upload only extra files, skip normal artifacts.
61    pub extra_files_only: Option<bool>,
62    /// Skip condition template (if rendered to "true", skip this upload).
63    #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
64    pub skip: Option<StringOrBool>,
65    /// Template-conditional gate: when the rendered result is falsy
66    /// (`"false"` / `"0"` / `"no"` / empty), the upload is skipped.
67    /// Render failure hard-errors. The `uploads[].if:` conditional gate.
68    #[serde(rename = "if")]
69    pub if_condition: Option<String>,
70    /// Re-upload an artifact even when an identical one already exists at the
71    /// target path (default: `false`).
72    ///
73    /// With the default, a re-run that finds the same version's artifact
74    /// already uploaded with a matching SHA-256 records an idempotent SKIP
75    /// rather than re-PUTting it — so re-running a partially-failed release is
76    /// safe. A path that already holds a *different* artifact for the same
77    /// version still hard-errors (immutable-version drift) unless `overwrite`
78    /// is set. With `overwrite: true`, every artifact is PUT unconditionally.
79    pub overwrite: Option<bool>,
80    /// Override whether this upload failing should fail the overall release.
81    ///
82    /// Default: `false` — a failure here is logged but does not abort the
83    /// release. Set to `true` to fail the release on any error.
84    #[serde(default, skip_serializing_if = "Option::is_none")]
85    pub required: Option<bool>,
86    /// When `true`, a triggered rollback leaves this upload's artifacts in
87    /// place rather than issuing a server-side DELETE. Default `false`.
88    pub retain_on_rollback: Option<bool>,
89}