Skip to content

Commit

Permalink
Get template established
Browse files Browse the repository at this point in the history
  • Loading branch information
samueljmello committed Jul 25, 2023
1 parent d11fc9b commit 18c264e
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (

// tool vars
DefaultApiUrl string = "github.com"
DefaultIssueTitleTemplate string = "Post Migration Assessment"
DefaultIssueTitleTemplate string = "Post Migration Audit"
SourceRestClient api.RESTClient
TargetRestClient api.RESTClient
SourceGraphqlClient api.GQLClient
Expand Down Expand Up @@ -147,7 +147,7 @@ type secret struct {
Name string
}
type variables struct {
Variables []secret
Variables []variable
Total_Count int
}
type variable struct {
Expand Down Expand Up @@ -1082,14 +1082,39 @@ func ProcessIssues(client api.RESTClient, targetOrg string, reposToProcess []rep
// start timer
start := time.Now()

// create a template for the issue
issueTemplate := "# Audit Results\n"
issueTemplate += fmt.Sprintf(
"Audit last performed on %s at %s.\n\n",
time.Now().Format("2006-01-02"),
time.Now().Format("15:04:05"),
)
issueTemplate += "See below for migration details and whether "
issueTemplate += "you need to mitigate any items.\n\n"
issueTemplate += "## Details\n"
issueTemplate += "- **Migrated From:** %s\n"
issueTemplate += "- **Source Visibility:** %s\n\n"
issueTemplate += "## Items From Source\n"
issueTemplate += "- Variables: `%+v`\n"
issueTemplate += "- Secrets: `%+v`\n"
issueTemplate += "- Environments: `%+v`\n"
issueBody := fmt.Sprintf(
issueTemplate,
targetOrg,
repository.Visibility,
repository.Variables,
repository.Secrets,
repository.Environments,
)

if issuesResponse.Total_Count == 1 {

var updateResponse interface{}
// find issue number
foundIssue := issuesResponse.Items[0]
// update an issue
updateBody, err := json.Marshal(map[string]string{
"body": fmt.Sprintf("test: %s", time.Now()),
"body": issueBody,
})
if err != nil {
return err
Expand Down Expand Up @@ -1117,7 +1142,7 @@ func ProcessIssues(client api.RESTClient, targetOrg string, reposToProcess []rep
// create an issue
createBody, err := json.Marshal(map[string]string{
"title": DefaultIssueTitleTemplate,
"body": "first test",
"body": issueBody,
})
if err != nil {
return err
Expand Down

0 comments on commit 18c264e

Please sign in to comment.