Documentation ¶
Overview ¶
Package appcfg controls actions that can be performed around the app's configuration file and config directory. Currently we use HCL as the config file format.
Index ¶
- func ConfigFilePath() string
- func ConfigPath() string
- func CreateNewFile() error
- func RepoPath(ruleset string) string
- func RepoRulesPath(ruleset string) string
- func RulePath(ruleset, ruleID string) string
- func RulesetPath(ruleset string) string
- func RulesetsPath() string
- type Appcfg
- func (appcfg *Appcfg) AddRuleset(rs models.Ruleset) error
- func (appcfg *Appcfg) GetRule(rulesetName, ruleID string) (models.Rule, error)
- func (appcfg *Appcfg) GetRuleset(name string) (models.Ruleset, error)
- func (appcfg *Appcfg) RepositoryExists(repo string) bool
- func (appcfg *Appcfg) RulesetExists(name string) bool
- func (appcfg *Appcfg) SetRuleEnabled(ruleset, rule string, enabled bool) error
- func (appcfg *Appcfg) SetRulesetEnabled(name string, enabled bool) error
- func (appcfg *Appcfg) UpdateRuleset(rs models.Ruleset) error
- func (appcfg *Appcfg) UpsertRule(rulesetName string, newRule models.Rule) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigFilePath ¶
func ConfigFilePath() string
ConfigFilePath returns the absolute path of the configuration file. By default this is ~/.hclvet.d/.hclvet.hcl
func ConfigPath ¶
func ConfigPath() string
ConfigPath returns the absolute config path determined by environment variable. The default is ~/.hclvet.d
func RepoPath ¶
RepoPath returns the absolute path for the repo directory inside of a specific ruleset. By default this is ~/.hclvet.d/rulesets.d/<ruleset>/repo
func RepoRulesPath ¶
RepoRulesPath returns the absolute path for the rules directory inside of a repo directory of a ruleset By default this is ~/.hclvet.d/rulesets.d/<ruleset>/repo/rules
func RulePath ¶
RulePath returns the absolute path for a rule within a ruleset directory. By default this is ~/.hclvet.d/rulesets.d/<ruleset>/<ruleID>
func RulesetPath ¶
RulesetPath returns the directory path to a supplied ruleset name. By default this is ~/.hclvet.d/rulesets.d/<ruleset>
func RulesetsPath ¶
func RulesetsPath() string
RulesetsPath returns the absolute directory path of the directory that stores rulesets. By default this is ~/.hclvet.d/rulesets.d
Note: this is not the ruleset itself just the parent folder. Use RulesetPath() to get a path to a specific ruleset.
Types ¶
type Appcfg ¶
Appcfg represents the parsed hcl config of the main app configuration. We wrap this so that we can add other attributes in here.
func (*Appcfg) AddRuleset ¶
AddRuleset adds a new ruleset. Returns error if ruleset already exists.
func (*Appcfg) GetRule ¶
GetRule returns the rule object of a given name. Returns an error if ruleset or rule isn't found.
func (*Appcfg) GetRuleset ¶
GetRuleset returns the ruleset object of a given name. Returns an error if ruleset isn't found.
func (*Appcfg) RepositoryExists ¶
RepositoryExists checks to see if the config already has an entry for the repository in the config.
func (*Appcfg) RulesetExists ¶
RulesetExists determines if a ruleset has already been added.
func (*Appcfg) SetRuleEnabled ¶
SetRuleEnabled changes the enabled attribute on a rule. Returns an error if the ruleset or rule isn't found.
func (*Appcfg) SetRulesetEnabled ¶
SetRulesetEnabled changes the enabled attribute on a ruleset. Returns an error if the ruleset isn't found.
func (*Appcfg) UpdateRuleset ¶
UpdateRuleset updates an existing ruleset. Returns an error if the ruleset could not be found.
func (*Appcfg) UpsertRule ¶
UpsertRule adds a new rule to an already established ruleset if it does not exist. If the rule already exists it simply updates the rule with the newer information. Returns an error if the ruleset is not found or there was an error writing to the file.