//! Auto-generated models for flux-operator-fluxinstances
//! Generated from: flux-operator-fluxinstances.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.Npfd37zKnc/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::*;

/// FluxInstanceSpec defines the desired state of FluxInstance
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
#[kube(
    group = "fluxcd.controlplane.io",
    version = "v1",
    kind = "FluxInstance",
    plural = "fluxinstances"
)]
#[kube(namespaced)]
#[kube(status = "FluxInstanceStatus")]
#[kube(schema = "disabled")]
#[kube(derive = "Default")]
#[kube(derive = "PartialEq")]
pub struct FluxInstanceSpec {
    /// Cluster holds the specification of the Kubernetes cluster.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cluster: Option<FluxInstanceCluster>,
    /// CommonMetadata specifies the common labels and annotations that are
    /// applied to all resources. Any existing label or annotation will be
    /// overridden if its key matches a common one.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "commonMetadata"
    )]
    pub common_metadata: Option<FluxInstanceCommonMetadata>,
    /// Components is the list of controllers to install.
    /// Defaults to the core Flux controllers:
    ///   - source-controller
    ///   - kustomize-controller
    ///   - helm-controller
    ///   - notification-controller
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub components: Option<Vec<String>>,
    /// Distribution specifies the version and container registry to pull images from.
    pub distribution: FluxInstanceDistribution,
    /// Kustomize holds a set of patches that can be applied to the
    /// Flux installation, to customize the way Flux operates.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kustomize: Option<FluxInstanceKustomize>,
    /// MigrateResources instructs the controller to migrate the Flux custom resources
    /// from the previous version to the latest API version specified in the CRD.
    /// Defaults to true.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "migrateResources"
    )]
    pub migrate_resources: Option<bool>,
    /// Sharding holds the specification of the sharding configuration.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sharding: Option<FluxInstanceSharding>,
    /// Storage holds the specification of the source-controller
    /// persistent volume claim.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub storage: Option<FluxInstanceStorage>,
    /// Sync specifies the source for the cluster sync operation.
    /// When set, a Flux source (GitRepository, OCIRepository or Bucket)
    /// and Flux Kustomization are created to sync the cluster state
    /// with the source repository.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sync: Option<FluxInstanceSync>,
    /// Wait instructs the controller to check the health of all the reconciled
    /// resources. Defaults to true.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub wait: Option<bool>,
}

/// Cluster holds the specification of the Kubernetes cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceCluster {
    /// Domain is the cluster domain used for generating the FQDN of services.
    /// Defaults to 'cluster.local'.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Multitenant enables the multitenancy lockdown. Defaults to false.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub multitenant: Option<bool>,
    /// MultitenantWorkloadIdentity enables the multitenancy lockdown for
    /// workload identity. Defaults to false.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "multitenantWorkloadIdentity"
    )]
    pub multitenant_workload_identity: Option<bool>,
    /// NetworkPolicy restricts network access to the current namespace.
    /// Defaults to true.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "networkPolicy"
    )]
    pub network_policy: Option<bool>,
    /// ObjectLevelWorkloadIdentity enables the feature gate
    /// required for object-level workload identity.
    /// This feature is only available in Flux v2.6.0 and later.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "objectLevelWorkloadIdentity"
    )]
    pub object_level_workload_identity: Option<bool>,
    /// Size defines the vertical scaling profile of the Flux controllers.
    /// The size is used to determine the concurrency and CPU/Memory limits for the Flux controllers.
    /// Accepted values are: 'small', 'medium' and 'large'.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub size: Option<FluxInstanceClusterSize>,
    /// TenantDefaultDecryptionServiceAccount is the name of the service account
    /// to use as default for kustomize-controller SOPS decryption when the
    /// multitenant lockdown for workload identity is enabled. Defaults to the
    /// 'default' service account from the tenant namespace.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "tenantDefaultDecryptionServiceAccount"
    )]
    pub tenant_default_decryption_service_account: Option<String>,
    /// TenantDefaultKubeConfigServiceAccount is the name of the service account
    /// to use as default for kustomize-controller and helm-controller remote
    /// cluster access via spec.kubeConfig.configMapRef when the multitenant
    /// lockdown for workload identity is enabled. Defaults to the 'default'
    /// service account from the tenant namespace.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "tenantDefaultKubeConfigServiceAccount"
    )]
    pub tenant_default_kube_config_service_account: Option<String>,
    /// TenantDefaultServiceAccount is the name of the service account
    /// to use as default when the multitenant lockdown is enabled, for
    /// kustomize-controller and helm-controller.
    /// This field will also be used for multitenant workload identity
    /// lockdown for source-controller, notification-controller,
    /// image-reflector-controller and image-automation-controller.
    /// Defaults to the 'default' service account from the tenant namespace.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "tenantDefaultServiceAccount"
    )]
    pub tenant_default_service_account: Option<String>,
    /// Type specifies the distro of the Kubernetes cluster.
    /// Defaults to 'kubernetes'.
    #[serde(default, skip_serializing_if = "Option::is_none", rename = "type")]
    pub r#type: Option<FluxInstanceClusterType>,
}

/// Cluster holds the specification of the Kubernetes cluster.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum FluxInstanceClusterSize {
    #[serde(rename = "small")]
    Small,
    #[serde(rename = "medium")]
    Medium,
    #[serde(rename = "large")]
    Large,
}

/// Cluster holds the specification of the Kubernetes cluster.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum FluxInstanceClusterType {
    #[serde(rename = "kubernetes")]
    Kubernetes,
    #[serde(rename = "openshift")]
    Openshift,
    #[serde(rename = "aws")]
    Aws,
    #[serde(rename = "azure")]
    Azure,
    #[serde(rename = "gcp")]
    Gcp,
}

/// CommonMetadata specifies the common labels and annotations that are
/// applied to all resources. Any existing label or annotation will be
/// overridden if its key matches a common one.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceCommonMetadata {
    /// Annotations to be added to the object's metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub annotations: Option<BTreeMap<String, String>>,
    /// Labels to be added to the object's metadata.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub labels: Option<BTreeMap<String, String>>,
}

/// Distribution specifies the version and container registry to pull images from.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceDistribution {
    /// Artifact is the URL to the OCI artifact containing
    /// the latest Kubernetes manifests for the distribution,
    /// e.g. 'oci://ghcr.io/controlplaneio-fluxcd/flux-operator-manifests:latest'.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub artifact: Option<String>,
    /// ArtifactPullSecret is the name of the Kubernetes secret
    /// to use for pulling the Kubernetes manifests for the distribution specified in the Artifact field.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "artifactPullSecret"
    )]
    pub artifact_pull_secret: Option<String>,
    /// ImagePullSecret is the name of the Kubernetes secret
    /// to use for pulling images.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "imagePullSecret"
    )]
    pub image_pull_secret: Option<String>,
    /// Registry address to pull the distribution images from
    /// e.g. 'ghcr.io/fluxcd'.
    pub registry: String,
    /// Variant specifies the Flux distribution flavor stored
    /// in the registry.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub variant: Option<FluxInstanceDistributionVariant>,
    /// Version semver expression e.g. '2.x', '2.3.x'.
    pub version: String,
}

/// Distribution specifies the version and container registry to pull images from.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum FluxInstanceDistributionVariant {
    #[serde(rename = "upstream-alpine")]
    UpstreamAlpine,
    #[serde(rename = "enterprise-alpine")]
    EnterpriseAlpine,
    #[serde(rename = "enterprise-distroless")]
    EnterpriseDistroless,
    #[serde(rename = "enterprise-distroless-fips")]
    EnterpriseDistrolessFips,
}

/// Kustomize holds a set of patches that can be applied to the
/// Flux installation, to customize the way Flux operates.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceKustomize {
    /// Strategic merge and JSON patches, defined as inline YAML objects,
    /// capable of targeting objects based on kind, label and annotation selectors.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub patches: Option<Vec<FluxInstanceKustomizePatches>>,
}

/// Patch contains an inline StrategicMerge or JSON6902 patch, and the target the patch should
/// be applied to.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceKustomizePatches {
    /// Patch contains an inline StrategicMerge patch or an inline JSON6902 patch with
    /// an array of operation objects.
    pub patch: String,
    /// Target points to the resources that the patch document should be applied to.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub target: Option<FluxInstanceKustomizePatchesTarget>,
}

/// Target points to the resources that the patch document should be applied to.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceKustomizePatchesTarget {
    /// AnnotationSelector is a string that follows the label selection expression
    /// <https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api>
    /// It matches with the resource annotations.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "annotationSelector"
    )]
    pub annotation_selector: Option<String>,
    /// Group is the API group to select resources from.
    /// Together with Version and Kind it is capable of unambiguously identifying and/or selecting resources.
    /// <https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub group: Option<String>,
    /// Kind of the API Group to select resources from.
    /// Together with Group and Version it is capable of unambiguously
    /// identifying and/or selecting resources.
    /// <https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,
    /// LabelSelector is a string that follows the label selection expression
    /// <https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api>
    /// It matches with the resource labels.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "labelSelector"
    )]
    pub label_selector: Option<String>,
    /// Name to match resources with.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Namespace to select resources from.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub namespace: Option<String>,
    /// Version of the API Group to select resources from.
    /// Together with Group and Kind it is capable of unambiguously identifying and/or selecting resources.
    /// <https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md>
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub version: Option<String>,
}

/// Sharding holds the specification of the sharding configuration.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceSharding {
    /// Key is the label key used to shard the resources.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub key: Option<String>,
    /// Shards is the list of shard names.
    pub shards: Vec<String>,
    /// Storage defines if the source-controller shards
    /// should use an emptyDir or a persistent volume claim for storage.
    /// Accepted values are 'ephemeral' or 'persistent', defaults to 'ephemeral'.
    /// For 'persistent' to take effect, the '.spec.storage' field must be set.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub storage: Option<FluxInstanceShardingStorage>,
}

/// Sharding holds the specification of the sharding configuration.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum FluxInstanceShardingStorage {
    #[serde(rename = "ephemeral")]
    Ephemeral,
    #[serde(rename = "persistent")]
    Persistent,
}

/// Storage holds the specification of the source-controller
/// persistent volume claim.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceStorage {
    /// Class is the storage class to use for the PVC.
    pub class: String,
    /// Size is the size of the PVC.
    pub size: String,
}

/// Sync specifies the source for the cluster sync operation.
/// When set, a Flux source (GitRepository, OCIRepository or Bucket)
/// and Flux Kustomization are created to sync the cluster state
/// with the source repository.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct FluxInstanceSync {
    /// Interval is the time between syncs.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub interval: Option<String>,
    /// Kind is the kind of the source.
    pub kind: FluxInstanceSyncKind,
    /// Name is the name of the Flux source and kustomization resources.
    /// When not specified, the name is set to the namespace name of the FluxInstance.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Path is the path to the source directory containing
    /// the kustomize overlay or plain Kubernetes manifests.
    pub path: String,
    /// Provider specifies OIDC provider for source authentication.
    /// For OCIRepository and Bucket the provider can be set to 'aws', 'azure' or 'gcp'.
    /// For GitRepository the provider can be set to 'aws' (requires Flux 2.9 or later),
    /// 'azure' or 'github'.
    /// To disable OIDC authentication the provider can be set to 'generic' or left empty.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub provider: Option<FluxInstanceSyncProvider>,
    /// PullSecret specifies the Kubernetes Secret containing the
    /// authentication credentials for the source.
    /// For Git over HTTP/S sources, the secret must contain username and password fields.
    /// For Git over SSH sources, the secret must contain known_hosts and identity fields.
    /// For OCI sources, the secret must be of type kubernetes.io/dockerconfigjson.
    /// For Bucket sources, the secret must contain accesskey and secretkey fields.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "pullSecret"
    )]
    pub pull_secret: Option<String>,
    /// Ref is the source reference, can be a Git ref name e.g. 'refs/heads/main',
    /// an OCI tag e.g. 'latest' or a bucket name e.g. 'flux'.
    #[serde(rename = "ref")]
    pub r#ref: String,
    /// URL is the source URL, can be a Git repository HTTP/S or SSH address,
    /// an OCI repository address or a Bucket endpoint.
    pub url: String,
}

/// Sync specifies the source for the cluster sync operation.
/// When set, a Flux source (GitRepository, OCIRepository or Bucket)
/// and Flux Kustomization are created to sync the cluster state
/// with the source repository.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum FluxInstanceSyncKind {
    #[serde(rename = "OCIRepository")]
    OciRepository,
    GitRepository,
    Bucket,
}

/// Sync specifies the source for the cluster sync operation.
/// When set, a Flux source (GitRepository, OCIRepository or Bucket)
/// and Flux Kustomization are created to sync the cluster state
/// with the source repository.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum FluxInstanceSyncProvider {
    #[serde(rename = "generic")]
    Generic,
    #[serde(rename = "aws")]
    Aws,
    #[serde(rename = "azure")]
    Azure,
    #[serde(rename = "gcp")]
    Gcp,
    #[serde(rename = "github")]
    Github,
}

/// FluxInstanceStatus defines the observed state of FluxInstance
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceStatus {
    /// Components contains the container images used by the components.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub components: Option<Vec<FluxInstanceStatusComponents>>,
    /// Conditions contains the readiness conditions of the object.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub conditions: Option<Vec<Condition>>,
    /// History contains the reconciliation history of the FluxInstance
    /// as a list of snapshots ordered by the last reconciled time.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub history: Option<Vec<FluxInstanceStatusHistory>>,
    /// Inventory contains a list of Kubernetes resource object references
    /// last applied on the cluster.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub inventory: Option<FluxInstanceStatusInventory>,
    /// LastAppliedRevision is the version and digest of the
    /// distribution config that was last reconcile.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastAppliedRevision"
    )]
    pub last_applied_revision: Option<String>,
    /// LastArtifactRevision is the digest of the last pulled
    /// distribution artifact.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastArtifactRevision"
    )]
    pub last_artifact_revision: Option<String>,
    /// LastAttemptedRevision is the version and digest of the
    /// distribution config that was last attempted to reconcile.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastAttemptedRevision"
    )]
    pub last_attempted_revision: Option<String>,
    /// LastHandledForceAt holds the value of the most recent
    /// force request value, so a change of the annotation value
    /// can be detected.
    #[serde(
        default,
        skip_serializing_if = "Option::is_none",
        rename = "lastHandledForceAt"
    )]
    pub last_handled_force_at: Option<String>,
    /// 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>,
}

/// ComponentImage represents a container image used by a component.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceStatusComponents {
    /// Digest of the container image.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub digest: Option<String>,
    /// Name of the component.
    pub name: String,
    /// Repository address of the container image.
    pub repository: String,
    /// Tag of the container image.
    pub tag: String,
}

/// Snapshot represents a point-in-time record of a group of resources reconciliation,
/// including timing information, status, and a unique digest identifier.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceStatusHistory {
    /// Digest is the checksum in the format `<algo>:<hex>` of the resources in this snapshot.
    pub digest: String,
    /// FirstReconciled is the time when this revision was first reconciled to the cluster.
    #[serde(rename = "firstReconciled")]
    pub first_reconciled: String,
    /// LastReconciled is the time when this revision was last reconciled to the cluster.
    #[serde(rename = "lastReconciled")]
    pub last_reconciled: String,
    /// LastReconciledDuration is time it took to reconcile the resources in this revision.
    #[serde(rename = "lastReconciledDuration")]
    pub last_reconciled_duration: String,
    /// LastReconciledStatus is the status of the last reconciliation.
    #[serde(rename = "lastReconciledStatus")]
    pub last_reconciled_status: String,
    /// Metadata contains additional information about the snapshot.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub metadata: Option<BTreeMap<String, String>>,
    /// TotalReconciliations is the total number of reconciliations that have occurred for this snapshot.
    #[serde(rename = "totalReconciliations")]
    pub total_reconciliations: i64,
}

/// Inventory contains a list of Kubernetes resource object references
/// last applied on the cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceStatusInventory {
    /// Entries of Kubernetes resource object references.
    pub entries: Vec<FluxInstanceStatusInventoryEntries>,
}

/// ResourceRef contains the information necessary to locate a resource within a cluster.
#[derive(Serialize, Deserialize, Clone, Debug, Default, PartialEq)]
pub struct FluxInstanceStatusInventoryEntries {
    /// ID is the string representation of the Kubernetes resource object's metadata,
    /// in the format '<namespace>_<name>_<group>_<kind>'.
    pub id: String,
    /// Version is the API version of the Kubernetes resource object's kind.
    pub v: String,
}
