//! Auto-generated models for image-reflector-controller
//! Generated from: image-reflector-controller.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.RVwS2bnOp1/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::*;

/// ImagePolicySpec defines the parameters for calculating the
/// ImagePolicy.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[kube(
    group = "image.toolkit.fluxcd.io",
    version = "v1",
    kind = "ImagePolicy",
    plural = "imagepolicies"
)]
#[kube(namespaced)]
#[kube(status = "ImagePolicyStatus")]
#[kube(schema = "disabled")]
#[kube(derive = "Default")]
#[kube(derive = "PartialEq")]
pub struct ImagePolicySpec {
    /// DigestReflectionPolicy governs the setting of the `.status.latestRef.digest` field.
    ///
    /// Never: The digest field will always be set to the empty string.
    ///
    /// IfNotPresent: The digest field will be set to the digest of the elected
    /// latest image if the field is empty and the image did not change.
    ///
    /// Always: The digest field will always be set to the digest of the elected
    /// latest image.
    ///
    /// Default: Never.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "digestReflectionPolicy"
    )]
    pub digest_reflection_policy: Option<ImagePolicyDigestReflectionPolicy>,
    /// FilterTags enables filtering for only a subset of tags based on a set of
    /// rules. If no rules are provided, all the tags from the repository will be
    /// ordered and compared.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "filterTags"
    )]
    pub filter_tags: Option<ImagePolicyFilterTags>,
    /// ImageRepositoryRef points at the object specifying the image
    /// being scanned
    #[serde(rename = "imageRepositoryRef")]
    pub image_repository_ref: ImagePolicyImageRepositoryRef,
    /// Interval is the length of time to wait between
    /// refreshing the digest of the latest tag when the
    /// reflection policy is set to "Always".
    ///
    /// Defaults to 10m.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    /// Policy gives the particulars of the policy to be followed in
    /// selecting the most recent image
    pub policy: ImagePolicyPolicy,
    /// This flag tells the controller to suspend subsequent policy reconciliations.
    /// It does not apply to already started reconciliations. Defaults to false.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub suspend: Option<bool>,
}

/// ImagePolicySpec defines the parameters for calculating the
/// ImagePolicy.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ImagePolicyDigestReflectionPolicy {
    Always,
    IfNotPresent,
    Never,
}

/// FilterTags enables filtering for only a subset of tags based on a set of
/// rules. If no rules are provided, all the tags from the repository will be
/// ordered and compared.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyFilterTags {
    /// Extract allows a capture group to be extracted from the specified regular
    /// expression pattern, useful before tag evaluation.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub extract: Option<String>,
    /// Pattern specifies a regular expression pattern used to filter for image
    /// tags.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub pattern: Option<String>,
}

/// ImageRepositoryRef points at the object specifying the image
/// being scanned
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyImageRepositoryRef {
    /// Name of the referent.
    pub name: String,
    /// Namespace of the referent, when not specified it acts as LocalObjectReference.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
}

/// Policy gives the particulars of the policy to be followed in
/// selecting the most recent image
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyPolicy {
    /// Alphabetical set of rules to use for alphabetical ordering of the tags.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub alphabetical: Option<ImagePolicyPolicyAlphabetical>,
    /// Numerical set of rules to use for numerical ordering of the tags.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub numerical: Option<ImagePolicyPolicyNumerical>,
    /// SemVer gives a semantic version range to check against the tags
    /// available.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub semver: Option<ImagePolicyPolicySemver>,
}

/// Alphabetical set of rules to use for alphabetical ordering of the tags.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyPolicyAlphabetical {
    /// Order specifies the sorting order of the tags. Given the letters of the
    /// alphabet as tags, ascending order would select Z, and descending order
    /// would select A.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub order: Option<ImagePolicyPolicyAlphabeticalOrder>,
}

/// Alphabetical set of rules to use for alphabetical ordering of the tags.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ImagePolicyPolicyAlphabeticalOrder {
    #[serde(rename = "asc")]
    Asc,
    #[serde(rename = "desc")]
    Desc,
}

/// Numerical set of rules to use for numerical ordering of the tags.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyPolicyNumerical {
    /// Order specifies the sorting order of the tags. Given the integer values
    /// from 0 to 9 as tags, ascending order would select 9, and descending order
    /// would select 0.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub order: Option<ImagePolicyPolicyNumericalOrder>,
}

/// Numerical set of rules to use for numerical ordering of the tags.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ImagePolicyPolicyNumericalOrder {
    #[serde(rename = "asc")]
    Asc,
    #[serde(rename = "desc")]
    Desc,
}

/// SemVer gives a semantic version range to check against the tags
/// available.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyPolicySemver {
    /// Range gives a semver range for the image tag; the highest
    /// version within the range that's a tag yields the latest image.
    pub range: String,
}

/// ImagePolicyStatus defines the observed state of ImagePolicy
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyStatus {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
    /// 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>,
    /// LatestRef gives the first in the list of images scanned by
    /// the image repository, when filtered and ordered according
    /// to the policy.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "latestRef")]
    pub latest_ref: Option<ImagePolicyStatusLatestRef>,
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedGeneration"
    )]
    pub observed_generation: Option<i64>,
    /// ObservedPreviousRef is the observed previous LatestRef. It is used
    /// to keep track of the previous and current images.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedPreviousRef"
    )]
    pub observed_previous_ref: Option<ImagePolicyStatusObservedPreviousRef>,
}

/// LatestRef gives the first in the list of images scanned by
/// the image repository, when filtered and ordered according
/// to the policy.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyStatusLatestRef {
    /// Digest is the image's digest.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub digest: Option<String>,
    /// Name is the bare image's name.
    pub name: String,
    /// Tag is the image's tag.
    pub tag: String,
}

/// ObservedPreviousRef is the observed previous LatestRef. It is used
/// to keep track of the previous and current images.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImagePolicyStatusObservedPreviousRef {
    /// Digest is the image's digest.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub digest: Option<String>,
    /// Name is the bare image's name.
    pub name: String,
    /// Tag is the image's tag.
    pub tag: String,
}

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

#[allow(unused_imports)]
use self::prelude::*;

/// ImageRepositorySpec defines the parameters for scanning an image
/// repository, e.g., `fluxcd/flux`.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[kube(
    group = "image.toolkit.fluxcd.io",
    version = "v1",
    kind = "ImageRepository",
    plural = "imagerepositories"
)]
#[kube(namespaced)]
#[kube(status = "ImageRepositoryStatus")]
#[kube(schema = "disabled")]
#[kube(derive = "Default")]
#[kube(derive = "PartialEq")]
pub struct ImageRepositorySpec {
    /// AccessFrom defines an ACL for allowing cross-namespace references
    /// to the ImageRepository object based on the caller's namespace labels.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "accessFrom"
    )]
    pub access_from: Option<ImageRepositoryAccessFrom>,
    /// CertSecretRef can be given the name of a Secret containing
    /// either or both of
    ///
    /// - a PEM-encoded client certificate (`tls.crt`) and private
    /// key (`tls.key`);
    /// - a PEM-encoded CA certificate (`ca.crt`)
    ///
    /// and whichever are supplied, will be used for connecting to the
    /// registry. The client cert and key are useful if you are
    /// authenticating with a certificate; the CA cert is useful if
    /// you are using a self-signed server certificate. The Secret must
    /// be of type `Opaque` or `kubernetes.io/tls`.
    ///
    /// Note: Support for the `caFile`, `certFile` and `keyFile` keys has
    /// been deprecated.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "certSecretRef"
    )]
    pub cert_secret_ref: Option<ImageRepositoryCertSecretRef>,
    /// ExclusionList is a list of regex strings used to exclude certain tags
    /// from being stored in the database.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "exclusionList"
    )]
    pub exclusion_list: Option<Vec<String>>,
    /// Image is the name of the image repository
    pub image: String,
    /// Insecure allows connecting to a non-TLS HTTP container registry.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub insecure: Option<bool>,
    /// Interval is the length of time to wait between
    /// scans of the image repository.
    pub interval: String,
    /// The provider used for authentication, can be 'aws', 'azure', 'gcp' or 'generic'.
    /// When not specified, defaults to 'generic'.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider: Option<ImageRepositoryProvider>,
    /// ProxySecretRef specifies the Secret containing the proxy configuration
    /// to use while communicating with the container registry.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "proxySecretRef"
    )]
    pub proxy_secret_ref: Option<ImageRepositoryProxySecretRef>,
    /// SecretRef can be given the name of a secret containing
    /// credentials to use for the image registry. The secret should be
    /// created with `kubectl create secret docker-registry`, or the
    /// equivalent.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "secretRef")]
    pub secret_ref: Option<ImageRepositorySecretRef>,
    /// ServiceAccountName is the name of the Kubernetes ServiceAccount used to authenticate
    /// the image pull if the service account has attached pull secrets.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "serviceAccountName"
    )]
    pub service_account_name: Option<String>,
    /// This flag tells the controller to suspend subsequent image scans.
    /// It does not apply to already started scans. Defaults to false.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub suspend: Option<bool>,
    /// Timeout for image scanning.
    /// Defaults to 'Interval' duration.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timeout: Option<String>,
}

/// AccessFrom defines an ACL for allowing cross-namespace references
/// to the ImageRepository object based on the caller's namespace labels.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositoryAccessFrom {
    /// NamespaceSelectors is the list of namespace selectors to which this ACL applies.
    /// Items in this list are evaluated using a logical OR operation.
    #[serde(rename = "namespaceSelectors")]
    pub namespace_selectors: Vec<ImageRepositoryAccessFromNamespaceSelectors>,
}

/// NamespaceSelector selects the namespaces to which this ACL applies.
/// An empty map of MatchLabels matches all namespaces in a cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositoryAccessFromNamespaceSelectors {
    /// MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
    /// map is equivalent to an element of matchExpressions, whose key field is "key", the
    /// operator is "In", and the values array contains only "value". The requirements are ANDed.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "matchLabels"
    )]
    pub match_labels: Option<BTreeMap<String, String>>,
}

/// CertSecretRef can be given the name of a Secret containing
/// either or both of
///
/// - a PEM-encoded client certificate (`tls.crt`) and private
/// key (`tls.key`);
/// - a PEM-encoded CA certificate (`ca.crt`)
///
/// and whichever are supplied, will be used for connecting to the
/// registry. The client cert and key are useful if you are
/// authenticating with a certificate; the CA cert is useful if
/// you are using a self-signed server certificate. The Secret must
/// be of type `Opaque` or `kubernetes.io/tls`.
///
/// Note: Support for the `caFile`, `certFile` and `keyFile` keys has
/// been deprecated.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositoryCertSecretRef {
    /// Name of the referent.
    pub name: String,
}

/// ImageRepositorySpec defines the parameters for scanning an image
/// repository, e.g., `fluxcd/flux`.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ImageRepositoryProvider {
    #[serde(rename = "generic")]
    Generic,
    #[serde(rename = "aws")]
    Aws,
    #[serde(rename = "azure")]
    Azure,
    #[serde(rename = "gcp")]
    Gcp,
}

/// ProxySecretRef specifies the Secret containing the proxy configuration
/// to use while communicating with the container registry.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositoryProxySecretRef {
    /// Name of the referent.
    pub name: String,
}

/// SecretRef can be given the name of a secret containing
/// credentials to use for the image registry. The secret should be
/// created with `kubectl create secret docker-registry`, or the
/// equivalent.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositorySecretRef {
    /// Name of the referent.
    pub name: String,
}

/// ImageRepositoryStatus defines the observed state of ImageRepository
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositoryStatus {
    /// CanonicalName is the name of the image repository with all the
    /// implied bits made explicit; e.g., `docker.io/library/alpine`
    /// rather than `alpine`.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "canonicalImageName"
    )]
    pub canonical_image_name: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
    /// 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>,
    /// LastScanResult contains the number of fetched tags.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastScanResult"
    )]
    pub last_scan_result: Option<ImageRepositoryStatusLastScanResult>,
    /// ObservedExclusionList is a list of observed exclusion list. It reflects
    /// the exclusion rules used for the observed scan result in
    /// spec.lastScanResult.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedExclusionList"
    )]
    pub observed_exclusion_list: Option<Vec<String>>,
    /// ObservedGeneration is the last reconciled generation.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "observedGeneration"
    )]
    pub observed_generation: Option<i64>,
}

/// LastScanResult contains the number of fetched tags.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct ImageRepositoryStatusLastScanResult {
    /// LatestTags is a small sample of the tags found in the last scan.
    /// It's the first 10 tags when sorting all the tags in descending
    /// alphabetical order.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "latestTags"
    )]
    pub latest_tags: Option<Vec<String>>,
    /// Revision is a stable hash of the scanned tags.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub revision: Option<String>,
    /// ScanTime is the time when the last scan was performed.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "scanTime")]
    pub scan_time: Option<String>,
    /// TagCount is the number of tags found in the last scan.
    #[serde(rename = "tagCount")]
    pub tag_count: i64,
}

// ---
