Skip to content

Commit

Permalink
Proposal on using custom diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Zavhorodnii committed Jun 10, 2024
1 parent c82bf84 commit 7dbcd59
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions internal/threagile/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Config struct {
KeyFolder string

InputFile string
UseCustomDataFlowDiagram bool
UseCustomDataAssetDiagram bool
DataFlowDiagramFilenamePNG string
DataAssetDiagramFilenamePNG string
DataFlowDiagramFilenameDOT string
Expand Down Expand Up @@ -77,6 +79,8 @@ func (c *Config) Defaults(buildTimestamp string) *Config {
KeyFolder: KeyDir,

InputFile: InputFile,
UseCustomDataFlowDiagram: false,
UseCustomDataAssetDiagram: false,
DataFlowDiagramFilenamePNG: DataFlowDiagramFilenamePNG,
DataAssetDiagramFilenamePNG: DataAssetDiagramFilenamePNG,
DataFlowDiagramFilenameDOT: DataFlowDiagramFilenameDOT,
Expand Down Expand Up @@ -241,6 +245,12 @@ func (c *Config) Merge(config Config, values map[string]any) {
case strings.ToLower("InputFile"):
c.InputFile = config.InputFile

case strings.ToLower("UseCustomDataAssetDiagram"):
c.UseCustomDataAssetDiagram = config.UseCustomDataAssetDiagram

case strings.ToLower("UseCustomDataFlowDiagram"):
c.UseCustomDataFlowDiagram = config.UseCustomDataFlowDiagram

case strings.ToLower("DataFlowDiagramFilenamePNG"):
c.DataFlowDiagramFilenamePNG = config.DataFlowDiagramFilenamePNG

Expand Down Expand Up @@ -425,6 +435,14 @@ func (c *Config) GetInputFile() string {
return c.InputFile
}

func (c *Config) GetUseCustomDataFlowDiagram() bool {
return c.UseCustomDataFlowDiagram
}

func (c *Config) GetUseCustomDataAssetDiagram() bool {
return c.UseCustomDataAssetDiagram
}

func (c *Config) GetDataFlowDiagramFilenamePNG() string {
return c.DataFlowDiagramFilenamePNG
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/report/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type reportConfigReader interface {
GetTempFolder() string

GetInputFile() string
GetUseCustomDataAssetDiagram() bool
GetUseCustomDataFlowDiagram() bool
GetDataFlowDiagramFilenamePNG() string
GetDataAssetDiagramFilenamePNG() string
GetDataFlowDiagramFilenameDOT() string
Expand Down Expand Up @@ -86,7 +88,7 @@ func Generate(config reportConfigReader, readResult *model.ReadResult, commands
diagramDPI = config.GetMaxGraphvizDPI()
}
// Data-flow Diagram rendering
if generateDataFlowDiagram {
if generateDataFlowDiagram && !config.GetUseCustomDataFlowDiagram() {
gvFile := filepath.Join(config.GetOutputFolder(), config.GetDataFlowDiagramFilenameDOT())
if !config.GetKeepDiagramSourceFiles() {
tmpFileGV, err := os.CreateTemp(config.GetTempFolder(), config.GetDataFlowDiagramFilenameDOT())
Expand All @@ -108,7 +110,7 @@ func Generate(config reportConfigReader, readResult *model.ReadResult, commands
}
}
// Data Asset Diagram rendering
if generateDataAssetsDiagram {
if generateDataAssetsDiagram && !config.GetUseCustomDataAssetDiagram() {
gvFile := filepath.Join(config.GetOutputFolder(), config.GetDataAssetDiagramFilenameDOT())
if !config.GetKeepDiagramSourceFiles() {
tmpFile, err := os.CreateTemp(config.GetTempFolder(), config.GetDataAssetDiagramFilenameDOT())
Expand Down

0 comments on commit 7dbcd59

Please sign in to comment.