Documentation ¶
Index ¶
- func BackendConfigForPath(host, path string, ing *v1beta1.Ingress, env ValidatorEnv) (*backendconfig.BackendConfig, error)
- func NewService(name, ns string, port int) *v1.Service
- type BackendConfigBuilder
- func (b *BackendConfigBuilder) Build() *backendconfig.BackendConfig
- func (b *BackendConfigBuilder) EnableCDN(enabled bool) *BackendConfigBuilder
- func (b *BackendConfigBuilder) SetCachePolicy(cachePolicy *backendconfig.CacheKeyPolicy) *BackendConfigBuilder
- func (b *BackendConfigBuilder) SetIAPConfig(enabled bool, secret string) *BackendConfigBuilder
- func (b *BackendConfigBuilder) SetSecurityPolicy(securityPolicy string) *BackendConfigBuilder
- type BackendService
- type CheckResponseAction
- type DefaultValidatorEnv
- type Feature
- type FeatureValidator
- type ForwardingRule
- type GCLB
- type GCLBDeleteOptions
- type HostPath
- type IngressBuilder
- func (i *IngressBuilder) AddHost(host string) *IngressBuilder
- func (i *IngressBuilder) AddPath(host, path, service string, port intstr.IntOrString) *IngressBuilder
- func (i *IngressBuilder) AddTLS(hosts []string, secretName string) *IngressBuilder
- func (i *IngressBuilder) Build() *v1beta1.Ingress
- func (i *IngressBuilder) DefaultBackend(service string, port intstr.IntOrString) *IngressBuilder
- func (i *IngressBuilder) Host(host string) *v1beta1.IngressRule
- func (i *IngressBuilder) Path(host, path, service string, port intstr.IntOrString) *v1beta1.HTTPIngressPath
- type IngressResult
- type IngressValidator
- type IngressValidatorAttributes
- type MockValidatorEnv
- type NullValidator
- func (*NullValidator) CheckResponse(string, string, *http.Response, []byte) (CheckResponseAction, error)
- func (*NullValidator) ConfigureAttributes(env ValidatorEnv, ing *v1beta1.Ingress, a *IngressValidatorAttributes) error
- func (*NullValidator) HasAlphaResource(resourceType string) bool
- func (*NullValidator) HasBetaResource(resourceType string) bool
- func (*NullValidator) ModifyRequest(string, string, *http.Request)
- type PathResult
- type ServiceMap
- type TargetHTTPProxy
- type TargetHTTPSProxy
- type URLMap
- type ValidatorEnv
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackendConfigForPath ¶
func BackendConfigForPath(host, path string, ing *v1beta1.Ingress, env ValidatorEnv) (*backendconfig.BackendConfig, error)
BackendConfigForPath returns the BackendConfig associated with the given path. Note: This function returns an empty object (not nil pointer) if a BackendConfig did not exist in the given environment.
Types ¶
type BackendConfigBuilder ¶
type BackendConfigBuilder struct {
// contains filtered or unexported fields
}
BackendConfigBuilder is syntactic sugar for creating BackendConfig specs for testing purposes.
backendConfig := NewBackendConfigBuilder("ns1", "name1").Build()
func NewBackendConfigBuilder ¶
func NewBackendConfigBuilder(ns, name string) *BackendConfigBuilder
NewBackendConfigBuilder instantiates a new BackendConfig.
func NewBackendConfigBuilderFromExisting ¶
func NewBackendConfigBuilderFromExisting(b *backendconfig.BackendConfig) *BackendConfigBuilder
NewBackendConfigBuilderFromExisting creates a BackendConfigBuilder from an existing BackendConfig object. The BackendConfigBuilder object will be copied.
func (*BackendConfigBuilder) Build ¶
func (b *BackendConfigBuilder) Build() *backendconfig.BackendConfig
Build returns a constructed BackendConfig. The BackendConfig is a copy, so the Builder can be reused to construct multiple BackendConfig definitions.
func (*BackendConfigBuilder) EnableCDN ¶
func (b *BackendConfigBuilder) EnableCDN(enabled bool) *BackendConfigBuilder
EnableCDN enables or disables CDN on the BackendConfig.
func (*BackendConfigBuilder) SetCachePolicy ¶
func (b *BackendConfigBuilder) SetCachePolicy(cachePolicy *backendconfig.CacheKeyPolicy) *BackendConfigBuilder
SetCachePolicy specifies the cache policy on the BackendConfig.
func (*BackendConfigBuilder) SetIAPConfig ¶
func (b *BackendConfigBuilder) SetIAPConfig(enabled bool, secret string) *BackendConfigBuilder
SetIAPConfig enables or disables IAP on the BackendConfig and also sets the secret which contains the OAuth credentials.
func (*BackendConfigBuilder) SetSecurityPolicy ¶
func (b *BackendConfigBuilder) SetSecurityPolicy(securityPolicy string) *BackendConfigBuilder
SetSecurityPolicy sets security policy on the BackendConfig.
type BackendService ¶
type BackendService struct { GA *compute.BackendService Alpha *computealpha.BackendService Beta *computebeta.BackendService }
BackendService is a union of the API version types.
type CheckResponseAction ¶
type CheckResponseAction int
CheckResponseAction is the action to be taken when evaluating the CheckResponse.
const ( // CheckResponseContinue continues with the standard response checking. CheckResponseContinue CheckResponseAction = iota // CheckResponseSkip skips the standard response checking. CheckResponseSkip CheckResponseAction = iota )
type DefaultValidatorEnv ¶
type DefaultValidatorEnv struct {
// contains filtered or unexported fields
}
DefaultValidatorEnv is a ValidatorEnv that gets data from the Kubernetes clientset.
func (*DefaultValidatorEnv) BackendConfigs ¶
func (e *DefaultValidatorEnv) BackendConfigs() (map[string]*backendconfig.BackendConfig, error)
BackendConfigs implements ValidatorEnv.
func (*DefaultValidatorEnv) Cloud ¶
func (e *DefaultValidatorEnv) Cloud() cloud.Cloud
DefaultValidatorEnv implements ValidatorEnv.
type Feature ¶
type Feature interface { // Name of the feature. Name() string // NewValidator returns a new validator instance. NewValidator() FeatureValidator }
Feature represents an extension to the "vanilla" behavior of Ingress.
type FeatureValidator ¶
type FeatureValidator interface { // Name of the feature. Name() string // ConfigureAttributes of the validation for given the environment and // the Ingress object. ConfigureAttributes(env ValidatorEnv, ing *v1beta1.Ingress, a *IngressValidatorAttributes) error // ModifyRequest adds the appropriate headers for testing the feature, if // necessary. ModifyRequest(host, path string, req *http.Request) // CheckResponse checks the HTTP response from the validation for // correctness. Return (CheckResponseContinue, nil) if you wish to continue // with the standard Response validation. Return (CheckResponseSkip, nil) // if you wish to skip the standard Response validation for the current // request. If (_, err) is returned, then the response is considered to be // an error. CheckResponse(host, path string, resp *http.Response, body []byte) (CheckResponseAction, error) HasAlphaResource(resourceType string) bool HasBetaResource(resourceType string) bool }
FeatureValidator is a validator for the Feature. It has various hooks to the standard validation routine.
func FeatureValidators ¶
func FeatureValidators(fs []Feature) []FeatureValidator
FeatureValidators returns a list of validators.
type ForwardingRule ¶
type ForwardingRule struct { GA *compute.ForwardingRule Alpha *computealpha.ForwardingRule Beta *computebeta.ForwardingRule }
ForwardingRule is a union of the API version types.
type GCLB ¶
type GCLB struct { VIP string ForwardingRule map[meta.Key]*ForwardingRule TargetHTTPProxy map[meta.Key]*TargetHTTPProxy TargetHTTPSProxy map[meta.Key]*TargetHTTPSProxy URLMap map[meta.Key]*URLMap BackendService map[meta.Key]*BackendService }
GCLB contains the resources for a load balancer.
func GCLBForVIP ¶
func GCLBForVIP(ctx context.Context, c cloud.Cloud, vip string, validators []FeatureValidator) (*GCLB, error)
GCLBForVIP retrieves all of the resources associated with the GCLB for a given VIP.
func (*GCLB) CheckResourceDeletion ¶
func (g *GCLB) CheckResourceDeletion(ctx context.Context, c cloud.Cloud, options *GCLBDeleteOptions) error
CheckResourceDeletion checks the existance of the resources. Returns nil if all of the associated resources no longer exist.
type GCLBDeleteOptions ¶
type GCLBDeleteOptions struct { // SkipDefaultBackend indicates whether to skip checking for the // system default backend. SkipDefaultBackend bool }
GCLBDeleteOptions may be provided when cleaning up GCLB resource.
type HostPath ¶
HostPath maps an entry in Ingress to a specific service. Host == "" and Path == "" denotes the default backend.
type IngressBuilder ¶
type IngressBuilder struct {
// contains filtered or unexported fields
}
IngressBuilder is syntactic sugar for creating Ingress specs for testing purposes.
ing := NewIngressBuilder("ns1", "name1", "127.0.0.1").Build()
func NewIngressBuilder ¶
func NewIngressBuilder(ns, name, vip string) *IngressBuilder
NewIngressBuilder instantiates a new IngressBuilder.
func NewIngressBuilderFromExisting ¶
func NewIngressBuilderFromExisting(i *v1beta1.Ingress) *IngressBuilder
NewIngressBuilderFromExisting creates a IngressBuilder from an existing Ingress object. The Ingress object will be copied.
func (*IngressBuilder) AddHost ¶
func (i *IngressBuilder) AddHost(host string) *IngressBuilder
AddHost adds a rule for a host entry if it did not yet exist.
func (*IngressBuilder) AddPath ¶
func (i *IngressBuilder) AddPath(host, path, service string, port intstr.IntOrString) *IngressBuilder
AddPath a new path for the given host if it did not already exist.
func (*IngressBuilder) AddTLS ¶
func (i *IngressBuilder) AddTLS(hosts []string, secretName string) *IngressBuilder
AddTLS adds a TLS secret reference.
func (*IngressBuilder) Build ¶
func (i *IngressBuilder) Build() *v1beta1.Ingress
Build returns a constructed Ingress. The Ingress is a copy, so the Builder can be reused to construct multiple Ingress definitions.
func (*IngressBuilder) DefaultBackend ¶
func (i *IngressBuilder) DefaultBackend(service string, port intstr.IntOrString) *IngressBuilder
DefaultBackend sets the default backend.
func (*IngressBuilder) Host ¶
func (i *IngressBuilder) Host(host string) *v1beta1.IngressRule
Host returns the rule for a host and creates it if it did not exist.
func (*IngressBuilder) Path ¶
func (i *IngressBuilder) Path(host, path, service string, port intstr.IntOrString) *v1beta1.HTTPIngressPath
Path returns the Path matching the (host, path), appending the entry if it does not already exist.
type IngressResult ¶
type IngressResult struct { Err error Paths []*PathResult }
IngressResult is the result of an Ingress validation.
type IngressValidator ¶
type IngressValidator struct {
// contains filtered or unexported fields
}
IngressValidator encapsulates the logic required to validate a given configuration is behaving correctly.
func NewIngressValidator ¶
func NewIngressValidator(env ValidatorEnv, ing *v1beta1.Ingress, features []Feature, attribs *IngressValidatorAttributes) (*IngressValidator, error)
NewIngressValidator returns a new validator for checking the correctness of an Ingress spec against the behavior of the instantiated load balancer. If attribs is nil, then the default set of attributes will be used.
func (*IngressValidator) Check ¶
func (v *IngressValidator) Check(ctx context.Context) *IngressResult
Check runs all of the checks against the instantiated load balancer.
func (*IngressValidator) CheckPaths ¶
func (v *IngressValidator) CheckPaths(ctx context.Context, vr *IngressResult) error
CheckPaths checks the host, paths that have been configured. Checks are run in parallel.
type IngressValidatorAttributes ¶
type IngressValidatorAttributes struct { CheckHTTP bool CheckHTTPS bool RejectInsecureCerts bool RequestTimeout time.Duration // HTTPPort and HTTPSPort are used only for unit testing. HTTPPort int HTTPSPort int }
IngressValidatorAttributes are derived attributes governing how the Ingress is validated. Features will use this structure to express changes to the standard checks by modifying this struct.
type MockValidatorEnv ¶
type MockValidatorEnv struct { BackendConfigsMap map[string]*backendconfig.BackendConfig ServicesMap map[string]*v1.Service MockCloud *cloud.MockGCE }
MockValidatorEnv is an environment that is used for mock testing.
func (*MockValidatorEnv) BackendConfigs ¶
func (e *MockValidatorEnv) BackendConfigs() (map[string]*backendconfig.BackendConfig, error)
BackendConfigs implements ValidatorEnv.
func (*MockValidatorEnv) Cloud ¶
func (e *MockValidatorEnv) Cloud() cloud.Cloud
Cloud implements ValidatorEnv.
type NullValidator ¶
type NullValidator struct { }
NullValidator is a feature that does nothing. Embed this object to reduce the amount of boilerplate required to implement a feature that doesn't require all of the hooks.
func (*NullValidator) CheckResponse ¶
func (*NullValidator) CheckResponse(string, string, *http.Response, []byte) (CheckResponseAction, error)
CheckResponse implements Feature.
func (*NullValidator) ConfigureAttributes ¶
func (*NullValidator) ConfigureAttributes(env ValidatorEnv, ing *v1beta1.Ingress, a *IngressValidatorAttributes) error
ConfigureAttributes implements Feature.
func (*NullValidator) HasAlphaResource ¶
func (*NullValidator) HasAlphaResource(resourceType string) bool
HasAlphaResource implements Feature.
func (*NullValidator) HasBetaResource ¶
func (*NullValidator) HasBetaResource(resourceType string) bool
HasBetaResource implements Feature.
func (*NullValidator) ModifyRequest ¶
func (*NullValidator) ModifyRequest(string, string, *http.Request)
ModifyRequest implements Feature.
type PathResult ¶
PathResult is the result of validating a path.
type ServiceMap ¶
type ServiceMap map[HostPath]*v1beta1.IngressBackend
ServiceMap is a map of (host, path) to the appropriate BackendConfig(s).
func ServiceMapFromIngress ¶
func ServiceMapFromIngress(ing *v1beta1.Ingress) ServiceMap
ServiceMapFromIngress creates a service map from the Ingress object. Note: duplicate entries (e.g. invalid configurations) will result in the first entry to be chosen.
type TargetHTTPProxy ¶
type TargetHTTPProxy struct { GA *compute.TargetHttpProxy Alpha *computealpha.TargetHttpProxy Beta *computebeta.TargetHttpProxy }
TargetHTTPProxy is a union of the API version types.
type TargetHTTPSProxy ¶
type TargetHTTPSProxy struct { GA *compute.TargetHttpsProxy Alpha *computealpha.TargetHttpsProxy Beta *computebeta.TargetHttpsProxy }
TargetHTTPSProxy is a union of the API version types.
type URLMap ¶
type URLMap struct { GA *compute.UrlMap Alpha *computealpha.UrlMap Beta *computebeta.UrlMap }
URLMap is a union of the API version types.
type ValidatorEnv ¶
type ValidatorEnv interface { BackendConfigs() (map[string]*backendconfig.BackendConfig, error) Services() (map[string]*v1.Service, error) Cloud() cloud.Cloud }
ValidatorEnv captures non-Ingress spec related environment that affect the set of validations and Features.
func NewDefaultValidatorEnv ¶
NewDefaultValidatorEnv returns a new ValidatorEnv.