Skip to main content

anodizer_core/config/
blob.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::{
5    ExtraFileSpec, StringOrBool, TemplatedExtraFile, deserialize_string_or_bool_opt,
6    deserialize_string_or_vec_opt,
7};
8
9// ---------------------------------------------------------------------------
10// BlobConfig (S3/GCS/Azure cloud storage)
11// ---------------------------------------------------------------------------
12
13#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
14#[serde(default, deny_unknown_fields)]
15pub struct BlobConfig {
16    /// Unique identifier for this blob config.
17    pub id: Option<String>,
18    /// Cloud storage provider: s3, gcs (or gs), or azblob (or azure).
19    pub provider: String,
20    /// Bucket or container name (supports templates).
21    pub bucket: String,
22    /// Directory/folder within the bucket (supports templates).
23    /// Default: `{{ ProjectName }}/{{ Tag }}`.
24    pub directory: Option<String>,
25    /// AWS region (S3 only).
26    pub region: Option<String>,
27    /// Custom endpoint URL for S3-compatible storage (e.g. MinIO, R2, DO Spaces).
28    pub endpoint: Option<String>,
29    /// Disable SSL for the connection (S3 only, default: false).
30    pub disable_ssl: Option<bool>,
31    /// Enable path-style addressing for S3-compatible backends.
32    /// Defaults to `true` when `endpoint` is set (MinIO, R2, DO Spaces need this),
33    /// `false` otherwise (standard AWS virtual-hosted style).
34    pub s3_force_path_style: Option<bool>,
35    /// Canned ACL for uploaded objects.
36    /// **S3**: one of `private` (default), `public-read`, `public-read-write`,
37    /// `authenticated-read`, `aws-exec-read`, `bucket-owner-read`,
38    /// `bucket-owner-full-control`. The accepted ACL set;
39    /// AWS's `log-delivery-write` is intentionally omitted because it is only
40    /// valid on `S3LogBucket` targets and would silently fail on a normal bucket.
41    /// **GCS**: pass the camelCase predefined-ACL name (e.g. `publicRead`,
42    /// `bucketOwnerFullControl`); not validated up-front, so a typo surfaces
43    /// as a 400 from the GCS API at upload time.
44    pub acl: Option<String>,
45    /// HTTP Cache-Control header values, joined with ", " when uploading.
46    /// Accepts a string (single value) or array of strings in YAML.
47    #[serde(deserialize_with = "deserialize_string_or_vec_opt", default)]
48    pub cache_control: Option<Vec<String>>,
49    /// HTTP Content-Disposition header (supports templates).
50    /// Default: `"attachment;filename={{Filename}}"`. Set to `"-"` to disable.
51    pub content_disposition: Option<String>,
52    /// AWS KMS encryption key for server-side encryption (S3 only).
53    pub kms_key: Option<String>,
54    /// Build IDs to include. Empty means all artifacts.
55    pub ids: Option<Vec<String>>,
56    /// Glob patterns matched against each artifact's file name; anodizer drops
57    /// any artifact whose name matches at least one glob from THIS blob target
58    /// only (other destinations are unaffected). Use it to keep heavy sidecars
59    /// off a mirror — e.g. checksums, signatures, and SBOMs — while archives
60    /// still upload. Composes with `ids:` (both filters apply). `None`/empty
61    /// keeps everything.
62    ///
63    /// ```yaml
64    /// blobs:
65    ///   - provider: s3
66    ///     bucket: my-mirror
67    ///     exclude: ["*.sha256", "*.sig", "*.cdx.json"]
68    /// ```
69    #[serde(default, skip_serializing_if = "Option::is_none")]
70    pub exclude: Option<Vec<String>>,
71    /// Skip this blob config. Accepts bool or template string
72    /// (e.g. `"{{ if IsSnapshot }}true{{ endif }}"` for conditional skip).
73    /// Accepts the legacy `disable:` spelling via serde alias for back-compat.
74    #[serde(
75        alias = "disable",
76        deserialize_with = "deserialize_string_or_bool_opt",
77        default
78    )]
79    pub skip: Option<StringOrBool>,
80    /// Also upload `dist/metadata.json`. The sibling `dist/artifacts.json`
81    /// manifest is never uploaded — it stays local to the dist directory.
82    pub include_meta: Option<bool>,
83    /// Pre-existing files to upload (supports glob patterns).
84    pub extra_files: Option<Vec<ExtraFileSpec>>,
85    /// Extra files whose contents are rendered through the template engine before upload.
86    /// Unlike `extra_files` which copy as-is, template variables like `{{ Tag }}` are expanded.
87    pub templated_extra_files: Option<Vec<TemplatedExtraFile>>,
88    /// Upload only extra files (skip artifacts).
89    pub extra_files_only: Option<bool>,
90    /// Maximum number of parallel uploads for this blob config.
91    /// Overrides the global `--parallelism` setting when set.
92    pub parallelism: Option<usize>,
93    /// When `true`, a failed blob upload counts as a required-publisher
94    /// failure: trips the submitter gate (chocolatey/winget/snapcraft/aur
95    /// don't run if blob failed) and surfaces in
96    /// `report.required_failures()` so the CLI exits non-zero.
97    ///
98    /// Default: `false`. Snapshot release pipelines typically don't
99    /// require blobs; production pipelines that ship binaries via S3/GCS
100    /// often do.
101    ///
102    /// When multiple blob configs exist, the blob stage records ONE
103    /// aggregated `PublisherResult`: `required = true` if ANY config opted
104    /// in. Same semantics as "any required blob target failing should
105    /// fail the release."
106    pub required: Option<bool>,
107    /// Template-conditional gate: when the rendered result is falsy
108    /// (`"false"` / `"0"` / `"no"` / empty), the blob config is skipped.
109    /// Render failure hard-errors. The `blobs[].if:` conditional gate.
110    #[serde(rename = "if")]
111    pub if_condition: Option<String>,
112    /// When `true`, a triggered rollback leaves this publisher's work in
113    /// place rather than attempting to undo it. Default `false`.
114    pub retain_on_rollback: Option<bool>,
115}