client: moved cacert logic from 'serve' cmd to client

This commit is contained in:
David Allen 2024-11-14 16:53:00 -07:00
parent 043f8ec120
commit dac6c2306f
Signed by: towk
GPG key ID: 793B2924A49B3A3F
3 changed files with 70 additions and 59 deletions

View file

@ -36,6 +36,7 @@ type (
TemplatePaths []string
PluginPath string
Target string
Client *configurator.SmdClient
Verbose bool
}
)
@ -409,17 +410,24 @@ func Generate(config *configurator.Config, params Params) (FileMap, error) {
func GenerateWithTarget(config *configurator.Config, params Params) (FileMap, error) {
// load generator plugins to generate configs or to print
var (
client configurator.SmdClient
target configurator.Target
generator Generator
err error
ok bool
)
// check if we have a client from params first and create new one if not
if params.Client == nil {
client = configurator.NewSmdClient(
configurator.WithHost(config.SmdClient.Host),
configurator.WithPort(config.SmdClient.Port),
configurator.WithAccessToken(config.AccessToken),
configurator.WithCertPoolFile(config.CertPath),
)
target configurator.Target
generator Generator
err error
ok bool
)
} else {
client = *params.Client
}
// check if a target is supplied
if len(params.Args) == 0 && params.Target == "" {