Skip to main content

flux9s/models/_generated/
source_watcher.rs

1//! Auto-generated models for source-watcher
2//! Generated from: source-watcher.crds.yaml
3//! DO NOT EDIT - This file is auto-generated by kopium
4#![allow(clippy::all)]
5
6// WARNING: generated by kopium - manual changes will be overwritten
7// kopium command: kopium --filename doc1.yaml --derive Default --derive PartialEq --docs --smart-derive-elision
8// kopium version: 0.24.1
9
10#[allow(unused_imports)]
11mod prelude {
12    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
13    pub use kube::CustomResource;
14    pub use serde::{Deserialize, Serialize};
15    pub use std::collections::BTreeMap;
16}
17
18use self::prelude::*;
19
20/// ArtifactGeneratorSpec defines the desired state of ArtifactGenerator.
21#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
22#[kube(
23    group = "source.extensions.fluxcd.io",
24    version = "v1beta1",
25    kind = "ArtifactGenerator",
26    plural = "artifactgenerators"
27)]
28#[kube(namespaced)]
29#[kube(status = "ArtifactGeneratorStatus")]
30#[kube(schema = "disabled")]
31#[kube(derive = "Default")]
32#[kube(derive = "PartialEq")]
33pub struct ArtifactGeneratorSpec {
34    /// OutputArtifacts is a list of output artifacts to be generated.
35    pub artifacts: Vec<ArtifactGeneratorArtifacts>,
36    /// CommonMetadata specifies the common labels and annotations that are
37    /// applied to all resources. Any existing label or annotation will be
38    /// overridden if its key matches a common one.
39    #[serde(
40        default,
41        skip_serializing_if = "Option::is_none",
42        rename = "commonMetadata"
43    )]
44    pub common_metadata: Option<ArtifactGeneratorCommonMetadata>,
45    /// ManagedNamespaces defines how the controller manages the namespaces
46    /// targeted by the generated artifacts. When omitted, the target namespaces
47    /// are unmanaged: they must already exist and are left untouched.
48    #[serde(
49        default,
50        skip_serializing_if = "Option::is_none",
51        rename = "managedNamespaces"
52    )]
53    pub managed_namespaces: Option<ArtifactGeneratorManagedNamespaces>,
54    /// PathPattern specifies a directory traversal pattern to match within the sources.
55    /// The format is "@<alias>/<pattern>". Named captures in the pattern (e.g. "{app}")
56    /// can be used as placeholders in OutputArtifacts fields.
57    #[serde(
58        default,
59        skip_serializing_if = "Option::is_none",
60        rename = "pathPattern"
61    )]
62    pub path_pattern: Option<String>,
63    /// ServiceAccountName is the name of the ServiceAccount used to authorize
64    /// the reconciliation of the generated ExternalArtifacts and the managed
65    /// Namespaces. The name is resolved in the ArtifactGenerator namespace. When
66    /// specified, the controller checks this ServiceAccount with
67    /// SubjectAccessReview for every namespace targeted by the generated
68    /// ExternalArtifacts, including the ArtifactGenerator namespace, and its
69    /// RBAC bindings determine the namespaces in which they can be created,
70    /// updated and deleted.
71    /// When not specified, the controller uses its own credentials for
72    /// ExternalArtifacts in the ArtifactGenerator namespace, and the
73    /// ServiceAccount configured with the --default-service-account flag
74    /// (when set) for artifacts targeting another namespace.
75    /// Namespace management (.spec.managedNamespaces) always requires a
76    /// ServiceAccount for authorization, so either this field or the
77    /// --default-service-account flag must be set; otherwise the reconciliation
78    /// fails with a terminal error. The controller performs the namespace
79    /// operations with its own credentials.
80    #[serde(
81        default,
82        skip_serializing_if = "Option::is_none",
83        rename = "serviceAccountName"
84    )]
85    pub service_account_name: Option<String>,
86    /// Sources is a list of references to the Flux source-controller
87    /// resources that will be used to generate the artifact.
88    pub sources: Vec<ArtifactGeneratorSources>,
89}
90
91/// OutputArtifact defines the desired state of an ExternalArtifact
92/// generated by the ArtifactGenerator.
93#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
94pub struct ArtifactGeneratorArtifacts {
95    /// Copy defines a list of copy operations to perform from the sources to the generated artifact.
96    /// The copy operations are performed in the order they are listed with existing files
97    /// being overwritten by later copy operations.
98    pub copy: Vec<ArtifactGeneratorArtifactsCopy>,
99    /// InputsFrom specifies a source path to a YAML file whose contents are
100    /// exported in the ExternalArtifact .status.exportedInputs field.
101    /// The format is "@<alias>/<path>", where <alias> references a source or
102    /// "artifact" for the generated artifact itself. When pathPattern is set,
103    /// the path may use capture placeholders such as "{module}".
104    #[serde(
105        default,
106        skip_serializing_if = "Option::is_none",
107        rename = "inputsFrom"
108    )]
109    pub inputs_from: Option<String>,
110    /// Name is the name of the generated artifact.
111    /// When pathPattern is set, this field may use capture placeholders such as "{app}".
112    /// The maximum length accommodates capture placeholders; the effective
113    /// limits are enforced by the CEL validation when pathPattern is not set.
114    pub name: String,
115    /// Namespace is the namespace of the generated artifact.
116    /// If not provided, defaults to the same namespace as the ArtifactGenerator.
117    /// When pathPattern is set, this field may use capture placeholders such as "{app}".
118    /// The credentials used to reconcile the artifact are described in
119    /// .spec.serviceAccountName: an explicit ServiceAccount applies to every
120    /// generated artifact, while the --default-service-account flag only applies
121    /// to artifacts in a namespace other than the ArtifactGenerator namespace.
122    /// The maximum length accommodates capture placeholders; the effective
123    /// limits are enforced by the CEL validation when pathPattern is not set.
124    #[serde(default, skip_serializing_if = "Option::is_none")]
125    pub namespace: Option<String>,
126    /// OriginRevision is used to set the 'org.opencontainers.image.revision'
127    /// annotation on the generated artifact metadata.
128    /// If specified, it must point to an existing source alias in the format "@<alias>".
129    /// If the referenced source has an origin revision (e.g. a Git commit SHA),
130    /// it will be used to set the annotation on the generated artifact.
131    /// If the referenced source does not have an origin revision, the field is ignored.
132    #[serde(
133        default,
134        skip_serializing_if = "Option::is_none",
135        rename = "originRevision"
136    )]
137    pub origin_revision: Option<String>,
138    /// Revision is the revision of the generated artifact.
139    /// If specified, it must point to an existing source alias in the format "@<alias>".
140    /// If not specified, the revision is automatically set to the digest of the artifact content.
141    #[serde(default, skip_serializing_if = "Option::is_none")]
142    pub revision: Option<String>,
143}
144
145#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
146pub struct ArtifactGeneratorArtifactsCopy {
147    /// Exclude specifies a list of glob patterns to exclude
148    /// files and dirs matched by the 'From' field. Patterns are matched
149    /// against paths relative to the source alias root or to the non-glob
150    /// prefix of 'From'. Patterns without a separator (e.g. "*.md") match
151    /// the file name at any depth.
152    #[serde(default, skip_serializing_if = "Option::is_none")]
153    pub exclude: Option<Vec<String>>,
154    /// From specifies the source (by alias) and the glob pattern to match files.
155    /// The format is "@<alias>/<glob-pattern>". When pathPattern is set,
156    /// the path may use capture placeholders such as "{app}".
157    pub from: String,
158    /// Optional, when set to true, allows the copy operation to silently
159    /// skip when the source path or glob pattern matches no files.
160    /// When false (default), the reconciliation fails with an error if
161    /// no files are matched.
162    #[serde(default, skip_serializing_if = "Option::is_none")]
163    pub optional: Option<bool>,
164    /// Strategy specifies the copy strategy to use.
165    /// 'Overwrite' will overwrite existing files in the destination.
166    /// 'Merge' is for merging YAML files using Helm values merge strategy.
167    /// 'Extract' is for extracting the contents of tarball archives (.tar.gz, .tgz)
168    /// When using glob patterns, non-tarball files are silently skipped. For single file sources,
169    /// the file must be a tarball or an error is returned. Directories are not supported.
170    /// If not specified, defaults to 'Overwrite'.
171    #[serde(default, skip_serializing_if = "Option::is_none")]
172    pub strategy: Option<ArtifactGeneratorArtifactsCopyStrategy>,
173    /// To specifies the destination path within the artifact.
174    /// The format is "@artifact/path", the alias "artifact"
175    /// refers to the root path of the generated artifact. When pathPattern
176    /// is set, the path may use capture placeholders such as "{app}".
177    pub to: String,
178}
179
180#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
181pub enum ArtifactGeneratorArtifactsCopyStrategy {
182    Overwrite,
183    Merge,
184    Extract,
185}
186
187/// CommonMetadata specifies the common labels and annotations that are
188/// applied to all resources. Any existing label or annotation will be
189/// overridden if its key matches a common one.
190#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
191pub struct ArtifactGeneratorCommonMetadata {
192    /// Annotations to be added to the object's metadata.
193    #[serde(default, skip_serializing_if = "Option::is_none")]
194    pub annotations: Option<BTreeMap<String, String>>,
195    /// Labels to be added to the object's metadata.
196    #[serde(default, skip_serializing_if = "Option::is_none")]
197    pub labels: Option<BTreeMap<String, String>>,
198}
199
200/// ManagedNamespaces defines how the controller manages the namespaces
201/// targeted by the generated artifacts. When omitted, the target namespaces
202/// are unmanaged: they must already exist and are left untouched.
203#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
204pub struct ArtifactGeneratorManagedNamespaces {
205    /// AllowedNames is a list of CEL expressions that define the set of
206    /// namespaces the ArtifactGenerator agrees to manage. Each expression
207    /// receives the namespace name through the 'ns' string variable and must
208    /// return a boolean. A namespace is managed only when at least one
209    /// expression returns true. The 'default', 'kube-system', 'kube-public'
210    /// and 'flux-system' namespaces are always rejected, regardless of the
211    /// expressions.
212    #[serde(rename = "allowedNames")]
213    pub allowed_names: Vec<String>,
214    /// Metadata defines how the metadata of the desired namespaces is built,
215    /// on top of .spec.commonMetadata.
216    #[serde(default, skip_serializing_if = "Option::is_none")]
217    pub metadata: Option<ArtifactGeneratorManagedNamespacesMetadata>,
218    /// Prune specifies whether the controller deletes managed namespaces that
219    /// are no longer targeted by any generated artifact, or when the
220    /// ArtifactGenerator is deleted.
221    pub prune: bool,
222}
223
224/// Metadata defines how the metadata of the desired namespaces is built,
225/// on top of .spec.commonMetadata.
226#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
227pub struct ArtifactGeneratorManagedNamespacesMetadata {
228    /// From is a list of metadata operations applied in order to the desired
229    /// namespaces, on top of .spec.commonMetadata and .fromSource.
230    #[serde(default, skip_serializing_if = "Option::is_none")]
231    pub from: Option<Vec<ArtifactGeneratorManagedNamespacesMetadataFrom>>,
232    /// FromSource sources namespace metadata from a NamespaceMetadata file
233    /// inside a source artifact.
234    #[serde(
235        default,
236        skip_serializing_if = "Option::is_none",
237        rename = "fromSource"
238    )]
239    pub from_source: Option<ArtifactGeneratorManagedNamespacesMetadataFromSource>,
240}
241
242/// NamespaceMetadataFrom defines a metadata operation applied to a desired
243/// namespace.
244#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
245pub struct ArtifactGeneratorManagedNamespacesMetadataFrom {
246    /// Annotations to be applied to the namespace.
247    #[serde(default, skip_serializing_if = "Option::is_none")]
248    pub annotations: Option<BTreeMap<String, String>>,
249    /// Labels to be applied to the namespace.
250    #[serde(default, skip_serializing_if = "Option::is_none")]
251    pub labels: Option<BTreeMap<String, String>>,
252    /// Namespace is the name of the desired namespace the metadata applies to,
253    /// or '*' to apply the metadata to all desired namespaces.
254    pub namespace: String,
255    /// Strategy specifies how the labels and annotations are applied.
256    /// 'Reset' clears all the existing labels and annotations before applying
257    /// the ones defined in the operation (fields that are not set clear the
258    /// corresponding metadata), 'Override' merges the ones defined in the
259    /// operation into the existing values, overriding existing keys, while
260    /// 'Merge' merges only the absent keys, preserving existing values.
261    pub strategy: ArtifactGeneratorManagedNamespacesMetadataFromStrategy,
262}
263
264/// NamespaceMetadataFrom defines a metadata operation applied to a desired
265/// namespace.
266#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
267pub enum ArtifactGeneratorManagedNamespacesMetadataFromStrategy {
268    Reset,
269    Override,
270    Merge,
271}
272
273/// FromSource sources namespace metadata from a NamespaceMetadata file
274/// inside a source artifact.
275#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
276pub struct ArtifactGeneratorManagedNamespacesMetadataFromSource {
277    /// AllowedAnnotations is a schema for the annotations that the
278    /// NamespaceMetadata file is allowed to set. Each key is an annotation key
279    /// and each value is a CEL expression that receives the annotation value
280    /// through the 'value' string variable and must return a boolean.
281    /// Annotations whose key is not present in this map are ignored, while
282    /// annotations whose value does not satisfy the respective expression are
283    /// rejected.
284    /// The expressions are compiled, so a malformed expression or one that
285    /// does not return a boolean fails validation at the start of the
286    /// reconciliation.
287    #[serde(
288        default,
289        skip_serializing_if = "Option::is_none",
290        rename = "allowedAnnotations"
291    )]
292    pub allowed_annotations: Option<BTreeMap<String, String>>,
293    /// AllowedLabels is a schema for the labels that the NamespaceMetadata
294    /// file is allowed to set. Each key is a label key and each value is a
295    /// CEL expression that receives the label value through the 'value' string
296    /// variable and must return a boolean. Labels whose key is not present in
297    /// this map are ignored, while labels whose value does not satisfy the
298    /// respective expression are rejected.
299    /// The expressions are compiled, so a malformed expression or one that
300    /// does not return a boolean fails validation at the start of the
301    /// reconciliation.
302    #[serde(
303        default,
304        skip_serializing_if = "Option::is_none",
305        rename = "allowedLabels"
306    )]
307    pub allowed_labels: Option<BTreeMap<String, String>>,
308    /// Path is the path to the NamespaceMetadata file inside a source artifact,
309    /// in the format "@<alias>/<path>". When pathPattern is set, the path may
310    /// use capture placeholders such as "{namespace}". Only namespace-level
311    /// captures are allowed, so that every artifact targeting a namespace
312    /// resolves to the same file.
313    pub path: String,
314}
315
316/// SourceReference contains the reference to a Flux source-controller resource.
317#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
318pub struct ArtifactGeneratorSources {
319    /// Alias of the source within the ArtifactGenerator context.
320    /// The alias must be unique per ArtifactGenerator, and must consist
321    /// of lower case alphanumeric characters, underscores, and hyphens.
322    /// It must start and end with an alphanumeric character.
323    pub alias: String,
324    /// Kind of the source.
325    pub kind: ArtifactGeneratorSourcesKind,
326    /// Name of the source.
327    pub name: String,
328    /// Namespace of the source.
329    /// If not provided, defaults to the same namespace as the ArtifactGenerator.
330    #[serde(default, skip_serializing_if = "Option::is_none")]
331    pub namespace: Option<String>,
332}
333
334/// SourceReference contains the reference to a Flux source-controller resource.
335#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
336pub enum ArtifactGeneratorSourcesKind {
337    Bucket,
338    GitRepository,
339    #[serde(rename = "OCIRepository")]
340    OciRepository,
341    HelmChart,
342    ExternalArtifact,
343}
344
345/// ArtifactGeneratorStatus defines the observed state of ArtifactGenerator.
346#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
347pub struct ArtifactGeneratorStatus {
348    /// Conditions holds the conditions for the ArtifactGenerator.
349    #[serde(default, skip_serializing_if = "Option::is_none")]
350    pub conditions: Option<Vec<Condition>>,
351    /// Inventory contains the list of objects managed by the ArtifactGenerator,
352    /// such as the generated ExternalArtifacts and the managed Namespaces.
353    #[serde(default, skip_serializing_if = "Option::is_none")]
354    pub inventory: Option<Vec<ArtifactGeneratorStatusInventory>>,
355    /// LastHandledReconcileAt holds the value of the most recent
356    /// reconcile request value, so a change of the annotation value
357    /// can be detected.
358    #[serde(
359        default,
360        skip_serializing_if = "Option::is_none",
361        rename = "lastHandledReconcileAt"
362    )]
363    pub last_handled_reconcile_at: Option<String>,
364    /// ObservedSourcesDigest is a hash representing the current state of
365    /// all the sources referenced by the ArtifactGenerator.
366    #[serde(
367        default,
368        skip_serializing_if = "Option::is_none",
369        rename = "observedSourcesDigest"
370    )]
371    pub observed_sources_digest: Option<String>,
372}
373
374/// InventoryEntry contains a reference to an object managed by the
375/// ArtifactGenerator, such as a generated ExternalArtifact or a managed
376/// Namespace.
377#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
378pub struct ArtifactGeneratorStatusInventory {
379    /// Digest of the referent object. For generated artifacts this is the
380    /// artifact content digest; for managed namespaces this is a digest of the
381    /// metadata applied by the controller.
382    pub digest: String,
383    /// Filename is the name of the artifact file.
384    #[serde(default, skip_serializing_if = "Option::is_none")]
385    pub filename: Option<String>,
386    /// Kind is the kind of the referent object.
387    #[serde(default, skip_serializing_if = "Option::is_none")]
388    pub kind: Option<ArtifactGeneratorStatusInventoryKind>,
389    /// Name of the referent object.
390    pub name: String,
391    /// Namespace of the referent object. Empty for cluster-scoped objects.
392    #[serde(default, skip_serializing_if = "Option::is_none")]
393    pub namespace: Option<String>,
394}
395
396/// InventoryEntry contains a reference to an object managed by the
397/// ArtifactGenerator, such as a generated ExternalArtifact or a managed
398/// Namespace.
399#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
400pub enum ArtifactGeneratorStatusInventoryKind {
401    ExternalArtifact,
402    Namespace,
403}