Skip to content

Commit

Permalink
c/k/app/{,options}: uglify ApplyTo
Browse files Browse the repository at this point in the history
  • Loading branch information
ibihim committed Sep 10, 2024
1 parent 144327b commit c634618
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/kube-rbac-proxy/app/kube-rbac-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (opts *completedProxyRunOptions) ProxyConfig() (*server.KubeRBACProxyConfig
return nil, err
}

if err := opts.ProxyOptions.ApplyTo(proxyConfig); err != nil {
if err := opts.ProxyOptions.ApplyTo(proxyConfig.KubeRBACProxyInfo, proxyConfig.DelegatingAuthentication, proxyConfig.SecureServing); err != nil {
return nil, err
}

Expand Down
19 changes: 10 additions & 9 deletions cmd/kube-rbac-proxy/app/options/proxyoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/ghodss/yaml"
"github.com/spf13/pflag"

serverconfig "k8s.io/apiserver/pkg/server"
"k8s.io/klog/v2"

"github.com/brancz/kube-rbac-proxy/pkg/authn/identityheaders"
Expand Down Expand Up @@ -120,30 +121,30 @@ func (o *ProxyOptions) Validate() []error {
return errs
}

func (o *ProxyOptions) ApplyTo(config *server.KubeRBACProxyConfig) error {
func (o *ProxyOptions) ApplyTo(krpInfo *server.KubeRBACProxyInfo, authInfo *serverconfig.AuthenticationInfo, serving *serverconfig.SecureServingInfo) error {
var err error

config.KubeRBACProxyInfo.UpstreamURL, err = url.Parse(o.Upstream)
krpInfo.UpstreamURL, err = url.Parse(o.Upstream)
if err != nil {
return fmt.Errorf("failed to parse upstream URL: %w", err)
}

if err := config.KubeRBACProxyInfo.SetUpstreamTransport(o.UpstreamCAFile, o.UpstreamClientCertFile, o.UpstreamClientKeyFile); err != nil {
if err := krpInfo.SetUpstreamTransport(o.UpstreamCAFile, o.UpstreamClientCertFile, o.UpstreamClientKeyFile); err != nil {
return fmt.Errorf("failed to setup transport for upstream: %w", err)
}

if configFileName := o.ConfigFileName; len(configFileName) > 0 {
config.KubeRBACProxyInfo.Authorization, err = parseAuthorizationConfigFile(configFileName)
krpInfo.Authorization, err = parseAuthorizationConfigFile(configFileName)
if err != nil {
return fmt.Errorf("failed to read the config file: %w", err)
}
}

config.SecureServing.DisableHTTP2 = o.DisableHTTP2Serving
config.KubeRBACProxyInfo.UpstreamHeaders = o.UpstreamHeader
config.KubeRBACProxyInfo.IgnorePaths = o.IgnorePaths
config.KubeRBACProxyInfo.AllowPaths = o.AllowPaths
config.DelegatingAuthentication.APIAudiences = o.TokenAudiences
serving.DisableHTTP2 = o.DisableHTTP2Serving
krpInfo.UpstreamHeaders = o.UpstreamHeader
krpInfo.IgnorePaths = o.IgnorePaths
krpInfo.AllowPaths = o.AllowPaths
authInfo.APIAudiences = o.TokenAudiences

return nil
}
Expand Down

0 comments on commit c634618

Please sign in to comment.