Skip to content

Commit

Permalink
fix: set dynamic client
Browse files Browse the repository at this point in the history
Signed-off-by: FogDong <[email protected]>
  • Loading branch information
FogDong committed Aug 13, 2024
1 parent efa246c commit 5fafeb1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -79,6 +80,8 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())
Expect(k8sClient).NotTo(BeNil())
singleton.KubeClient.Set(k8sClient)
fakeDynamicClient := fake.NewSimpleDynamicClient(testScheme)
singleton.DynamicClient.Set(fakeDynamicClient)

reconciler = &WorkflowRunReconciler{
Client: k8sClient,
Expand Down
3 changes: 3 additions & 0 deletions pkg/generator/suit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic/fake"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/utils/pointer"
Expand Down Expand Up @@ -66,6 +67,8 @@ var _ = BeforeSuite(func(done Done) {
Expect(err).ToNot(HaveOccurred())
Expect(k8sClient).ToNot(BeNil())
singleton.KubeClient.Set(k8sClient)
fakeDynamicClient := fake.NewSimpleDynamicClient(scheme)
singleton.DynamicClient.Set(fakeDynamicClient)

close(done)
}, 60)
Expand Down
3 changes: 2 additions & 1 deletion pkg/providers/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/kubevela/pkg/util/runtime"
"github.com/kubevela/pkg/util/singleton"
kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/klog/v2"

"github.com/kubevela/workflow/pkg/providers/email"
"github.com/kubevela/workflow/pkg/providers/http"
Expand Down Expand Up @@ -66,7 +67,7 @@ var DefaultCompiler = singleton.NewSingleton[*cuex.Compiler](func() *cuex.Compil
c := compiler.Get()
if EnableExternalPackageForDefaultCompiler {
if err := c.LoadExternalPackages(context.Background()); err != nil && !kerrors.IsNotFound(err) {
// klog.Errorf("failed to load external packages for cuex default compiler: %s", err.Error())
klog.Errorf("failed to load external packages for cuex default compiler: %s", err.Error())
}
}
if EnableExternalPackageWatchForDefaultCompiler {
Expand Down
6 changes: 6 additions & 0 deletions pkg/tasks/builtin/step_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ import (
"sigs.k8s.io/yaml"

monitorContext "github.com/kubevela/pkg/monitor/context"
"github.com/kubevela/pkg/util/singleton"
"github.com/kubevela/workflow/api/v1alpha1"
wfContext "github.com/kubevela/workflow/pkg/context"
"github.com/kubevela/workflow/pkg/types"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic/fake"
)

type testEngine struct {
Expand Down Expand Up @@ -207,6 +210,9 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context {
err = json.Unmarshal(testCaseJson, &cm)
r.NoError(err)

fakeDynamicClient := fake.NewSimpleDynamicClient(runtime.NewScheme())
singleton.DynamicClient.Set(fakeDynamicClient)

wfCtx := new(wfContext.WorkflowContext)
err = wfCtx.LoadFromConfigMap(context.Background(), cm)
r.NoError(err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/tasks/custom/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic/fake"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -652,6 +653,8 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context {
},
}
singleton.KubeClient.Set(cli)
fakeDynamicClient := fake.NewSimpleDynamicClient(runtime.NewScheme())
singleton.DynamicClient.Set(fakeDynamicClient)
wfCtx, err := wfContext.NewContext(context.Background(), "default", "app-v1", nil)
r.NoError(err)
cuectx := cuecontext.New()
Expand Down

0 comments on commit 5fafeb1

Please sign in to comment.