Commit 5779abd3 authored by Geoff Simmons's avatar Geoff Simmons

Run golint on pkg/haproxy/*.go, and fix to make golint happy.

For the most part by adding go docs, and by using Go naming
conventions in a few cases.

Remove some commented-out code while we're here.
parent c79d990b
...@@ -68,6 +68,7 @@ check: build ...@@ -68,6 +68,7 @@ check: build
golint ./pkg/controller/... golint ./pkg/controller/...
golint ./pkg/interfaces/... golint ./pkg/interfaces/...
golint ./pkg/varnish/... golint ./pkg/varnish/...
golint ./pkg/haproxy/...
golint ./pkg/apis/varnishingress/v1alpha1/... golint ./pkg/apis/varnishingress/v1alpha1/...
golint ./cmd/... golint ./cmd/...
go test -v ./pkg/controller/... ./pkg/interfaces/... ./pkg/varnish/... go test -v ./pkg/controller/... ./pkg/interfaces/... ./pkg/varnish/...
......
This diff is collapsed.
...@@ -33,6 +33,8 @@ import ( ...@@ -33,6 +33,8 @@ import (
"net/url" "net/url"
) )
// FaccessError encapsulates an error response from an faccess server.
// Satisfies the error interface.
type FaccessError struct { type FaccessError struct {
Status int Status int
PEM string PEM string
...@@ -42,11 +44,22 @@ func (err FaccessError) Error() string { ...@@ -42,11 +44,22 @@ func (err FaccessError) Error() string {
return err.PEM + ": " + http.StatusText(err.Status) 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 { type FaccessClient struct {
baseURL *url.URL baseURL *url.URL
client *http.Client 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 { func NewFaccessClient(host string) *FaccessClient {
return &FaccessClient{ return &FaccessClient{
baseURL: &url.URL{ baseURL: &url.URL{
...@@ -61,6 +74,10 @@ func (client *FaccessClient) getHost() string { ...@@ -61,6 +74,10 @@ func (client *FaccessClient) getHost() string {
return client.baseURL.Host 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) { func (client *FaccessClient) PEMExists(spec SecretSpec) (bool, error) {
relPath := &url.URL{Path: spec.CertName()} relPath := &url.URL{Path: spec.CertName()}
url := client.baseURL.ResolveReference(relPath) url := client.baseURL.ResolveReference(relPath)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment