2016-09-22 18:00:09 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 The Kubernetes Authors.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-11-10 22:56:29 +00:00
|
|
|
package sslpassthrough
|
2016-09-22 18:00:09 +00:00
|
|
|
|
|
|
|
import (
|
2017-04-01 14:39:42 +00:00
|
|
|
extensions "k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
2016-11-16 18:24:26 +00:00
|
|
|
|
2016-11-10 22:56:29 +00:00
|
|
|
"k8s.io/ingress/core/pkg/ingress/annotations/parser"
|
2016-12-29 20:02:06 +00:00
|
|
|
ing_errors "k8s.io/ingress/core/pkg/ingress/errors"
|
2016-09-22 18:00:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2016-11-10 22:56:29 +00:00
|
|
|
passthrough = "ingress.kubernetes.io/ssl-passthrough"
|
2016-09-22 18:00:09 +00:00
|
|
|
)
|
|
|
|
|
2016-12-29 20:02:06 +00:00
|
|
|
type sslpt struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewParser creates a new SSL passthrough annotation parser
|
|
|
|
func NewParser() parser.IngressAnnotation {
|
|
|
|
return sslpt{}
|
|
|
|
}
|
|
|
|
|
2016-11-10 22:56:29 +00:00
|
|
|
// ParseAnnotations parses the annotations contained in the ingress
|
|
|
|
// rule used to indicate if is required to configure
|
2016-12-29 20:02:06 +00:00
|
|
|
func (a sslpt) Parse(ing *extensions.Ingress) (interface{}, error) {
|
2016-11-10 22:56:29 +00:00
|
|
|
if ing.GetAnnotations() == nil {
|
2016-12-29 20:02:06 +00:00
|
|
|
return false, ing_errors.ErrMissingAnnotations
|
2016-09-22 18:00:09 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 22:56:29 +00:00
|
|
|
return parser.GetBoolAnnotation(passthrough, ing)
|
2016-09-22 18:00:09 +00:00
|
|
|
}
|