Skip to content

Commit

Permalink
feat(interface): checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Sanvoisin committed Jun 30, 2023
1 parent e75b936 commit 8a9c69f
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions checks/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package checks

import (
"fmt"
"guacamole/data"
"os"
"strconv"

Expand All @@ -10,31 +11,30 @@ import (

func Checks() {
fmt.Println("Guacamole is cooking 🥑")
totalChecks := 2
totalChecksOk := 0
// Checking the module for provider
check1 := ProviderInModule()
// Checkoing the naming of the resources
check2 := Naming()
//Calculating the score in percentage
if check1.Status == "✅" {
totalChecksOk++
// List of checks to perform
listOfChecks := []func() data.Check{
ProviderInModule,
Naming,
}
if check2.Status == "✅" {
totalChecksOk++
totalChecks := len(listOfChecks)
// Displaying the results
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Check", "Status", "Related guidelines"})
for i, check := range listOfChecks {
c := check()
if c.Status == "✅" {
totalChecksOk++
}
t.AppendRows([]table.Row{
{i + 1, c.Name, c.Status, c.RelatedGuidelines},
})
}
score := strconv.Itoa(totalChecksOk*100/totalChecks) + "%"
if score == "100%" {
score = score + " 🎉"
}
// Displaying the results
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Check", "Status", "Related guidelines"})
t.AppendRows([]table.Row{
{1, check1.Name, check1.Status, check1.RelatedGuidelines},
{2, check2.Name, check2.Status, check2.RelatedGuidelines},
})
t.AppendFooter(table.Row{"", "", "Score", score})
t.Render()
fmt.Println("Your guacamole is ready 🥑")
Expand Down

0 comments on commit 8a9c69f

Please sign in to comment.