Skip to content

Commit

Permalink
patch: embedding templates and increasing wait time for results pulling.
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-viles committed Nov 1, 2022
1 parent cc595de commit e59e2e7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
23 changes: 15 additions & 8 deletions cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.
package cmd

import (
"embed"
"encoding/json"
"fmt"
"github.com/drew-viles/baskio/pkg/constants"
Expand All @@ -34,6 +35,12 @@ import (
"time"
)

//go:embed templates/*.html.gotmpl
var htmlTmpl embed.FS

//go:embed templates/js/*.js.gotmpl
var jsTmpl embed.FS

// fetchPagesRepo pulls the GitHub pages repo locally for modification.
func fetchPagesRepo(ghUser, ghToken, ghProject, ghBranch string) (string, *git.Repository, error) {
pagesRepo := fmt.Sprintf("https://%s:%s@github.com/%s/%s.git", ghUser, ghToken, ghUser, ghProject)
Expand Down Expand Up @@ -170,7 +177,7 @@ func generateHTMLTemplate(baseDir string, allReports map[int]constants.Year) err
log.Println("generating index.html")
// HTML template
htmlTarget := strings.Join([]string{baseDir, "index.html"}, "/")
htmlTmpl := "templates/index.html.gotmpl"

htmlFile, err := os.Create(htmlTarget)
if err != nil {
return err
Expand All @@ -179,7 +186,7 @@ func generateHTMLTemplate(baseDir string, allReports map[int]constants.Year) err
"inc": func(x int) int {
return x + 1
},
}).ParseFiles(htmlTmpl))
}).ParseFS(htmlTmpl))
if err != nil {
return err
}
Expand All @@ -203,7 +210,7 @@ func generateJSTemplates(baseDir string, allReports map[int]constants.Year) erro
// main.js template
log.Println("generating main.js")
mainJSTarget := filepath.Join(jsDir, "main.js")
mainJSTmpl := "templates/js/main.js.gotmpl"
//mainJSTmpl := "templates/js/main.js.gotmpl"
mainFile, err := os.Create(mainJSTarget)
if err != nil {
return err
Expand All @@ -213,7 +220,7 @@ func generateJSTemplates(baseDir string, allReports map[int]constants.Year) erro
"inc": func(x int) int {
return x + 1
},
}).ParseFiles(mainJSTmpl))
}).ParseFS(jsTmpl))
if err != nil {
return err
}
Expand All @@ -226,7 +233,7 @@ func generateJSTemplates(baseDir string, allReports map[int]constants.Year) erro
// class.js template
log.Println("generating class.js")
classJSTarget := filepath.Join(jsDir, "class.js")
classJSTmpl := "templates/js/class.js.gotmpl"
//classJSTmpl := "templates/js/class.js.gotmpl"
classFile, err := os.Create(classJSTarget)
if err != nil {
return err
Expand All @@ -236,7 +243,7 @@ func generateJSTemplates(baseDir string, allReports map[int]constants.Year) erro
"inc": func(x int) int {
return x + 1
},
}).ParseFiles(classJSTmpl))
}).ParseFS(jsTmpl))
if err != nil {
return err
}
Expand All @@ -249,7 +256,7 @@ func generateJSTemplates(baseDir string, allReports map[int]constants.Year) erro
// reports.js template
log.Println("generating reports.js")
reportJSTarget := filepath.Join(jsDir, "reports.js")
reportJSTmpl := "templates/js/reports.js.gotmpl"
//reportJSTmpl := "templates/js/reports.js.gotmpl"
reportFile, err := os.Create(reportJSTarget)
if err != nil {
return err
Expand All @@ -259,7 +266,7 @@ func generateJSTemplates(baseDir string, allReports map[int]constants.Year) erro
"inc": func(x int) int {
return x + 1
},
}).ParseFiles(reportJSTmpl))
}).ParseFS(jsTmpl))
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func fetchResultsFromServer(freeIP string, kp *keypairs.KeyPair) (*os.File, erro
defer client.Close()

log.Println("Successfully connected to ssh server.")
log.Println("waiting for the results of the scan to become available.")
time.Sleep(1 * time.Minute)
log.Println("waiting 2 minutes for the results of the scan to become available.")
time.Sleep(2 * time.Minute)

remoteCommand := "while [ ! -f /tmp/results.json ] && [ -s /tmp/results.json ] ; do echo \"results not ready\"; sleep 5; done;"
err = sshconnect.RunRemoteCommand(client, remoteCommand)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit e59e2e7

Please sign in to comment.