Skip to content

Commit

Permalink
Merge pull request #1 from kubewarden/renaming
Browse files Browse the repository at this point in the history
Rename to kubewarden
  • Loading branch information
flavio authored Apr 2, 2021
2 parents 477bc33 + 2b78ccf commit 39b95df
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
env:
WASM_BINARY_NAME: psp_capabilities
OCI_TARGET: ghcr.io/chimera-kube/policies/psp-capabilities
OCI_TARGET: ghcr.io/kubewarden/policies/psp-capabilities
steps:
-
name: Checkout code
Expand Down
57 changes: 15 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "psp-capabilities"
version = "0.1.0"
version = "0.1.1"
authors = ["Flavio Castelli <[email protected]>"]
edition = "2018"

Expand All @@ -9,12 +9,11 @@ crate-type = ["cdylib"]

[dependencies]
anyhow = "1.0"
jmespatch = "0.3.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
wapc-guest = "0.4.0"
jsonpath_lib = "0.2.6"
chimera-kube-policy-sdk = { git = "https://github.com/chimera-kube/policy-sdk-rust.git", branch = "main" }
kubewarden-policy-sdk = "0.1.0"
k8s-openapi = { version = "0.11.0", features = ["v1_20"] }

[dev-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Continuous integration | License
-----------------------|--------
![Continuous integration](https://github.com/chimera-kube/psp-capabilities/workflows/Continuous%20integration/badge.svg) | [![License: Apache 2.0](https://img.shields.io/badge/License-Apache2.0-brightgreen.svg)](https://opensource.org/licenses/Apache-2.0)
![Continuous integration](https://github.com/kubewarden/psp-capabilities/workflows/Continuous%20integration/badge.svg) | [![License: Apache 2.0](https://img.shields.io/badge/License-Apache2.0-brightgreen.svg)](https://opensource.org/licenses/Apache-2.0)


This Chimera Policy is a replacement for the Kubernetes Pod Security Policy
This Kubewarden Policy is a replacement for the Kubernetes Pod Security Policy
that controls the usage of Containers capabilities:

* [Deprecated PSP](https://kubernetes.io/docs/concepts/policy/pod-security-policy/#capabilities)
Expand Down Expand Up @@ -210,9 +210,9 @@ spec:
# Obtain policy
The policy is automatically published as an OCI artifact inside of
[this](https://github.com/orgs/chimera-kube/packages/container/package/policies%2Fpsp-capabilities)
[this](https://github.com/orgs/kubewarden/packages/container/package/policies%2Fpsp-capabilities)
container registry.
# Using the policy
The easiest way to use this policy is through the [chimera-controller](https://github.com/chimera-kube/chimera-controller).
The easiest way to use this policy is through the [kubewarden-controller](https://github.com/kubewarden/kubewarden-controller).
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use mutate::patch_object;
mod settings;
use settings::Settings;

use chimera_kube_policy_sdk::{
accept_request, reject_request, request::ValidationRequest, validate_settings,
use kubewarden_policy_sdk::{
accept_request, mutate_request, reject_request, request::ValidationRequest, validate_settings,
};

#[no_mangle]
Expand All @@ -24,7 +24,13 @@ fn validate(payload: &[u8]) -> CallResult {
let validation_req = ValidationRequest::<Settings>::new(payload)?;

match validate_added_caps(&validation_req) {
Ok(()) => accept_request(patch_object(&validation_req)?),
Ok(()) => {
if let Some(patched_object) = patch_object(&validation_req)? {
mutate_request(&patched_object)
} else {
accept_request()
}
}
Err(val_res) => reject_request(Some(val_res.to_string()), None),
}
}
Expand All @@ -34,7 +40,7 @@ mod tests {
use super::*;
use anyhow::Result;

use chimera_kube_policy_sdk::test::Testcase;
use kubewarden_policy_sdk::test::Testcase;
use test_helpers::configuration;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/mutate.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Result};
use chimera_kube_policy_sdk::request::ValidationRequest;
use k8s_openapi::api::core::v1::{Capabilities, Pod, SecurityContext};
use kubewarden_policy_sdk::request::ValidationRequest;
use std::collections::HashSet;

use crate::settings::Settings;
Expand Down
4 changes: 2 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Settings {
}
}

impl chimera_kube_policy_sdk::settings::Validatable for Settings {
impl kubewarden_policy_sdk::settings::Validatable for Settings {
fn validate(&self) -> Result<(), String> {
let denied: HashSet<String> = self
.allowed_capabilities
Expand Down Expand Up @@ -60,7 +60,7 @@ mod tests {
use super::*;
use anyhow::Result;

use chimera_kube_policy_sdk::settings::Validatable;
use kubewarden_policy_sdk::settings::Validatable;
use test_helpers::configuration;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::settings::Settings;

use jsonpath_lib as jsonpath;

use chimera_kube_policy_sdk::request::ValidationRequest;
use kubewarden_policy_sdk::request::ValidationRequest;

pub(crate) fn validate_added_caps(validation_req: &ValidationRequest<Settings>) -> Result<()> {
let add_queries = vec![
Expand Down

0 comments on commit 39b95df

Please sign in to comment.