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 22, 2024
1 parent d76a8db commit f170762
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,62 @@

package flags

import (
"crypto/tls"

"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// global command-line flags
const (
VerboseOpt = "verbose"
)

// Flags - Options to be used by a helm operator
type Flags struct {
EnableHTTP2 bool
SecureMetrics bool
}

// AddTo - Add the ansible operator flags to the the flagset
func (f *Flags) AddTo(flagSet *pflag.FlagSet) {

Check failure on line 35 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / unit

undefined: pflag

Check failure on line 35 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

undefined: pflag

Check failure on line 35 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

undefined: pflag
// Store flagset internally to be used for lookups later.
f.flagSet = flagSet

Check failure on line 37 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / unit

f.flagSet undefined (type *Flags has no field or method flagSet)

Check failure on line 37 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

f.flagSet undefined (type *Flags has no field or method flagSet)

Check failure on line 37 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

f.flagSet undefined (type *Flags has no field or method flagSet)

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.
// Values of options take precedence over flag defaults,
// as values are assume to have been explicitly set.
func (f *Flags) ToManagerOptions(options manager.Options) manager.Options {

Check failure on line 55 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / unit

undefined: manager

Check failure on line 55 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

undefined: manager

Check failure on line 55 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

undefined: manager
// Alias FlagSet.Changed so options are still updated when fields are empty.
changed := func(flagName string) bool {

Check failure on line 57 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / unit

changed declared and not used

Check failure on line 57 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

changed declared and not used
return f.flagSet.Changed(flagName)

Check failure on line 58 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / unit

f.flagSet undefined (type *Flags has no field or method flagSet)

Check failure on line 58 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

f.flagSet undefined (type *Flags has no field or method flagSet)
}
if f.flagSet == nil {

Check failure on line 60 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / unit

f.flagSet undefined (type *Flags has no field or method flagSet)

Check failure on line 60 in internal/flags/flags.go

View workflow job for this annotation

GitHub Actions / sanity

f.flagSet undefined (type *Flags has no field or method flagSet) (typecheck)
changed = func(flagName string) bool { return false }
}

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 f170762

Please sign in to comment.