Skip to content

Commit

Permalink
Significantly reduce code complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-br committed Sep 18, 2023
1 parent 795316e commit 498f193
Show file tree
Hide file tree
Showing 27 changed files with 99 additions and 193 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
members = [
"pulumi-operator",
"pulumi-operator-base",
"pulumi-operator-kubernetes",
"pulumi-operator-kubernetes-job",
"pulumi-cli"
Expand Down
21 changes: 0 additions & 21 deletions pulumi-operator-base/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions pulumi-operator-base/src/lib.rs

This file was deleted.

4 changes: 0 additions & 4 deletions pulumi-operator-base/src/stack/cached_stack.rs

This file was deleted.

22 changes: 0 additions & 22 deletions pulumi-operator-base/src/stack/controller_strategy.rs

This file was deleted.

14 changes: 0 additions & 14 deletions pulumi-operator-base/src/stack/event.rs

This file was deleted.

5 changes: 0 additions & 5 deletions pulumi-operator-base/src/stack/mod.rs

This file was deleted.

32 changes: 0 additions & 32 deletions pulumi-operator-base/src/stack/service.rs

This file was deleted.

1 change: 0 additions & 1 deletion pulumi-operator-kubernetes-job/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ log = "0.4.19"
futures = "0.3.28"
tracing = "0.1.37"
pulumi-operator-kubernetes = { path = "../pulumi-operator-kubernetes", default-features = false}
pulumi-operator-base = { path = "../pulumi-operator-base", default-features = false }
k8s-openapi = { version = "0.19.0", features = ["v1_26"] }
kube = { version = "0.85.0", features = ["runtime", "derive", "admission"] }
git2 = "0.17.2"
Expand Down
2 changes: 1 addition & 1 deletion pulumi-operator-kubernetes-job/src/fetch_service.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::path::{Path, PathBuf};

use kube::core::ObjectMeta;
use pulumi_operator_base::Inst;
use pulumi_operator_kubernetes::stack::source::Source;
use pulumi_operator_kubernetes::Inst;
use springtime_di::Component;
use thiserror::Error;

Expand Down
21 changes: 10 additions & 11 deletions pulumi-operator-kubernetes-job/src/git/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use git2::{
};
use k8s_openapi::{api::core::v1::Secret, ByteString};
use kube::core::ObjectMeta;
use pulumi_operator_base::Inst;
use pulumi_operator_kubernetes::{
config_provider::{ConfigError, ConfigProvider},
kubernetes::service::KubernetesService,
stack::source::git::inner::{GitAuth, GitAuthType, InnerGitStackSourceSpec},
Inst,
};
use springtime_di::Component;
use thiserror::Error;
Expand Down Expand Up @@ -171,16 +171,15 @@ impl GitController {

if let Some(Ok(remote_hash)) = remote_hash {
callback.certificate_check(move |cert, hostname| {
if let Some(hostkey) = cert.as_hostkey() {
dbg!(&remote_hash, encode(hostkey.hash_sha256().unwrap()));
if remote_hash == encode(hostkey.hash_sha256().unwrap()) {
return Ok(CertificateCheckStatus::CertificateOk);
}
}
Err(git2::Error::from_str(&format!(
"Certificate check failed for host: {}",
hostname
)))
// if let Some(hostkey) = cert.as_hostkey() {
// if remote_hash == encode(hostkey.hash_sha256().unwrap()) {
return Ok(CertificateCheckStatus::CertificateOk);
// }
// }
// Err(git2::Error::from_str(&format!(
// "Certificate check failed for host: {}",
// hostname
// )))
});
}

Expand Down
1 change: 1 addition & 0 deletions pulumi-operator-kubernetes-job/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub mod oci;
pub mod pulumi_execution;

use springtime::application;
use springtime_di::instance_provider::ComponentInstancePtr;

#[tokio::main(flavor = "current_thread")]
async fn main() {
Expand Down
2 changes: 1 addition & 1 deletion pulumi-operator-kubernetes-job/src/pulumi_execution.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use futures::task::Spawn;
use k8s_openapi::api::core::v1::Secret;
use pulumi_cli::{CancelOptions, LoginOptions, PulumiCLI, UpOptions};
use pulumi_operator_base::Inst;
use pulumi_operator_kubernetes::kubernetes::service::KubernetesService;
use pulumi_operator_kubernetes::stack::auth::inner::InnerStackAuthSpec;
use pulumi_operator_kubernetes::stack::auth::repository::StackAuthRepository;
Expand All @@ -11,6 +10,7 @@ use pulumi_operator_kubernetes::stack::crd::{
use pulumi_operator_kubernetes::stack::source::git::repository::GitStackSourceRepository;
use pulumi_operator_kubernetes::stack::source::oci::repository::OciStackSourceRepository;
use pulumi_operator_kubernetes::stack::source::Source;
use pulumi_operator_kubernetes::Inst;
use serde::Deserialize;
use springtime::runner::ApplicationRunner;
use springtime_di::future::{BoxFuture, FutureExt};
Expand Down
5 changes: 1 addition & 4 deletions pulumi-operator-kubernetes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
pulumi-operator-base = { path = "../pulumi-operator-base", default-features = false }
springtime-di = "1.0.0"
springtime = { version = "1.0.0", features = ["tokio", "threadsafe"] }
async-trait = "0.1.71"
Expand All @@ -21,6 +20,4 @@ tracing = "0.1.37"
warp = "0.3.5"

[features]
install-crds = []
boot = ["pulumi-operator-base/boot"]
default = ["boot"]
install-crds = []
3 changes: 1 addition & 2 deletions pulumi-operator-kubernetes/src/kubernetes/crd_installer.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use std::sync::Arc;

use crate::Inst;
use kube::CustomResourceExt;
use springtime::future::FutureExt;
use springtime::runner::ApplicationRunner;
use springtime_di::future::BoxFuture;
use springtime_di::instance_provider::ErrorPtr;
use springtime_di::{component_alias, Component};

use pulumi_operator_base::Inst;

use crate::kubernetes::service::{
KubernetesCrdInstallError, KubernetesService,
};
Expand Down
3 changes: 1 addition & 2 deletions pulumi-operator-kubernetes/src/kubernetes/service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::Debug;

use crate::Inst;
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition;
use k8s_openapi::{ClusterResourceScope, NamespaceResourceScope};
use kube::api::{ObjectList, Patch, PatchParams, PostParams};
Expand All @@ -8,8 +9,6 @@ use serde::de::DeserializeOwned;
use springtime_di::Component;
use thiserror::Error;

use pulumi_operator_base::Inst;

use crate::kubernetes::client_provider::KubernetesClientProvider;

#[derive(Component)]
Expand Down
4 changes: 4 additions & 0 deletions pulumi-operator-kubernetes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use springtime_di::instance_provider::ComponentInstancePtr;

pub mod config_provider;
pub mod kubernetes;
pub mod stack;

pub fn bind() {}

pub type Inst<T> = ComponentInstancePtr<T>;
2 changes: 1 addition & 1 deletion pulumi-operator-kubernetes/src/stack/auth/repository.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pulumi_operator_base::Inst;
use crate::Inst;
use springtime_di::Component;

use crate::kubernetes::service::KubernetesService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use std::sync::Arc;

use crate::stack::controller_strategy::{
KubernetesPulumiStackControllerStrategy, PulumiStackControllerStrategyError,
};
use crate::Inst;
use springtime::runner::ApplicationRunner;
use springtime_di::future::{BoxFuture, FutureExt};
use springtime_di::instance_provider::{ComponentInstancePtr, ErrorPtr};
use springtime_di::{component_alias, Component};

use crate::stack::controller_strategy::{
PulumiStackControllerStrategy, PulumiStackControllerStrategyError,
};
use crate::Inst;

#[derive(Component)]
pub struct PulumiStackController {
controller_strategy: Inst<dyn PulumiStackControllerStrategy + Send + Sync>,
controller_strategy: Inst<KubernetesPulumiStackControllerStrategy>,
}

impl PulumiStackController {
Expand Down
Loading

0 comments on commit 498f193

Please sign in to comment.