...
 
Commits (2)
......@@ -68,6 +68,7 @@ check: build
golint ./pkg/controller/...
golint ./pkg/interfaces/...
golint ./pkg/varnish/...
golint ./pkg/haproxy/...
golint ./pkg/apis/varnishingress/v1alpha1/...
golint ./cmd/...
go test -v ./pkg/controller/... ./pkg/interfaces/... ./pkg/varnish/...
......
This diff is collapsed.
......@@ -33,6 +33,8 @@ import (
"net/url"
)
// FaccessError encapsulates an error response from an faccess server.
// Satisfies the error interface.
type FaccessError struct {
Status int
PEM string
......@@ -42,11 +44,22 @@ func (err FaccessError) Error() string {
return err.PEM + ": " + http.StatusText(err.Status)
}
// FaccessClient sends requests to an http-faccess server to determine
// if a file exists and is readable. This is used to find out when a
// PEM file exists (as projected into a SecretVolume), so that haproxy
// can be reloaded with the TLS certificate in its configuration.
//
// https://code.uplex.de/testing/http-faccess
type FaccessClient struct {
baseURL *url.URL
client *http.Client
}
// NewFaccessClient returns a client for the http-faccess server
// listening at host.
//
// host may have the form "addr" or "addr:port", where addr may be a
// host name or IP address.
func NewFaccessClient(host string) *FaccessClient {
return &FaccessClient{
baseURL: &url.URL{
......@@ -61,6 +74,10 @@ func (client *FaccessClient) getHost() string {
return client.baseURL.Host
}
// PEMExists returns true iff the http-faccess server reports that the
// PEM file corresponding to spec exists and is readable.
//
// A non-nil error return may wrap FaccessError.
func (client *FaccessClient) PEMExists(spec SecretSpec) (bool, error) {
relPath := &url.URL{Path: spec.CertName()}
url := client.baseURL.ResolveReference(relPath)
......
This diff is collapsed.
......@@ -193,6 +193,8 @@ func (vc *Controller) EvtGenerator(svcEvt interfaces.SvcEventGenerator) {
vc.svcEvt = svcEvt
}
// HasVarnishSvc returns true iff the configuration of the service
// identified by svcKey has been specified for the Varnish controller.
func (vc *Controller) HasVarnishSvc(svcKey string) bool {
_, ok := vc.svcs[svcKey]
return ok
......