Manager: allow setup to finish without Blender #104306

Manually merged
Sybren A. Stüvel merged 34 commits from abelli/flamenco:issue100195 into main 2024-09-09 11:22:42 +02:00
Showing only changes of commit c718f0d01b - Show all commits

View File

@ -21,6 +21,14 @@ import (
"projects.blender.org/studio/flamenco/pkg/api"
)
var (
ErrSetupConfigUnusableSource = errors.New("sources should not have the 'is_usable' field set to false")
ErrSetupConfigEmptyStorageLocation = errors.New("'storageLocation' field must not be empty")
ErrSetupConfigEmptyPath = errors.New("'path' field must not be empty while using the 'file_association' source")
ErrSetupConfigEmptyPathOrInput = errors.New("'path' or 'input' fields must not be empty while using the 'input_path' or 'path_envvar' sources")
ErrSetupConfigEmptySource = errors.New("'source' field must not be empty")
)
func (f *Flamenco) GetVersion(e echo.Context) error {
return e.JSON(http.StatusOK, api.FlamencoVersion{
Version: appinfo.ExtendedVersion(),
@ -266,8 +274,8 @@ func (f *Flamenco) SaveSetupAssistantConfig(e echo.Context) error {
logger = logger.With().Interface("config", setupAssistantCfg).Logger()
if err := checkSetupAssistantConfig(setupAssistantCfg); err != nil {
logger.Warn().Msg("setup assistant: configuration is invalid or incomplete, " + err.Error())
return sendAPIError(e, http.StatusBadRequest, "configuration is invalid or incomplete")
logger.Error().AnErr("cause", err).Msg("setup assistant: configuration is incomplete")
return sendAPIError(e, http.StatusBadRequest, "configuration is incomplete: %v", err)
}
conf := f.config.Get()
@ -337,11 +345,11 @@ func commandNeedsQuoting(cmd string) bool {
func checkSetupAssistantConfig(config api.SetupAssistantConfig) error {
if config.StorageLocation == "" {
return errors.New("'storageLocation' field must not be empty")
return ErrSetupConfigEmptyStorageLocation
}
if !config.BlenderExecutable.IsUsable {
return errors.New("sources cannot have the 'is_usable' field set to false")
return ErrSetupConfigUnusableSource
}
switch config.BlenderExecutable.Source {
@ -350,16 +358,20 @@ func checkSetupAssistantConfig(config api.SetupAssistantConfig) error {
case api.BlenderPathSourceFileAssociation:
if config.BlenderExecutable.Path == "" {
return errors.New("'path' field must not be empty while using the 'file_association' source")
return ErrSetupConfigEmptyPath
}
case api.BlenderPathSourceInputPath, api.BlenderPathSourcePathEnvvar:
if config.BlenderExecutable.Path == "" ||
config.BlenderExecutable.Input == "" {
return errors.New("'path' or 'input' fields must not be empty while using the 'input_path' or 'path_envvar' sources")
return ErrSetupConfigEmptyPathOrInput
}
case "":
return ErrSetupConfigEmptySource
default:
return errors.New("unknown 'source' field value: " + string(config.BlenderExecutable.Source))
return fmt.Errorf("unknown 'source' field value: %v", config.BlenderExecutable.Source)
}
return nil