Files
warewulf/internal/pkg/api/apiconfig/client_server.go
Christian Goll 342236b9b9 updated test for yaml/v3
Signed-off-by: Christian Goll <cgoll@suse.com>
2024-10-17 15:30:54 -04:00

39 lines
935 B
Go

package apiconfig
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
// ClientServerConfig is the full client server configuration.
// wwapird is a client of wwapid.
// wwapird serves REST. (WareWulf API Rest Daemon)
type ClientServerConfig struct {
ClientApiConfig ClientApiConfig `yaml:"clientapi"`
ServerApiConfig ServerApiConfig `yaml:"serverapi"`
ClientTlsConfig TlsConfig `yaml:"clienttls"`
ServerTlsConfig TlsConfig `yaml:"servertls"`
}
// NewClientServer loads the client config from the given configFilePath.
func NewClientServer(configFilePath string) (config ClientServerConfig, err error) {
log.Printf("Loading api client server configuration from: %v\n", configFilePath)
var fileBytes []byte
fileBytes, err = os.ReadFile(configFilePath)
if err != nil {
return
}
err = yaml.Unmarshal(fileBytes, &config)
if err != nil {
return
}
log.Printf("api client server config: %#v\n", config)
return
}