Envtest based integration tests for Fission (#2858)
* skeleton for envtest fission * Refactor code and add CLI test * hack * Update server test * remove skip-ci for lint tests * Pass client go storagesvc * Add clientGen interface across code * Fix storagesvc test * Fix cmd client * add retry in server test * Fix concurrenct access to pool deployment * Remove old executor test * get rid of ginkgo/gomega * disable flaky test * flaky test * revert ci change * handle err from ParseBool --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> Co-authored-by: Pranoy Kundu <pranoy1998k@gmail.com>
This commit is contained in:
co-authored by
Pranoy Kundu
parent
15e16fcc82
commit
8a17d391c5
@@ -35,10 +35,10 @@ import (
|
||||
type (
|
||||
ClientOptions struct {
|
||||
KubeContext string
|
||||
Namespace string
|
||||
RestConfig *rest.Config
|
||||
}
|
||||
Client struct {
|
||||
Options ClientOptions
|
||||
ClientConfig clientcmd.ClientConfig
|
||||
RestConfig *rest.Config
|
||||
FissionClientSet versioned.Interface
|
||||
KubernetesClient kubernetes.Interface
|
||||
@@ -98,29 +98,36 @@ func GetClientConfig(kubeContext string) (clientcmd.ClientConfig, error) {
|
||||
}
|
||||
|
||||
func NewClient(opts ClientOptions) (*Client, error) {
|
||||
client := &Client{
|
||||
Options: opts,
|
||||
client := &Client{}
|
||||
var err error
|
||||
var cmdConfig clientcmd.ClientConfig
|
||||
if len(opts.Namespace) > 0 {
|
||||
client.Namespace = opts.Namespace
|
||||
} else {
|
||||
cmdConfig, err = GetClientConfig(opts.KubeContext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
namespace, _, err := cmdConfig.Namespace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client.Namespace = namespace
|
||||
}
|
||||
cmdConfig, err := GetClientConfig(opts.KubeContext)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client.ClientConfig = cmdConfig
|
||||
|
||||
namespace, _, err := cmdConfig.Namespace()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client.Namespace = namespace
|
||||
console.Verbose(2, "Kubeconfig default namespace %q", namespace)
|
||||
console.Verbose(2, "Kubeconfig default namespace %q", client.Namespace)
|
||||
|
||||
restConfig, err := cmdConfig.ClientConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if opts.RestConfig != nil {
|
||||
client.RestConfig = opts.RestConfig
|
||||
} else {
|
||||
restConfig, err := cmdConfig.ClientConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
client.RestConfig = restConfig
|
||||
}
|
||||
client.RestConfig = restConfig
|
||||
|
||||
clientGen := crd.NewClientGeneratorWithRestConfig(restConfig)
|
||||
clientGen := crd.NewClientGeneratorWithRestConfig(client.RestConfig)
|
||||
clientset, err := clientGen.GetKubernetesClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user