xianyun_deploy/deployer/helm/mod.rs
1//! Helm chart deployer.
2//!
3//! Ported from `internal/deployer/helm`.
4
5pub mod chartdeps;
6pub mod chartresolve;
7pub mod chartsource;
8pub mod manager;
9pub mod overrider;
10
11#[cfg(test)]
12pub(crate) mod httpfixture;
13#[cfg(test)]
14pub(crate) mod test_support;
15
16use thiserror::Error;
17
18/// Errors used across this module, ported from the `Err*` sentinels declared
19/// at the top of `manager.go`. Only the sentinels this session's submodules
20/// (`chartdeps`, `chartresolve`, `chartsource`, `overrider`) actually raise
21/// are ported so far; `manager.go`'s remaining sentinels
22/// (`ErrNotHelmDeployer`, `ErrRepositoryNotFound`, `ErrValuesFileNotFound`,
23/// `ErrMissingRepository`, `ErrMissingVersionMap`, `ErrMissingRelease`,
24/// `ErrVersionRequiresRepository`) are deferred to when `deployer::helm::manager`
25/// itself is implemented -- see `PORT_NOTES.md`.
26#[derive(Debug, Error)]
27pub enum HelmError {
28 /// The deployer config's type is not `"helm"`, or it has no `helm`
29 /// block, when a helm-specific operation was attempted.
30 #[error("deployer is not a helm deployer")]
31 NotHelmDeployer,
32
33 /// A repository referenced by a deployer (via `deployerConfig.repository`)
34 /// is not found in `caproniConfig.repositories`.
35 #[error("repository {0}: repository not found")]
36 RepositoryNotFound(String),
37
38 /// A referenced values file doesn't exist.
39 #[error("values file not found: {0}")]
40 ValuesFileNotFound(String),
41
42 /// `repository` is missing for a `gitlab_repo_version_files` override.
43 #[error("repository is required for gitlab_repo_version_files override")]
44 MissingRepository,
45
46 /// `version_map` is missing or the file it names doesn't exist.
47 #[error("version_map is required or not found: {0}")]
48 MissingVersionMap(String),
49
50 /// `helm.release` is required but not configured.
51 #[error("helm.release is required when not using edit mode with a repository")]
52 MissingRelease,
53
54 /// `release.version` is set without `helm.repository`.
55 #[error("helm.release.version requires helm.repository to be configured")]
56 VersionRequiresRepository,
57
58 /// No chart found in the directory helm unpacked into.
59 #[error("no chart found in the unpacked archive: {0}")]
60 ChartNotUnpacked(String),
61
62 /// More than one chart found in the directory helm unpacked into.
63 #[error("more than one chart found in the unpacked archive: {0}")]
64 AmbiguousUnpackedChart(String),
65
66 /// Dynamic overrides configured with a type not yet supported.
67 #[error("dynamic overrides are not yet implemented: type {0:?}")]
68 DynamicOverridesNotImplemented(String),
69
70 /// Dynamic override configured with an unrecognized type.
71 #[error("unknown dynamic override type: {0:?}")]
72 UnknownDynamicOverrideType(String),
73
74 /// `version_map` is empty.
75 #[error("version_map is empty: {0}")]
76 EmptyVersionMap(String),
77
78 /// An inline `value_map` entry is not a scalar, list, or map.
79 #[error(
80 "inline value_map values must be a string, number, boolean, list, or map: key {0:?} has type {1}"
81 )]
82 UnsupportedInlineValueType(String, &'static str),
83
84 /// An `inline_file` `value_map` entry is not a string (file path).
85 #[error("inline_file value_map values must be a string (file path): key {0:?} has type {1}")]
86 UnsupportedInlineFileValueType(String, &'static str),
87
88 /// A Helm key path contains an empty segment.
89 #[error("helm key path has an empty segment: {0:?}")]
90 InvalidHelmKey(String),
91
92 /// A Helm key path traverses a value that is not a map.
93 #[error("helm key path conflicts with an earlier scalar value: {0:?}")]
94 ConflictingHelmKey(String),
95
96 /// Failure reading or writing a chart file, or parsing a chart's
97 /// `Chart.lock`, `helm repo list -o json`, or a `version_map` file.
98 #[error("{0}")]
99 Io(String),
100
101 /// A helm backend call failed. `context` carries the same
102 /// human-readable prefix Go's `fmt.Errorf("...: %w", err)` calls used.
103 #[error("{context}: {source}")]
104 Backend {
105 context: String,
106 #[source]
107 source: xianyun_executor::exec::ExecError,
108 },
109}