22 lines
533 B
Go
22 lines
533 B
Go
package service_definition
|
|
|
|
import (
|
|
"github.com/goccy/go-yaml"
|
|
"os"
|
|
)
|
|
|
|
func GetServiceDefinitionFromFile(path string) (ServiceDefinition, error) {
|
|
var definition ServiceDefinition
|
|
|
|
defData, err := os.ReadFile(path)
|
|
|
|
if err != nil {
|
|
return ServiceDefinition{}, &FileDoesNotExistError{Message: "Could not find service configuration file", ExpectedPath: path}
|
|
}
|
|
|
|
if err = yaml.Unmarshal(defData, &definition); err != nil {
|
|
return ServiceDefinition{}, &InvalidServiceDefinitionError{Path: path}
|
|
}
|
|
|
|
return definition, nil
|
|
}
|