Compare commits

..

No commits in common. "1754f86bf3b26994a45aa127b6a8218ff4ddb791" and "2d2ef6903bf3929168f4176c2e11153a1d7773b2" have entirely different histories.

12 changed files with 35 additions and 85 deletions

View File

@ -1,2 +1,2 @@
[advisories] [advisories]
ignore = ["RUSTSEC-2024-0344", "RUSTSEC-2025-0023"] ignore = ["RUSTSEC-2024-0344"]

View File

@ -1,2 +0,0 @@
[env]
RUSTC_BOOTSTRAP = "1"

View File

@ -18,12 +18,8 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Set timestamp and release version - name: Get Git commit timestamps
run: | run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
git fetch --prune --unshallow --tags --force
echo "RELEASE_VERSION=$(git describe --always --dirty='--modified')" >> $GITHUB_ENV
cat $GITHUB_ENV
- name: Login to registry - name: Login to registry
uses: docker/login-action@v3 uses: docker/login-action@v3
@ -56,9 +52,25 @@ jobs:
type=semver,pattern=v{{major}}.{{minor}} type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}} type=semver,pattern=v{{major}}
- name: Build container - name: Build and export to docker
id: build id: build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with:
context: .
load: true
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
- name: Generate CRDs
run: |
docker run --rm ${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
- name: Push container
uses: docker/build-push-action@v6
id: push
with: with:
context: . context: .
push: true push: true
@ -66,28 +78,20 @@ jobs:
provenance: mode=max provenance: mode=max
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }} annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
"RELEASE_VERSION=${{ env.RELEASE_VERSION }}"
env: env:
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }} SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
- name: Generate CRDs
run: |
docker run --rm ${{ env.OCI_REPO }}@${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
- name: Kustomize manifests - name: Kustomize manifests
run: | run: |
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.build.outputs.digest }}/" > ./manifests.yaml ./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.push.outputs.digest }}/" > ./manifests.yaml
- name: Push manifests - name: Push manifests
run: | run: |
flux push artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \ flux push artifact oci://$OCI_REPO/manifests:latest \
--path="./manifests.yaml" \ --path="./manifests.yaml" \
--source="$(git config --get remote.origin.url)" \ --source="$(git config --get remote.origin.url)" \
--revision="$(git rev-parse HEAD)" \ --revision="$(git rev-parse HEAD)" \
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /') $(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
flux tag artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \ flux tag artifact oci://$OCI_REPO/manifests:latest \
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /') $(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /')

View File

@ -2,19 +2,17 @@ fail_fast: true
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 rev: v4.6.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-yaml - id: check-yaml
args:
- --allow-multiple-documents
- id: check-toml - id: check-toml
- id: check-added-large-files - id: check-added-large-files
- id: check-merge-conflict - id: check-merge-conflict
- repo: https://github.com/crate-ci/typos - repo: https://github.com/crate-ci/typos
rev: v1.31.1 rev: v1.21.0
hooks: hooks:
- id: typos - id: typos
args: ["--force-exclude"] args: ["--force-exclude"]
@ -45,17 +43,6 @@ repos:
name: audit name: audit
description: Audit packages description: Audit packages
entry: cargo audit entry: cargo audit
args: ["--deny", "warnings"]
language: system
pass_filenames: false
verbose: true
always_run: true
- id: udeps
name: unused
description: Check for unused crates
entry: cargo +nightly udeps
args: ["--workspace"]
language: system language: system
types: [file] types: [file]
files: (\.rs|Cargo.lock)$ files: (\.rs|Cargo.lock)$

21
Cargo.lock generated
View File

@ -785,26 +785,6 @@ version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "git-version"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
dependencies = [
"git-version-macro",
]
[[package]]
name = "git-version-macro"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]] [[package]]
name = "gloo-timers" name = "gloo-timers"
version = "0.3.0" version = "0.3.0"
@ -1448,7 +1428,6 @@ dependencies = [
"chrono", "chrono",
"cynic", "cynic",
"futures", "futures",
"git-version",
"insta", "insta",
"k8s-openapi", "k8s-openapi",
"kube", "kube",

View File

@ -34,7 +34,6 @@ reqwest = { version = "0.12.14", default-features = false, features = [
"json", "json",
"rustls-tls", "rustls-tls",
] } ] }
git-version = "0.3.9"
[dev-dependencies] [dev-dependencies]
insta = { workspace = true } insta = { workspace = true }

View File

@ -1,4 +1,4 @@
FROM rust:1.86 AS base FROM rust:1.85 AS base
ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
RUN cargo install cargo-chef --locked --version 0.1.71 && \ RUN cargo install cargo-chef --locked --version 0.1.71 && \
cargo install cargo-auditable --locked --version 0.6.6 cargo install cargo-auditable --locked --version 0.6.6
@ -13,8 +13,6 @@ COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json RUN cargo chef cook --release --recipe-path recipe.json
COPY . . COPY . .
ARG RELEASE_VERSION
ENV RELEASE_VERSION=${RELEASE_VERSION}
RUN cargo auditable build --release RUN cargo auditable build --release
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime FROM gcr.io/distroless/cc-debian12:nonroot AS runtime

View File

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "1.86" channel = "1.85"
profile = "default" profile = "default"
components = ["rust-analyzer"] components = ["rust-analyzer"]

View File

@ -1,7 +1,3 @@
#![feature(let_chains)]
pub mod context; pub mod context;
pub mod lldap; pub mod lldap;
pub mod resources; pub mod resources;
mod version;
pub use version::VERSION;

View File

@ -7,7 +7,6 @@ use kube::runtime::controller::{self, Action};
use kube::runtime::reflector::ObjectRef; use kube::runtime::reflector::ObjectRef;
use kube::runtime::{Controller, watcher}; use kube::runtime::{Controller, watcher};
use kube::{Api, Client as KubeClient, Resource}; use kube::{Api, Client as KubeClient, Resource};
use lldap_controller::VERSION;
use lldap_controller::context::Context; use lldap_controller::context::Context;
use lldap_controller::lldap::LldapConfig; use lldap_controller::lldap::LldapConfig;
use lldap_controller::resources::{ use lldap_controller::resources::{
@ -48,7 +47,7 @@ async fn main() -> anyhow::Result<()> {
Registry::default().with(logger).with(env_filter).init(); Registry::default().with(logger).with(env_filter).init();
} }
info!(version = VERSION, "Starting"); info!("Starting controller");
let client = KubeClient::try_default().await?; let client = KubeClient::try_default().await?;

View File

@ -1,18 +1,19 @@
use std::time::Duration; use std::time::Duration;
use kube::api::{Patch, PatchParams}; use kube::{
use kube::runtime::controller::Action; Api, CELSchema, CustomResource,
use kube::{Api, CELSchema, CustomResource}; api::{Patch, PatchParams},
runtime::controller::Action,
};
use queries::AttributeType; use queries::AttributeType;
use schemars::JsonSchema; use schemars::JsonSchema;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::json; use serde_json::json;
use tracing::{debug, trace, warn}; use tracing::{debug, trace, warn};
use crate::{context::ControllerEvents, lldap, resources::Error};
use super::Reconcile; use super::Reconcile;
use crate::context::ControllerEvents;
use crate::lldap;
use crate::resources::Error;
#[derive(Deserialize, Serialize, Clone, Copy, Debug, JsonSchema)] #[derive(Deserialize, Serialize, Clone, Copy, Debug, JsonSchema)]
pub enum Type { pub enum Type {

View File

@ -1,11 +0,0 @@
pub const VERSION: &str = get_version();
const fn get_version() -> &'static str {
if let Some(version) = std::option_env!("RELEASE_VERSION")
&& !version.is_empty()
{
version
} else {
git_version::git_version!(fallback = "unknown")
}
}