Split TLS loading to allow 3rd parties to load keys easily

The LoadTLSFiles method is useful for configuration code that needs
to read the current client config and get values out for creating
other config files.
This commit is contained in:
Clayton Coleman
2015-02-19 20:54:21 -05:00
parent 5eb71a1877
commit 60c014334f
2 changed files with 45 additions and 32 deletions

View File

@@ -18,7 +18,6 @@ package client
import (
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
@@ -274,19 +273,6 @@ func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTrip
return rt, nil
}
// dataFromSliceOrFile returns data from the slice (if non-empty), or from the file,
// or an error if an error occurred reading the file
func dataFromSliceOrFile(data []byte, file string) ([]byte, error) {
if len(data) > 0 {
return data, nil
}
fileData, err := ioutil.ReadFile(file)
if err != nil {
return []byte{}, err
}
return fileData, nil
}
// DefaultServerURL converts a host, host:port, or URL string to the default base server API path
// to use with a Client at a given API version following the standard conventions for a
// Kubernetes API.