12 const networkTopologyDir string = "topo-network/"
13 const containerTopologyDir string = "topo-containers/"
20 type ActionResult struct {
27 type JsonResult struct {
34 func assertFileSize(f1, f2 string) error {
35 fi1, err := os.Stat(f1)
40 fi2, err1 := os.Stat(f2)
45 if fi1.Size() != fi2.Size() {
46 return fmt.Errorf("file sizes differ (%d vs %d)", fi1.Size(), fi2.Size())
51 func (c *Stanza) newStanza(name string) *Stanza {
52 c.append("\n" + name + " {")
57 func (c *Stanza) append(name string) *Stanza {
58 c.content += strings.Repeat(" ", c.pad)
59 c.content += name + "\n"
63 func (c *Stanza) close() *Stanza {
69 func (s *Stanza) toString() string {
73 func (s *Stanza) saveToFile(fileName string) error {
74 fo, err := os.Create(fileName)
80 _, err = io.Copy(fo, strings.NewReader(s.content))
84 // newHttpClient creates [http.Client] with disabled proxy and redirects, it also sets timeout to 30seconds.
85 func newHttpClient() *http.Client {
86 transport := http.DefaultTransport
87 transport.(*http.Transport).Proxy = nil
88 transport.(*http.Transport).DisableKeepAlives = true
89 client := &http.Client{
91 Timeout: time.Second * 30,
92 CheckRedirect: func(req *http.Request, via []*http.Request) error {
93 return http.ErrUseLastResponse