Refactoring
This commit is contained in:
10
ca.go
10
ca.go
@@ -41,7 +41,7 @@ type _CAConfig struct {
|
||||
Paths Paths `hcl:"paths,block"`
|
||||
}
|
||||
|
||||
func (c *_CAConfig) StateName() string {
|
||||
func (c *_CAConfig) GetStateFileName() string {
|
||||
return c.Label + "_state.json"
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ type CertificateDefinition struct {
|
||||
SAN []string `hcl:"san,optional"`
|
||||
}
|
||||
|
||||
func (def *CertificateDefinition) fillDefaultValues(defaults *CertificateDefaults) {
|
||||
func (def *CertificateDefinition) FillDefaultValues(defaults *CertificateDefaults) {
|
||||
if defaults == nil {
|
||||
return
|
||||
}
|
||||
@@ -150,7 +150,9 @@ var CACert *x509.Certificate
|
||||
|
||||
// LoadCAConfig parses and validates the CA config from the given path and stores it in the CAConfig global variable
|
||||
func LoadCAConfig() error {
|
||||
fmt.Printf("Loading CA config from %s\n", CAConfigPath)
|
||||
if verbose {
|
||||
fmt.Printf("Loading CA config from \"%s\"", CAConfigPath)
|
||||
}
|
||||
parser := hclparse.NewParser()
|
||||
file, diags := parser.ParseHCLFile(CAConfigPath)
|
||||
if diags.HasErrors() {
|
||||
@@ -598,7 +600,7 @@ func ProvisionCertificates(filePath string, overwrite bool, dryRun bool, verbose
|
||||
// to render templates and fill missing fields from defaults
|
||||
for i := range certDefs.Certificates {
|
||||
// Fill missing fields from defaults, if provided
|
||||
certDefs.Certificates[i].fillDefaultValues(certDefs.Defaults)
|
||||
certDefs.Certificates[i].FillDefaultValues(certDefs.Defaults)
|
||||
// Render templates in the definition using the variables map
|
||||
// with added definition name.
|
||||
variables := certDefs.Variables
|
||||
|
@@ -34,7 +34,7 @@ type CertificateRecord struct {
|
||||
}
|
||||
|
||||
func caStatePath() string {
|
||||
return filepath.Join(filepath.Dir(CAConfigPath), CAConfig.StateName())
|
||||
return filepath.Join(filepath.Dir(CAConfigPath), CAConfig.GetStateFileName())
|
||||
}
|
||||
|
||||
// LoadCAState loads the CA state from a JSON file
|
||||
|
Reference in New Issue
Block a user