mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-05 06:01:24 +02:00
feat: add ensure defaults to all migrated structs
Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
|
||||
"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/util/ptr"
|
||||
)
|
||||
|
||||
// validateProviders is the initial validation migration for multiple providrers
|
||||
@@ -97,9 +96,9 @@ func validateGoogleConfig(provider options.Provider) []string {
|
||||
|
||||
hasAdminEmail := provider.GoogleConfig.AdminEmail != ""
|
||||
hasSAJSON := provider.GoogleConfig.ServiceAccountJSON != ""
|
||||
useADC := ptr.Deref(provider.GoogleConfig.UseApplicationDefaultCredentials, false)
|
||||
useADC := provider.GoogleConfig.UseApplicationDefaultCredentials
|
||||
|
||||
if !hasAdminEmail && !hasSAJSON && !useADC {
|
||||
if !hasAdminEmail && !hasSAJSON && !(*useADC) {
|
||||
return msgs
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ func validateGoogleConfig(provider options.Provider) []string {
|
||||
}
|
||||
|
||||
_, err := os.Stat(provider.GoogleConfig.ServiceAccountJSON)
|
||||
if !useADC {
|
||||
if !(*useADC) {
|
||||
if !hasSAJSON {
|
||||
msgs = append(msgs, "missing setting: google-service-account-json or google-use-application-default-credentials")
|
||||
} else if err != nil {
|
||||
|
||||
@@ -54,12 +54,12 @@ func validateUpstream(upstream options.Upstream, ids, paths map[string]struct{})
|
||||
func validateStaticUpstream(upstream options.Upstream) []string {
|
||||
msgs := []string{}
|
||||
|
||||
if !*upstream.Static && upstream.StaticCode != nil {
|
||||
if !(*upstream.Static) && upstream.StaticCode != nil {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has staticCode (%d), but is not a static upstream, set 'static' for a static response", upstream.ID, *upstream.StaticCode))
|
||||
}
|
||||
|
||||
// Checks after this only make sense when the upstream is static
|
||||
if !*upstream.Static {
|
||||
if !(*upstream.Static) {
|
||||
return msgs
|
||||
}
|
||||
|
||||
@@ -72,10 +72,10 @@ func validateStaticUpstream(upstream options.Upstream) []string {
|
||||
if upstream.FlushInterval != nil && *upstream.FlushInterval != options.DefaultUpstreamFlushInterval {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has flushInterval, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
if upstream.PassHostHeader != nil {
|
||||
if *upstream.PassHostHeader {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has passHostHeader, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
if upstream.ProxyWebSockets != nil {
|
||||
if *upstream.ProxyWebSockets {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has proxyWebSockets, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ func validateStaticUpstream(upstream options.Upstream) []string {
|
||||
func validateUpstreamURI(upstream options.Upstream) []string {
|
||||
msgs := []string{}
|
||||
|
||||
if !*upstream.Static && upstream.URI == "" {
|
||||
if !(*upstream.Static) && upstream.URI == "" {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has empty uri: uris are required for all non-static upstreams", upstream.ID))
|
||||
return msgs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user