Documentation ¶
Overview ¶
Package flagutil contains utilities and interfaces shared between several Prow commands.
Package flagutil contains utilities and interfaces shared between several test-infra commands.
Index ¶
- Constants
- Variables
- func CheckAuthorizations(client authorizationv1.SelfSubjectAccessReviewInterface, namespace string, ...) error
- type Bool
- type BugzillaOptions
- type ControllerManagerOptions
- type FlagParameter
- type GerritFields
- type GerritOptions
- type GitHubEnablementOptions
- type GitHubOptions
- func (o *GitHubOptions) AddCustomizedFlags(fs *flag.FlagSet, paramFuncs ...FlagParameter)
- func (o *GitHubOptions) AddFlags(fs *flag.FlagSet)
- func (o *GitHubOptions) GitClientFactory(cookieFilePath string, cacheDir *string, dryRun, persistCache 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 InstrumentationOptions
- type JiraFlagParameter
- type JiraOptions
- type KubernetesClientOptions
- type KubernetesOptions
- func (o *KubernetesOptions) AddFlags(fs *flag.FlagSet)
- func (o *KubernetesOptions) AddKubeconfigChangeCallback(callback func()) error
- func (o *KubernetesOptions) BuildClusterClients(namespace string, dryRun bool) (buildClusterClients map[string]corev1.PodInterface, err error)
- func (o *KubernetesOptions) BuildClusterCoreV1Clients(dryRun bool) (v1Clients map[string]corev1.CoreV1Interface, err error)
- func (o *KubernetesOptions) BuildClusterUncachedRuntimeClients(dryRun bool) (map[string]ctrlruntimeclient.Client, error)
- func (o *KubernetesOptions) BuildClusters(dryRun bool, requiredTestPodVerbs []string, callBack func(), namespace string, ...) (map[string]cluster.Cluster, error)
- func (o *KubernetesOptions) ClusterClientForContext(context string, dryRun bool) (kubernetesClient kubernetes.Interface, err error)
- func (o *KubernetesOptions) InfrastructureClusterClient(dryRun bool) (kubernetesClient kubernetes.Interface, err error)
- func (o *KubernetesOptions) InfrastructureClusterConfig(dryRun bool) (*rest.Config, error)
- func (o *KubernetesOptions) KnownClusters(dryRun bool) (map[string]rest.Config, error)
- func (o *KubernetesOptions) LoadClusterConfigs(callBacks ...func()) (map[string]rest.Config, error)
- func (o *KubernetesOptions) ProwJobClient(namespace string, dryRun bool) (prowJobClient prowv1.ProwJobInterface, err error)
- func (o *KubernetesOptions) ProwJobClientset(dryRun bool) (prowJobClientset prow.Interface, err error)
- func (o *KubernetesOptions) SetDisabledClusters(disabledClusters sets.Set[string])
- func (o *KubernetesOptions) Validate(_ bool) error
- type OptionGroup
- type StorageClientOptions
- func (o *StorageClientOptions) AddFlags(fs *flag.FlagSet)
- func (o *StorageClientOptions) HasGCSCredentials() bool
- func (o *StorageClientOptions) HasS3Credentials() bool
- func (o *StorageClientOptions) StorageClient(ctx context.Context) (io.Opener, error)
- func (o *StorageClientOptions) Validate(dryRun bool) error
- type Strings
Constants ¶
const ( DefaultMetricsPort = 9090 DefaultPProfPort = 6060 DefaultHealthPort = 8081 DefaultMemoryProfileInterval = 30 * time.Second )
Variables ¶
var MissingPermissions = errors.New("missing permissions")
Functions ¶
func CheckAuthorizations ¶
func CheckAuthorizations(client authorizationv1.SelfSubjectAccessReviewInterface, namespace string, requiredTestPodVerbs []string) error
CheckAuthorizations checks if we are able to perform the required actions against test pods for the provided pod verbs (requiredTestPodVerbs).
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 BugzillaOptions ¶
type BugzillaOptions struct { ApiKeyPath string // contains filtered or unexported fields }
BugzillaOptions holds options for interacting with Bugzilla.
func (*BugzillaOptions) AddFlags ¶
func (o *BugzillaOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects Bugzilla options into the given FlagSet.
func (*BugzillaOptions) BugzillaClient ¶
func (o *BugzillaOptions) BugzillaClient() (bugzilla.Client, error)
BugzillaClient returns a Bugzilla client.
func (*BugzillaOptions) Validate ¶
func (o *BugzillaOptions) Validate(dryRun bool) error
Validate validates Bugzilla options.
type ControllerManagerOptions ¶
type ControllerManagerOptions struct { TimeoutListingProwJobs time.Duration TimeoutListingProwJobsDefault time.Duration }
func (*ControllerManagerOptions) AddFlags ¶
func (o *ControllerManagerOptions) AddFlags(fs *flag.FlagSet)
func (*ControllerManagerOptions) Validate ¶
func (o *ControllerManagerOptions) Validate(_ bool) error
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 GerritFields ¶
type GerritFields struct {
MaxQPS, MaxBurst int // No throttling when unset.
}
type GerritOptions ¶
type GerritOptions struct { GerritFields // contains filtered or unexported fields }
func (*GerritOptions) AddFlags ¶
func (o *GerritOptions) AddFlags(fs *flag.FlagSet)
func (*GerritOptions) SetDefaultThrottle ¶
func (o *GerritOptions) SetDefaultThrottle(MaxQPS, MaxBurst int)
func (*GerritOptions) Validate ¶
func (o *GerritOptions) Validate(dryrun bool) error
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) GitClientFactory ¶
func (o *GitHubOptions) GitClientFactory(cookieFilePath string, cacheDir *string, dryRun, persistCache 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 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 JiraFlagParameter ¶
type JiraFlagParameter func(*jiraFlagParams)
JiraFlagParameter is a functional option type for configuring Jira flags
func JiraDefaultBearerTokenFile ¶
func JiraDefaultBearerTokenFile(bearerTokenFile string) JiraFlagParameter
JiraDefaultBearerTokenFile sets the default Jira bearer token file
func JiraDefaultEndpoint ¶
func JiraDefaultEndpoint(endpoint string) JiraFlagParameter
JiraDefaultEndpoint sets the default Jira endpoint
func JiraNoBasicAuth ¶
func JiraNoBasicAuth() JiraFlagParameter
JiraNoBasicAuth disables the presence of the basic auth flags
type JiraOptions ¶
type JiraOptions struct {
// contains filtered or unexported fields
}
func (*JiraOptions) AddCustomizedFlags ¶
func (o *JiraOptions) AddCustomizedFlags(fs *flag.FlagSet, params ...JiraFlagParameter)
AddCustomizedFlags injects Jira options into the given FlagSet. Behavior can be customized via functional options.
func (*JiraOptions) AddFlags ¶
func (o *JiraOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects Jira options into the given FlagSet
func (*JiraOptions) Validate ¶
func (o *JiraOptions) Validate(_ bool) error
type KubernetesClientOptions ¶
type KubernetesClientOptions struct {
// contains filtered or unexported fields
}
KubernetesClientOptions holds options for interacting with Kubernetes.
func (*KubernetesClientOptions) AddFlags ¶
func (o *KubernetesClientOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects Kubernetes options into the given FlagSet.
func (*KubernetesClientOptions) KubeClient ¶
func (o *KubernetesClientOptions) KubeClient() (kubernetes.Interface, error)
KubeClient returns a Kubernetes client.
func (*KubernetesClientOptions) ProwJobClient ¶
func (o *KubernetesClientOptions) ProwJobClient() (versioned.Interface, error)
ProwJobClient returns a Kubernetes client.
func (*KubernetesClientOptions) Validate ¶
func (o *KubernetesClientOptions) Validate(dryRun bool) error
Validate validates Kubernetes options.
type KubernetesOptions ¶
type KubernetesOptions struct { NOInClusterConfigDefault bool // contains filtered or unexported fields }
KubernetesOptions holds options for interacting with Kubernetes. These options are both useful for clients interacting with ProwJobs and other resources on the infrastructure cluster, as well as Pods on build clusters.
func (*KubernetesOptions) AddFlags ¶
func (o *KubernetesOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects Kubernetes options into the given FlagSet.
func (*KubernetesOptions) AddKubeconfigChangeCallback ¶
func (o *KubernetesOptions) AddKubeconfigChangeCallback(callback func()) error
AddKubeconfigChangeCallback adds a callback that gets called whenever the kubeconfig changes. The main usecase for this is to exit components that can not reload a kubeconfig at runtime so the kubelet restarts them
func (*KubernetesOptions) BuildClusterClients ¶
func (o *KubernetesOptions) BuildClusterClients(namespace string, dryRun bool) (buildClusterClients map[string]corev1.PodInterface, err error)
BuildClusterClients returns Pod clients for build clusters.
func (*KubernetesOptions) BuildClusterCoreV1Clients ¶
func (o *KubernetesOptions) BuildClusterCoreV1Clients(dryRun bool) (v1Clients map[string]corev1.CoreV1Interface, err error)
BuildClusterCoreV1Clients returns core v1 clients for build clusters.
func (*KubernetesOptions) BuildClusterUncachedRuntimeClients ¶
func (o *KubernetesOptions) BuildClusterUncachedRuntimeClients(dryRun bool) (map[string]ctrlruntimeclient.Client, error)
BuildClusterUncachedRuntimeClients returns ctrlruntimeclients for the build cluster in a non-caching implementation.
func (*KubernetesOptions) BuildClusters ¶
func (o *KubernetesOptions) BuildClusters(dryRun bool, requiredTestPodVerbs []string, callBack func(), namespace string, opts ...func(*cluster.Options)) (map[string]cluster.Cluster, error)
BuildClusters returns the build clusters.
func (*KubernetesOptions) ClusterClientForContext ¶
func (o *KubernetesOptions) ClusterClientForContext(context string, dryRun bool) (kubernetesClient kubernetes.Interface, err error)
ClusterClientForContext returns a Kubernetes client for the given context name.
func (*KubernetesOptions) InfrastructureClusterClient ¶
func (o *KubernetesOptions) InfrastructureClusterClient(dryRun bool) (kubernetesClient kubernetes.Interface, err error)
InfrastructureClusterClient returns a Kubernetes client for the infrastructure cluster.
func (*KubernetesOptions) InfrastructureClusterConfig ¶
func (o *KubernetesOptions) InfrastructureClusterConfig(dryRun bool) (*rest.Config, error)
InfrastructureClusterConfig returns the *rest.Config for the infrastructure cluster
func (*KubernetesOptions) KnownClusters ¶
func (*KubernetesOptions) LoadClusterConfigs ¶
func (o *KubernetesOptions) LoadClusterConfigs(callBacks ...func()) (map[string]rest.Config, error)
LoadClusterConfigs returns the resolved rest.Configs and each callback function will be executed if the underlying kubeconfig files are modified. This function is for the case where the rest.Configs are needed without interests of the clients.
func (*KubernetesOptions) ProwJobClient ¶
func (o *KubernetesOptions) ProwJobClient(namespace string, dryRun bool) (prowJobClient prowv1.ProwJobInterface, err error)
ProwJobClient returns a ProwJob client.
func (*KubernetesOptions) ProwJobClientset ¶
func (o *KubernetesOptions) ProwJobClientset(dryRun bool) (prowJobClientset prow.Interface, err error)
ProwJobClientset returns a ProwJob clientset for use in informer factories.
func (*KubernetesOptions) SetDisabledClusters ¶
func (o *KubernetesOptions) SetDisabledClusters(disabledClusters sets.Set[string])
SetDisabledClusters sets disabledClusters It has no effects if the options have been resolved.
func (*KubernetesOptions) Validate ¶
func (o *KubernetesOptions) Validate(_ bool) error
Validate validates Kubernetes options.
type OptionGroup ¶
type OptionGroup interface { // AddFlags injects options into the given FlagSet. AddFlags(fs *flag.FlagSet) // Validate validates options. Validate(dryRun bool) error }
OptionGroup provides an interface which can be implemented by an option handler (e.g. for GitHub or Kubernetes) to support generic option-group handling.
type StorageClientOptions ¶
type StorageClientOptions struct { // GCSCredentialsFile is used for reading/writing to GCS block storage. // It's optional, if you want to write to local paths or GCS credentials auto-discovery is used. // If set, this file is used to read/write to gs:// paths // If not, credential auto-discovery is used GCSCredentialsFile string `json:"gcs_credentials_file,omitempty"` // S3CredentialsFile is used for reading/writing to s3 block storage. // It's optional, if you want to write to local paths or S3 credentials auto-discovery is used. // If set, this file is used to read/write to s3:// paths // If not, go cloud credential auto-discovery is used // For more details see the prow/io/providers pkg. S3CredentialsFile string `json:"s3_credentials_file,omitempty"` }
func (*StorageClientOptions) AddFlags ¶
func (o *StorageClientOptions) AddFlags(fs *flag.FlagSet)
AddFlags injects status client options into the given FlagSet.
func (*StorageClientOptions) HasGCSCredentials ¶
func (o *StorageClientOptions) HasGCSCredentials() bool
func (*StorageClientOptions) HasS3Credentials ¶
func (o *StorageClientOptions) HasS3Credentials() bool
func (*StorageClientOptions) StorageClient ¶
StorageClient returns a Storage client.
func (*StorageClientOptions) Validate ¶
func (o *StorageClientOptions) Validate(dryRun bool) error
Validate validates options.
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