Skip to content

Commit

Permalink
Rapid reset scaffold remediation
Browse files Browse the repository at this point in the history
Signed-off-by: Catherine Chan-Tse <cchantse@redhat.com>
  • Loading branch information
oceanc80 committed Jan 23, 2024
1 parent 422d542 commit ff0d606
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/ansible/flags/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
package flags

import (
"crypto/tls"
"runtime"
"time"

"github.com/spf13/pflag"
"k8s.io/client-go/tools/leaderelection/resourcelock"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// Flags - Options to be used by an ansible operator
Expand All @@ -44,6 +46,8 @@ type Flags struct {
AnsibleArgs string
AnsibleLogEvents string
ProxyPort int
EnableHTTP2 bool
SecureMetrics bool

// Path to a controller-runtime componentconfig file.
// If this is empty, use default values.
Expand Down Expand Up @@ -197,6 +201,17 @@ func (f *Flags) AddTo(flagSet *pflag.FlagSet) {
8888,
"Ansible proxy server port. Defaults to 8888.",
)
flagSet.BoolVar(&f.EnableHTTP2,
"enable-http2",
false,
"enables HTTP/2 on the webhook and metrics servers",
)

flagSet.BoolVar(&f.SecureMetrics,
"metrics-secure",
false,
"enables secure serving of the metrics endpoint",
)
}

// ToManagerOptions uses the flag set in f to configure options.
Expand Down Expand Up @@ -241,5 +256,15 @@ func (f *Flags) ToManagerOptions(options manager.Options) manager.Options {
options.GracefulShutdownTimeout = &f.GracefulShutdownTimeout
}

disableHTTP2 := func(c *tls.Config) {
c.NextProtos = []string{"http/1.1"}
}
if !f.EnableHTTP2 {
options.WebhookServer = webhook.NewServer(webhook.Options{
TLSOpts: []func(*tls.Config){disableHTTP2},
})
options.Metrics.TLSOpts = append(options.Metrics.TLSOpts, disableHTTP2)
}
options.Metrics.SecureServing = f.SecureMetrics
return options
}

0 comments on commit ff0d606

Please sign in to comment.