helm_rs/command/release/options.rs
1//! The value types of the flags several release commands share.
2
3/// The `--dry-run` strategies (`addDryRunFlag`, `pkg/cmd/helpers.go`). The bare `--dry-run` and
4/// the boolean forms are deprecated legacy spellings of [`DryRun::Client`] and [`DryRun::None`]
5/// and are not modelled.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum DryRun {
8 /// `none`: run for real (Helm's default).
9 None,
10 /// `client`: render and simulate without contacting the cluster.
11 Client,
12 /// `server`: simulate on the API server, which needs a cluster connection.
13 Server,
14}
15
16impl DryRun {
17 /// The flag value.
18 #[must_use]
19 pub fn as_str(self) -> &'static str {
20 match self {
21 Self::None => "none",
22 Self::Client => "client",
23 Self::Server => "server",
24 }
25 }
26}
27
28/// The `--wait` strategies (`waitValue`, `pkg/cmd/flags.go`). Helm's default when the flag is
29/// omitted is `hookOnly`; the bare `--wait` means `watcher`, so the CLI backend always writes the
30/// explicit `--wait=<strategy>` form.
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32pub enum WaitStrategy {
33 /// `watcher`: wait until every resource reports ready, using status watchers.
34 Watcher,
35 /// `hookOnly`: wait for hooks only, not for the release's resources.
36 HookOnly,
37 /// `legacy`: the Helm 3 polling wait.
38 Legacy,
39}
40
41impl WaitStrategy {
42 /// The flag value.
43 #[must_use]
44 pub fn as_str(self) -> &'static str {
45 match self {
46 Self::Watcher => "watcher",
47 Self::HookOnly => "hookOnly",
48 Self::Legacy => "legacy",
49 }
50 }
51}
52
53/// The `--server-side` choice of `upgrade` and `rollback` (a string flag there; `install` has a
54/// plain boolean instead).
55#[derive(Debug, Clone, Copy, PartialEq, Eq)]
56pub enum ServerSide {
57 /// `auto`: take the method of the previous release (Helm's default).
58 Auto,
59 /// `true`: apply objects on the server.
60 Enabled,
61 /// `false`: apply objects on the client.
62 Disabled,
63}
64
65impl ServerSide {
66 /// The flag value.
67 #[must_use]
68 pub fn as_str(self) -> &'static str {
69 match self {
70 Self::Auto => "auto",
71 Self::Enabled => "true",
72 Self::Disabled => "false",
73 }
74 }
75}
76
77/// How to resolve a conflict with live objects. Helm rejects `--force-replace` together with
78/// `--force-conflicts`, so the two are one choice.
79#[derive(Debug, Clone, Copy, PartialEq, Eq)]
80pub enum Force {
81 /// `--force-replace`: replace the objects instead of patching them.
82 Replace,
83 /// `--force-conflicts`: with server-side apply, take over fields owned by other managers.
84 Conflicts,
85}
86
87/// Which values an upgrade starts from. Helm documents `--reset-values` as winning over
88/// `--reuse-values`, which wins over `--reset-then-reuse-values`, so only the winner is modelled.
89/// Without a mode, Helm starts from the chart's values.
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
91pub enum ValuesMode {
92 /// `--reset-values`: the values built into the chart.
93 Reset,
94 /// `--reuse-values`: the last release's values.
95 Reuse,
96 /// `--reset-then-reuse-values`: the chart's values, then the last release's, then the
97 /// overrides given now.
98 ResetThenReuse,
99}
100
101/// How the release of an install is named. Helm refuses a name together with `--generate-name`
102/// or `--name-template`, so the three are one choice.
103#[derive(Debug, Clone, PartialEq, Eq)]
104pub enum ReleaseName {
105 /// The `NAME` argument.
106 Named(String),
107 /// `--generate-name`: Helm derives a name from the chart and the time.
108 Generated,
109 /// `--name-template`: Helm renders the name from this template.
110 Template(String),
111}