Skip to content

Commit

Permalink
refactor: remove app.chart attr (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
leroyguillaume authored Jul 27, 2024
1 parent bf676de commit 801a6f3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 47 deletions.
11 changes: 0 additions & 11 deletions charts/simpaas/crds/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ spec:
properties:
spec:
properties:
chart:
description: Chart to use to install app.
oneOf:
- required:
- builtIn
properties:
builtIn:
description: Built-in chart.
type: object
type: object
namespace:
description: Namespace.
type: string
Expand Down Expand Up @@ -109,7 +99,6 @@ spec:
description: Helm chart values.
type: object
required:
- chart
- namespace
- owner
- services
Expand Down
6 changes: 1 addition & 5 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use uuid::Uuid;
use validator::{Validate, ValidationError, ValidationErrors};

use crate::{
domain::{Action, App, AppSpec, Chart, Invitation, InvitationSpec, Service, User, UserSpec},
domain::{Action, App, AppSpec, Invitation, InvitationSpec, Service, User, UserSpec},
jwt::JwtEncoder,
kube::{AppFilter, KubeClient, FINALIZER},
pwd::PasswordEncoder,
Expand Down Expand Up @@ -163,9 +163,6 @@ struct AppFilterQuery {
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, JsonSchema, Serialize, Validate)]
#[serde(rename_all = "camelCase")]
struct CreateAppRequest {
/// Chart to use to install app.
#[serde(default)]
chart: Chart,
/// Name.
#[serde(deserialize_with = "string_trim")]
#[validate(length(min = 1))]
Expand Down Expand Up @@ -348,7 +345,6 @@ async fn create_app<J: JwtEncoder, K: KubeClient, P: PasswordEncoder>(
}
let namespace = req.namespace.unwrap_or_else(|| req.name.clone());
let spec = AppSpec {
chart: req.chart,
namespace,
owner: username,
services: req.services,
Expand Down
23 changes: 0 additions & 23 deletions src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ impl Display for Action<'_> {
)]
#[serde(rename_all = "camelCase")]
pub struct AppSpec {
/// Chart to use to install app.
pub chart: Chart,
/// Namespace.
pub namespace: String,
/// Owner of the app.
Expand All @@ -64,27 +62,6 @@ pub struct AppSpec {
pub values: Map<String, Value>,
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, JsonSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum Chart {
/// Built-in chart.
BuiltIn {},
}

impl Default for Chart {
fn default() -> Self {
Self::BuiltIn {}
}
}

impl Display for Chart {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
match self {
Self::BuiltIn {} => write!(f, "built_in"),
}
}
}

#[derive(Clone, Debug, Deserialize, Eq, PartialEq, JsonSchema, Serialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct Expose {
Expand Down
11 changes: 3 additions & 8 deletions src/helm/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use std::path::PathBuf;

use tracing::{debug, error, instrument};

use crate::{
cmd::CommandRunner,
domain::{App, Chart},
};
use crate::{cmd::CommandRunner, domain::App};

use super::{HelmClient, Result};

Expand Down Expand Up @@ -79,11 +76,9 @@ impl<R: CommandRunner> HelmClient for CliHelmClient<R> {
Ok(())
}

#[instrument("helm_upgrade", skip(self, app, filepaths), fields(app.chart = %app.spec.chart, app.name = name, app.namespace = app.spec.namespace))]
#[instrument("helm_upgrade", skip(self, app, filepaths), fields(app.name = name, app.namespace = app.spec.namespace))]
async fn upgrade(&self, name: &str, app: &App, filepaths: &[PathBuf]) -> Result {
let chart = match &app.spec.chart {
Chart::BuiltIn {} => self.args.chart_path.to_str().ok_or(Error::InvalidUnicode)?,
};
let chart = self.args.chart_path.to_str().ok_or(Error::InvalidUnicode)?;
let mut args = vec![
"upgrade",
"-n",
Expand Down

0 comments on commit 801a6f3

Please sign in to comment.