Skip to content

Commit

Permalink
chore/add slug as critera for fetching account metadata (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
duonganhthu43 committed Aug 1, 2023
1 parent 2d8bc04 commit 2886764
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dozer-cli/src/cli/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub struct Cloud {
pub enum CloudCommands {
/// Login to Dozer Cloud service
Login {
#[arg(long = "organisation-name")]
organisation_name: Option<String>,
#[arg(long = "organisation_slug")]
organisation_slug: Option<String>,
},
/// Deploy application to Dozer Cloud
Deploy(DeployCommandArgs),
Expand Down
2 changes: 1 addition & 1 deletion dozer-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub trait CloudOrchestrator {
fn login(
&mut self,
cloud: Cloud,
organisation_name: Option<String>,
organisation_slug: Option<String>,
) -> Result<(), OrchestrationError>;
fn execute_secrets_command(
&mut self,
Expand Down
4 changes: 2 additions & 2 deletions dozer-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ fn run() -> Result<(), OrchestrationError> {
match cloud.command.clone() {
CloudCommands::Deploy(deploy) => dozer.deploy(cloud, deploy, cli.config_paths),
CloudCommands::Api(api) => dozer.api(cloud, api),
CloudCommands::Login { organisation_name } => {
dozer.login(cloud, organisation_name)
CloudCommands::Login { organisation_slug } => {
dozer.login(cloud, organisation_slug)
}
CloudCommands::Secrets(command) => {
dozer.execute_secrets_command(cloud, command)
Expand Down
4 changes: 2 additions & 2 deletions dozer-cli/src/simple/cloud/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ pub struct TokenResponse {
}
impl LoginSvc {
pub async fn new(
organisation_name: String,
organisation_slug: String,
target_url: String,
) -> Result<Self, CloudLoginError> {
let mut client = DozerPublicClient::connect(target_url.to_owned()).await?;
let company_info = client
.company_metadata(CompanyRequest {
criteria: Some(Criteria::Name(organisation_name.to_owned())),
criteria: Some(Criteria::Slug(organisation_slug.to_owned())),
})
.await
.map_err(|e| {
Expand Down
14 changes: 7 additions & 7 deletions dozer-cli/src/simple/cloud_orchestrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,24 +355,24 @@ impl CloudOrchestrator for SimpleOrchestrator {
fn login(
&mut self,
cloud: Cloud,
organisation_name: Option<String>,
organisation_slug: Option<String>,
) -> Result<(), OrchestrationError> {
info!("Organisation and client details can be created in https://dashboard.dev.getdozer.io/login \n");
let organisation_name = match organisation_name {
let organisation_slug = match organisation_slug {
None => {
let mut organisation_name = String::new();
println!("Please enter your organisation name:");
let mut organisation_slug = String::new();
println!("Please enter your organisation slug:");
io::stdin()
.read_line(&mut organisation_name)
.read_line(&mut organisation_slug)
.map_err(FailedToReadOrganisationName)?;
organisation_name.trim().to_string()
organisation_slug.trim().to_string()
}
Some(name) => name,
};

self.runtime.block_on(async move {
let login_svc = LoginSvc::new(
organisation_name,
organisation_slug,
cloud
.target_url
.unwrap_or(DEFAULT_CLOUD_TARGET_URL.to_string()),
Expand Down
3 changes: 2 additions & 1 deletion dozer-types/protos/cloud.proto
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,15 @@ message QueryGraph {
message CompanyRequest {
oneof criteria {
string iss = 1;
string name = 2;
string slug = 2;
}
}
message CompanyResponse {
string name = 1;
string auth_url = 2;
string iss = 3;
string jwks_url = 4;
string slug = 5;
}

message Secret {
Expand Down

0 comments on commit 2886764

Please sign in to comment.