You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
- In the root command, all flags are now correctly available as environmental variables, except for `--config` flag. This was already supposed to be the case, but due to bugs in the implementation it didn't work properly. - All configuration options (unless I missed something) that are available as flags should now properly update the configuration when using the `config init` and `config set` commands. - Flag names are now consistently in the lowerCamelCase format. All flags that were in a different format have been updated in a backwards compatible way. For a transitionary period of at least 6 months, both will work: - `--dir-mode` --> `--dirMode` - `--hide-login-button` --> `--hideLoginButton` - `--create-user-dir` --> `--createUserDir` - `--minimum-password-length` --> `--minimumPasswordLength` - `--socket-perm` --> `--socketPerm` - `--disable-thumbnails` --> `--disableThumbnails` - `--disable-preview-resize` --> `--disablePreviewResize` - `--disable-exec` --> `--disableExec` - `--disable-type-detection-by-header` --> `--disableTypeDetectionByHeader` - `--img-processors` --> `--imageProcessors` - `--cache-dir` --> `--cacheDir` - `--token-expiration-time` --> `--tokenExpirationTime` - `--baseurl` --> `--baseURL`
36 lines
794 B
Go
36 lines
794 B
Go
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/samber/lo"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// TestEnvCollisions ensures that there are no collisions in the produced environment
|
|
// variable names for all commands and their flags.
|
|
func TestEnvCollisions(t *testing.T) {
|
|
testEnvCollisions(t, rootCmd)
|
|
}
|
|
|
|
func testEnvCollisions(t *testing.T, cmd *cobra.Command) {
|
|
for _, cmd := range cmd.Commands() {
|
|
testEnvCollisions(t, cmd)
|
|
}
|
|
|
|
replacements := generateEnvKeyReplacements(cmd)
|
|
envVariables := []string{}
|
|
|
|
for i := range replacements {
|
|
if i%2 != 0 {
|
|
envVariables = append(envVariables, replacements[i])
|
|
}
|
|
}
|
|
|
|
duplicates := lo.FindDuplicates(envVariables)
|
|
|
|
if len(duplicates) > 0 {
|
|
t.Errorf("Found duplicate environment variable keys for command %q: %v", cmd.Name(), duplicates)
|
|
}
|
|
}
|