Skip to content

Commit

Permalink
add logging and safety to enum-->string
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Feb 5, 2025
1 parent bb0ef88 commit 72abfa6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/github_issue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ impl From<Action> for String {
Action::List => String::from("List"),
Action::Read => String::from("Read"),
Action::Update => String::from("Update"),
_ => String::from("Unknown"),
}
}
}
Expand Down Expand Up @@ -120,7 +121,9 @@ impl<'issue> Issue<'issue> {
}),
None => octocrab::Octocrab::default(),
};
log::debug!("built octocrab client");
let issues = client.issues(self.owner, self.repo);
log::debug!("built octocrab issues");
// execute action and assign returned issue
let issue = match action {
// create an issue
Expand All @@ -132,6 +135,7 @@ impl<'issue> Issue<'issue> {
// update an issue
Action::Update => self.update(issues).await?,
};
log::debug!("issue interfacing completed");

Ok(issue)
}
Expand Down Expand Up @@ -161,6 +165,8 @@ impl<'issue> Issue<'issue> {
if self.milestone.is_some() {
issue = issue.milestone(self.milestone);
}

log::debug!("creating issue");
// send and await the issue
match issue.send().await {
// return created issue
Expand Down Expand Up @@ -190,6 +196,7 @@ impl<'issue> Issue<'issue> {
match self.number {
// issue number specified
Some(number) => {
log::debug!("reading issue");
// retrieve the issue with the handler
match issues.get(number).await {
Ok(issue) => return Ok(issue),
Expand Down Expand Up @@ -245,6 +252,8 @@ impl<'issue> Issue<'issue> {
let labels = self.labels.clone().unwrap();
issue_page = issue_page.labels(&labels[..]);
}*/

log::debug!("listing issues");
// send and await the issue page
let page = match issue_page.send().await {
// return issue pages
Expand Down Expand Up @@ -306,6 +315,8 @@ impl<'issue> Issue<'issue> {
if self.milestone.is_some() {
issue = issue.milestone(self.milestone.unwrap());
}

log::debug!("updating issue");
// send and await the issue
match issue.send().await {
// return updated issue
Expand Down
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ impl concourse_resource::Resource for GithubIssue {
panic!("the check step was unable to return a github issue from the source values");
}
};
log::info!("the github issue information was successfully retrieved");
log::info!(
"the github issue information was successfully retrieved for number {}",
issue.number
);

// return one sized version vector if issue is open and two sized if closed
match issue.state {
Expand Down Expand Up @@ -141,7 +144,11 @@ impl concourse_resource::Resource for GithubIssue {
);
}
};
log::info!("successful {} for the github issue", String::from(action));
log::info!(
"successful {} for the github issue number {}",
String::from(action),
issue.number
);

if source.number().is_none() {
// store created issue number in file for subsequent check step
Expand Down

0 comments on commit 72abfa6

Please sign in to comment.