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
18 changes: 2 additions & 16 deletions src/commands/connect/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,26 +203,12 @@ impl ConnectAuthStatusCommand {

if !me_full.organizations.is_empty() {
println!("\nOrganizations:");
// Calculate column widths
let max_slug = me_full
.organizations
.iter()
.map(|o| o.slug.len())
.max()
.unwrap_or(0);
for org in &me_full.organizations {
println!(
" {:<width$} role: {}",
org.slug,
org.role,
width = max_slug
);
println!(" {} (id: {}) role: {}", org.name, org.id, org.role);
}
println!(
"\nTip: Use org slugs with --org (e.g., --org {})",
me_full.organizations[0].slug
"\nTip: Use org ID with --org or set connect.org in avocado.yaml"
);
println!(" or set connect.org in avocado.yaml");
}
}
Err(e) => {
Expand Down
1 change: 0 additions & 1 deletion src/commands/connect/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub struct MeResponse {
pub struct OrgInfo {
pub id: String,
pub name: String,
pub slug: String,
pub role: String,
}

Expand Down
21 changes: 9 additions & 12 deletions src/commands/connect/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@ impl ConnectInitCommand {
// Non-interactive: use provided org
me.organizations
.iter()
.find(|o| o.slug == *org_flag || o.id == *org_flag)
.find(|o| o.id == *org_flag)
.cloned()
.ok_or_else(|| {
anyhow::anyhow!(
"Organization '{}' not found. Available: {}",
org_flag,
me.organizations
.iter()
.map(|o| o.slug.as_str())
.map(|o| o.name.as_str())
.collect::<Vec<_>>()
.join(", ")
)
})?
} else if me.organizations.len() == 1 {
let org = me.organizations[0].clone();
print_info(
&format!("Auto-selected organization: {} ({})", org.name, org.slug),
&format!("Auto-selected organization: {} ({})", org.name, org.id),
OutputLevel::Normal,
);
org
Expand All @@ -61,12 +61,12 @@ impl ConnectInitCommand {
};

// 3. Fetch projects for selected org
let projects = client.list_projects(&selected_org.slug).await?;
let projects = client.list_projects(&selected_org.id).await?;

if projects.is_empty() {
anyhow::bail!(
"No projects found in org '{}'. Create a project in the web UI first.",
selected_org.slug
selected_org.name
);
}

Expand Down Expand Up @@ -100,7 +100,7 @@ impl ConnectInitCommand {

// 5. Fetch server key
print_info("Fetching server signing key...", OutputLevel::Normal);
let server_key = client.get_tuf_server_key(&selected_org.slug).await?;
let server_key = client.get_tuf_server_key(&selected_org.id).await?;

// 6. Write to avocado.yaml
let config_path = Path::new(&self.config_path);
Expand All @@ -113,7 +113,7 @@ impl ConnectInitCommand {

config_edit::set_connect_fields(
config_path,
&selected_org.slug,
&selected_org.id,
&selected_project.id,
&server_key.public_key_hex,
)?;
Expand All @@ -132,10 +132,7 @@ impl ConnectInitCommand {

println!();
print_success("Connect configured:", OutputLevel::Normal);
println!(
" Org: {} ({})",
selected_org.name, selected_org.slug
);
println!(" Org: {} ({})", selected_org.name, selected_org.id);
println!(
" Project: {} (id: {})",
selected_project.name, selected_project.id
Expand All @@ -156,7 +153,7 @@ fn prompt_select_org(orgs: &[OrgInfo]) -> Result<OrgInfo> {
" [{}] {} ({}) - role: {}",
i + 1,
org.name,
org.slug,
org.id,
org.role
);
}
Expand Down
18 changes: 6 additions & 12 deletions src/commands/connect/orgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ impl ConnectOrgsListCommand {
return Ok(());
}

let max_slug = me
.organizations
.iter()
.map(|o| o.slug.len())
.max()
.unwrap_or(0);
let max_name = me
.organizations
.iter()
Expand All @@ -35,20 +29,20 @@ impl ConnectOrgsListCommand {
.unwrap_or(0);

println!(
"{:<slug_w$} {:<name_w$} ROLE",
"SLUG",
"{:<name_w$} {:<id_w$} ROLE",
"NAME",
slug_w = max_slug,
"ID",
name_w = max_name,
id_w = 36,
);
for org in &me.organizations {
println!(
"{:<slug_w$} {:<name_w$} {}",
org.slug,
"{:<name_w$} {:<id_w$} {}",
org.name,
org.id,
org.role,
slug_w = max_slug,
name_w = max_name,
id_w = 36,
);
}

Expand Down
44 changes: 22 additions & 22 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ enum ConnectCommands {
},
/// Initialize connect settings in avocado.yaml (org, project, server key)
Init {
/// Organization slug or ID (skip interactive prompt)
/// Organization ID (skip interactive prompt)
#[arg(long)]
org: Option<String>,
/// Project name or ID (skip interactive prompt)
Expand Down Expand Up @@ -478,7 +478,7 @@ enum ConnectCommands {
},
/// Upload current runtime build to the Connect platform
Upload {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Project ID (or set connect.project in avocado.yaml)
Expand Down Expand Up @@ -507,7 +507,7 @@ enum ConnectCommands {
},
/// Retrieve the Connect server's TUF signing public key
ServerKey {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -533,7 +533,7 @@ enum ConnectCommands {
enum ConnectTrustCommands {
/// Show fleet trust status for an organization
Status {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -548,7 +548,7 @@ enum ConnectTrustCommands {
/// Name of the local root signing key to use
#[arg(long)]
key: String,
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -563,7 +563,7 @@ enum ConnectTrustCommands {
/// Name of the local root signing key (required at security level 2)
#[arg(long)]
key: Option<String>,
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -585,7 +585,7 @@ enum ConnectKeysCommands {
/// Name of the local signing key (from 'avocado signing-keys list')
#[arg(long)]
key: String,
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -599,7 +599,7 @@ enum ConnectKeysCommands {
Approve {
/// Key ID of the staged key to approve
keyid: String,
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -611,7 +611,7 @@ enum ConnectKeysCommands {
},
/// List delegate keys registered with the server
List {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Filter by key type: content or root
Expand All @@ -628,7 +628,7 @@ enum ConnectKeysCommands {
Retire {
/// Key ID of the staged key to discard
keyid: String,
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -654,7 +654,7 @@ enum ConnectOrgsCommands {
enum ConnectProjectsCommands {
/// List projects in an organization
List {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -666,7 +666,7 @@ enum ConnectProjectsCommands {
},
/// Create a new project
Create {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Project name
Expand All @@ -684,7 +684,7 @@ enum ConnectProjectsCommands {
},
/// Delete a project
Delete {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Project ID to delete
Expand All @@ -706,7 +706,7 @@ enum ConnectProjectsCommands {
enum ConnectDevicesCommands {
/// List devices in an organization
List {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -718,7 +718,7 @@ enum ConnectDevicesCommands {
},
/// Create a new device
Create {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Device name
Expand All @@ -736,7 +736,7 @@ enum ConnectDevicesCommands {
},
/// Delete a device
Delete {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Device ID to delete
Expand All @@ -758,7 +758,7 @@ enum ConnectDevicesCommands {
enum ConnectCohortsCommands {
/// List cohorts in a project
List {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Project ID (or set connect.project in avocado.yaml)
Expand All @@ -773,7 +773,7 @@ enum ConnectCohortsCommands {
},
/// Create a new cohort
Create {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Project ID (or set connect.project in avocado.yaml)
Expand All @@ -794,7 +794,7 @@ enum ConnectCohortsCommands {
},
/// Delete a cohort
Delete {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Project ID (or set connect.project in avocado.yaml)
Expand All @@ -819,7 +819,7 @@ enum ConnectCohortsCommands {
enum ConnectClaimTokensCommands {
/// List claim tokens in an organization
List {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Path to avocado.yaml configuration file
Expand All @@ -831,7 +831,7 @@ enum ConnectClaimTokensCommands {
},
/// Create a new claim token
Create {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Token name
Expand All @@ -855,7 +855,7 @@ enum ConnectClaimTokensCommands {
},
/// Delete a claim token
Delete {
/// Organization slug or ID (or set connect.org in avocado.yaml)
/// Organization ID (or set connect.org in avocado.yaml)
#[arg(long)]
org: Option<String>,
/// Claim token ID to delete
Expand Down
Loading