Documentation ¶
Overview ¶
Package flagutil contains utilities and interfaces shared between several Prow commands.
Index ¶
- Constants
- type Bool
- type FlagParameter
- type GitHubEnablementOptions
- type GitHubOptions
- func (o *GitHubOptions) AddCustomizedFlags(fs *flag.FlagSet, paramFuncs ...FlagParameter)
- func (o *GitHubOptions) AddFlags(fs *flag.FlagSet)
- func (o *GitHubOptions) GitClient(dryRun bool) (client *git.Client, err error)
- func (o *GitHubOptions) GitClientFactory(cookieFilePath string, cacheDir *string, dryRun bool) (gitv2.ClientFactory, error)
- func (o *GitHubOptions) GitHubClient(dryRun bool) (github.Client, error)
- func (o *GitHubOptions) GitHubClientWithAccessToken(token string) (github.Client, error)
- func (o *GitHubOptions) GitHubClientWithLogFields(dryRun bool, fields logrus.Fields) (github.Client, error)
- func (o *GitHubOptions) Validate(bool) error
- type GitOptions
- type InstrumentationOptions
- type Strings
Constants ¶
const ( DefaultMetricsPort = 9090 DefaultPProfPort = 6060 DefaultHealthPort = 8081 DefaultMemoryProfileInterval = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bool ¶
Bool holds a boolean flag value, tracking whether it was set explicitly.
func (*Bool) IsBoolFlag ¶
IsBoolFlag causes golang to consider --foo to mean --foo=true
type FlagParameter ¶
type FlagParameter func(options *flagParams)
func DisableThrottlerOptions ¶
func DisableThrottlerOptions() FlagParameter
DisableThrottlerOptions suppresses the presence of throttler-related flags, effectively disallowing external users to parametrize default throttling behavior. This is useful mostly when a program creates multiple GH clients with different behavior.
func ThrottlerDefaults ¶
func ThrottlerDefaults(hourlyTokens, allowedBursts int) FlagParameter
ThrottlerDefaults allows to customize the default values of flags that control the throttler behavior. Setting `hourlyTokens` to zero disables throttling by default.
type GitHubEnablementOptions ¶
type GitHubEnablementOptions struct {
// contains filtered or unexported fields
}
GitHubEnablementOptions allows enable/disable functionality on a github org or org/repo level. If either EnabledOrgs or EnabledRepos is set, only org/repos in those are allowed, otherwise everything that is not in DisabledOrgs or DisabledRepos is allowed.
func (*GitHubEnablementOptions) AddFlags ¶
func (o *GitHubEnablementOptions) AddFlags(fs *flag.FlagSet)
func (*GitHubEnablementOptions) EnablementChecker ¶
func (o *GitHubEnablementOptions) EnablementChecker() func(org, repo string) bool
func (*GitHubEnablementOptions) Validate ¶
func (o *GitHubEnablementOptions) Validate(_ bool) error
type GitHubOptions ¶
type GitHubOptions struct { Host string TokenPath string AllowAnonymous bool AllowDirectAccess bool AppID string AppPrivateKeyPath string ThrottleHourlyTokens int ThrottleAllowBurst int OrgThrottlers Strings // contains filtered or unexported fields }
GitHubOptions holds options for interacting with GitHub.
Set AllowAnonymous to be true if you want to allow anonymous github access. Set AllowDirectAccess to be true if you want to suppress warnings on direct github access (without ghproxy).
func (*GitHubOptions) AddCustomizedFlags ¶
func (o *GitHubOptions) AddCustomizedFlags(fs *flag.FlagSet, paramFuncs ...FlagParameter)
AddCustomizedFlags injects GitHub options into the given FlagSet. Behavior can be customized via the functional options.
func (*GitHubOptions) AddFlags ¶
func (o *GitHubOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects GitHub options into the given FlagSet
func (*GitHubOptions) GitClient ¶
func (o *GitHubOptions) GitClient(dryRun bool) (client *git.Client, err error)
GitClient returns a Git client.
func (*GitHubOptions) GitClientFactory ¶
func (o *GitHubOptions) GitClientFactory(cookieFilePath string, cacheDir *string, dryRun bool) (gitv2.ClientFactory, error)
GitClientFactory returns git.ClientFactory. Passing non-empty cookieFilePath will result in git ClientFactory to work with Gerrit. TODO(chaodaiG): move this logic to somewhere more appropriate instead of in github.go.
func (*GitHubOptions) GitHubClient ¶
func (o *GitHubOptions) GitHubClient(dryRun bool) (github.Client, error)
GitHubClient returns a GitHub client.
func (*GitHubOptions) GitHubClientWithAccessToken ¶
func (o *GitHubOptions) GitHubClientWithAccessToken(token string) (github.Client, error)
GitHubClientWithAccessToken creates a GitHub client from an access token.
func (*GitHubOptions) GitHubClientWithLogFields ¶
func (o *GitHubOptions) GitHubClientWithLogFields(dryRun bool, fields logrus.Fields) (github.Client, error)
GitHubClientWithLogFields returns a GitHub client with extra logging fields
func (*GitHubOptions) Validate ¶
func (o *GitHubOptions) Validate(bool) error
Validate validates GitHub options. Note that validate updates the GitHubOptions to add default values for TokenPath and graphqlEndpoint.
type GitOptions ¶
type GitOptions struct {
// contains filtered or unexported fields
}
GitOptions holds options for interacting with git.
func (*GitOptions) AddFlags ¶
func (o *GitOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects Git options into the given FlagSet.
func (*GitOptions) GitClient ¶
func (o *GitOptions) GitClient(userClient github.UserClient, token func() []byte, censor func(content []byte) []byte, dryRun bool) (git.ClientFactory, error)
GitClient creates a new git client.
func (*GitOptions) Validate ¶
func (o *GitOptions) Validate(dryRun bool) error
Validate validates Git options.
type InstrumentationOptions ¶
type InstrumentationOptions struct { // MetricsPort is the port which is used to serve metrics MetricsPort int // PProfPort is the port which is used to serve pprof PProfPort int // HealthPort is the port which is used to serve liveness and readiness HealthPort int // ProfileMemory determines if the process should profile memory ProfileMemory bool // MemoryProfileInterval is the interval at which memory profiles should be dumped MemoryProfileInterval time.Duration }
InstrumentationOptions holds common options which are used across Prow components
func DefaultInstrumentationOptions ¶
func DefaultInstrumentationOptions() InstrumentationOptions
DefaultInstrumentationOptions returns an initialized options struct, mostly for use in tests.
func (*InstrumentationOptions) AddFlags ¶
func (o *InstrumentationOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects common options into the given FlagSet.
func (*InstrumentationOptions) Validate ¶
func (o *InstrumentationOptions) Validate(_ bool) error
type Strings ¶
type Strings struct {
// contains filtered or unexported fields
}
Strings represents the value of a flag that accept multiple strings.
func NewStrings ¶
NewStrings returns a Strings struct that defaults to the value of def if left unset.
func NewStringsBeenSet ¶
NewStringsBeenSet returns a Strings struct with beenSet: true