Skip to content

Commit

Permalink
fix: fix id and namespace error
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Jan 15, 2024
1 parent 402d63d commit e1f0227
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.7.0"
version = "0.7.1"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/amphitheatre-app/amphitheatre"
Expand All @@ -21,7 +21,7 @@ members = [
# https://doc.rust-lang.org/cargo/reference/workspaces.html#the-workspacedependencies-table
[workspace.dependencies]
anyhow = "1.0"
amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.7.0" }
amp-common = { git = "https://github.com/amphitheatre-app/common", tag = "v0.7.1" }
amp-resolver = { path = "resolver" }
amp-resources = { path = "resources" }
async-nats = "0.33.0"
Expand Down
2 changes: 1 addition & 1 deletion apiserver/src/services/playbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ impl PlaybookService {
let resource = Playbook::new(
&uuid.to_string(),
PlaybookSpec {
id: uuid.to_string(),
title: req.title.to_string(),
description: req.description.clone(),
namespace: format!("amp-{}", uuid),
preface: req.preface.clone(),
..PlaybookSpec::default()
},
Expand Down
2 changes: 1 addition & 1 deletion controllers/src/playbook_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,6 @@ pub async fn cleanup(playbook: &Playbook, ctx: &Arc<Context>, _recorder: &Record
#[inline]
fn reference(playbook: &Playbook) -> ObjectReference {
let mut reference = playbook.object_ref(&());
reference.namespace = Some(playbook.spec.namespace.to_string());
reference.namespace = Some(playbook.spec.namespace());
reference
}
6 changes: 3 additions & 3 deletions resources/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ use serde_json::json;
use tracing::{debug, error, info};

pub async fn exists(client: &Client, playbook: &Playbook, name: &str) -> Result<bool> {
let namespace = playbook.spec.namespace.clone();
let namespace = playbook.spec.namespace();
let api: Api<Actor> = Api::namespaced(client.clone(), namespace.as_str());

Ok(api.get_opt(name).await.map_err(Error::KubeError)?.is_some())
}

pub async fn create(client: &Client, playbook: &Playbook, spec: &ActorSpec) -> Result<Actor> {
let namespace = playbook.spec.namespace.clone();
let namespace = playbook.spec.namespace();
let api: Api<Actor> = Api::namespaced(client.clone(), namespace.as_str());

let name = spec.name.clone();
Expand All @@ -48,7 +48,7 @@ pub async fn create(client: &Client, playbook: &Playbook, spec: &ActorSpec) -> R
}

pub async fn update(client: &Client, playbook: &Playbook, spec: &ActorSpec) -> Result<Actor> {
let namespace = playbook.spec.namespace.clone();
let namespace = playbook.spec.namespace();
let api: Api<Actor> = Api::namespaced(client.clone(), namespace.as_str());

let name = spec.name.clone();
Expand Down
4 changes: 2 additions & 2 deletions resources/src/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use super::error::{Error, Result};

pub async fn create(client: &Client, playbook: &Playbook) -> Result<Namespace> {
let api: Api<Namespace> = Api::all(client.clone());
let name = playbook.spec.namespace.clone();
let name = playbook.spec.namespace();

let resource = new(playbook);
debug!("The namespace resource:\n {:?}\n", resource);
Expand All @@ -38,7 +38,7 @@ pub async fn create(client: &Client, playbook: &Playbook) -> Result<Namespace> {
}

fn new(playbook: &Playbook) -> Namespace {
let name = playbook.spec.namespace.clone();
let name = playbook.spec.namespace();
let owner_reference = playbook.controller_owner_ref(&()).unwrap();
let labels = BTreeMap::from([
("app.kubernetes.io/managed-by".into(), "Amphitheatre".into()),
Expand Down

0 comments on commit e1f0227

Please sign in to comment.