github.com/Cloud-Foundations/Dominator@v0.3.4/cmd/builder-tool/getDirectedGraph.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/Cloud-Foundations/Dominator/imagebuilder/client"
     8  	"github.com/Cloud-Foundations/Dominator/lib/log"
     9  	proto "github.com/Cloud-Foundations/Dominator/proto/imaginator"
    10  )
    11  
    12  func getDirectedGraphSubcommand(args []string, logger log.DebugLogger) error {
    13  	if err := getDirectedGraph(logger); err != nil {
    14  		return fmt.Errorf("error getting directed graph: %s", err)
    15  	}
    16  	return nil
    17  }
    18  
    19  func getDirectedGraph(logger log.Logger) error {
    20  	srpcClient := getImaginatorClient()
    21  	req := proto.GetDirectedGraphRequest{
    22  		Excludes: digraphExcludes,
    23  		Includes: digraphIncludes,
    24  	}
    25  	if result, err := client.GetDirectedGraph(srpcClient, req); err != nil {
    26  		return err
    27  	} else {
    28  		if len(result.GraphvizDot) > 0 {
    29  			os.Stdout.Write(result.GraphvizDot)
    30  			if result.GraphvizDot[len(result.GraphvizDot)-1] != '\n' {
    31  				fmt.Println()
    32  			}
    33  		}
    34  		if *showFetchLog {
    35  			os.Stderr.Write(result.FetchLog)
    36  		}
    37  	}
    38  	return nil
    39  }