Documentation ¶
Index ¶
- func FileExists(filename string) bool
- func FolderExists(filename string) bool
- func GetCurrentExecPath() string
- func GetParams(regEx, str string) (paramsMap map[string]string)
- func GetParamsWithRegex(compRegEx *regexp.Regexp, str string) (paramsMap map[string]string)
- type HttpClientInterface
- type IK8sClientHelper
- type K8sClient
- type K8sClientHelper
- type RealHTTPClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileExists ¶
FileExists checks if a file exists and is not a directory before we try using it to prevent further errors.
func FolderExists ¶
FolderExists checks if a file exists and is not a directory before we try using it to prevent further errors.
func GetCurrentExecPath ¶
func GetCurrentExecPath() string
GetCurrentExecPath returns the path of the executable file
Types ¶
type HttpClientInterface ¶
type HttpClientInterface interface { SendRequest( url string, cookieJar *cookiejar.Jar, header map[string]string, method string, payload io.Reader, queryParams map[string]string, skipInsecureVerify bool, username string, password string, timeout time.Duration, ) (content string, statusCode int, err error) }
HttpClientInterface is a simple interface that defines the functions of a HTTP client
type IK8sClientHelper ¶
type IK8sClientHelper interface { GetClient(pathToCfg string) (*K8sClient, error) GetClientAndConfig(pathToCfg string) (*K8sClient, *rest.Config, error) }
IK8sClientHelper is the interface to get a Client Using this way, we can easily create a mock object that satisfies this interface
type K8sClient ¶
type K8sClient struct {
Clientset kubernetes.Interface
}
K8sClient is the wrapper of Kubernetes K8sClient that helps us easier to mock and test using Dependency Injection
type K8sClientHelper ¶
type K8sClientHelper struct { }
ClienHelper is a helper class that implement IClientHelper, and returns the real Kubernetes Clientset
func (K8sClientHelper) GetClient ¶
func (c K8sClientHelper) GetClient(pathToCfg string) (*K8sClient, error)
GetClient returns a Kubernetes Clientset which is built from a given config file path, for example `~/.kube/config` if the file path is empty, we will use the mode "InCluster" (with a token of serviec account stored in `/var/run/secrets/kubernetes.io/serviceaccount/token`) otherwise, use the server information and authentication information from the path
func (K8sClientHelper) GetClientAndConfig ¶
GetClientAndConfig returns a Kubernetes Clientset and the REST configuration which is built from a given config file path, for example `~/.kube/config` if the file path is empty, we will use the mode "InCluster" (with a token of serviec account stored in `/var/run/secrets/kubernetes.io/serviceaccount/token`) otherwise, use the server information and authentication information from the path
type RealHTTPClient ¶
type RealHTTPClient struct { }
RealHTTPClient implements the real http client service
func (RealHTTPClient) SendRequest ¶
func (RealHTTPClient) SendRequest( url string, cookieJar *cookiejar.Jar, header map[string]string, method string, payload io.Reader, queryParams map[string]string, skipInsecureVerify bool, username string, password string, timeout time.Duration, ) (content string, statusCode int, err error)
SendRequest sends a get request and return the response if the response is compressed, un-compress it first and then return