|
|
|
|
@@ -20,7 +20,7 @@ use clap::{App, SubCommand, Arg};
|
|
|
|
|
|
|
|
|
|
mod cmn;
|
|
|
|
|
|
|
|
|
|
use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg,
|
|
|
|
|
use cmn::{InvalidOptionsError, CLIError, JsonTokenStorage, arg_from_str, writer_from_opts, parse_kv_arg,
|
|
|
|
|
input_file_from_opts, input_mime_from_opts, FieldCursor, FieldError, CallType, UploadProtocol,
|
|
|
|
|
calltype_from_str, remove_json_null_values, ComplexType, JsonType, JsonTypeInfo};
|
|
|
|
|
|
|
|
|
|
@@ -36,19 +36,19 @@ enum DoitError {
|
|
|
|
|
ApiError(api::Error),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Engine<'n, 'a> {
|
|
|
|
|
opt: ArgMatches<'n, 'a>,
|
|
|
|
|
struct Engine<'n> {
|
|
|
|
|
opt: ArgMatches<'n>,
|
|
|
|
|
hub: api::DeploymentManager<hyper::Client, Authenticator<DefaultAuthenticatorDelegate, JsonTokenStorage, hyper::Client>>,
|
|
|
|
|
gp: Vec<&'static str>,
|
|
|
|
|
gpm: Vec<(&'static str, &'static str)>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
fn _deployments_delete(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
impl<'n> Engine<'n> {
|
|
|
|
|
fn _deployments_delete(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.deployments().delete(opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
_ => {
|
|
|
|
|
@@ -61,7 +61,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v } ));
|
|
|
|
|
@@ -74,7 +74,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -97,10 +97,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _deployments_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _deployments_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.deployments().get(opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
_ => {
|
|
|
|
|
@@ -113,7 +113,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v } ));
|
|
|
|
|
@@ -126,7 +126,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -149,13 +149,13 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _deployments_insert(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _deployments_insert(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
|
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
|
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
|
|
|
|
|
|
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let last_errc = err.issues.len();
|
|
|
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
|
|
|
let mut temp_cursor = field_cursor.clone();
|
|
|
|
|
@@ -169,8 +169,8 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
|
|
|
|
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
|
|
|
match &temp_cursor.to_string()[..] {
|
|
|
|
|
"update-time" => Some(("updateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
|
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
|
|
|
@@ -196,7 +196,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
let mut request: api::Deployment = json::value::from_value(object).unwrap();
|
|
|
|
|
let mut call = self.hub.deployments().insert(request, opt.value_of("project").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
_ => {
|
|
|
|
|
@@ -209,7 +209,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v } ));
|
|
|
|
|
@@ -222,7 +222,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -245,10 +245,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _deployments_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _deployments_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.deployments().list(opt.value_of("project").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"page-token" => {
|
|
|
|
|
@@ -270,7 +270,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v));
|
|
|
|
|
@@ -284,7 +284,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -307,13 +307,13 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _deployments_patch(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _deployments_patch(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
|
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
|
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
|
|
|
|
|
|
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let last_errc = err.issues.len();
|
|
|
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
|
|
|
let mut temp_cursor = field_cursor.clone();
|
|
|
|
|
@@ -327,8 +327,8 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
|
|
|
|
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
|
|
|
match &temp_cursor.to_string()[..] {
|
|
|
|
|
"update-time" => Some(("updateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
|
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
|
|
|
@@ -354,7 +354,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
let mut request: api::Deployment = json::value::from_value(object).unwrap();
|
|
|
|
|
let mut call = self.hub.deployments().patch(request, opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"update-policy" => {
|
|
|
|
|
@@ -376,7 +376,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["delete-policy", "update-policy", "create-policy"].iter().map(|v|*v));
|
|
|
|
|
@@ -390,7 +390,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -413,13 +413,13 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _deployments_update(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _deployments_update(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
|
|
|
|
|
let mut field_cursor = FieldCursor::default();
|
|
|
|
|
let mut object = json::value::Value::Object(Default::default());
|
|
|
|
|
|
|
|
|
|
for kvarg in opt.values_of("kv").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for kvarg in opt.values_of("kv").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let last_errc = err.issues.len();
|
|
|
|
|
let (key, value) = parse_kv_arg(&*kvarg, err, false);
|
|
|
|
|
let mut temp_cursor = field_cursor.clone();
|
|
|
|
|
@@ -433,8 +433,8 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
|
|
|
|
|
|
|
|
let type_info: Option<(&'static str, JsonTypeInfo)> =
|
|
|
|
|
match &temp_cursor.to_string()[..] {
|
|
|
|
|
"update-time" => Some(("updateTime", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
|
|
|
"description" => Some(("description", JsonTypeInfo { jtype: JsonType::String, ctype: ComplexType::Pod })),
|
|
|
|
|
@@ -460,7 +460,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
let mut request: api::Deployment = json::value::from_value(object).unwrap();
|
|
|
|
|
let mut call = self.hub.deployments().update(request, opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"update-policy" => {
|
|
|
|
|
@@ -482,7 +482,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["delete-policy", "update-policy", "create-policy"].iter().map(|v|*v));
|
|
|
|
|
@@ -496,7 +496,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -519,10 +519,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _manifests_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _manifests_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.manifests().get(opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""), opt.value_of("manifest").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
_ => {
|
|
|
|
|
@@ -535,7 +535,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v } ));
|
|
|
|
|
@@ -548,7 +548,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -571,10 +571,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _manifests_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _manifests_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.manifests().list(opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"page-token" => {
|
|
|
|
|
@@ -596,7 +596,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v));
|
|
|
|
|
@@ -610,7 +610,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -633,10 +633,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _operations_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _operations_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.operations().get(opt.value_of("project").unwrap_or(""), opt.value_of("operation").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
_ => {
|
|
|
|
|
@@ -649,7 +649,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v } ));
|
|
|
|
|
@@ -662,7 +662,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -685,10 +685,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _operations_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _operations_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.operations().list(opt.value_of("project").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"page-token" => {
|
|
|
|
|
@@ -710,7 +710,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v));
|
|
|
|
|
@@ -724,7 +724,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -747,10 +747,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _resources_get(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _resources_get(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.resources().get(opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""), opt.value_of("resource").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
_ => {
|
|
|
|
|
@@ -763,7 +763,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v } ));
|
|
|
|
|
@@ -776,7 +776,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -799,10 +799,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _resources_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _resources_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.resources().list(opt.value_of("project").unwrap_or(""), opt.value_of("deployment").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"page-token" => {
|
|
|
|
|
@@ -824,7 +824,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v));
|
|
|
|
|
@@ -838,7 +838,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -861,10 +861,10 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn _types_list(&self, opt: &ArgMatches<'n, 'a>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
fn _types_list(&self, opt: &ArgMatches<'n>, dry_run: bool, err: &mut InvalidOptionsError)
|
|
|
|
|
-> Result<(), DoitError> {
|
|
|
|
|
let mut call = self.hub.types().list(opt.value_of("project").unwrap_or(""));
|
|
|
|
|
for parg in opt.values_of("v").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for parg in opt.values_of("v").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
let (key, value) = parse_kv_arg(&*parg, err, false);
|
|
|
|
|
match key {
|
|
|
|
|
"page-token" => {
|
|
|
|
|
@@ -886,7 +886,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !found {
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
err.issues.push(CLIError::UnknownParameter(key.to_string(),
|
|
|
|
|
{let mut v = Vec::new();
|
|
|
|
|
v.extend(self.gp.iter().map(|v|*v));
|
|
|
|
|
v.extend(["filter", "page-token", "max-results"].iter().map(|v|*v));
|
|
|
|
|
@@ -900,7 +900,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
Ok(())
|
|
|
|
|
} else {
|
|
|
|
|
assert!(err.issues.len() == 0);
|
|
|
|
|
for scope in self.opt.values_of("url").unwrap_or(Vec::new()).iter() {
|
|
|
|
|
for scope in self.opt.values_of("url").map(|i|i.collect()).unwrap_or(Vec::new()).iter() {
|
|
|
|
|
call = call.add_scope(scope);
|
|
|
|
|
}
|
|
|
|
|
let mut ostream = match writer_from_opts(opt.value_of("out")) {
|
|
|
|
|
@@ -1024,14 +1024,14 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Please note that this call will fail if any part of the opt can't be handled
|
|
|
|
|
fn new(opt: ArgMatches<'a, 'n>) -> Result<Engine<'a, 'n>, InvalidOptionsError> {
|
|
|
|
|
fn new(opt: ArgMatches<'n>) -> Result<Engine<'n>, InvalidOptionsError> {
|
|
|
|
|
let (config_dir, secret) = {
|
|
|
|
|
let config_dir = match cmn::assure_config_dir_exists(opt.value_of("folder").unwrap_or("~/.google-service-cli")) {
|
|
|
|
|
Err(e) => return Err(InvalidOptionsError::single(e, 3)),
|
|
|
|
|
Ok(p) => p,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
match cmn::application_secret_from_directory(&config_dir, "deploymentmanager2-beta2-secret.json",
|
|
|
|
|
match cmn::application_secret_from_directory(&config_dir, "deploymentmanager2-beta2-secret.json",
|
|
|
|
|
"{\"installed\":{\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"client_secret\":\"hCsslbCUyfehWMmbkG8vTYxG\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"client_email\":\"\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"oob\"],\"client_x509_cert_url\":\"\",\"client_id\":\"620010449518-9ngf7o4dhs0dka470npqvor6dc5lqb9b.apps.googleusercontent.com\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\"}}") {
|
|
|
|
|
Ok(secret) => (config_dir, secret),
|
|
|
|
|
Err(e) => return Err(InvalidOptionsError::single(e, 4))
|
|
|
|
|
@@ -1051,7 +1051,7 @@ impl<'n, 'a> Engine<'n, 'a> {
|
|
|
|
|
db_dir: config_dir.clone(),
|
|
|
|
|
}, None);
|
|
|
|
|
|
|
|
|
|
let client =
|
|
|
|
|
let client =
|
|
|
|
|
if opt.is_present("debug") {
|
|
|
|
|
hyper::Client::with_connector(mock::TeeConnector {
|
|
|
|
|
connector: hyper::net::HttpsConnector::<hyper::net::Openssl>::default()
|
|
|
|
|
@@ -1090,7 +1090,7 @@ fn main() {
|
|
|
|
|
let mut exit_status = 0i32;
|
|
|
|
|
let arg_data = [
|
|
|
|
|
("deployments", "methods: 'delete', 'get', 'insert', 'list', 'patch' and 'update'", vec![
|
|
|
|
|
("delete",
|
|
|
|
|
("delete",
|
|
|
|
|
Some(r##"Deletes a deployment and all of the resources in the deployment."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/deployments_delete",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1118,7 +1118,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("get",
|
|
|
|
|
("get",
|
|
|
|
|
Some(r##"Gets information about a specific deployment."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/deployments_get",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1146,7 +1146,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("insert",
|
|
|
|
|
("insert",
|
|
|
|
|
Some(r##"Creates a deployment and all of the resources described by the deployment manifest."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/deployments_insert",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1174,7 +1174,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("list",
|
|
|
|
|
("list",
|
|
|
|
|
Some(r##"Lists all deployments for a given project."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/deployments_list",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1196,7 +1196,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("patch",
|
|
|
|
|
("patch",
|
|
|
|
|
Some(r##"Updates a deployment and all of the resources described by the deployment manifest. This method supports patch semantics."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/deployments_patch",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1230,7 +1230,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("update",
|
|
|
|
|
("update",
|
|
|
|
|
Some(r##"Updates a deployment and all of the resources described by the deployment manifest."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/deployments_update",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1267,7 +1267,7 @@ fn main() {
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
("manifests", "methods: 'get' and 'list'", vec![
|
|
|
|
|
("get",
|
|
|
|
|
("get",
|
|
|
|
|
Some(r##"Gets information about a specific manifest."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/manifests_get",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1301,7 +1301,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("list",
|
|
|
|
|
("list",
|
|
|
|
|
Some(r##"Lists all manifests for a given deployment."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/manifests_list",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1332,7 +1332,7 @@ fn main() {
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
("operations", "methods: 'get' and 'list'", vec![
|
|
|
|
|
("get",
|
|
|
|
|
("get",
|
|
|
|
|
Some(r##"Gets information about a specific operation."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/operations_get",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1360,7 +1360,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("list",
|
|
|
|
|
("list",
|
|
|
|
|
Some(r##"Lists all operations for a project."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/operations_list",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1385,7 +1385,7 @@ fn main() {
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
("resources", "methods: 'get' and 'list'", vec![
|
|
|
|
|
("get",
|
|
|
|
|
("get",
|
|
|
|
|
Some(r##"Gets information about a single resource."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/resources_get",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1419,7 +1419,7 @@ fn main() {
|
|
|
|
|
Some(false),
|
|
|
|
|
Some(false)),
|
|
|
|
|
]),
|
|
|
|
|
("list",
|
|
|
|
|
("list",
|
|
|
|
|
Some(r##"Lists all resources in a given deployment."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/resources_list",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1450,7 +1450,7 @@ fn main() {
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
("types", "methods: 'list'", vec![
|
|
|
|
|
("list",
|
|
|
|
|
("list",
|
|
|
|
|
Some(r##"Lists all resource types for Deployment Manager."##),
|
|
|
|
|
"Details at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli/types_list",
|
|
|
|
|
vec![
|
|
|
|
|
@@ -1478,7 +1478,7 @@ fn main() {
|
|
|
|
|
|
|
|
|
|
let mut app = App::new("deploymentmanager2-beta2")
|
|
|
|
|
.author("Sebastian Thiel <byronimo@gmail.com>")
|
|
|
|
|
.version("0.3.2+20150831")
|
|
|
|
|
.version("0.3.3+20160125")
|
|
|
|
|
.about("The Deployment Manager API allows users to declaratively configure, deploy and run complex solutions on the Google Cloud Platform.")
|
|
|
|
|
.after_help("All documentation details can be found at http://byron.github.io/google-apis-rs/google_deploymentmanager2_beta2_cli")
|
|
|
|
|
.arg(Arg::with_name("url")
|
|
|
|
|
@@ -1502,7 +1502,7 @@ fn main() {
|
|
|
|
|
.multiple(false)
|
|
|
|
|
.takes_value(false));
|
|
|
|
|
|
|
|
|
|
for &(main_command_name, ref about, ref subcommands) in arg_data.iter() {
|
|
|
|
|
for &(main_command_name, about, ref subcommands) in arg_data.iter() {
|
|
|
|
|
let mut mcmd = SubCommand::with_name(main_command_name).about(about);
|
|
|
|
|
|
|
|
|
|
for &(sub_command_name, ref desc, url_info, ref args) in subcommands {
|
|
|
|
|
@@ -1513,7 +1513,7 @@ fn main() {
|
|
|
|
|
scmd = scmd.after_help(url_info);
|
|
|
|
|
|
|
|
|
|
for &(ref arg_name, ref flag, ref desc, ref required, ref multi) in args {
|
|
|
|
|
let arg_name_str =
|
|
|
|
|
let arg_name_str =
|
|
|
|
|
match (arg_name, flag) {
|
|
|
|
|
(&Some(an), _ ) => an,
|
|
|
|
|
(_ , &Some(f)) => f,
|
|
|
|
|
|