diff options
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/config.go | 13 | ||||
| -rw-r--r-- | internal/config/flags.go | 7 | ||||
| -rw-r--r-- | internal/config/helpers.gen.go | 99 | 
3 files changed, 76 insertions, 43 deletions
| diff --git a/internal/config/config.go b/internal/config/config.go index ecbd079e6..cc37e9bfd 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -125,14 +125,15 @@ type Configuration struct {  	SyslogProtocol string `name:"syslog-protocol" usage:"Protocol to use when directing logs to syslog. Leave empty to connect to local syslog."`  	SyslogAddress  string `name:"syslog-address" usage:"Address:port to send syslog logs to. Leave empty to connect to local syslog."` -	// TODO: move these elsewhere, these are more ephemeral vs long-running flags like above -	AdminAccountUsername string `name:"username" usage:"the username to create/delete/etc"` -	AdminAccountEmail    string `name:"email" usage:"the email address of this account"` -	AdminAccountPassword string `name:"password" usage:"the password to set for this account"` -	AdminTransPath       string `name:"path" usage:"the path of the file to import from/export to"` -  	AdvancedCookiesSamesite   string `name:"advanced-cookies-samesite" usage:"'strict' or 'lax', see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite"`  	AdvancedRateLimitRequests int    `name:"advanced-rate-limit-requests" usage:"Amount of HTTP requests to permit within a 5 minute window. 0 or less turns rate limiting off."` + +	// TODO: move these elsewhere, these are more ephemeral vs long-running flags like above +	AdminAccountUsername  string `name:"username" usage:"the username to create/delete/etc"` +	AdminAccountEmail     string `name:"email" usage:"the email address of this account"` +	AdminAccountPassword  string `name:"password" usage:"the password to set for this account"` +	AdminTransPath        string `name:"path" usage:"the path of the file to import from/export to"` +	AdminMediaPruneDryRun bool   `name:"dry-run" usage:"perform a dry run and only log number of items eligible for pruning"`  }  // MarshalMap will marshal current Configuration into a map structure (useful for JSON). diff --git a/internal/config/flags.go b/internal/config/flags.go index ddc3c60de..c5df1c8b2 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -178,3 +178,10 @@ func AddAdminTrans(cmd *cobra.Command) {  		panic(err)  	}  } + +// AddAdminMediaPrune attaches flags pertaining to media storage prune commands. +func AddAdminMediaPrune(cmd *cobra.Command) { +	name := AdminMediaPruneDryRunFlag() +	usage := fieldtag("AdminMediaPruneDryRun", "usage") +	cmd.Flags().Bool(name, true, usage) +} diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index 2786f5b5a..579814b99 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -1745,6 +1745,56 @@ func GetSyslogAddress() string { return global.GetSyslogAddress() }  // SetSyslogAddress safely sets the value for global configuration 'SyslogAddress' field  func SetSyslogAddress(v string) { global.SetSyslogAddress(v) } +// GetAdvancedCookiesSamesite safely fetches the Configuration value for state's 'AdvancedCookiesSamesite' field +func (st *ConfigState) GetAdvancedCookiesSamesite() (v string) { +	st.mutex.Lock() +	v = st.config.AdvancedCookiesSamesite +	st.mutex.Unlock() +	return +} + +// SetAdvancedCookiesSamesite safely sets the Configuration value for state's 'AdvancedCookiesSamesite' field +func (st *ConfigState) SetAdvancedCookiesSamesite(v string) { +	st.mutex.Lock() +	defer st.mutex.Unlock() +	st.config.AdvancedCookiesSamesite = v +	st.reloadToViper() +} + +// AdvancedCookiesSamesiteFlag returns the flag name for the 'AdvancedCookiesSamesite' field +func AdvancedCookiesSamesiteFlag() string { return "advanced-cookies-samesite" } + +// GetAdvancedCookiesSamesite safely fetches the value for global configuration 'AdvancedCookiesSamesite' field +func GetAdvancedCookiesSamesite() string { return global.GetAdvancedCookiesSamesite() } + +// SetAdvancedCookiesSamesite safely sets the value for global configuration 'AdvancedCookiesSamesite' field +func SetAdvancedCookiesSamesite(v string) { global.SetAdvancedCookiesSamesite(v) } + +// GetAdvancedRateLimitRequests safely fetches the Configuration value for state's 'AdvancedRateLimitRequests' field +func (st *ConfigState) GetAdvancedRateLimitRequests() (v int) { +	st.mutex.Lock() +	v = st.config.AdvancedRateLimitRequests +	st.mutex.Unlock() +	return +} + +// SetAdvancedRateLimitRequests safely sets the Configuration value for state's 'AdvancedRateLimitRequests' field +func (st *ConfigState) SetAdvancedRateLimitRequests(v int) { +	st.mutex.Lock() +	defer st.mutex.Unlock() +	st.config.AdvancedRateLimitRequests = v +	st.reloadToViper() +} + +// AdvancedRateLimitRequestsFlag returns the flag name for the 'AdvancedRateLimitRequests' field +func AdvancedRateLimitRequestsFlag() string { return "advanced-rate-limit-requests" } + +// GetAdvancedRateLimitRequests safely fetches the value for global configuration 'AdvancedRateLimitRequests' field +func GetAdvancedRateLimitRequests() int { return global.GetAdvancedRateLimitRequests() } + +// SetAdvancedRateLimitRequests safely sets the value for global configuration 'AdvancedRateLimitRequests' field +func SetAdvancedRateLimitRequests(v int) { global.SetAdvancedRateLimitRequests(v) } +  // GetAdminAccountUsername safely fetches the Configuration value for state's 'AdminAccountUsername' field  func (st *ConfigState) GetAdminAccountUsername() (v string) {  	st.mutex.Lock() @@ -1845,52 +1895,27 @@ func GetAdminTransPath() string { return global.GetAdminTransPath() }  // SetAdminTransPath safely sets the value for global configuration 'AdminTransPath' field  func SetAdminTransPath(v string) { global.SetAdminTransPath(v) } -// GetAdvancedCookiesSamesite safely fetches the Configuration value for state's 'AdvancedCookiesSamesite' field -func (st *ConfigState) GetAdvancedCookiesSamesite() (v string) { +// GetAdminMediaPruneDryRun safely fetches the Configuration value for state's 'AdminMediaPruneDryRun' field +func (st *ConfigState) GetAdminMediaPruneDryRun() (v bool) {  	st.mutex.Lock() -	v = st.config.AdvancedCookiesSamesite +	v = st.config.AdminMediaPruneDryRun  	st.mutex.Unlock()  	return  } -// SetAdvancedCookiesSamesite safely sets the Configuration value for state's 'AdvancedCookiesSamesite' field -func (st *ConfigState) SetAdvancedCookiesSamesite(v string) { +// SetAdminMediaPruneDryRun safely sets the Configuration value for state's 'AdminMediaPruneDryRun' field +func (st *ConfigState) SetAdminMediaPruneDryRun(v bool) {  	st.mutex.Lock()  	defer st.mutex.Unlock() -	st.config.AdvancedCookiesSamesite = v +	st.config.AdminMediaPruneDryRun = v  	st.reloadToViper()  } -// AdvancedCookiesSamesiteFlag returns the flag name for the 'AdvancedCookiesSamesite' field -func AdvancedCookiesSamesiteFlag() string { return "advanced-cookies-samesite" } +// AdminMediaPruneDryRunFlag returns the flag name for the 'AdminMediaPruneDryRun' field +func AdminMediaPruneDryRunFlag() string { return "dry-run" } -// GetAdvancedCookiesSamesite safely fetches the value for global configuration 'AdvancedCookiesSamesite' field -func GetAdvancedCookiesSamesite() string { return global.GetAdvancedCookiesSamesite() } +// GetAdminMediaPruneDryRun safely fetches the value for global configuration 'AdminMediaPruneDryRun' field +func GetAdminMediaPruneDryRun() bool { return global.GetAdminMediaPruneDryRun() } -// SetAdvancedCookiesSamesite safely sets the value for global configuration 'AdvancedCookiesSamesite' field -func SetAdvancedCookiesSamesite(v string) { global.SetAdvancedCookiesSamesite(v) } - -// GetAdvancedRateLimitRequests safely fetches the Configuration value for state's 'AdvancedRateLimitRequests' field -func (st *ConfigState) GetAdvancedRateLimitRequests() (v int) { -	st.mutex.Lock() -	v = st.config.AdvancedRateLimitRequests -	st.mutex.Unlock() -	return -} - -// SetAdvancedRateLimitRequests safely sets the Configuration value for state's 'AdvancedRateLimitRequests' field -func (st *ConfigState) SetAdvancedRateLimitRequests(v int) { -	st.mutex.Lock() -	defer st.mutex.Unlock() -	st.config.AdvancedRateLimitRequests = v -	st.reloadToViper() -} - -// AdvancedRateLimitRequestsFlag returns the flag name for the 'AdvancedRateLimitRequests' field -func AdvancedRateLimitRequestsFlag() string { return "advanced-rate-limit-requests" } - -// GetAdvancedRateLimitRequests safely fetches the value for global configuration 'AdvancedRateLimitRequests' field -func GetAdvancedRateLimitRequests() int { return global.GetAdvancedRateLimitRequests() } - -// SetAdvancedRateLimitRequests safely sets the value for global configuration 'AdvancedRateLimitRequests' field -func SetAdvancedRateLimitRequests(v int) { global.SetAdvancedRateLimitRequests(v) } +// SetAdminMediaPruneDryRun safely sets the value for global configuration 'AdminMediaPruneDryRun' field +func SetAdminMediaPruneDryRun(v bool) { global.SetAdminMediaPruneDryRun(v) } | 
