Files
kubesphere/test/e2e/framework/framework.go
KubeSphere CI Bot 447a51f08b feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
2024-09-06 11:05:52 +08:00

52 lines
1.1 KiB
Go

package framework
import (
"github.com/onsi/ginkgo/v2"
"k8s.io/apimachinery/pkg/runtime"
"kubesphere.io/client-go/kubesphere/scheme"
"kubesphere.io/client-go/rest"
)
type Framework struct {
Workspace string
Namespaces []string
}
// KubeSphereFramework provides an interface to a test control plane so
// that the implementation can vary without affecting tests.
type KubeSphereFramework interface {
RestClient() *rest.RESTClient
}
func NewKubeSphereFramework() KubeSphereFramework {
f := &Framework{}
ginkgo.AfterEach(f.AfterEach)
ginkgo.BeforeEach(f.BeforeEach)
return f
}
func (f *Framework) BeforeEach() {
}
func (f *Framework) AfterEach() {
}
func (f *Framework) RestClient() *rest.RESTClient {
ctx := TestContext
config := &rest.Config{
Host: ctx.Host,
Username: ctx.Username,
Password: ctx.Password,
ContentConfig: rest.ContentConfig{
NegotiatedSerializer: scheme.Codecs.WithoutConversion(),
ContentType: runtime.ContentTypeJSON,
},
}
c, err := rest.UnversionedRESTClientFor(config)
if err != nil {
panic(err)
}
return c
}