Skip to content

Commit

Permalink
fix:bug: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
howard-oc committed Apr 23, 2024
1 parent 6393414 commit 700fb9e
Showing 1 changed file with 27 additions and 31 deletions.
58 changes: 27 additions & 31 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
pub mod pipeline;
pub mod promise;
use log;
use crate::pipeline::PipelineConfig;
use std::{env, process};
use dotenv::dotenv;
use log;
use std::{env, process};

// Structure to hold potential errors
#[derive(Debug)]
struct EnvVarError {
var_name: String,
}



pub fn run_pipeline(args:Vec<String>) {


pub fn run_pipeline(args: Vec<String>) {
dotenv().ok();

// Validate environment variables up front
Expand All @@ -30,12 +26,11 @@ pub fn run_pipeline(args:Vec<String>) {
}
}


if args.len() < 2 {
log::warn!("Usage: <command> [build, pipeline, load, push, rmi, pull]");
process::exit(1);
}

// Extract validated environment variables
let workflow_type = env::var("KRATIX_WORKFLOW_TYPE").unwrap();
let base_instance = env::var("BASE_INSTANCE").unwrap();
Expand All @@ -44,58 +39,59 @@ pub fn run_pipeline(args:Vec<String>) {
let kratix_input_dir = env::var("KRATIX_INPUT").unwrap();
let kratix_output_dir = env::var("KRATIX_OUTPUT").unwrap();


let config = PipelineConfig::new(
&base_instance,
&res_dir,
&dep_dir,
&kratix_output_dir,
&kratix_input_dir,
&workflow_type);
&base_instance,
&res_dir,
&dep_dir,
&kratix_output_dir,
&kratix_input_dir,
&workflow_type,
);

log::debug!("<- Start Pipeline ({}) ->", config.workflow_type());



match config.workflow_type() {
"promise" => {
// Fullful promise.yaml
if let Err(err) =
// tmp/transfer/dependecies -> /kratix/output
pipeline::copy_files(config.dep_dir(), config.kratix_output_dir()) {
pipeline::copy_files(config.dep_dir(), config.kratix_output_dir())
{
log::warn!("Error during file copy: {}", err);
}
},
}
"resource" => {
log::debug!(" 1. transform resource");
// Fullfil resource_request.yaml
promise::transform(config.res_dir(),
config.base_instance(),
config.kratix_output_dir(),
config.kratix_input_dir());
},
promise::transform(
config.res_dir(),
config.base_instance(),
config.kratix_output_dir(),
config.kratix_input_dir(),
);
}
"request" => {
log::debug!(" 1. transform request");
// Fullfil resource_request.yaml
promise::transform(config.res_dir(),
config.base_instance(),
config.kratix_output_dir(),
config.kratix_input_dir());
promise::transform(
config.res_dir(),
config.base_instance(),
config.kratix_output_dir(),
config.kratix_input_dir(),
);
}
_ => {
log::error!("No workflow_type");
}
}


//pipeline::status();

//pipeline::list_files_recursively(_kratix_output_dir);

log::debug!("<- End Pipeline ->");
}


// validation function
fn validate_env_vars() -> Result<(), Vec<EnvVarError>> {
let required_vars = vec![
Expand Down

0 comments on commit 700fb9e

Please sign in to comment.