try calculating version number
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
9
main.go
9
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 := "<table><tr><td>New Table Row 1</td></tr></table>"
|
||||
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 := "<table><tbody><tr><th>VM Name</th><th>Cluster Name</th></tr><tr><td>VM1</td><td>Cluster1</td></tr></tbody></table>"
|
||||
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,
|
||||
|
Reference in New Issue
Block a user