Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ tempdir = "^0.3"
term = "^0.5"
untrusted = "^0.6"
webpki = "^0.18"
strfmt = "0.1.6"
strfmt = "0.1.6"
1 change: 1 addition & 0 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ fn do_logs(
clickwriteln!(writer, "Could not start editor: {}", e.description());
}
} else {
// TODO: This needs to use a channel to not block forever on -f now
while !env.ctrlcbool.load(Ordering::SeqCst) {
if let Ok(amt) = reader.read_line(&mut line) {
if amt > 0 {
Expand Down
62 changes: 62 additions & 0 deletions src/command_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use std::path::PathBuf;
use std::rc::Rc;

/// Things the can come after a | or > char in input
#[derive(Debug, PartialEq)]
enum RightExpr<'a> {
None,
/// pipe to command with args
Expand Down Expand Up @@ -797,6 +798,67 @@ Other help topics (type 'help [TOPIC]' for details)
dir.close().unwrap();
}

#[test]
fn unexpected_chars() {
let p = parse_line("test || this");
assert!(p.is_err());
assert_eq!(
p.err().unwrap().description(),
"Parse error at 5: unexpected ||"
);

let p = parse_line("test >>> this");
assert!(p.is_err());
assert_eq!(
p.err().unwrap().description(),
"Parse error at 5: unexpected >>"
);

let p = parse_line("test >>>> this");
assert!(p.is_err());
assert_eq!(
p.err().unwrap().description(),
"Parse error at 5: unexpected >>"
);

let p = build_parser_expr("a * b", std::ops::Range { start: 2, end: 5 });
assert!(p.is_err());
assert_eq!(
p.err().unwrap().description(),
"Parse error at 2: unexpected separator"
);
}

#[test]
fn build_parser_exp() {
let p = build_parser_expr("a | b", std::ops::Range { start: 2, end: 5 });
assert!(p.is_ok());
let r = p.unwrap();
assert_eq!(r.0, "a ");
assert_eq!(r.1, RightExpr::Pipe(" b"));

let p = build_parser_expr("a > b", std::ops::Range { start: 2, end: 5 });
assert!(p.is_ok());
let r = p.unwrap();
assert_eq!(r.0, "a ");
assert_eq!(r.1, RightExpr::Redir("b"));

let p = build_parser_expr("a >> b", std::ops::Range { start: 2, end: 6 });
assert!(p.is_ok());
let r = p.unwrap();
assert_eq!(r.0, "a ");
assert_eq!(r.1, RightExpr::Append("b"));
}

#[test]
fn hist_ignore() {
let mut p = get_processor();
let buf = vec![];
let writer = ClickWriter::with_buffer(buf, false);
p.process_line(" testcmd", writer);
assert_eq!(p.rl.history().len(), 0);
}

#[test]
fn test_alias_expand_line() {
let mut cc = ClickConfig::default();
Expand Down
9 changes: 8 additions & 1 deletion src/config/kube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use certs::{get_cert, get_cert_from_pem, get_key_from_str, get_private_key};
use error::{KubeErrNo, KubeError};
use kube::{ClientCertKey, Kluster, KlusterAuth};

use super::kubefile::AuthProvider;
use super::kubefile::{AuthProvider, ExecProvider};

#[derive(Debug)]
pub struct ClusterConf {
Expand Down Expand Up @@ -64,6 +64,7 @@ pub enum UserAuth {
KeyCertData(String, String),
UserPass(String, String),
AuthProvider(Box<AuthProvider>),
ExecProvider(ExecProvider),
}

#[derive(Debug)]
Expand Down Expand Up @@ -92,6 +93,9 @@ impl From<super::kubefile::UserConf> for UserConf {
if let Some(auth_provider) = conf.auth_provider {
auth_vec.push(UserAuth::AuthProvider(Box::new(auth_provider)))
}
if let Some(exec_conf) = conf.exec {
auth_vec.push(UserAuth::ExecProvider(ExecProvider::new(exec_conf)))
}
UserConf { auths: auth_vec }
}
}
Expand Down Expand Up @@ -336,6 +340,9 @@ impl Config {
provider.copy_up();
auth = Some(KlusterAuth::with_auth_provider(*provider.clone()))
}
UserAuth::ExecProvider(ref provider) => {
auth = Some(KlusterAuth::with_exec_provider(provider.clone()))
}
UserAuth::KeyCertData(ref cert_data, ref key_data) => {
client_cert_key = Some(cert_key_from_data(cert_data, key_data, context_name))
}
Expand Down
Loading