Created kubernetes Service User CRD
This commit is contained in:
parent
53a025363c
commit
729f1483c9
843
Cargo.lock
generated
843
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
|
@ -8,7 +8,7 @@ members = ["queries"]
|
|||
|
||||
[workspace.dependencies]
|
||||
cynic = "3.10.0"
|
||||
insta = "1.42.2"
|
||||
insta = { version = "1.42.2", features = ["yaml"] }
|
||||
|
||||
[dependencies]
|
||||
queries = { path = "./queries" }
|
||||
|
@ -19,6 +19,11 @@ serde_json = "1.0.140"
|
|||
surf = "2.3.2"
|
||||
cynic = { workspace = true, features = ["http-surf"] }
|
||||
tokio = { version = "1.44.0", features = ["full"] }
|
||||
kube = { version = "0.99.0", features = ["derive"] }
|
||||
k8s-openapi = { version = "0.24.0", features = ["v1_31"] }
|
||||
schemars = "0.8.22"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_yaml = "0.9.34"
|
||||
|
||||
[dev-dependencies]
|
||||
insta = { workspace = true }
|
||||
|
|
6
authelia.yaml
Normal file
6
authelia.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: lldap.huizinga.dev/v1
|
||||
kind: ServiceUser
|
||||
metadata:
|
||||
name: authelia
|
||||
spec:
|
||||
passwordManager: false
|
8
src/bin/crdgen.rs
Normal file
8
src/bin/crdgen.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use kube::CustomResourceExt;
|
||||
|
||||
fn main() {
|
||||
print!(
|
||||
"{}",
|
||||
serde_yaml::to_string(&lldap_controller::resources::ServiceUser::crd()).unwrap()
|
||||
)
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
pub mod lldap;
|
||||
pub mod resources;
|
||||
|
|
42
src/resources.rs
Normal file
42
src/resources.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use kube::CustomResource;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(CustomResource, Deserialize, Serialize, Clone, Debug, JsonSchema)]
|
||||
#[kube(
|
||||
kind = "ServiceUser",
|
||||
group = "lldap.huizinga.dev",
|
||||
version = "v1",
|
||||
namespaced,
|
||||
status = "ServiceUserStatus"
|
||||
)]
|
||||
#[kube(
|
||||
shortname = "lsu",
|
||||
doc = "Custom resource for managing Service Users inside of LLDAP",
|
||||
printcolumn = r#"{"name":"Exists", "type":"boolean", "description":"Does the service user exist in LLDAP", "jsonPath":".status.exists"}"#,
|
||||
printcolumn = r#"{"name":"Manager", "type":"boolean", "description":"Can the service user manage passwords", "jsonPath":".spec.passwordManager"}"#,
|
||||
printcolumn = r#"{"name":"Age", "type":"date", "jsonPath":".metadata.creationTimestamp"}"#
|
||||
)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ServiceUserSpec {
|
||||
#[serde(default)]
|
||||
password_manager: bool,
|
||||
#[serde(default)]
|
||||
additional_groups: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone, Default, Debug, JsonSchema)]
|
||||
pub struct ServiceUserStatus {
|
||||
pub exists: bool,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use kube::CustomResourceExt;
|
||||
|
||||
#[test]
|
||||
fn service_user_crd_output() {
|
||||
insta::assert_yaml_snapshot!(ServiceUser::crd());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
source: src/resources.rs
|
||||
expression: "ServiceUser::crd()"
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: serviceusers.lldap.huizinga.dev
|
||||
spec:
|
||||
group: lldap.huizinga.dev
|
||||
names:
|
||||
categories: []
|
||||
kind: ServiceUser
|
||||
plural: serviceusers
|
||||
shortNames:
|
||||
- lsu
|
||||
singular: serviceuser
|
||||
scope: Namespaced
|
||||
versions:
|
||||
- additionalPrinterColumns:
|
||||
- description: Does the service user exist in LLDAP
|
||||
jsonPath: ".status.exists"
|
||||
name: Exists
|
||||
type: boolean
|
||||
- description: Can the service user manage passwords
|
||||
jsonPath: ".spec.passwordManager"
|
||||
name: Manager
|
||||
type: boolean
|
||||
- jsonPath: ".metadata.creationTimestamp"
|
||||
name: Age
|
||||
type: date
|
||||
name: v1
|
||||
schema:
|
||||
openAPIV3Schema:
|
||||
description: Custom resource for managing Service Users inside of LLDAP
|
||||
properties:
|
||||
spec:
|
||||
properties:
|
||||
additionalGroups:
|
||||
default: []
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
passwordManager:
|
||||
default: false
|
||||
type: boolean
|
||||
type: object
|
||||
status:
|
||||
nullable: true
|
||||
properties:
|
||||
exists:
|
||||
type: boolean
|
||||
required:
|
||||
- exists
|
||||
type: object
|
||||
required:
|
||||
- spec
|
||||
title: ServiceUser
|
||||
type: object
|
||||
served: true
|
||||
storage: true
|
||||
subresources:
|
||||
status: {}
|
Loading…
Reference in New Issue
Block a user