-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved project management with
make
, burn
, and new move
comma…
…nds (#81) * rw `burn`; sync on `make` & `burn` * implement function move operation
- Loading branch information
Showing
11 changed files
with
941 additions
and
449 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,101 @@ | ||
use std::rc::Rc; | ||
|
||
use clap::ArgMatches; | ||
use dialoguer::Confirm; | ||
|
||
use crate::projectfs::{locate_asml_manifest, Project}; | ||
use crate::terraform; | ||
use crate::transpiler::toml::asml::ServiceRef; | ||
use crate::transpiler::toml::{asml, service}; | ||
|
||
pub fn command(matches: Option<&ArgMatches>) { | ||
let matches = match matches { | ||
Some(matches) => matches, | ||
_ => panic!("could not get matches for make command"), | ||
}; | ||
|
||
let manifest = match locate_asml_manifest() { | ||
Some(manifest) => manifest, | ||
None => panic!("could not find assemblylift.toml in tree"), | ||
}; | ||
let mut manifest_dir = manifest.1.clone(); | ||
manifest_dir.pop(); | ||
|
||
let project = Project::new(manifest.0.project.name.clone(), Some(manifest_dir.clone())); | ||
|
||
let mut resource_type: Option<&str> = None; | ||
let mut resource_name: Option<&str> = None; | ||
for el in matches | ||
.values_of("resource") | ||
.expect("must specify either 'service', 'function' as an argument to burn") | ||
{ | ||
if resource_type.is_none() { | ||
resource_type = Some(el); | ||
continue; | ||
} | ||
if resource_name.is_none() { | ||
resource_name = Some(el); | ||
continue; | ||
} | ||
} | ||
|
||
match resource_type { | ||
// Some("all") => terraform::commands::destroy(), | ||
|
||
Some("service") => { | ||
let service_name = resource_name.unwrap(); | ||
if Confirm::new() | ||
.with_prompt(format!( | ||
"Are you sure you want to destroy service \"{}\"?\nThis is PERMANENT!", | ||
service_name | ||
)) | ||
.interact() | ||
.unwrap() | ||
{ | ||
let mut manifest: asml::Manifest = manifest.0.clone(); | ||
manifest.remove_service(service_name); | ||
manifest | ||
.write(manifest_dir.clone()) | ||
.expect("could not write assemblylift.toml"); | ||
|
||
let mut service_dir = manifest_dir.clone(); | ||
service_dir.push("services"); | ||
service_dir.push(service_name); | ||
std::fs::remove_dir_all(service_dir).expect("could not remove service directory"); | ||
} | ||
} | ||
|
||
Some("function") => { | ||
let resource_name = resource_name.unwrap().to_string(); | ||
let function_name: Vec<&str> = resource_name.split(".").collect(); | ||
if function_name.len() != 2 { | ||
panic!("syntax is `burn function <service>.<function>`") | ||
} | ||
|
||
if Confirm::new() | ||
.with_prompt(format!( | ||
"Are you sure you want to destroy function \"{}\"\nThis is PERMANENT!", | ||
resource_name | ||
)) | ||
.interact() | ||
.unwrap() | ||
{ | ||
let service_dir = &*project.service_dir(function_name[0].into()).dir().clone(); | ||
let mut manifest_file = service_dir.clone(); | ||
manifest_file.push("service.toml"); | ||
let mut service_manifest = service::Manifest::read(&manifest_file).unwrap(); | ||
service_manifest.remove_function(function_name[1]); | ||
service_manifest.write(service_dir.clone()).unwrap(); | ||
std::fs::remove_dir_all( | ||
&*project | ||
.service_dir(function_name[0].into()) | ||
.function_dir(function_name[1].into()), | ||
) | ||
.expect("could not remove service directory"); | ||
} | ||
} | ||
|
||
pub fn command(_matches: Option<&ArgMatches>) { | ||
terraform::commands::destroy(); | ||
Some(_) => panic!("must specify either 'service', 'function', or 'all' as an argument to burn"), | ||
None => panic!("must specify either 'service', 'function' or 'all' as an argument to burn"), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ pub mod burn; | |
pub mod cast; | ||
pub mod init; | ||
pub mod make; | ||
pub mod r#move; | ||
pub mod pack; | ||
pub mod push; | ||
pub mod user; |
Oops, something went wrong.