From 220eca018cbc232b3e0411d59245d01c3fc21509 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Thu, 26 Oct 2023 15:41:28 +1100 Subject: [PATCH] try calculating version number --- main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 55c6efa..bddc223 100644 --- a/main.go +++ b/main.go @@ -217,11 +217,11 @@ func updateHtml(htmlContent string, heading string, newTable string) string { // Find the h2 heading that matches our heading passed to the function doc.Find("h2").Each(func(i int, s *goquery.Selection) { if s.Text() == heading { + fmt.Printf("Found h2 element matching '%s'\n", heading) // Find the table that follows this h2 heading table := s.NextFiltered("table") // Replace the table with a new table - //newTableHTML := "
New Table Row 1
" newTable, _ := goquery.NewDocumentFromReader(strings.NewReader(newTable)) table.ReplaceWithSelection(newTable.Selection) } @@ -244,7 +244,6 @@ func updateHtml(htmlContent string, heading string, newTable string) string { func main() { // Command line flags - vURL := flag.String("url", "", "The URL of a vCenter server, eg https://server.domain.example/sdk") vUser := flag.String("user", "", "The username to use when connecting to vCenter") vPass := flag.String("password", "", "The password to use when connecting to vCenter") @@ -288,6 +287,7 @@ func main() { log.Printf("Updated vCenter URL to '%v'\n", u) } } + vCenterHostname := u.Host log.Printf("Connecting to vCenter %s\n", u) u.User = url.UserPassword(*vUser, *vPass) @@ -340,6 +340,7 @@ func main() { } fmt.Printf("%+v\n", c) fmt.Printf("Current version number : '%d'\n", c.Version.Number) + newVersion := c.Version.Number + 1 // Generate new content for confluence @@ -347,7 +348,7 @@ func main() { //dummyTable := "
VM NameCluster Name
VM1Cluster1
" newTable := generateBusSharingTable() - newContent := updateHtml(c.Body.Storage.Value, "wsdc-vc-npr.srv.westpac.com.au", newTable) + newContent := updateHtml(c.Body.Storage.Value, vCenterHostname, newTable) fmt.Printf("New Content: %v\n", newContent) data := &goconfluence.Content{ @@ -361,7 +362,7 @@ func main() { }, }, Version: &goconfluence.Version{ - Number: 6, + Number: newVersion, }, Space: &goconfluence.Space{ Key: *cSpaceKey,