Skip to content

Commit

Permalink
Add version field to config file
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Jul 17, 2024
1 parent b0d8d66 commit c5d1729
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cli/cmd/project/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,15 @@ impl Input {
};
if let Some(details) = opt_details {
let target = self.target_dir()?.join(&details.slug);
let renku_project_cfg = RenkuProjectConfig {
renku_url: ctx.renku_url.clone(),
project: ProjectInfo {
let renku_project_cfg = RenkuProjectConfig::new(
&ctx.renku_url,
ProjectInfo {
id: details.id.clone(),
namespace: details.namespace.clone(),
slug: details.slug.clone(),
},
};
);

ctx.write_err(&SimpleMessage {
message: format!(
"Cloning {} ({}) into {}...",
Expand Down
12 changes: 12 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ pub enum ConfigError {

#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct RenkuProjectConfig {
/// The version of this config file.
version: u16,

/// The base url to the renku platform.
pub renku_url: String,

Expand All @@ -43,6 +46,14 @@ pub struct ProjectInfo {
}

impl RenkuProjectConfig {
pub fn new<S: AsRef<str>>(renku_url: S, project: ProjectInfo) -> RenkuProjectConfig {
RenkuProjectConfig {
version: 1,
renku_url: renku_url.as_ref().into(),
project,
}
}

pub fn read(file: &Path) -> Result<RenkuProjectConfig, ConfigError> {
let cnt = std::fs::read_to_string(file).map_err(|e| ConfigError::ReadFile {
source: e,
Expand Down Expand Up @@ -82,6 +93,7 @@ impl RenkuProjectConfig {
#[test]
fn write_and_read_config() {
let data = RenkuProjectConfig {
version: 1,
renku_url: "http://renkulab.io".into(),
project: ProjectInfo {
id: "abc123".into(),
Expand Down

0 comments on commit c5d1729

Please sign in to comment.