forked from kubernetes-sigs/cluster-api-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f08b1ca
commit a89ebc6
Showing
6 changed files
with
1,114 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package framework | ||
|
||
import ( | ||
"flag" | ||
"strings" | ||
|
||
"github.com/kubernetes-incubator/apiserver-builder/pkg/controller" | ||
"k8s.io/client-go/kubernetes" | ||
apiregistrationclientset "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset" | ||
"sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var kubeconfig string | ||
|
||
// ClusterID set by -cluster-id flag | ||
var ClusterID string | ||
|
||
func init() { | ||
flag.StringVar(&kubeconfig, "kubeconfig", "", "kubeconfig file") | ||
flag.StringVar(&ClusterID, "cluster-id", "", "cluster ID") | ||
flag.Parse() | ||
} | ||
|
||
// Framework supports common operations used by tests | ||
type Framework struct { | ||
KubeClient *kubernetes.Clientset | ||
CAPIClient *clientset.Clientset | ||
APIRegistrationClient *apiregistrationclientset.Clientset | ||
Kubeconfig string | ||
} | ||
|
||
// NewFramework setups a new framework | ||
func NewFramework() *Framework { | ||
f := &Framework{ | ||
Kubeconfig: kubeconfig, | ||
} | ||
|
||
BeforeEach(f.BeforeEach) | ||
|
||
return f | ||
} | ||
|
||
// BeforeEach to be run before each spec responsible for building various clientsets | ||
func (f *Framework) BeforeEach() { | ||
By("Creating a kubernetes client") | ||
|
||
if f.KubeClient == nil { | ||
config, err := controller.GetConfig(f.Kubeconfig) | ||
Expect(err).NotTo(HaveOccurred()) | ||
f.KubeClient, err = kubernetes.NewForConfig(config) | ||
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
|
||
if f.CAPIClient == nil { | ||
config, err := controller.GetConfig(f.Kubeconfig) | ||
Expect(err).NotTo(HaveOccurred()) | ||
f.CAPIClient, err = clientset.NewForConfig(config) | ||
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
|
||
if f.APIRegistrationClient == nil { | ||
config, err := controller.GetConfig(f.Kubeconfig) | ||
Expect(err).NotTo(HaveOccurred()) | ||
f.APIRegistrationClient, err = apiregistrationclientset.NewForConfig(config) | ||
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
|
||
} | ||
|
||
// IgnoreNotFoundErr ignores not found errors in case resource | ||
// that does not exist is to be deleted | ||
func IgnoreNotFoundErr(err error) { | ||
if err != nil { | ||
if !strings.Contains(err.Error(), "not found") { | ||
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
} | ||
} | ||
|
||
// SigKubeDescribe is a wrapper function for ginkgo describe. Adds namespacing. | ||
func SigKubeDescribe(text string, body func()) bool { | ||
return Describe("[sigs.k8s.io] "+text, body) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.