mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-14 11:22:15 +01:00
adding new attribute lock (#8)
This commit is contained in:
@@ -20,6 +20,7 @@ type (
|
||||
port string
|
||||
logsLevel logrus.Level
|
||||
logsFormatter logrus.Formatter
|
||||
lock bool
|
||||
// commands associates a file extension with a Command instance.
|
||||
// Particular case: ".pdf" extension is used for the merge command.
|
||||
commands map[string]*Command
|
||||
@@ -126,6 +127,16 @@ func GetLogsFormatter() logrus.Formatter {
|
||||
return config.logsFormatter
|
||||
}
|
||||
|
||||
// WithLock sets the lock strategy.
|
||||
func WithLock(lock bool) {
|
||||
config.lock = lock
|
||||
}
|
||||
|
||||
// HasLock returns the current lock strategy.
|
||||
func HasLock() bool {
|
||||
return config.lock
|
||||
}
|
||||
|
||||
type interpreterEmptyError struct {
|
||||
command string
|
||||
}
|
||||
|
||||
@@ -99,6 +99,24 @@ func TestGetLogsFormatter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithLock(t *testing.T) {
|
||||
lock := true
|
||||
WithLock(lock)
|
||||
|
||||
if config.lock != lock {
|
||||
t.Errorf("Configuration populated with a wrong lock strategy: got '%t' want '%t'", config.lock, lock)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasLock(t *testing.T) {
|
||||
lock := true
|
||||
config.lock = true
|
||||
|
||||
if HasLock() != lock {
|
||||
t.Errorf("Configuration returned a wrong port: got '%t' want '%t'", HasLock(), lock)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpreterEmptyError(t *testing.T) {
|
||||
err := &interpreterEmptyError{"echo hello world"}
|
||||
expected := fmt.Sprintf(interpreterEmptyErrorMessage, err.command)
|
||||
|
||||
@@ -23,6 +23,8 @@ func ParseFile(configurationFilePath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
WithLock(fileConfig.Commands.Lock)
|
||||
|
||||
// handles merge command first...
|
||||
cmd, err := NewCommand(fileConfig.Commands.Merge.Template, fileConfig.Commands.Merge.Interpreter, fileConfig.Commands.Merge.Timeout)
|
||||
if err != nil {
|
||||
@@ -57,6 +59,7 @@ type (
|
||||
Formatter string `yaml:"formatter"`
|
||||
} `yaml:"logs"`
|
||||
Commands struct {
|
||||
Lock bool `yaml:"lock"`
|
||||
Merge *mergeCommand `yaml:"merge"`
|
||||
Conversions []*conversionCommand `yaml:"conversions,omitempty"`
|
||||
} `yaml:"commands"`
|
||||
|
||||
Reference in New Issue
Block a user