//! Auto-generated models for source-watcher
//! Generated from: source-watcher.crds.yaml
//! DO NOT EDIT - This file is auto-generated by kopium
#![allow(clippy::all)]

// WARNING: generated by kopium - manual changes will be overwritten
// kopium command: kopium --filename /tmp/tmp.8ceCj5SIRs/doc1.yaml --derive Default --derive PartialEq --docs --smart-derive-elision
// kopium version: 0.23.0

#[allow(unused_imports)]
mod prelude {
    pub use k8s_openapi::apimachinery::pkg::apis::meta::v1::Condition;
    pub use kube::CustomResource;
    pub use serde::{Deserialize, Serialize};
    pub use std::collections::BTreeMap;
}

use self::prelude::*;

/// ArtifactGeneratorSpec defines the desired state of ArtifactGenerator.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[kube(
    group = "source.extensions.fluxcd.io",
    version = "v1beta1",
    kind = "ArtifactGenerator",
    plural = "artifactgenerators"
)]
#[kube(namespaced)]
#[kube(status = "ArtifactGeneratorStatus")]
#[kube(schema = "disabled")]
#[kube(derive = "Default")]
#[kube(derive = "PartialEq")]
pub struct ArtifactGeneratorSpec {
    /// OutputArtifacts is a list of output artifacts to be generated.
    pub artifacts: Vec<ArtifactGeneratorArtifacts>,
    /// Sources is a list of references to the Flux source-controller
    /// resources that will be used to generate the artifact.
    pub sources: Vec<ArtifactGeneratorSources>,
}

/// OutputArtifact defines the desired state of an ExternalArtifact
/// generated by the ArtifactGenerator.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ArtifactGeneratorArtifacts {
    /// Copy defines a list of copy operations to perform from the sources to the generated artifact.
    /// The copy operations are performed in the order they are listed with existing files
    /// being overwritten by later copy operations.
    pub copy: Vec<ArtifactGeneratorArtifactsCopy>,
    /// Name is the name of the generated artifact.
    pub name: String,
    /// OriginRevision is used to set the 'org.opencontainers.image.revision'
    /// annotation on the generated artifact metadata.
    /// If specified, it must point to an existing source alias in the format "@<alias>".
    /// If the referenced source has an origin revision (e.g. a Git commit SHA),
    /// it will be used to set the annotation on the generated artifact.
    /// If the referenced source does not have an origin revision, the field is ignored.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "originRevision"
    )]
    pub origin_revision: Option<String>,
    /// Revision is the revision of the generated artifact.
    /// If specified, it must point to an existing source alias in the format "@<alias>".
    /// If not specified, the revision is automatically set to the digest of the artifact content.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub revision: Option<String>,
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ArtifactGeneratorArtifactsCopy {
    /// Exclude specifies a list of glob patterns to exclude
    /// files and dirs matched by the 'From' field.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub exclude: Option<Vec<String>>,
    /// From specifies the source (by alias) and the glob pattern to match files.
    /// The format is "@<alias>/<glob-pattern>".
    pub from: String,
    /// Strategy specifies the copy strategy to use.
    /// 'Overwrite' will overwrite existing files in the destination.
    /// 'Merge' is for merging YAML files using Helm values merge strategy.
    /// 'Extract' is for extracting the contents of tarball archives (.tar.gz, .tgz)
    /// When using glob patterns, non-tarball files are silently skipped. For single file sources,
    /// the file must be a tarball or an error is returned. Directories are not supported.
    /// If not specified, defaults to 'Overwrite'.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub strategy: Option<ArtifactGeneratorArtifactsCopyStrategy>,
    /// To specifies the destination path within the artifact.
    /// The format is "@artifact/path", the alias "artifact"
    /// refers to the root path of the generated artifact.
    pub to: String,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ArtifactGeneratorArtifactsCopyStrategy {
    Overwrite,
    Merge,
    Extract,
}

/// SourceReference contains the reference to a Flux source-controller resource.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct ArtifactGeneratorSources {
    /// Alias of the source within the ArtifactGenerator context.
    /// The alias must be unique per ArtifactGenerator, and must consist
    /// of lower case alphanumeric characters, underscores, and hyphens.
    /// It must start and end with an alphanumeric character.
    pub alias: String,
    /// Kind of the source.
    pub kind: ArtifactGeneratorSourcesKind,
    /// Name of the source.
    pub name: String,
    /// Namespace of the source.
    /// If not provided, defaults to the same namespace as the ArtifactGenerator.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
}

/// SourceReference contains the reference to a Flux source-controller resource.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ArtifactGeneratorSourcesKind {
    Bucket,
    GitRepository,
    #[serde(rename = "OCIRepository")]
    OciRepository,
    HelmChart,
    ExternalArtifact,
}

/// ArtifactGeneratorStatus defines the observed state of ArtifactGenerator.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ArtifactGeneratorStatus {
    /// Conditions holds the conditions for the ArtifactGenerator.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
    /// Inventory contains the list of generated ExternalArtifact references.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub inventory: Option<Vec<ArtifactGeneratorStatusInventory>>,
    /// LastHandledReconcileAt holds the value of the most recent
    /// reconcile request value, so a change of the annotation value
    /// can be detected.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastHandledReconcileAt"
    )]
    pub last_handled_reconcile_at: Option<String>,
    /// ObservedSourcesDigest is a hash representing the current state of
    /// all the sources referenced by the ArtifactGenerator.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedSourcesDigest"
    )]
    pub observed_sources_digest: Option<String>,
}

/// ExternalArtifactReference contains the reference to a
/// generated ExternalArtifact along with its digest.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ArtifactGeneratorStatusInventory {
    /// Digest of the referent artifact.
    pub digest: String,
    /// Filename is the name of the artifact file.
    pub filename: String,
    /// Name of the referent artifact.
    pub name: String,
    /// Namespace of the referent artifact.
    pub namespace: String,
}
