Skip to content

Commit

Permalink
workflow patches
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Mar 3, 2023
1 parent e15a42a commit b66a1d5
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions ol/genesis-tools/src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ impl Default for GenesisWizard {
impl GenesisWizard {
/// start wizard for end-to-end genesis
pub fn start_wizard(&mut self) -> anyhow::Result<()> {
// check the git token is as expected, and set it.
self.git_token_check()?;

let to_genesis = Confirm::new()
.with_prompt("Skip registration, straight to genesis?")
.interact()
Expand Down Expand Up @@ -137,13 +140,13 @@ impl GenesisWizard {
thread::sleep(Duration::from_millis(100));
}
} else {
println!("Please wait for everyone to finish genesis and come back");
println!("Please wait for everyone to finish genesis and come back");
}

Ok(())
}

fn git_setup(&mut self) -> anyhow::Result<()> {
fn git_token_check(&mut self) -> anyhow::Result<()> {
let gh_token_path = self.data_path.join("github_token.txt");
if !Path::exists(&gh_token_path) {
println!("no github token found");
Expand All @@ -159,16 +162,16 @@ impl GenesisWizard {
}

self.github_token = std::fs::read_to_string(&gh_token_path)?;
OLProgress::complete(&format!("github token found, [{}]", &self.github_token));

let gh_client = diem_github_client::Client::new(
self.repo_owner.clone(),
let temp_gh_client = diem_github_client::Client::new(
self.repo_owner.clone(), // doesn't matter
self.repo_name.clone(),
"master".to_string(),
self.github_token.clone(),
);

// Use the github token to find out who is the user behind it.
self.github_username = gh_client.get_authenticated_user()?;
self.github_username = temp_gh_client.get_authenticated_user()?;

if !Confirm::new()
.with_prompt(format!(
Expand All @@ -181,6 +184,19 @@ impl GenesisWizard {
return Ok(());
}


Ok(())
}

fn git_setup(&mut self) -> anyhow::Result<()> {
let gh_client = diem_github_client::Client::new(
self.repo_owner.clone(),
self.repo_name.clone(),
"master".to_string(),
self.github_token.clone(),
);

// Use the github token to find out who is the user behind it
// check if a gitbhub repo was already created.
let user_gh_client = diem_github_client::Client::new(
self.github_username.clone(),
Expand Down Expand Up @@ -230,8 +246,6 @@ impl GenesisWizard {
self.data_path.clone(),
)?;



// # OPER does this
// # Submits operator key to github, and creates local OPERATOR_ACCOUNT
// oper-key:
Expand All @@ -248,15 +262,13 @@ impl GenesisWizard {

own.execute()?;


pb.set_message("registering the OPERATOR account.");
let op = OperatorKey {
key: Key::new(&val, &oper_shared),
};

op.execute()?;


// # OWNER does this
// # Submits operator key to github, does *NOT* create the OWNER_ACCOUNT locally
// owner-key:
Expand All @@ -271,7 +283,6 @@ impl GenesisWizard {

set_oper.execute()?;


// # OWNER does this
// # Links to an operator on github, creates the OWNER_ACCOUNT locally
// assign:
Expand Down Expand Up @@ -316,7 +327,7 @@ impl GenesisWizard {

pb.finish_and_clear();
OLProgress::complete("Registered configs on github");

Ok(())
}

Expand Down

0 comments on commit b66a1d5

Please sign in to comment.