Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running program #117

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 6 additions & 72 deletions internal/threagile/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"encoding/json"
"errors"
"fmt"
"gopkg.in/yaml.v3"
"log"
"os"
"path/filepath"
"runtime"
"strings"

"gopkg.in/yaml.v3"

"github.com/threagile/threagile/pkg/report"
"github.com/threagile/threagile/pkg/types"
)
Expand Down Expand Up @@ -64,75 +65,6 @@ type Config struct {
ReportConfigurationValue report.ReportConfiguation `json:"ReportConfiguration" yaml:"ReportConfiguration"`
}

type ConfigGetter interface {
GetBuildTimestamp() string
GetVerbose() bool
GetInteractive() bool
GetAppFolder() string
GetPluginFolder() string
GetDataFolder() string
GetOutputFolder() string
GetServerFolder() string
GetTempFolder() string
GetKeyFolder() string
GetTechnologyFilename() string
GetInputFile() string
GetDataFlowDiagramFilenamePNG() string
GetDataAssetDiagramFilenamePNG() string
GetDataFlowDiagramFilenameDOT() string
GetDataAssetDiagramFilenameDOT() string
GetReportFilename() string
GetExcelRisksFilename() string
GetExcelTagsFilename() string
GetJsonRisksFilename() string
GetJsonTechnicalAssetsFilename() string
GetJsonStatsFilename() string
GetReportLogoImagePath() string
GetTemplateFilename() string
GetRiskRulePlugins() []string
GetSkipRiskRules() []string
GetExecuteModelMacro() string
GetRiskExcelConfigHideColumns() []string
GetRiskExcelConfigSortByColumns() []string
GetRiskExcelConfigWidthOfColumns() map[string]float64
GetRiskExcelWrapText() bool
GetRiskExcelShrinkColumnsToFit() bool
GetRiskExcelColorText() bool
GetServerMode() bool
GetDiagramDPI() int
GetServerPort() int
GetGraphvizDPI() int
GetMinGraphvizDPI() int
GetMaxGraphvizDPI() int
GetBackupHistoryFilesToKeep() int
GetAddModelTitle() bool
GetKeepDiagramSourceFiles() bool
GetIgnoreOrphanedRiskTracking() bool
GetAttractiveness() Attractiveness
GetReportConfiguration() report.ReportConfiguation
GetThreagileVersion() string
GetProgressReporter() types.ProgressReporter
GetReportConfigurationHideChapters() map[report.ChaptersToShowHide]bool
}

type ConfigSetter interface {
SetVerbose(verbose bool)
SetInteractive(interactive bool)
SetAppFolder(appFolder string)
SetPluginFolder(pluginFolder string)
SetOutputFolder(outputFolder string)
SetServerFolder(serverFolder string)
SetTempFolder(tempFolder string)
SetInputFile(inputFile string)
SetTemplateFilename(templateFilename string)
SetRiskRulePlugins(riskRulePlugins []string)
SetSkipRiskRules(skipRiskRules []string)
SetServerMode(serverMode bool)
SetDiagramDPI(diagramDPI int)
SetServerPort(serverPort int)
SetIgnoreOrphanedRiskTracking(ignoreOrphanedRiskTracking bool)
}

func (c *Config) Defaults(buildTimestamp string) *Config {
*c = Config{
BuildTimestampValue: buildTimestamp,
Expand Down Expand Up @@ -280,7 +212,9 @@ func (c *Config) Load(configFilename string) error {
errorList = append(errorList, dataDirError)
}

c.TechnologyFilenameValue = c.CleanPath(c.TechnologyFilenameValue)
if c.TechnologyFilenameValue != "" {
c.TechnologyFilenameValue = c.CleanPath(c.TechnologyFilenameValue)
}

serverFolderError := c.CheckServerFolder()
if serverFolderError != nil {
Expand Down Expand Up @@ -381,7 +315,7 @@ func (c *Config) Merge(config Config, values map[string]any) {
c.TemplateFilenameValue = config.TemplateFilenameValue

case strings.ToLower("ReportLogoImagePath"):
c.TemplateFilenameValue = config.ReportLogoImagePathValue
c.ReportLogoImagePathValue = config.ReportLogoImagePathValue

case strings.ToLower("TechnologyFilename"):
c.TechnologyFilenameValue = config.TechnologyFilenameValue
Expand Down
Loading