Skip to content

Commit

Permalink
Rename HTTPProxy match Conditions to MatchConditions for disambiguati…
Browse files Browse the repository at this point in the history
…on. (#2695)

This is preparation to add a copy of the upstream Condition type to
the projectcontour.io/v1 api group.

Preparing to add Conditions (for status)  made me realize that we needed to
change the terminology everywhere in Contour (except the `conditions` yaml tag),
or else we could get very confused about Conditions (for routing and including)
versus Conditions (for status).

Signed-off-by: Nick Young <[email protected]>
  • Loading branch information
Nick Young authored Jul 20, 2020
1 parent 7074744 commit d4f992c
Show file tree
Hide file tree
Showing 37 changed files with 787 additions and 752 deletions.
32 changes: 21 additions & 11 deletions apis/projectcontour/v1/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,33 @@ type Include struct {
// Namespace of the HTTPProxy to include. Defaults to the current namespace if not supplied.
// +optional
Namespace string `json:"namespace,omitempty"`
// Conditions are a set of routing properties that is applied to an HTTPProxy in a namespace.
// +optional
Conditions []Condition `json:"conditions,omitempty"`
// Conditions are a set of rules that are applied to included HTTPProxies.
// In effect, they are added onto the Conditions of included HTTPProxy Route
// structs.
// When applied, they are merged using AND, with one exception:
// There can be only one Prefix MatchCondition per Conditions slice.
// More than one Prefix, or contradictory Conditions, will make the
// include invalid.
// +optional
Conditions []MatchCondition `json:"conditions,omitempty"`
}

// Condition are policies that are applied on top of HTTPProxies.
// MatchCondition are a general holder for matching rules for HTTPProxies.
// One of Prefix or Header must be provided.
type Condition struct {
type MatchCondition struct {
// Prefix defines a prefix match for a request.
// +optional
Prefix string `json:"prefix,omitempty"`

// Header specifies the header condition to match.
// +optional
Header *HeaderCondition `json:"header,omitempty"`
Header *HeaderMatchCondition `json:"header,omitempty"`
}

// HeaderCondition specifies how to conditionally match against HTTP
// HeaderMatchCondition specifies how to conditionally match against HTTP
// headers. The Name field is required, but only one of the remaining
// fields should be be provided.
type HeaderCondition struct {
type HeaderMatchCondition struct {
// Name is the name of the header to match against. Name is required.
// Header names are case insensitive.
Name string `json:"name"`
Expand Down Expand Up @@ -139,9 +145,13 @@ type TLS struct {

// Route contains the set of routes for a virtual host.
type Route struct {
// Conditions are a set of routing properties that is applied to an HTTPProxy in a namespace.
// Conditions are a set of rules that are applied to a Route.
// When applied, they are merged using AND, with one exception:
// There can be only one Prefix MatchCondition per Conditions slice.
// More than one Prefix, or contradictory Conditions, will make the
// route invalid.
// +optional
Conditions []Condition `json:"conditions,omitempty"`
Conditions []MatchCondition `json:"conditions,omitempty"`
// Services are the services to proxy traffic.
// +kubebuilder:validation:MinItems=1
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -360,7 +370,7 @@ type RetryPolicy struct {
type ReplacePrefix struct {
// Prefix specifies the URL path prefix to be replaced.
//
// If Prefix is specified, it must exactly match the Condition
// If Prefix is specified, it must exactly match the MatchCondition
// prefix that is rendered by the chain of including HTTPProxies
// and only that path prefix will be replaced by Replacement.
// This allows HTTPProxies that are included through multiple
Expand Down
52 changes: 26 additions & 26 deletions apis/projectcontour/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 17 additions & 10 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ spec:
to an HTTPProxy in a namespace.
properties:
conditions:
description: Conditions are a set of routing properties that is
applied to an HTTPProxy in a namespace.
description: 'Conditions are a set of rules that are applied to
included HTTPProxies. In effect, they are added onto the Conditions
of included HTTPProxy Route structs. When applied, they are
merged using AND, with one exception: There can be only one
Prefix MatchCondition per Conditions slice. More than one Prefix,
or contradictory Conditions, will make the include invalid.'
items:
description: Condition are policies that are applied on top
of HTTPProxies. One of Prefix or Header must be provided.
description: MatchCondition are a general holder for matching
rules for HTTPProxies. One of Prefix or Header must be provided.
properties:
header:
description: Header specifies the header condition to match.
Expand Down Expand Up @@ -125,11 +129,14 @@ spec:
description: Route contains the set of routes for a virtual host.
properties:
conditions:
description: Conditions are a set of routing properties that is
applied to an HTTPProxy in a namespace.
description: 'Conditions are a set of rules that are applied to
a Route. When applied, they are merged using AND, with one exception:
There can be only one Prefix MatchCondition per Conditions slice.
More than one Prefix, or contradictory Conditions, will make
the route invalid.'
items:
description: Condition are policies that are applied on top
of HTTPProxies. One of Prefix or Header must be provided.
description: MatchCondition are a general holder for matching
rules for HTTPProxies. One of Prefix or Header must be provided.
properties:
header:
description: Header specifies the header condition to match.
Expand Down Expand Up @@ -233,8 +240,8 @@ spec:
prefix:
description: "Prefix specifies the URL path prefix to
be replaced. \n If Prefix is specified, it must exactly
match the Condition prefix that is rendered by the
chain of including HTTPProxies and only that path
match the MatchCondition prefix that is rendered by
the chain of including HTTPProxies and only that path
prefix will be replaced by Replacement. This allows
HTTPProxies that are included through multiple roots
to only replace specific path prefixes, leaving others
Expand Down
27 changes: 17 additions & 10 deletions examples/render/contour.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,15 @@ spec:
to an HTTPProxy in a namespace.
properties:
conditions:
description: Conditions are a set of routing properties that is
applied to an HTTPProxy in a namespace.
description: 'Conditions are a set of rules that are applied to
included HTTPProxies. In effect, they are added onto the Conditions
of included HTTPProxy Route structs. When applied, they are
merged using AND, with one exception: There can be only one
Prefix MatchCondition per Conditions slice. More than one Prefix,
or contradictory Conditions, will make the include invalid.'
items:
description: Condition are policies that are applied on top
of HTTPProxies. One of Prefix or Header must be provided.
description: MatchCondition are a general holder for matching
rules for HTTPProxies. One of Prefix or Header must be provided.
properties:
header:
description: Header specifies the header condition to match.
Expand Down Expand Up @@ -237,11 +241,14 @@ spec:
description: Route contains the set of routes for a virtual host.
properties:
conditions:
description: Conditions are a set of routing properties that is
applied to an HTTPProxy in a namespace.
description: 'Conditions are a set of rules that are applied to
a Route. When applied, they are merged using AND, with one exception:
There can be only one Prefix MatchCondition per Conditions slice.
More than one Prefix, or contradictory Conditions, will make
the route invalid.'
items:
description: Condition are policies that are applied on top
of HTTPProxies. One of Prefix or Header must be provided.
description: MatchCondition are a general holder for matching
rules for HTTPProxies. One of Prefix or Header must be provided.
properties:
header:
description: Header specifies the header condition to match.
Expand Down Expand Up @@ -345,8 +352,8 @@ spec:
prefix:
description: "Prefix specifies the URL path prefix to
be replaced. \n If Prefix is specified, it must exactly
match the Condition prefix that is rendered by the
chain of including HTTPProxies and only that path
match the MatchCondition prefix that is rendered by
the chain of including HTTPProxies and only that path
prefix will be replaced by Replacement. This allows
HTTPProxies that are included through multiple roots
to only replace specific path prefixes, leaving others
Expand Down
14 changes: 7 additions & 7 deletions internal/contour/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func TestClusterVisit(t *testing.T) {
Fqdn: "www.example.com",
},
Routes: []projcontour.Route{{
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestClusterVisit(t *testing.T) {
HealthCheckPolicy: &projcontour.HTTPHealthCheckPolicy{
Path: "/healthy",
},
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -435,7 +435,7 @@ func TestClusterVisit(t *testing.T) {
UnhealthyThresholdCount: 97,
HealthyThresholdCount: 96,
},
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -492,7 +492,7 @@ func TestClusterVisit(t *testing.T) {
LoadBalancerPolicy: &projcontour.LoadBalancerPolicy{
Strategy: "RoundRobin",
},
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -536,7 +536,7 @@ func TestClusterVisit(t *testing.T) {
LoadBalancerPolicy: &projcontour.LoadBalancerPolicy{
Strategy: "WeightedLeastRequest",
},
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -581,7 +581,7 @@ func TestClusterVisit(t *testing.T) {
LoadBalancerPolicy: &projcontour.LoadBalancerPolicy{
Strategy: "Random",
},
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -628,7 +628,7 @@ func TestClusterVisit(t *testing.T) {
LoadBalancerPolicy: &projcontour.LoadBalancerPolicy{
Strategy: "lulz",
},
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down
10 changes: 5 additions & 5 deletions internal/contour/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestListenerVisit(t *testing.T) {
Fqdn: "www.example.com",
},
Routes: []projcontour.Route{{
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -1462,7 +1462,7 @@ func TestListenerVisit(t *testing.T) {
Fqdn: "www.example.com",
},
Routes: []projcontour.Route{{
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -1516,7 +1516,7 @@ func TestListenerVisit(t *testing.T) {
Fqdn: "www.example.com",
},
Routes: []projcontour.Route{{
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -1570,7 +1570,7 @@ func TestListenerVisit(t *testing.T) {
Fqdn: "www.example.com",
},
Routes: []projcontour.Route{{
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down Expand Up @@ -1624,7 +1624,7 @@ func TestListenerVisit(t *testing.T) {
Fqdn: "www.example.com",
},
Routes: []projcontour.Route{{
Conditions: []projcontour.Condition{{
Conditions: []projcontour.MatchCondition{{
Prefix: "/",
}},
Services: []projcontour.Service{{
Expand Down
Loading

0 comments on commit d4f992c

Please sign in to comment.