Skip to content

Commit

Permalink
Improve help text for cloud profiles and correct url/device id valida…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: James Rhodes <[email protected]>
  • Loading branch information
jarhodes314 committed Dec 13, 2024
1 parent 3409583 commit 7cb04c5
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/core/tedge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ mockito = { workspace = true }
mqtt_tests = { workspace = true }
pem = { workspace = true }
predicates = { workspace = true }
rcgen = { workspace = true }
tedge_test_utils = { workspace = true }
tempfile = { workspace = true }
test-case = { workspace = true }
Expand Down
9 changes: 9 additions & 0 deletions crates/core/tedge/src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ use tedge_config::ProfileName;
pub enum CloudArg {
C8y {
/// The cloud profile you wish to use
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
},
Az {
/// The cloud profile you wish to use
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
},
Aws {
/// The cloud profile you wish to use
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
Expand Down Expand Up @@ -148,4 +151,10 @@ impl MaybeBorrowedCloud<'_> {
Self::Azure(Some(profile)) => format!("az@{profile}-bridge.conf").into(),
}
}

pub fn profile_name(&self) -> Option<&ProfileName> {
match self {
Self::Aws(profile) | Self::Azure(profile) | Self::C8y(profile) => profile.as_deref(),
}
}
}
30 changes: 25 additions & 5 deletions crates/core/tedge/src/cli/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ pub enum ConfigCmd {
/// Configuration key. Run `tedge config list --doc` for available keys
key: ReadableKey,

/// Cloud profile
/// The cloud profile you wish to use, if accessing a cloud configuration
/// (i.e. `c8y.*`, `az.*` or `aws.*`). If you don't wish to use cloud profiles,
/// or want to access the default profile, don't supply this.
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
},
Expand All @@ -25,7 +29,11 @@ pub enum ConfigCmd {
/// Configuration value.
value: String,

/// Cloud profile
/// The cloud profile you wish to use, if accessing a cloud configuration
/// (i.e. `c8y.*`, `az.*` or `aws.*`). If you don't wish to use cloud profiles,
/// or want to access the default profile, don't supply this.
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
},
Expand All @@ -35,7 +43,11 @@ pub enum ConfigCmd {
/// Configuration key. Run `tedge config list --doc` for available keys
key: WritableKey,

/// Cloud profile
/// The cloud profile you wish to use, if accessing a cloud configuration
/// (i.e. `c8y.*`, `az.*` or `aws.*`). If you don't wish to use cloud profiles,
/// or want to access the default profile, don't supply this.
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
},
Expand All @@ -48,7 +60,11 @@ pub enum ConfigCmd {
/// Configuration value.
value: String,

/// Cloud profile
/// The cloud profile you wish to use, if accessing a cloud configuration
/// (i.e. `c8y.*`, `az.*` or `aws.*`). If you don't wish to use cloud profiles,
/// or want to access the default profile, don't supply this.
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
profile: Option<ProfileName>,
},
Expand All @@ -61,8 +77,12 @@ pub enum ConfigCmd {
/// Configuration value.
value: String,

/// The cloud profile you wish to use, if accessing a cloud configuration
/// (i.e. `c8y.*`, `az.*` or `aws.*`). If you don't wish to use cloud profiles,
/// or want to access the default profile, don't supply this.
///
/// [env: TEDGE_CLOUD_PROFILE]
#[clap(long)]
/// Cloud profile
profile: Option<ProfileName>,
},

Expand Down
Loading

0 comments on commit 7cb04c5

Please sign in to comment.