From b32875d019d05a2f4c23a678264c138c56626941 Mon Sep 17 00:00:00 2001 From: FogDong Date: Mon, 24 Apr 2023 17:00:10 +0800 Subject: [PATCH 01/17] Chore: refactor the cue engine with cuex Signed-off-by: FogDong --- cmd/main.go | 10 - controllers/suite_test.go | 9 +- controllers/testdata/apply-object.yaml | 18 +- controllers/testdata/test-apply.yaml | 54 +- controllers/workflow_test.go | 10 +- controllers/workflowrun_controller.go | 15 +- go.mod | 112 +-- go.sum | 775 ++---------------- pkg/context/context.go | 79 +- pkg/context/context_test.go | 86 +- pkg/context/interface.go | 12 +- pkg/cue/model/keyword.go | 2 + pkg/cue/model/value/error.go | 29 + pkg/cue/model/value/value.go | 126 ++- pkg/cue/model/value/value_test.go | 64 -- pkg/debug/context.go | 20 +- pkg/debug/context_test.go | 27 +- pkg/errors/errors.go | 36 + pkg/executor/options.go | 53 ++ pkg/executor/suit_test.go | 2 + pkg/executor/workflow.go | 63 +- pkg/executor/workflow_test.go | 95 +-- pkg/generator/generator.go | 42 +- pkg/generator/generator_test.go | 4 +- pkg/generator/suit_test.go | 2 + pkg/hooks/data_passing.go | 27 +- pkg/hooks/data_passing_test.go | 63 +- pkg/providers/compiler.go | 44 + pkg/providers/kube/handle_test.go | 582 ------------- pkg/providers/legacy/email/email.cue | 31 + .../{email/send.go => legacy/email/email.go} | 108 ++- .../email/email_test.go} | 135 ++- pkg/providers/legacy/http/http.cue | 54 ++ pkg/providers/legacy/http/http.go | 239 ++++++ .../do_test.go => legacy/http/http_test.go} | 309 ++++--- .../http/ratelimiter/ratelimiter.go | 0 .../http/ratelimiter/ratelimiter_test.go | 0 .../{ => legacy}/http/testdata/certs.go | 0 pkg/providers/legacy/kube/kube.cue | 106 +++ pkg/providers/legacy/kube/kube.go | 331 ++++++++ pkg/providers/legacy/kube/kube_test.go | 436 ++++++++++ pkg/providers/legacy/legacy.go | 39 + pkg/providers/legacy/metrics/metrics.cue | 13 + pkg/providers/legacy/metrics/prom_check.go | 216 +++++ .../{ => legacy}/metrics/prom_check_test.go | 55 +- pkg/providers/legacy/util/util.cue | 46 ++ pkg/providers/legacy/util/util.go | 194 +++++ pkg/providers/{ => legacy}/util/util_test.go | 221 +++-- pkg/providers/legacy/workspace/workspace.cue | 59 ++ pkg/providers/legacy/workspace/workspace.go | 211 +++++ .../{ => legacy}/workspace/workspace_test.go | 244 +++--- pkg/providers/providers.go | 59 -- pkg/providers/providers_test.go | 43 - pkg/providers/types/types.go | 115 +++ pkg/tasks/builtin/step_group.go | 15 +- pkg/tasks/builtin/step_group_test.go | 2 +- pkg/tasks/custom/action.go | 166 ++++ pkg/tasks/custom/task.go | 435 ++-------- pkg/tasks/custom/task_test.go | 513 ++++++------ pkg/tasks/discover.go | 2 +- pkg/tasks/discover_test.go | 2 +- pkg/tasks/template/load.go | 11 +- pkg/tasks/template/load_test.go | 4 +- pkg/types/types.go | 51 +- pkg/utils/main_test.go | 2 + pkg/utils/utils.go | 18 +- pkg/utils/utils_test.go | 8 +- .../workflowrun/validating_handler.go | 2 +- 68 files changed, 3786 insertions(+), 3170 deletions(-) create mode 100644 pkg/cue/model/value/error.go create mode 100644 pkg/errors/errors.go create mode 100644 pkg/executor/options.go create mode 100644 pkg/providers/compiler.go delete mode 100644 pkg/providers/kube/handle_test.go create mode 100644 pkg/providers/legacy/email/email.cue rename pkg/providers/{email/send.go => legacy/email/email.go} (51%) rename pkg/providers/{email/send_test.go => legacy/email/email_test.go} (51%) create mode 100644 pkg/providers/legacy/http/http.cue create mode 100644 pkg/providers/legacy/http/http.go rename pkg/providers/{http/do_test.go => legacy/http/http_test.go} (54%) rename pkg/providers/{ => legacy}/http/ratelimiter/ratelimiter.go (100%) rename pkg/providers/{ => legacy}/http/ratelimiter/ratelimiter_test.go (100%) rename pkg/providers/{ => legacy}/http/testdata/certs.go (100%) create mode 100644 pkg/providers/legacy/kube/kube.cue create mode 100644 pkg/providers/legacy/kube/kube.go create mode 100644 pkg/providers/legacy/kube/kube_test.go create mode 100644 pkg/providers/legacy/legacy.go create mode 100644 pkg/providers/legacy/metrics/metrics.cue create mode 100644 pkg/providers/legacy/metrics/prom_check.go rename pkg/providers/{ => legacy}/metrics/prom_check_test.go (65%) create mode 100644 pkg/providers/legacy/util/util.cue create mode 100644 pkg/providers/legacy/util/util.go rename pkg/providers/{ => legacy}/util/util_test.go (62%) create mode 100644 pkg/providers/legacy/workspace/workspace.cue create mode 100644 pkg/providers/legacy/workspace/workspace.go rename pkg/providers/{ => legacy}/workspace/workspace_test.go (56%) delete mode 100644 pkg/providers/providers.go delete mode 100644 pkg/providers/providers_test.go create mode 100644 pkg/providers/types/types.go create mode 100644 pkg/tasks/custom/action.go diff --git a/cmd/main.go b/cmd/main.go index 00685c3..31c7459 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -53,7 +53,6 @@ import ( "github.com/kubevela/workflow/controllers" "github.com/kubevela/workflow/pkg/backup" "github.com/kubevela/workflow/pkg/common" - "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/features" "github.com/kubevela/workflow/pkg/monitor/watcher" "github.com/kubevela/workflow/pkg/types" @@ -222,15 +221,6 @@ func main() { } } - pd, err := packages.NewPackageDiscover(mgr.GetConfig()) - if err != nil { - klog.Error(err, "Failed to create CRD discovery for CUE package client") - if !packages.IsCUEParseErr(err) { - os.Exit(1) - } - } - controllerArgs.PackageDiscover = pd - if useWebhook { klog.InfoS("Enable webhook", "server port", strconv.Itoa(webhookPort)) webhook.Register(mgr, controllerArgs) diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 1113a2a..98aa366 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -33,8 +33,8 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/api/v1alpha1" - "github.com/kubevela/workflow/pkg/cue/packages" //+kubebuilder:scaffold:imports ) @@ -69,9 +69,6 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) Expect(cfg).NotTo(BeNil()) - pd, err := packages.NewPackageDiscover(cfg) - Expect(err).To(BeNil()) - testScheme = scheme.Scheme err = v1alpha1.AddToScheme(testScheme) Expect(err).NotTo(HaveOccurred()) @@ -81,14 +78,12 @@ var _ = BeforeSuite(func() { k8sClient, err = client.New(cfg, client.Options{Scheme: testScheme}) Expect(err).NotTo(HaveOccurred()) Expect(k8sClient).NotTo(BeNil()) + singleton.KubeClient.Set(k8sClient) reconciler = &WorkflowRunReconciler{ Client: k8sClient, Scheme: testScheme, Recorder: event.NewAPIRecorder(recorder), - Args: Args{ - PackageDiscover: pd, - }, } }, 60) diff --git a/controllers/testdata/apply-object.yaml b/controllers/testdata/apply-object.yaml index b2a7aea..e8a095e 100644 --- a/controllers/testdata/apply-object.yaml +++ b/controllers/testdata/apply-object.yaml @@ -6,6 +6,18 @@ metadata: spec: schematic: cue: - template: "import (\n\t\"vela/op\"\n)\n\napply: op.#Apply & {\n\tvalue: parameter.value\n\tcluster: - parameter.cluster\n}\nparameter: {\n\t// +usage=Specify the value of the object\n\tvalue: - {...}\n\t// +usage=Specify the cluster of the object\n\tcluster: *\"\" | string\n}\n" \ No newline at end of file + template: | + import ( + "vela/op" + ) + + apply: op.#Apply & { + value: parameter.value + cluster: parameter.cluster + } + parameter: { + // +usage=Specify the value of the object + value: {...} + // +usage=Specify the cluster of the object + cluster: *"" | string + } \ No newline at end of file diff --git a/controllers/testdata/test-apply.yaml b/controllers/testdata/test-apply.yaml index 0597b1b..c5274b9 100644 --- a/controllers/testdata/test-apply.yaml +++ b/controllers/testdata/test-apply.yaml @@ -6,14 +6,46 @@ metadata: spec: schematic: cue: - template: "import (\t\"vela/op\"\n)\n\noutput: op.#Apply & {\n\tvalue: {\n\t\tapiVersion: - \"apps/v1\"\n\t\tkind: \"Deployment\"\n\t\tmetadata: {\n\t\t\tname: - \ context.stepName\n\t\t\tnamespace: context.namespace\n\t\t}\n\t\tspec: - {\n\t\t\tselector: matchLabels: wr: context.stepName\n\t\t\ttemplate: {\n\t\t\t\tmetadata: - labels: wr: context.stepName\n\t\t\t\tspec: containers: [{\n\t\t\t\t\tname: - \ context.stepName\n\t\t\t\t\timage: parameter.image\n\t\t\t\t\tif parameter[\"cmd\"] - != _|_ {\n\t\t\t\t\t\tcommand: parameter.cmd\n\t\t\t\t\t}\n\t\t\t\t\tif parameter[\"message\"] - != _|_ {\n\t\t\t\t\t\tenv: [{\n\t\t\t\t\t\t\tname: \"MESSAGE\"\n\t\t\t\t\t\t\tvalue: - parameter.message\n\t\t\t\t\t\t}]\n\t\t\t\t\t}\n\t\t\t\t}]\n\t\t\t}\n\t\t}\n\t}\n}\nwait: - op.#ConditionalWait & {\n\tcontinue: output.value.status.readyReplicas == - 1\n}\nparameter: {\n\timage: string\n\tcmd?: [...string]\n\tmessage?: string\n}\n" \ No newline at end of file + template: | + import ( "vela/op" + ) + + output: op.#Apply & { + value: { + apiVersion: "apps/v1" + kind: "Deployment" + metadata: { + name: context.stepName + namespace: context.namespace + } + spec: { + selector: matchLabels: wr: context.stepName + template: { + metadata: labels: wr: context.stepName + spec: containers: [{ + name: context.stepName + image: parameter.image + if parameter["cmd"] != _|_ { + command: parameter.cmd + } + if parameter["message"] != _|_ { + env: [{ + name: "MESSAGE" + value: parameter.message + }] + } + }] + } + } + } + } + wait: op.#ConditionalWait & { + if len(output.value.status) > 0 if output.value.status.readyReplicas == 1 { + continue: true + } + } + parameter: { + image: string + cmd?: [...string] + message?: string + } \ No newline at end of file diff --git a/controllers/workflow_test.go b/controllers/workflow_test.go index 3864362..81db30b 100644 --- a/controllers/workflow_test.go +++ b/controllers/workflow_test.go @@ -789,11 +789,19 @@ var _ = Describe("Test Workflow", func() { checkRun := &v1alpha1.WorkflowRun{} Expect(k8sClient.Get(ctx, wrKey, checkRun)).Should(BeNil()) + for i := 0; i < wfTypes.MaxWorkflowStepErrorRetryTimes; i++ { + tryReconcile(reconciler, wr.Name, wr.Namespace) + Expect(k8sClient.Get(ctx, wrKey, checkRun)).Should(BeNil()) + Expect(checkRun.Status.Message).Should(BeEquivalentTo("")) + Expect(checkRun.Status.Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStateExecuting)) + Expect(checkRun.Status.Steps[0].Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStepPhaseFailed)) + } + tryReconcile(reconciler, wr.Name, wr.Namespace) Expect(k8sClient.Get(ctx, wrKey, checkRun)).Should(BeNil()) Expect(checkRun.Status.Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStateFailed)) Expect(checkRun.Status.Steps[0].Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStepPhaseFailed)) - Expect(checkRun.Status.Steps[0].Reason).Should(BeEquivalentTo(wfTypes.StatusReasonRendering)) + Expect(checkRun.Status.Steps[0].Reason).Should(BeEquivalentTo(wfTypes.StatusReasonFailedAfterRetries)) Expect(checkRun.Status.Steps[1].Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStepPhaseSkipped)) }) diff --git a/controllers/workflowrun_controller.go b/controllers/workflowrun_controller.go index bad0c2e..67c7fea 100644 --- a/controllers/workflowrun_controller.go +++ b/controllers/workflowrun_controller.go @@ -44,11 +44,11 @@ import ( "github.com/kubevela/workflow/api/condition" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/executor" "github.com/kubevela/workflow/pkg/features" "github.com/kubevela/workflow/pkg/generator" "github.com/kubevela/workflow/pkg/monitor/metrics" + providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) @@ -58,8 +58,6 @@ type Args struct { ConcurrentReconciles int // IgnoreWorkflowWithoutControllerRequirement indicates that workflow controller will not process the workflowrun without 'workflowrun.oam.dev/controller-version-require' annotation. IgnoreWorkflowWithoutControllerRequirement bool - // PackageDiscover discover the packages - PackageDiscover *packages.PackageDiscover } // WorkflowRunReconciler reconciles a WorkflowRun object @@ -90,6 +88,10 @@ func (r *WorkflowRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) defer cancel() ctx = types.SetNamespaceInCtx(ctx, req.Namespace) + ctx = providertypes.WithLabelParams(ctx, map[string]string{ + types.LabelWorkflowRunName: req.Name, + types.LabelWorkflowRunNamespace: req.Namespace, + }) logCtx := monitorContext.NewTraceContext(ctx, "").AddTag("workflowrun", req.String()) logCtx.Info("Start reconcile workflowrun") @@ -128,10 +130,7 @@ func (r *WorkflowRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) } isUpdate := instance.Status.Message != "" - runners, err := generator.GenerateRunners(logCtx, instance, types.StepGeneratorOptions{ - PackageDiscover: r.PackageDiscover, - Client: r.Client, - }) + runners, err := generator.GenerateRunners(logCtx, instance, types.StepGeneratorOptions{}) if err != nil { logCtx.Error(err, "[generate runners]") r.Recorder.Event(run, event.Warning(v1alpha1.ReasonGenerate, errors.WithMessage(err, v1alpha1.MessageFailedGenerate))) @@ -143,7 +142,7 @@ func (r *WorkflowRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) Client: r.Client, run: run, } - executor := executor.New(instance, r.Client, patcher.patchStatus) + executor := executor.New(instance, executor.WithStatusPatcher(patcher.patchStatus)) state, err := executor.ExecuteRunners(logCtx, runners) if err != nil { logCtx.Error(err, "[execute runners]") diff --git a/go.mod b/go.mod index 2541ada..ff40d30 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/hashicorp/go-version v1.6.0 github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6 github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d - github.com/oam-dev/kubevela v1.8.0-beta.1.0.20230410031905-d8af20224298 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.27.5 github.com/pkg/errors v0.9.1 @@ -35,63 +34,26 @@ require ( k8s.io/klog/v2 v2.90.0 k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 sigs.k8s.io/controller-runtime v0.14.5 - sigs.k8s.io/kind v0.17.0 sigs.k8s.io/yaml v1.3.0 ) require ( - github.com/AlecAivazis/survey/v2 v2.1.1 // indirect - github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect - github.com/BurntSushi/toml v1.2.1 // indirect - github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver v1.5.0 // indirect - github.com/Masterminds/semver/v3 v3.1.1 // indirect - github.com/Masterminds/sprig v2.22.0+incompatible // indirect - github.com/Microsoft/go-winio v0.6.0 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/agext/levenshtein v1.2.3 // indirect - github.com/alessio/shellescape v1.4.1 // indirect - github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 // indirect github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect - github.com/briandowns/spinner v1.11.1 // indirect - github.com/buger/jsonparser v1.1.1 // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/cloudtty/cloudtty v0.2.0 // indirect github.com/cockroachdb/apd/v2 v2.0.2 // indirect - github.com/containerd/containerd v1.6.18 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/deckarep/golang-set v1.8.0 // indirect - github.com/docker/cli v20.10.20+incompatible // indirect - github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/docker/docker v20.10.24+incompatible // indirect - github.com/docker/docker-credential-helpers v0.7.0 // indirect - github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-metrics v0.0.1 // indirect - github.com/docker/go-units v0.5.0 // indirect github.com/emicklei/go-restful/v3 v3.10.2 // indirect - github.com/emirpasic/gods v1.18.1 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect - github.com/fatih/color v1.13.0 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect - github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect github.com/frankban/quicktest v1.11.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/getkin/kin-openapi v0.94.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect - github.com/go-errors/errors v1.0.1 // indirect - github.com/go-git/gcfg v1.5.0 // indirect - github.com/go-git/go-billy/v5 v5.4.1 // indirect - github.com/go-git/go-git/v5 v5.6.1 // indirect github.com/go-kit/kit v0.10.0 // indirect github.com/go-kit/log v0.2.0 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect @@ -103,91 +65,40 @@ require ( github.com/go-openapi/swag v0.19.15 // indirect github.com/go-stack/stack v1.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/google/btree v1.0.1 // indirect github.com/google/cel-go v0.12.6 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/gorilla/mux v1.8.0 // indirect - github.com/gosuri/uitable v0.0.4 // indirect - github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect + github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/hcl/v2 v2.16.2 // indirect - github.com/huandu/xstrings v1.3.2 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jellydator/ttlcache/v3 v3.0.1 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.16.3 // indirect - github.com/kubevela/prism v1.7.0-alpha.1.0.20230403030519-b7e45f7f842e // indirect - github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/magiconair/properties v1.8.6 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/lib/pq v1.10.7 // indirect github.com/mailru/easyjson v0.7.6 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect - github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/moby/locker v1.0.1 // indirect - github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect - github.com/morikuni/aec v1.0.0 // indirect github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect - github.com/nacos-group/nacos-sdk-go/v2 v2.1.0 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/oam-dev/cluster-gateway v1.9.0-alpha.1 // indirect - github.com/oam-dev/cluster-register v1.0.4-0.20220928064144-5f76a9d7ca8c // indirect - github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 // indirect - github.com/oam-dev/terraform-controller v0.7.10 // indirect - github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc2 // indirect - github.com/openkruise/kruise-api v1.3.0 // indirect - github.com/openkruise/rollouts v0.1.1-0.20220622054609-149e5a48da5e // indirect github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725 // indirect - github.com/pelletier/go-toml v1.9.5 // indirect - github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pierrec/lz4 v2.6.0+incompatible // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect - github.com/rivo/uniseg v0.4.3 // indirect - github.com/sergi/go-diff v1.1.0 // indirect - github.com/sirupsen/logrus v1.9.0 // indirect - github.com/skeema/knownhosts v1.1.0 // indirect github.com/spf13/cobra v1.6.1 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect - github.com/tidwall/gjson v1.14.4 // indirect - github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.0 // indirect - github.com/wercker/stern v0.0.0-20190705090245-4fa46dd6987f // indirect - github.com/wonderflow/cert-manager-api v1.0.4-0.20210304051430-e08aa76f6c5f // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xlab/treeprint v1.2.0 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect go.etcd.io/etcd/api/v3 v3.5.5 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect go.etcd.io/etcd/client/v3 v3.5.5 // indirect - go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 // indirect go.opentelemetry.io/otel v1.10.0 // indirect @@ -198,51 +109,36 @@ require ( go.opentelemetry.io/otel/sdk v1.10.0 // indirect go.opentelemetry.io/otel/trace v1.10.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect - go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/crypto v0.17.0 // indirect - golang.org/x/mod v0.9.0 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/oauth2 v0.6.0 // indirect golang.org/x/sync v0.1.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.7.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect google.golang.org/grpc v1.53.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - helm.sh/helm/v3 v3.10.3 // indirect - istio.io/api v0.0.0-20220512212136-561ffec82582 // indirect - istio.io/client-go v1.13.4 // indirect - istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e // indirect - k8s.io/cli-runtime v0.26.3 // indirect k8s.io/klog v1.0.0 // indirect k8s.io/kms v0.26.3 // indirect - k8s.io/kube-aggregator v0.26.3 // indirect k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect k8s.io/kubectl v0.26.3 // indirect - k8s.io/metrics v0.26.3 // indirect open-cluster-management.io/api v0.10.0 // indirect - oras.land/oras-go v1.2.0 // indirect sigs.k8s.io/apiserver-network-proxy v0.0.30 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36 // indirect sigs.k8s.io/apiserver-runtime v1.1.2-0.20221118041430-0a6394f6dda3 // indirect - sigs.k8s.io/gateway-api v0.4.3 // indirect sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect - sigs.k8s.io/kustomize/api v0.12.1 // indirect - sigs.k8s.io/kustomize/kyaml v0.13.9 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) diff --git a/go.sum b/go.sum index 70b4b3e..901e2f9 100644 --- a/go.sum +++ b/go.sum @@ -10,41 +10,14 @@ cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiy cuelang.org/go v0.5.0 h1:D6N0UgTGJCOxFKU8RU+qYvavKNsVc/+ZobmifStVJzU= cuelang.org/go v0.5.0/go.mod h1:okjJBHFQFer+a41sAe2SaGm1glWS8oEb6CmJvn5Zdws= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/AlecAivazis/survey/v2 v2.1.1 h1:LEMbHE0pLj75faaVEKClEX1TM4AJmmnOh9eimREzLWI= -github.com/AlecAivazis/survey/v2 v2.1.1/go.mod h1:9FJRdMdDm8rnT+zHVbvQT2RTSTLq0Ttd6q3Vl2fahjk= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Azure/go-ansiterm v0.0.0-20210608223527-2377c96fe795/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest v0.11.1/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= -github.com/Azure/go-autorest/autorest v0.11.12/go.mod h1:eipySxLmqSyC5s5k1CLupqet0PSENBEDP93LQ9a8QYw= -github.com/Azure/go-autorest/autorest v0.11.18/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= -github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= -github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= -github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +<<<<<<< HEAD github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= @@ -59,11 +32,12 @@ github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2B github.com/Microsoft/hcsshim v0.9.6 h1:VwnDOgLeoi2du6dAznfmspNqTiwczvjv4K7NxuY9jsY= github.com/Microsoft/hcsshim v0.9.6/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= -github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8 h1:xzYJEypr/85nBpB11F9br+3HUrpgb+fcm5iADzXXYEw= -github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +<<<<<<< HEAD github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -73,57 +47,34 @@ github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdko github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= -github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= -github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= -github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agiledragon/gomonkey/v2 v2.4.0 h1:YDQJYiSQ8o78dCMXehU1E4F/Kh4jPX+MV+/iK/yfL7s= github.com/agiledragon/gomonkey/v2 v2.4.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= -github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= -github.com/ahmetb/gen-crd-api-reference-docs v0.3.0/go.mod h1:TdjdkYhlOifCQWPs1UdTma97kQQMozf5h26hTuG70u8= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= -github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704 h1:PpfENOj/vPfhhy9N2OFRjpue0hjM5XqAp2thFmkXXIk= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= github.com/aliyun/aliyun-log-go-sdk v0.1.38 h1:u20nIZWQnmxOgGdHfMfdmD3h9CaQYANd18Q12pNo1KY= github.com/aliyun/aliyun-log-go-sdk v0.1.38/go.mod h1:1QQ59pEJiVVXqKgbHcU6FWIgxT5RKBt+CT8AiQ2bEts= -github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= -github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10 h1:yL7+Jz0jTC6yykIK/Wh74gnTJnrGr5AyrNMXuA0gves= github.com/antlr/antlr4/runtime/Go/antlr v1.4.10/go.mod h1:F7bn7fEU90QkQ3tnmaTx3LTKLEDqnwWODIYppRQ5hnY= -github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= -github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -131,12 +82,9 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= -github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= +<<<<<<< HEAD github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0= @@ -152,6 +100,8 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0Bsq github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -159,37 +109,27 @@ github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= -github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY/k9Os/UFtwERei2/XzGemhpGnBKNg= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= -github.com/cloudtty/cloudtty v0.2.0 h1:QvDbb2hZl7nSfLDrKkbjIixjkW6seSVBX3N/GRmioyM= -github.com/cloudtty/cloudtty v0.2.0/go.mod h1:RRVb8fLrfpzjsLFqaUk74ouRvZ2drVCvSN3ZzidHju8= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= +<<<<<<< HEAD github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= @@ -204,23 +144,14 @@ github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw= -github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crossplane/crossplane-runtime v0.19.2 h1:9qBnhpqKN4x6apF2siaQ6PvgxqBXbGcKmgeD8mSIDO8= github.com/crossplane/crossplane-runtime v0.19.2/go.mod h1:OJQ1NxtQK2ZTRmvtnQPoy8LsXsARTnVydRVDQEgIuz4= github.com/cue-exp/kubevelafix v0.0.0-20220922150317-aead819d979d h1:VNJA1nSKA8Xna5wjUIMItHlWmEej8Bb9fZ3vCNtIAX0= @@ -228,6 +159,7 @@ github.com/cue-exp/kubevelafix v0.0.0-20220922150317-aead819d979d/go.mod h1:SyTr github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +<<<<<<< HEAD github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -256,23 +188,24 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emicklei/proto v1.10.0 h1:pDGyFRVV5RvV+nkBK9iy3q67FBy9Xa7vwrOTE+g5aGw= +<<<<<<< HEAD github.com/emicklei/proto v1.10.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -280,31 +213,19 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= -github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.11.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= -github.com/fatih/color v0.0.0-20180516100307-2d684516a886/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.10.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= @@ -314,28 +235,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= -github.com/getkin/kin-openapi v0.94.0 h1:bAxg2vxgnHHHoeefVdmGbR+oxtJlcv5HsJJa3qmAHuo= -github.com/getkin/kin-openapi v0.94.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q= -github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= -github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= -github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= -github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= -github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= -github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= -github.com/go-git/go-git-fixtures/v4 v4.3.1 h1:y5z6dd3qi8Hl+stezc8p3JxDkoTRqMAlKnXHuzrfjTQ= -github.com/go-git/go-git-fixtures/v4 v4.3.1/go.mod h1:8LHG1a3SRW71ettAD/jW13h8c6AqjVSeL11RAdgaqpo= -github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= -github.com/go-git/go-git/v5 v5.6.1/go.mod h1:mvyoL6Unz0PiTQrGQfSfiLFhBH1c1e84ylC2MDs4ee8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= @@ -348,104 +248,49 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= -github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= -github.com/go-logr/logr v0.4.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= -github.com/go-logr/zapr v0.4.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk= github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= github.com/go-logr/zapr v1.2.3/go.mod h1:eIauM6P8qSvTw5o2ez6UEAfGjQKrxQTl5EoK+Qa2oG4= -github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= -github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= -github.com/go-openapi/analysis v0.19.2/go.mod h1:3P1osvZa9jKjb8ed2TPng3f0i/UY9snX6gxi44djMjk= -github.com/go-openapi/analysis v0.19.5/go.mod h1:hkEAkxagaIvIP7VTn8ygJNkd4kAYON2rCu0v0ObL0AU= -github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= -github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= -github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= -github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= -github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= -github.com/go-openapi/jsonreference v0.19.5/go.mod h1:RdybgQwPxbL4UEjuAruzK1x3nE69AqPYEJeo/TWfEeg= github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= -github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.19.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= -github.com/go-openapi/loads v0.19.2/go.mod h1:QAskZPMX5V0C2gvfkGZzJlINuP7Hx/4+ix5jWFxsNPs= -github.com/go-openapi/loads v0.19.4/go.mod h1:zZVHonKd8DXyxyw4yfnVjPzBjIQcLt0CCsn0N0ZrQsk= -github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= -github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= -github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= -github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= -github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= -github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= -github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= -github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= -github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= -github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= -github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= -github.com/go-openapi/validate v0.19.5/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +<<<<<<< HEAD github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= -github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -460,18 +305,18 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +<<<<<<< HEAD github.com/gomodule/redigo v1.8.2 h1:H5XSIre1MB5NbPYFp+i1NBbb5qN1W8Y8YAQoAYbkm8k= github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= -github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.12.6 h1:kjeKudqV0OygrAqA9fX6J55S8gj+Jre2tckIm5RoG4M= github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= @@ -489,11 +334,11 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= +<<<<<<< HEAD github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+IrK7d0gGgpjGGvd2kz+FzTHVzdqI= github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= @@ -501,31 +346,25 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaU github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= -github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= -github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= -github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= -github.com/googleapis/gnostic v0.5.5/go.mod h1:7+EbHbldMins07ALC74bsA81Ovc97DwqyJO1AENw9kA= -github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= +<<<<<<< HEAD github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= -github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +<<<<<<< HEAD github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -533,19 +372,16 @@ github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJr github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 h1:BZHcxBETFHIdVyhyEfOvn/RdU/QGdLI4y34qQGjGWO0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -559,7 +395,6 @@ github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iP github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= @@ -567,60 +402,30 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= -github.com/hashicorp/hcl/v2 v2.16.2 h1:mpkHZh/Tv+xet3sy3F9Ld4FyI2tUpWe9x3XtPx9f1a0= -github.com/hashicorp/hcl/v2 v2.16.2/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= -github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ= -github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= -github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jellydator/ttlcache/v3 v3.0.1 h1:cHgCSMS7TdQcoprXnWUptJZzyFsqs18Lt8VVhRuZYVU= github.com/jellydator/ttlcache/v3 v3.0.1/go.mod h1:WwTaEmcXQ3MTjOm4bsZoDFiCu/hMvNWLO1w67RXz6h4= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= -github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -630,21 +435,12 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= -github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= -github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= -github.com/klauspost/compress v1.16.3 h1:XuJt9zzcnaz6a16/OU53ZjWp/v7/42WcR5t2a0PcNQY= -github.com/klauspost/compress v1.16.3/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -652,10 +448,13 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +<<<<<<< HEAD github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -663,13 +462,9 @@ github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6 h1:VIWTjPp github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6/go.mod h1:8cXenu5zACvEHCMt1fnVvPOJkPN+dZQz7n8zaZf4heM= github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d h1:QMmTg33lUZEfTz94eYJKa6Nb7GDcEOmuXsXRt/dA5vk= github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d/go.mod h1:3ZWrl2+zb5ROdC2NJPPrL/4sun4M10wYfRP/9gF9WJE= -github.com/kubevela/prism v1.7.0-alpha.1.0.20230403030519-b7e45f7f842e h1:hc3ctkLfQVERra9IKDoAgMK4iMCY3XpXEJ0TfP9FhSQ= -github.com/kubevela/prism v1.7.0-alpha.1.0.20230403030519-b7e45f7f842e/go.mod h1:bEPKTha7KhDhJAPXYBNAHTMRyqffDvf9UqWZV2BtQtI= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +<<<<<<< HEAD github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= @@ -681,65 +476,37 @@ github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPK github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= -github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v0.0.0-20161203194507-b8bc1bf76747/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= -github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= -github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= -github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +<<<<<<< HEAD github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mmcloughlin/avo v0.5.0/go.mod h1:ChHFdoV7ql95Wi7vuq2YT1bwCJqiWdZrQ1im3VujLYM= @@ -752,6 +519,8 @@ github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXy github.com/moby/term v0.0.0-20210610120745-9d4ed1856297/go.mod h1:vgPCkQMyxTZ7IDy8SXRufE172gr8+K/JE/7hHFxHW3A= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI= github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -759,13 +528,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/2gBQ3RWajuToeY6ZtZTIKv2v7ThUy5KKusIT0yc0= -github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de h1:D5x39vF5KCwKQaw+OC9ZPiLVHXz3UFw2+psEX+gYcto= github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de/go.mod h1:kJun4WP5gFuHZgRjZUWWuH1DTxCtxbHDOIJsudS8jzY= -github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -773,8 +537,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= -github.com/nacos-group/nacos-sdk-go/v2 v2.1.0 h1:PxRwOzHhnK6eGGvioEGkn8s6XRXmUVuXu91i2yQcdDs= -github.com/nacos-group/nacos-sdk-go/v2 v2.1.0/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/t6HVLWdpsNDvmoWTw0g= github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= github.com/nats-io/jwt/v2 v2.0.1/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= github.com/nats-io/nats-server/v2 v2.9.3/go.mod h1:4sq8wvrpbvSzL1n3ZfEYnH4qeUuIl5W990j3kw13rRk= @@ -789,98 +551,60 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oam-dev/cluster-gateway v1.9.0-alpha.1 h1:1V9nm8XO4ZqJK6rkJ7c1kglQN8biQtrFiHaJnAtjjLE= github.com/oam-dev/cluster-gateway v1.9.0-alpha.1/go.mod h1:g8ivuGBu1MwtvM0AKGc81TvsLvEsosoUXENhbBFJgtc= -github.com/oam-dev/cluster-register v1.0.4-0.20220928064144-5f76a9d7ca8c h1:RE/33gzs9hoyegcTaUXDG/hayffJ197ljMUGNP6I/5A= -github.com/oam-dev/cluster-register v1.0.4-0.20220928064144-5f76a9d7ca8c/go.mod h1:nKEUMfuEB8pHKsaSah9IA+UQzezrPYebBdRozyNtlZc= -github.com/oam-dev/kubevela v1.8.0-beta.1.0.20230410031905-d8af20224298 h1:qROU6CUoe3RdsVNNTZwD1iDEBvRSMq5sqNk4bdz8e58= -github.com/oam-dev/kubevela v1.8.0-beta.1.0.20230410031905-d8af20224298/go.mod h1:yK22fw0YwPBYvXFiChZVDNMXdvUGViG2JpIvdNbVLEM= -github.com/oam-dev/stern v1.13.2 h1:jlGgtJbKmIVhzkH44ft5plkgs8XEfvxbFrQdX60CQR4= -github.com/oam-dev/stern v1.13.2/go.mod h1:0pLjZt0amXE/ErF16Rdrgd98H2owN8Hmn3/7CX5+AeA= -github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28 h1:tD8HiFKnt0jnwdTWjeqUnfnUYLD/+Nsmj8ZGIxqDWiU= -github.com/oam-dev/terraform-config-inspect v0.0.0-20210418082552-fc72d929aa28/go.mod h1:Mu8i0/DdplvnjwRbAYPsc8+LRR27n/mp8VWdkN10GzE= -github.com/oam-dev/terraform-controller v0.7.10 h1:e2STz6Od53S4Ra4+QQs65lujF50vIb6eQtTMuvvofjk= -github.com/oam-dev/terraform-controller v0.7.10/go.mod h1:xvgChKG0pij0WEKRrX7w30SdVBPVOlRl/+Mv7+2C1cI= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= +<<<<<<< HEAD github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= -github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= -github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.27.5 h1:T/X6I0RNFw/kTqgfkZPcQ5KU6vCnWNBGdtrIx2dpGeQ= github.com/onsi/gomega v1.27.5/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc2 h1:2zx/Stx4Wc5pIPDvIxHXvXtQFW/7XWJGmnM7r3wg034= -github.com/opencontainers/image-spec v1.1.0-rc2/go.mod h1:3OVijpioIKYWTqjiG0zfF6wvoJ4fAXGbjdZuI2NgsRQ= -github.com/openkruise/kruise-api v1.0.0/go.mod h1:kxV/UA/vrf/hz3z+kL21c0NOawC6K1ZjaKcJFgiOwsE= -github.com/openkruise/kruise-api v1.3.0 h1:yfEy64uXgSuX/5RwePLbwUK/uX8RRM8fHJkccel5ZIQ= -github.com/openkruise/kruise-api v1.3.0/go.mod h1:9ZX+ycdHKNzcA5ezAf35xOa2Mwfa2BYagWr0lKgi5dU= -github.com/openkruise/rollouts v0.1.1-0.20220622054609-149e5a48da5e h1:jUMEDsA0OOpp0262pK8MV8M2glac+jIjx+q5Aydn6G0= -github.com/openkruise/rollouts v0.1.1-0.20220622054609-149e5a48da5e/go.mod h1:SORsT96ssCqMJYSVA90v6Z52utlV2jxPlyGh4czRfHA= -github.com/openshift/build-machinery-go v0.0.0-20210115170933-e575b44a7a94/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725 h1:GC0oekPo2BDqK+2Mv6W/VuvkaUUMFcmqp0AZDN2vWrA= github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725/go.mod h1:OspkL5FZZapzNcka6UkNMFD7ifLT/dWUNvtwErpRK9k= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= -github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= +<<<<<<< HEAD github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -889,10 +613,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= @@ -901,79 +622,43 @@ github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+ github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/protocolbuffers/txtpbfmt v0.0.0-20220428173112-74888fd59c2b h1:zd/2RNzIRkoGGMjE+YIsZ85CnDIz672JK2F3Zl4vux4= github.com/protocolbuffers/txtpbfmt v0.0.0-20220428173112-74888fd59c2b/go.mod h1:KjY0wibdYKc4DYkerHSbguaf3JeIPGhNJBp2BNiFH78= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= -github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +<<<<<<< HEAD github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= -github.com/skeema/knownhosts v1.1.0/go.mod h1:sKFq3RD6/TKZkSWn8boUbDC7Qkgcv+8XXijpFO6roag= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= -github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.0-20180629152535-a114f312e075/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= -github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -981,11 +666,8 @@ github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1Sd github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -994,38 +676,15 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= -github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= -github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= -github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/wonderflow/cert-manager-api v1.0.4-0.20210304051430-e08aa76f6c5f h1:DAWUgvjpY7r474gC2ZWkWCJaaJLnTq1r1kF9KGckJV0= -github.com/wonderflow/cert-manager-api v1.0.4-0.20210304051430-e08aa76f6c5f/go.mod h1:1Se7MSg11/eNYlo4fWv6vOM55/jTBMOzg2DN1kVFiSc= -github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= -github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= -github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +<<<<<<< HEAD github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI= github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= @@ -1039,11 +698,10 @@ github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeW go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= -go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489 h1:1JFLBqwIgdyHN1ZtgjTBwO+blA6gVOmZurpiMEsETKo= -go.etcd.io/etcd v0.5.0-alpha.5.0.20200910180754-dd1b699fc489/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= +go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c h1:/RwRVN9EdXAVtdHxP7Ndn/tfmM9/goiwU0QTnLBgS4w= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.5 h1:BX4JIbQ7hl7+jL+g+2j5UAr0o1bctCm6/Ct+ArBGkf0= go.etcd.io/etcd/api/v3 v3.5.5/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8= @@ -1056,8 +714,8 @@ go.etcd.io/etcd/client/v2 v2.305.5/go.mod h1:zQjKllfqfBVyVStbt4FaosoX2iYd8fV/GRy go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.etcd.io/etcd/client/v3 v3.5.5 h1:q++2WTJbUgpQu4B6hCuT7VkdwaTP7Qz6Daak3WzbrlI= go.etcd.io/etcd/client/v3 v3.5.5/go.mod h1:aApjR4WGlSumpnJ2kloS75h6aHUmAyaPLjHMxpc7E7c= -go.etcd.io/etcd/pkg/v3 v3.5.0/go.mod h1:UzJGatBQ1lXChBkQF0AuAtkRQMYnHubxAEYIrC3MSsE= go.etcd.io/etcd/pkg/v3 v3.5.5 h1:Ablg7T7OkR+AeeeU32kdVhw/AGDsitkKPl7aW73ssjU= +<<<<<<< HEAD go.etcd.io/etcd/pkg/v3 v3.5.5/go.mod h1:6ksYFxttiUGzC2uxyqiyOEvhAiD0tuIqSZkX3TyPdaE= go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc= go.etcd.io/etcd/raft/v3 v3.5.5 h1:Ibz6XyZ60OYyRopu73lLM/P+qco3YtlZMOhnXNS051I= @@ -1069,45 +727,32 @@ go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qL go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +======= +go.etcd.io/etcd/raft/v3 v3.5.5 h1:Ibz6XyZ60OYyRopu73lLM/P+qco3YtlZMOhnXNS051I= +go.etcd.io/etcd/server/v3 v3.5.5 h1:jNjYm/9s+f9A9r6+SC4RvNaz6AqixpOvhrFdT0PvIj0= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib v0.20.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc= -go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.20.0/go.mod h1:oVGt1LRbBOBq1A5BQLlUg9UaU/54aiHw8cgjV3aWZ/E= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 h1:xFSRQBbXF6VvYRf2lqMJXxoB72XI1K/azav8TekHHSw= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0/go.mod h1:h8TWwRAhQpOd0aM5nYsRD8+flnkj+526GEIVlarH7eY= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.20.0/go.mod h1:2AboqHi0CiIZU0qwhtUfCYD1GeUzvvIXWNkhDt7ZMG4= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0 h1:Ajldaqhxqw/gNzQA45IKFWLdG7jZuXX/wBW1d5qvbUI= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.35.0/go.mod h1:9NiG9I2aHTKkcxqCILhjtyNA1QEiCjdBACv4IvrFQ+c= -go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= go.opentelemetry.io/otel v1.10.0 h1:Y7DTJMR6zs1xkS/upamJYk0SxxN4C9AqRd77jmZnyY4= go.opentelemetry.io/otel v1.10.0/go.mod h1:NbvWjCthWHKBEUMpf0/v8ZRZlni86PpGFEMA9pnQSnQ= -go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 h1:TaB+1rQhddO1sF71MpZOZAuSPW1klK2M8XxfrBMfK7Y= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0/go.mod h1:78XhIg8Ht9vR4tbLNUhXsiOnE2HOuSeKAiAcoVQEpOY= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0 h1:pDDYmo0QadUPal5fwXoY1pmMpFcdyhXOmL5drCrI3vU= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0/go.mod h1:Krqnjl22jUJ0HgMzw5eveuCvFDXY4nSYb4F8t5gdrag= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0 h1:KtiUEhQmj/Pa874bVYKGNVdq8NPKiacPbaRRtgXi+t4= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0/go.mod h1:OfUCyyIiDvNXHWpcWgbF+MWvqPZiNa3YDEnivcnYsV0= -go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= -go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= -go.opentelemetry.io/otel/sdk v0.20.0/go.mod h1:g/IcepuwNsoiX5Byy2nNV0ySUF1em498m7hBWC279Yc= go.opentelemetry.io/otel/sdk v1.10.0 h1:jZ6K7sVn04kk/3DNUdJ4mqRlGDiXAVuIG+MMENpTNdY= go.opentelemetry.io/otel/sdk v1.10.0/go.mod h1:vO06iKzD5baltJz1zarxMCNHFpUlUiOy4s65ECtn6kE= -go.opentelemetry.io/otel/sdk/export/metric v0.20.0/go.mod h1:h7RBNMsDJ5pmI1zExLi+bJK+Dr8NQCh0qGhm1KDnNlE= -go.opentelemetry.io/otel/sdk/metric v0.20.0/go.mod h1:knxiS8Xd4E/N+ZqKmUPf3gTTZ4/0TjTXukfxjzSTpHE= -go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/otel/trace v1.10.0 h1:npQMbR8o7mum8uF95yFbOEJffhs1sbCOfDh8zAJiH5E= go.opentelemetry.io/otel/trace v1.10.0/go.mod h1:Sij3YYczqAdz+EhmGhE6TpTxUO5/F/AzrK+kxfGqySM= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc= -go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -1115,53 +760,31 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66vU6XU= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +<<<<<<< HEAD go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +======= +>>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/arch v0.1.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220826181053-bd7e27e6170d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1176,80 +799,49 @@ golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+o golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210825183410-e898025ed96a/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= @@ -1260,206 +852,122 @@ golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190530182044-ad28b68e88f1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210817190340-bfb29a6856f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220825204002-c680a09ffe64/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= -golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.0.1/go.mod h1:IhYNNY4jnS53ZnfE4PAmpKtDpTCj1JFXc+3mwe7XcUU= gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= @@ -1472,20 +980,13 @@ google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= @@ -1494,7 +995,6 @@ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1520,30 +1020,19 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1559,149 +1048,34 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= -gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= -gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= -helm.sh/helm/v3 v3.10.3 h1:wL7IUZ7Zyukm5Kz0OUmIFZgKHuAgByCrUcJBtY0kDyw= -helm.sh/helm/v3 v3.10.3/go.mod h1:CXOcs02AYvrlPMWARNYNRgf2rNP7gLJQsi/Ubd4EDrI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -istio.io/api v0.0.0-20220512212136-561ffec82582 h1:AzLIET6ePAqxlWaXA6GOzapoRX1GRC6mZ8GY+cQIWYU= -istio.io/api v0.0.0-20220512212136-561ffec82582/go.mod h1:8ZZgyVgYrHhsFQarEgTfPnMGpdgTDZbxSjYhdwTUuAQ= -istio.io/client-go v1.13.4 h1:QJBFBkOaplyL/uBL7xo75mdE5G0i1uR6BR0u9/Wuo1E= -istio.io/client-go v1.13.4/go.mod h1:kM3WH/HCojq7BhCD894SZuaAXUKMswT+VQRaEEhTGj0= -istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e h1:z2WI3y55w0K3c6hmarcp5EcOiP4vVpTBXA8nYstP+cE= -istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e/go.mod h1:vJDAniIqryf/z///fgZqVPKJ7N2lBk7Gg8DCTB7oCfU= -k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= -k8s.io/api v0.18.6/go.mod h1:eeyxr+cwCjMdLAmr2W3RyDI0VvTawSg/3RFFBEnmZGI= -k8s.io/api v0.20.10/go.mod h1:0kei3F6biGjtRQBo5dUeujq6Ji3UCh9aOSfp/THYd7I= -k8s.io/api v0.21.1/go.mod h1:FstGROTmsSHBarKc8bylzXih8BLNYTiS3TZcsoEDg2s= -k8s.io/api v0.21.2/go.mod h1:Lv6UGJZ1rlMI1qusN8ruAp9PUBFyBwpEHAdG24vIsiU= -k8s.io/api v0.21.3/go.mod h1:hUgeYHUbBp23Ue4qdX9tR8/ANi/g3ehylAqDn9NWVOg= -k8s.io/api v0.22.1/go.mod h1:bh13rkTp3F1XEaLGykbyRD2QaTTzPm0e/BMd8ptFONY= -k8s.io/api v0.22.2/go.mod h1:y3ydYpLJAaDI+BbSe2xmGcqxiWHmWjkEeIbiwHvnPR8= -k8s.io/api v0.22.6/go.mod h1:q1F7IfaNrbi/83ebLy3YFQYLjPSNyunZ/IXQxMmbwCg= -k8s.io/api v0.23.0/go.mod h1:8wmDdLBHBNxtOIytwLstXt5E9PddnZb0GaMcqsvDBpg= -k8s.io/api v0.23.1/go.mod h1:WfXnOnwSqNtG62Y1CdjoMxh7r7u9QXGCkA1u0na2jgo= k8s.io/api v0.26.3 h1:emf74GIQMTik01Aum9dPP0gAypL8JTLl/lHa4V9RFSU= k8s.io/api v0.26.3/go.mod h1:PXsqwPMXBSBcL1lJ9CYDKy7kIReUydukS5JiRlxC3qE= -k8s.io/apiextensions-apiserver v0.18.2/go.mod h1:q3faSnRGmYimiocj6cHQ1I3WpLqmDgJFlKL37fC4ZvY= -k8s.io/apiextensions-apiserver v0.18.6/go.mod h1:lv89S7fUysXjLZO7ke783xOwVTm6lKizADfvUM/SS/M= -k8s.io/apiextensions-apiserver v0.21.2/go.mod h1:+Axoz5/l3AYpGLlhJDfcVQzCerVYq3K3CvDMvw6X1RA= -k8s.io/apiextensions-apiserver v0.21.3/go.mod h1:kl6dap3Gd45+21Jnh6utCx8Z2xxLm8LGDkprcd+KbsE= -k8s.io/apiextensions-apiserver v0.22.2/go.mod h1:2E0Ve/isxNl7tWLSUDgi6+cmwHi5fQRdwGVCxbC+KFA= -k8s.io/apiextensions-apiserver v0.22.6/go.mod h1:wNsLwy8mfIkGThiv4Qq/Hy4qRazViKXqmH5pfYiRKyY= k8s.io/apiextensions-apiserver v0.26.3 h1:5PGMm3oEzdB1W/FTMgGIDmm100vn7IaUP5er36dB+YE= k8s.io/apiextensions-apiserver v0.26.3/go.mod h1:jdA5MdjNWGP+njw1EKMZc64xAT5fIhN6VJrElV3sfpQ= -k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= -k8s.io/apimachinery v0.18.6/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko= -k8s.io/apimachinery v0.20.10/go.mod h1:kQa//VOAwyVwJ2+L9kOREbsnryfsGSkSM1przND4+mw= -k8s.io/apimachinery v0.21.1/go.mod h1:jbreFvJo3ov9rj7eWT7+sYiRx+qZuCYXwWT1bcDswPY= -k8s.io/apimachinery v0.21.2/go.mod h1:CdTY8fU/BlvAbJ2z/8kBwimGki5Zp8/fbVuLY8gJumM= -k8s.io/apimachinery v0.21.3/go.mod h1:H/IM+5vH9kZRNJ4l3x/fXP/5bOPJaVP/guptnZPeCFI= -k8s.io/apimachinery v0.22.1/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= -k8s.io/apimachinery v0.22.2/go.mod h1:O3oNtNadZdeOMxHFVxOreoznohCpy0z6mocxbZr7oJ0= -k8s.io/apimachinery v0.22.6/go.mod h1:ZvVLP5iLhwVFg2Yx9Gh5W0um0DUauExbRhe+2Z8I1EU= -k8s.io/apimachinery v0.23.0/go.mod h1:fFCTTBKvKcwTPFzjlcxp91uPFZr+JA0FubU4fLzzFYc= -k8s.io/apimachinery v0.23.1/go.mod h1:SADt2Kl8/sttJ62RRsi9MIV4o8f5S3coArm0Iu3fBno= k8s.io/apimachinery v0.26.3 h1:dQx6PNETJ7nODU3XPtrwkfuubs6w7sX0M8n61zHIV/k= k8s.io/apimachinery v0.26.3/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= -k8s.io/apiserver v0.18.2/go.mod h1:Xbh066NqrZO8cbsoenCwyDJ1OSi8Ag8I2lezeHxzwzw= -k8s.io/apiserver v0.18.6/go.mod h1:Zt2XvTHuaZjBz6EFYzpp+X4hTmgWGy8AthNVnTdm3Wg= -k8s.io/apiserver v0.21.2/go.mod h1:lN4yBoGyiNT7SC1dmNk0ue6a5Wi6O3SWOIw91TsucQw= -k8s.io/apiserver v0.21.3/go.mod h1:eDPWlZG6/cCCMj/JBcEpDoK+I+6i3r9GsChYBHSbAzU= -k8s.io/apiserver v0.22.2/go.mod h1:vrpMmbyjWrgdyOvZTSpsusQq5iigKNWv9o9KlDAbBHI= -k8s.io/apiserver v0.22.6/go.mod h1:OlL1rGa2kKWGj2JEXnwBcul/BwC9Twe95gm4ohtiIIs= k8s.io/apiserver v0.26.3 h1:blBpv+yOiozkPH2aqClhJmJY+rp53Tgfac4SKPDJnU4= k8s.io/apiserver v0.26.3/go.mod h1:CJe/VoQNcXdhm67EvaVjYXxR3QyfwpceKPuPaeLibTA= -k8s.io/cli-runtime v0.26.3 h1:3ULe0oI28xmgeLMVXIstB+ZL5CTGvWSMVMLeHxitIuc= -k8s.io/cli-runtime v0.26.3/go.mod h1:5YEhXLV4kLt/OSy9yQwtSSNZU2Z7aTEYta1A+Jg4VC4= -k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= -k8s.io/client-go v0.18.6/go.mod h1:/fwtGLjYMS1MaM5oi+eXhKwG+1UHidUEXRh6cNsdO0Q= -k8s.io/client-go v0.20.10/go.mod h1:fFg+aLoasv/R+xiVaWjxeqGFYltzgQcOQzkFaSRfnJ0= -k8s.io/client-go v0.21.1/go.mod h1:/kEw4RgW+3xnBGzvp9IWxKSNA+lXn3A7AuH3gdOAzLs= -k8s.io/client-go v0.21.2/go.mod h1:HdJ9iknWpbl3vMGtib6T2PyI/VYxiZfq936WNVHBRrA= -k8s.io/client-go v0.21.3/go.mod h1:+VPhCgTsaFmGILxR/7E1N0S+ryO010QBeNCv5JwRGYU= -k8s.io/client-go v0.22.1/go.mod h1:BquC5A4UOo4qVDUtoc04/+Nxp1MeHcVc1HJm1KmG8kk= -k8s.io/client-go v0.22.2/go.mod h1:sAlhrkVDf50ZHx6z4K0S40wISNTarf1r800F+RlCF6U= -k8s.io/client-go v0.22.6/go.mod h1:TffU4AV2idZGeP+g3kdFZP+oHVHWPL1JYFySOALriw0= -k8s.io/client-go v0.23.1/go.mod h1:6QSI8fEuqD4zgFK0xbdwfB/PthBsIxCJMa3s17WlcO0= k8s.io/client-go v0.26.3 h1:k1UY+KXfkxV2ScEL3gilKcF7761xkYsSD6BC9szIu8s= k8s.io/client-go v0.26.3/go.mod h1:ZPNu9lm8/dbRIPAgteN30RSXea6vrCpFvq+MateTUuQ= -k8s.io/code-generator v0.18.2/go.mod h1:+UHX5rSbxmR8kzS+FAv7um6dtYrZokQvjHpDSYRVkTc= -k8s.io/code-generator v0.18.6/go.mod h1:TgNEVx9hCyPGpdtCWA34olQYLkh3ok9ar7XfSsr8b6c= -k8s.io/code-generator v0.20.0/go.mod h1:UsqdF+VX4PU2g46NC2JRs4gc+IfrctnwHb76RNbWHJg= -k8s.io/code-generator v0.20.10/go.mod h1:i6FmG+QxaLxvJsezvZp0q/gAEzzOz3U53KFibghWToU= -k8s.io/code-generator v0.21.2/go.mod h1:8mXJDCB7HcRo1xiEQstcguZkbxZaqeUOrO9SsicWs3U= -k8s.io/code-generator v0.21.3/go.mod h1:K3y0Bv9Cz2cOW2vXUrNZlFbflhuPvuadW6JdnN6gGKo= -k8s.io/code-generator v0.22.0/go.mod h1:eV77Y09IopzeXOJzndrDyCI88UBok2h6WxAlBwpxa+o= -k8s.io/code-generator v0.22.2/go.mod h1:eV77Y09IopzeXOJzndrDyCI88UBok2h6WxAlBwpxa+o= -k8s.io/code-generator v0.22.6/go.mod h1:iOZwYADSgFPNGWfqHFfg1V0TNJnl1t0WyZluQp4baqU= -k8s.io/component-base v0.18.2/go.mod h1:kqLlMuhJNHQ9lz8Z7V5bxUUtjFZnrypArGl58gmDfUM= -k8s.io/component-base v0.18.6/go.mod h1:knSVsibPR5K6EW2XOjEHik6sdU5nCvKMrzMt2D4In14= -k8s.io/component-base v0.21.2/go.mod h1:9lvmIThzdlrJj5Hp8Z/TOgIkdfsNARQ1pT+3PByuiuc= -k8s.io/component-base v0.21.3/go.mod h1:kkuhtfEHeZM6LkX0saqSK8PbdO7A0HigUngmhhrwfGQ= -k8s.io/component-base v0.22.2/go.mod h1:5Br2QhI9OTe79p+TzPe9JKNQYvEKbq9rTJDWllunGug= -k8s.io/component-base v0.22.6/go.mod h1:ngHLefY4J5fq2fApNdbWyj4yh0lvw36do4aAjNN8rc8= k8s.io/component-base v0.26.3 h1:oC0WMK/ggcbGDTkdcqefI4wIZRYdK3JySx9/HADpV0g= k8s.io/component-base v0.26.3/go.mod h1:5kj1kZYwSC6ZstHJN7oHBqcJC6yyn41eR+Sqa/mQc8E= -k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20200114144118-36b2048a9120/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/gengo v0.0.0-20201113003025-83324d819ded/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/gengo v0.0.0-20201203183100-97869a43a9d9/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= -k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.2.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= -k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= -k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/klog/v2 v2.10.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= -k8s.io/klog/v2 v2.30.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/klog/v2 v2.90.0 h1:VkTxIV/FjRXn1fgNNcKGM8cfmL1Z33ZjXRTVxKCoF5M= k8s.io/klog/v2 v2.90.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kms v0.26.3 h1:+rC4BMeMBkH5hrfZt9WFMRrs2m3vY2rXymisNactcTY= k8s.io/kms v0.26.3/go.mod h1:69qGnf1NsFOQP07fBYqNLZklqEHSJF024JqYCaeVxHg= -k8s.io/kube-aggregator v0.26.3 h1:nc4H5ymGkWPU3c9U9UM468JcmNENY/s/mDYVW3t3uRo= -k8s.io/kube-aggregator v0.26.3/go.mod h1:SgBESB/+PfZAyceTPIanfQ7GtX9G/+mjfUbTHg3Twbo= -k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= -k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= -k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAGcJo0Tvi+dK12EcqSLqcWsryKMpfM= -k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= -k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw= -k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/kubectl v0.26.3 h1:bZ5SgFyeEXw6XTc1Qji0iNdtqAC76lmeIIQULg2wNXM= k8s.io/kubectl v0.26.3/go.mod h1:02+gv7Qn4dupzN3fi/9OvqqdW+uG/4Zi56vc4Zmsp1g= -k8s.io/metrics v0.26.3 h1:pHI8XtmBbGGdh7bL0s2C3v93fJfxyktHPAFsnRYnDTo= -k8s.io/metrics v0.26.3/go.mod h1:NNnWARAAz+ZJTs75Z66fJTV7jHcVb3GtrlDszSIr3fE= -k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= -k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210527160623-6fdb442a123b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -open-cluster-management.io/api v0.0.0-20210610125115-f57c747b84aa/go.mod h1:9qiA5h/8kvPQnJEOlAPHVjRO9a1jCmDhGzvgMBvXEaE= open-cluster-management.io/api v0.10.0 h1:B6/nwKO7cXDuKV5uJLjF/JUuPuiKsep08gfmAAWaKKc= open-cluster-management.io/api v0.10.0/go.mod h1:6BB/Y6r3hXlPjpJgDwIs6Ubxyx/kXXOg6D9Cntg1I9E= -oras.land/oras-go v1.2.0 h1:yoKosVIbsPoFMqAIFHTnrmOuafHal+J/r+I5bdbVWu4= -oras.land/oras-go v1.2.0/go.mod h1:pFNs7oHp2dYsYMSS82HaX5l4mpnGO7hbpPN6EWH2ltc= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= sigs.k8s.io/apiserver-network-proxy v0.0.30 h1:Zr5Zqd2GymcYUwijHUDEaQ1I3Dx0giTIWaD80N6j2mE= sigs.k8s.io/apiserver-network-proxy v0.0.30/go.mod h1:0wSWl5ohhp7kYl5XOP0w1IZSWTHhe9TojjDGityZxnc= @@ -1709,33 +1083,12 @@ sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36 h1:PUuX1qIFv309A sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.36/go.mod h1:WxjusMwXlKzfAs4p9km6XJRndVt2FROgMVCE4cdohFo= sigs.k8s.io/apiserver-runtime v1.1.2-0.20221118041430-0a6394f6dda3 h1:dyxGc8BvxTtTdDEHKRqm6fbV+FIv/i4Bb0xM8fm1SAo= sigs.k8s.io/apiserver-runtime v1.1.2-0.20221118041430-0a6394f6dda3/go.mod h1:HxSglExoUMNBtAqXUsvSLpMXPZglrY+iJ8UPsuQ2fas= -sigs.k8s.io/controller-runtime v0.6.0/go.mod h1:CpYf5pdNY/B352A1TFLAS2JVSlnGQ5O2cftPHndTroo= -sigs.k8s.io/controller-runtime v0.9.2/go.mod h1:TxzMCHyEUpaeuOiZx/bIdc2T81vfs/aKdvJt9wuu0zk= -sigs.k8s.io/controller-runtime v0.9.6/go.mod h1:q6PpkM5vqQubEKUKOM6qr06oXGzOBcCby1DA9FbyZeA= -sigs.k8s.io/controller-runtime v0.10.3/go.mod h1:CQp8eyUQZ/Q7PJvnIrB6/hgfTC1kBkGylwsLgOQi1WY= sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= -sigs.k8s.io/controller-tools v0.6.2/go.mod h1:oaeGpjXn6+ZSEIQkUe/+3I40PNiDYp9aeawbt3xTgJ8= -sigs.k8s.io/gateway-api v0.4.3 h1:9kdHAcfkyP7jVMSFshc8EYEKNLlFM7hbZL8vCKcMwps= -sigs.k8s.io/gateway-api v0.4.3/go.mod h1:r3eiNP+0el+NTLwaTfOrCNXy8TukC+dIM3ggc+fbNWk= -sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6/go.mod h1:p4QtZmO4uMYipTQNzagwnNoseA6OxSUutVw05NhYDRs= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kind v0.17.0 h1:CScmGz/wX66puA06Gj8OZb76Wmk7JIjgWf5JDvY7msM= -sigs.k8s.io/kind v0.17.0/go.mod h1:Qqp8AiwOlMZmJWs37Hgs31xcbiYXjtXlRBSftcnZXQk= -sigs.k8s.io/kustomize/api v0.12.1 h1:7YM7gW3kYBwtKvoY216ZzY+8hM+lV53LUayghNRJ0vM= -sigs.k8s.io/kustomize/api v0.12.1/go.mod h1:y3JUhimkZkR6sbLNwfJHxvo1TCLwuwm14sCYnkH6S1s= -sigs.k8s.io/kustomize/kyaml v0.13.9 h1:Qz53EAaFFANyNgyOEJbT/yoIHygK40/ZcvU3rgry2Tk= -sigs.k8s.io/kustomize/kyaml v0.13.9/go.mod h1:QsRbD0/KcU+wdk0/L0fIp2KLnohkVzs6fQ85/nOXac4= -sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= -sigs.k8s.io/structured-merge-diff/v3 v3.0.0/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= -sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.0/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= -sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= -sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/pkg/context/context.go b/pkg/context/context.go index 33c4684..3bb8938 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -24,6 +24,8 @@ import ( "sync" "time" + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" "github.com/pkg/errors" corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -31,7 +33,11 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/kubevela/pkg/cue/cuex" + "github.com/kubevela/pkg/cue/util" "github.com/kubevela/pkg/util/rand" + "github.com/kubevela/pkg/util/singleton" + "github.com/kubevela/workflow/pkg/cue/model/sets" "github.com/kubevela/workflow/pkg/cue/model/value" ) @@ -48,28 +54,34 @@ var ( // WorkflowContext is workflow context. type WorkflowContext struct { - cli client.Client store *corev1.ConfigMap memoryStore *sync.Map - vars *value.Value + vars cue.Value modified bool } // GetVar get variable from workflow context. -func (wf *WorkflowContext) GetVar(paths ...string) (*value.Value, error) { - return wf.vars.LookupValue(paths...) +func (wf *WorkflowContext) GetVar(paths ...string) (cue.Value, error) { + v := wf.vars.LookupPath(value.FieldPath(paths...)) + if !v.Exists() { + return v, fmt.Errorf("var %s not found", strings.Join(paths, ".")) + } + return v, nil } // SetVar set variable to workflow context. -func (wf *WorkflowContext) SetVar(v *value.Value, paths ...string) error { - str, err := v.String() +func (wf *WorkflowContext) SetVar(v cue.Value, paths ...string) error { + // convert value to string to set + str, err := sets.ToString(v) if err != nil { - return errors.WithMessage(err, "compile var") + return err } - if err := wf.vars.FillRaw(str, paths...); err != nil { + + wf.vars, err = value.FillRaw(wf.vars, str, paths...) + if err != nil { return err } - if err := wf.vars.Error(); err != nil { + if err := wf.vars.Err(); err != nil { return err } wf.modified = true @@ -134,31 +146,22 @@ func (wf *WorkflowContext) DeleteValueInMemory(paths ...string) { wf.memoryStore.Delete(strings.Join(paths, ".")) } -// MakeParameter make 'value' with string -func (wf *WorkflowContext) MakeParameter(parameter string) (*value.Value, error) { - if parameter == "" { - parameter = "{}" - } - - return wf.vars.MakeValue(parameter) -} - // Commit the workflow context and persist it's content. -func (wf *WorkflowContext) Commit() error { +func (wf *WorkflowContext) Commit(ctx context.Context) error { if !wf.modified { return nil } if err := wf.writeToStore(); err != nil { return err } - if err := wf.sync(); err != nil { + if err := wf.sync(ctx); err != nil { return errors.WithMessagef(err, "save context to configMap(%s/%s)", wf.store.Namespace, wf.store.Name) } return nil } func (wf *WorkflowContext) writeToStore() error { - varStr, err := wf.vars.String() + varStr, err := util.ToString(wf.vars) if err != nil { return err } @@ -171,32 +174,32 @@ func (wf *WorkflowContext) writeToStore() error { return nil } -func (wf *WorkflowContext) sync() error { - ctx := context.Background() +func (wf *WorkflowContext) sync(ctx context.Context) error { + cli := singleton.KubeClient.Get() store := &corev1.ConfigMap{} if EnableInMemoryContext { MemStore.UpdateInMemoryContext(wf.store) - } else if err := wf.cli.Get(ctx, types.NamespacedName{ + } else if err := cli.Get(ctx, types.NamespacedName{ Name: wf.store.Name, Namespace: wf.store.Namespace, }, store); err != nil { if kerrors.IsNotFound(err) { - return wf.cli.Create(ctx, wf.store) + return cli.Create(ctx, wf.store) } return err } - return wf.cli.Patch(ctx, wf.store, client.MergeFrom(store.DeepCopy())) + return cli.Patch(ctx, wf.store, client.MergeFrom(store.DeepCopy())) } // LoadFromConfigMap recover workflow context from configMap. -func (wf *WorkflowContext) LoadFromConfigMap(cm corev1.ConfigMap) error { +func (wf *WorkflowContext) LoadFromConfigMap(ctx context.Context, cm corev1.ConfigMap) error { if wf.store == nil { wf.store = &cm } data := cm.Data var err error - wf.vars, err = value.NewValue(data[ConfigMapKeyVars], nil, "") + wf.vars, err = cuex.DefaultCompiler.Get().CompileString(ctx, data[ConfigMapKeyVars]) if err != nil { return errors.WithMessage(err, "decode vars") } @@ -215,8 +218,8 @@ func (wf *WorkflowContext) StoreRef() *corev1.ObjectReference { } // NewContext new workflow context without initialize data. -func NewContext(ctx context.Context, cli client.Client, ns, name string, owner []metav1.OwnerReference) (Context, error) { - wfCtx, err := newContext(ctx, cli, ns, name, owner) +func NewContext(ctx context.Context, ns, name string, owner []metav1.OwnerReference) (Context, error) { + wfCtx, err := newContext(ctx, ns, name, owner) if err != nil { return nil, err } @@ -229,7 +232,8 @@ func CleanupMemoryStore(name, ns string) { workflowMemoryCache.Delete(fmt.Sprintf("%s-%s", name, ns)) } -func newContext(ctx context.Context, cli client.Client, ns, name string, owner []metav1.OwnerReference) (*WorkflowContext, error) { +func newContext(ctx context.Context, ns, name string, owner []metav1.OwnerReference) (*WorkflowContext, error) { + cli := singleton.KubeClient.Get() store := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: generateStoreName(name), @@ -274,13 +278,12 @@ func newContext(ctx context.Context, cli client.Client, ns, name string, owner [ } memCache := getMemoryStore(fmt.Sprintf("%s-%s", name, ns)) wfCtx := &WorkflowContext{ - cli: cli, store: store, memoryStore: memCache, modified: true, } var err error - wfCtx.vars, err = value.NewValue("", nil, "") + wfCtx.vars = cuecontext.New().CompileString("") return wfCtx, err } @@ -300,10 +303,11 @@ func getMemoryStore(key string) *sync.Map { } // LoadContext load workflow context from store. -func LoadContext(cli client.Client, ns, name, ctxName string) (Context, error) { +func LoadContext(ctx context.Context, ns, name, ctxName string) (Context, error) { var store corev1.ConfigMap store.Name = ctxName store.Namespace = ns + cli := singleton.KubeClient.Get() if EnableInMemoryContext { MemStore.GetOrCreateInMemoryContext(&store) } else if err := cli.Get(context.Background(), client.ObjectKey{ @@ -313,15 +317,14 @@ func LoadContext(cli client.Client, ns, name, ctxName string) (Context, error) { return nil, err } memCache := getMemoryStore(fmt.Sprintf("%s-%s", name, ns)) - ctx := &WorkflowContext{ - cli: cli, + wfCtx := &WorkflowContext{ store: &store, memoryStore: memCache, } - if err := ctx.LoadFromConfigMap(store); err != nil { + if err := wfCtx.LoadFromConfigMap(ctx, store); err != nil { return nil, err } - return ctx, nil + return wfCtx, nil } // generateStoreName generates the config map name of workflow context. diff --git a/pkg/context/context_test.go b/pkg/context/context_test.go index 3d30176..4a75dba 100644 --- a/pkg/context/context_test.go +++ b/pkg/context/context_test.go @@ -21,6 +21,8 @@ import ( "encoding/json" "testing" + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -29,7 +31,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" yamlUtil "sigs.k8s.io/yaml" - "github.com/kubevela/workflow/pkg/cue/model/value" + "github.com/kubevela/pkg/cue/util" + "github.com/kubevela/pkg/util/singleton" ) func TestVars(t *testing.T) { @@ -43,13 +46,12 @@ func TestVars(t *testing.T) { { variable: `input: "1.1.1.1"`, paths: []string{"clusterIP"}, - expected: `"1.1.1.1" -`, + expected: `"1.1.1.1"`, }, { variable: "input: 100", paths: []string{"football", "score"}, - expected: "100\n", + expected: "100", }, { variable: ` @@ -59,42 +61,26 @@ input: { }`, paths: []string{"football"}, expected: `score: 100 -result: 101 -`, +result: 101`, }, } for _, tCase := range testCases { r := require.New(t) - val, err := value.NewValue(tCase.variable, nil, "") - r.NoError(err) - input, err := val.LookupValue("input") - r.NoError(err) - err = wfCtx.SetVar(input, tCase.paths...) + cuectx := cuecontext.New() + val := cuectx.CompileString(tCase.variable) + input := val.LookupPath(cue.ParsePath("input")) + err := wfCtx.SetVar(input, tCase.paths...) r.NoError(err) result, err := wfCtx.GetVar(tCase.paths...) r.NoError(err) - rStr, err := result.String() + rStr, err := util.ToString(result) r.NoError(err) r.Equal(rStr, tCase.expected) } r := require.New(t) - param, err := wfCtx.MakeParameter(`{"name": "foo"}`) - r.NoError(err) - mark, err := wfCtx.GetVar("football") - r.NoError(err) - err = param.FillObject(mark) - r.NoError(err) - rStr, err := param.String() - r.NoError(err) - r.Equal(rStr, `name: "foo" -score: 100 -result: 101 -`) - - conflictV, err := value.NewValue(`score: 101`, nil, "") - r.NoError(err) - err = wfCtx.SetVar(conflictV, "football") + conflictV := cuecontext.New().CompileString(`score: 101`) + err := wfCtx.SetVar(conflictV, "football") r.Equal(err.Error(), "football.score: conflicting values 101 and 100") } @@ -116,37 +102,38 @@ func TestRefObj(t *testing.T) { } func TestContext(t *testing.T) { - cli := newCliForTest(t, nil) + newCliForTest(t, nil) r := require.New(t) + ctx := context.Background() - wfCtx, err := NewContext(context.Background(), cli, "default", "app-v1", []metav1.OwnerReference{{Name: "test1"}}) + wfCtx, err := NewContext(ctx, "default", "app-v1", []metav1.OwnerReference{{Name: "test1"}}) r.NoError(err) - err = wfCtx.Commit() + err = wfCtx.Commit(context.Background()) r.NoError(err) - _, err = NewContext(context.Background(), cli, "default", "app-v1", []metav1.OwnerReference{{Name: "test2"}}) + _, err = NewContext(ctx, "default", "app-v1", []metav1.OwnerReference{{Name: "test2"}}) r.NoError(err) - wfCtx, err = LoadContext(cli, "default", "app-v1", "workflow-app-v1-context") + wfCtx, err = LoadContext(ctx, "default", "app-v1", "workflow-app-v1-context") r.NoError(err) - err = wfCtx.Commit() + err = wfCtx.Commit(context.Background()) r.NoError(err) - cli = newCliForTest(t, nil) - _, err = LoadContext(cli, "default", "app-v1", "workflow-app-v1-context") + newCliForTest(t, nil) + _, err = LoadContext(ctx, "default", "app-v1", "workflow-app-v1-context") r.Equal(err.Error(), `configMap "workflow-app-v1-context" not found`) - _, err = NewContext(context.Background(), cli, "default", "app-v1", nil) + _, err = NewContext(ctx, "default", "app-v1", nil) r.NoError(err) } func TestGetStore(t *testing.T) { - cli := newCliForTest(t, nil) + newCliForTest(t, nil) r := require.New(t) - wfCtx, err := NewContext(context.Background(), cli, "default", "app-v1", nil) + wfCtx, err := NewContext(context.Background(), "default", "app-v1", nil) r.NoError(err) - err = wfCtx.Commit() + err = wfCtx.Commit(context.Background()) r.NoError(err) store := wfCtx.GetStore() @@ -154,12 +141,12 @@ func TestGetStore(t *testing.T) { } func TestMutableValue(t *testing.T) { - cli := newCliForTest(t, nil) + newCliForTest(t, nil) r := require.New(t) - wfCtx, err := NewContext(context.Background(), cli, "default", "app-v1", nil) + wfCtx, err := NewContext(context.Background(), "default", "app-v1", nil) r.NoError(err) - err = wfCtx.Commit() + err = wfCtx.Commit(context.Background()) r.NoError(err) wfCtx.SetMutableValue("value", "test", "key") @@ -172,12 +159,12 @@ func TestMutableValue(t *testing.T) { } func TestMemoryValue(t *testing.T) { - cli := newCliForTest(t, nil) + newCliForTest(t, nil) r := require.New(t) - wfCtx, err := NewContext(context.Background(), cli, "default", "app-v1", nil) + wfCtx, err := NewContext(context.Background(), "default", "app-v1", nil) r.NoError(err) - err = wfCtx.Commit() + err = wfCtx.Commit(context.Background()) r.NoError(err) wfCtx.SetValueInMemory("value", "test", "key") @@ -199,9 +186,9 @@ func TestMemoryValue(t *testing.T) { r.Equal(count, 11) } -func newCliForTest(t *testing.T, wfCm *corev1.ConfigMap) *test.MockClient { +func newCliForTest(t *testing.T, wfCm *corev1.ConfigMap) { r := require.New(t) - return &test.MockClient{ + cli := &test.MockClient{ MockGet: func(ctx context.Context, key client.ObjectKey, obj client.Object) error { o, ok := obj.(*corev1.ConfigMap) if ok { @@ -241,6 +228,7 @@ func newCliForTest(t *testing.T, wfCm *corev1.ConfigMap) *test.MockClient { return nil }, } + singleton.KubeClient.Set(cli) } func newContextForTest(t *testing.T) *WorkflowContext { @@ -254,7 +242,7 @@ func newContextForTest(t *testing.T) *WorkflowContext { wfCtx := &WorkflowContext{ store: &cm, } - err = wfCtx.LoadFromConfigMap(cm) + err = wfCtx.LoadFromConfigMap(context.Background(), cm) r.NoError(err) return wfCtx } diff --git a/pkg/context/interface.go b/pkg/context/interface.go index ea7f056..53fa17b 100644 --- a/pkg/context/interface.go +++ b/pkg/context/interface.go @@ -17,15 +17,16 @@ limitations under the License. package context import ( - corev1 "k8s.io/api/core/v1" + "context" - "github.com/kubevela/workflow/pkg/cue/model/value" + "cuelang.org/go/cue" + corev1 "k8s.io/api/core/v1" ) // Context is workflow context interface type Context interface { - GetVar(paths ...string) (*value.Value, error) - SetVar(v *value.Value, paths ...string) error + GetVar(paths ...string) (cue.Value, error) + SetVar(v cue.Value, paths ...string) error GetStore() *corev1.ConfigMap GetMutableValue(path ...string) string SetMutableValue(data string, path ...string) @@ -34,7 +35,6 @@ type Context interface { SetValueInMemory(data interface{}, paths ...string) GetValueInMemory(paths ...string) (interface{}, bool) DeleteValueInMemory(paths ...string) - Commit() error - MakeParameter(parameter string) (*value.Value, error) + Commit(ctx context.Context) error StoreRef() *corev1.ObjectReference } diff --git a/pkg/cue/model/keyword.go b/pkg/cue/model/keyword.go index d8c8058..8384bbb 100644 --- a/pkg/cue/model/keyword.go +++ b/pkg/cue/model/keyword.go @@ -25,6 +25,8 @@ const ( ConfigFieldName = "config" // ParameterFieldName is the keyword in CUE template to define users' input and the reference to the context parameter ParameterFieldName = "parameter" + // ContextFieldName is the keyword in CUE template to define context + ContextFieldName = "context" // ContextName is the name of context ContextName = "name" // ContextNamespace is the namespace of the app diff --git a/pkg/cue/model/value/error.go b/pkg/cue/model/value/error.go new file mode 100644 index 0000000..f55e9d0 --- /dev/null +++ b/pkg/cue/model/value/error.go @@ -0,0 +1,29 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package value + +import ( + "fmt" +) + +// LookUpNotFoundErr is the error type of lookup +type LookUpNotFoundErr string + +// Error . +func (e LookUpNotFoundErr) Error() string { + return fmt.Sprintf("failed to lookup value: var(path=%s) not exist", string(e)) +} diff --git a/pkg/cue/model/value/value.go b/pkg/cue/model/value/value.go index 49495ea..e0f50d1 100644 --- a/pkg/cue/model/value/value.go +++ b/pkg/cue/model/value/value.go @@ -28,11 +28,11 @@ import ( "cuelang.org/go/cue/build" "cuelang.org/go/cue/cuecontext" "cuelang.org/go/cue/format" - "cuelang.org/go/cue/literal" "cuelang.org/go/cue/parser" "github.com/cue-exp/kubevelafix" "github.com/pkg/errors" + "github.com/kubevela/pkg/cue/util" "github.com/kubevela/workflow/pkg/cue/model/sets" "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/stdlib" @@ -191,27 +191,6 @@ func TagFieldOrder(root *ast.File) error { return nil } -// ProcessScript preprocess the script builtin function. -func ProcessScript(root *ast.File) error { - return sets.PreprocessBuiltinFunc(root, "script", func(values []ast.Node) (ast.Expr, error) { - for _, v := range values { - lit, ok := v.(*ast.BasicLit) - if ok { - src, err := literal.Unquote(lit.Value) - if err != nil { - return nil, errors.WithMessage(err, "unquote script value") - } - expr, err := parser.ParseExpr("-", src) - if err != nil { - return nil, errors.Errorf("script value(%s) is invalid CueLang", src) - } - return expr, nil - } - } - return nil, errors.New("script parameter error") - }) -} - type visitor struct { r map[string]struct{} } @@ -304,6 +283,20 @@ func (val *Value) makeValueWithFile(files ...*ast.File) (*Value, error) { return v, nil } +// FillRaw unify the value with the cue format string x at the given path. +func FillRaw(val cue.Value, x string, paths ...string) (cue.Value, error) { + file, err := parser.ParseFile("-", x, parser.ParseComments) + if err != nil { + return cue.Value{}, err + } + xInst := val.Context().BuildFile(file) + v := val.FillPath(FieldPath(paths...), xInst) + if v.Err() != nil { + return cue.Value{}, v.Err() + } + return v, nil +} + // FillRaw unify the value with the cue format string x at the given path. func (val *Value) FillRaw(x string, paths ...string) error { file, err := parser.ParseFile("-", x, parser.ParseComments) @@ -390,6 +383,22 @@ func setValue(orig ast.Node, expr ast.Expr, selectors []cue.Selector) error { return nil } +// SetValueByScript set the value v at the given script path. +// nolint:staticcheck +func SetValueByScript(base, v cue.Value, path ...string) (cue.Value, error) { + cuepath := FieldPath(path...) + selectors := cuepath.Selectors() + node := base.Syntax(cue.ResolveReferences(true)) + if err := setValue(node, v.Syntax(cue.ResolveReferences(true)).(ast.Expr), selectors); err != nil { + return cue.Value{}, err + } + b, err := format.Node(node) + if err != nil { + return cue.Value{}, err + } + return base.Context().CompileBytes(b), nil +} + // SetValueByScript set the value v at the given script path. // nolint:staticcheck func (val *Value) SetValueByScript(v *Value, path ...string) error { @@ -496,6 +505,79 @@ func isSelector(node ast.Node) bool { } } +// LookupValueByScript reports the value by cue script. +func LookupValueByScript(val cue.Value, script string) (cue.Value, error) { + var outputKey = "zz_output__" + script = strings.TrimSpace(script) + scriptFile, err := parser.ParseFile("-", script, parser.ParseComments) + if err != nil { + return cue.Value{}, errors.WithMessage(err, "parse script") + } + isScriptPath, err := isScript(script) + if err != nil { + return cue.Value{}, err + } + + if !isScriptPath { + v := val.LookupPath(cue.ParsePath(script)) + if !v.Exists() { + return cue.Value{}, LookUpNotFoundErr(script) + } + } + + raw, err := util.ToString(val) + if err != nil { + return cue.Value{}, err + } + + rawFile, err := parser.ParseFile("-", raw, parser.ParseComments) + if err != nil { + return cue.Value{}, errors.WithMessage(err, "parse script") + } + + behindKey(scriptFile, outputKey) + + newV, err := makeValueWithFiles(rawFile, scriptFile) + if err != nil { + return cue.Value{}, err + } + + v := newV.LookupPath(cue.ParsePath(outputKey)) + if !v.Exists() { + return cue.Value{}, LookUpNotFoundErr(outputKey) + } + return v, nil +} + +func makeValueWithFiles(files ...*ast.File) (cue.Value, error) { + builder := &build.Instance{} + newFile := &ast.File{} + imports := map[string]*ast.ImportSpec{} + for _, f := range files { + for _, importSpec := range f.Imports { + if _, ok := imports[importSpec.Name.String()]; !ok { + imports[importSpec.Name.String()] = importSpec + } + } + newFile.Decls = append(newFile.Decls, f.Decls...) + } + + for _, imp := range imports { + newFile.Imports = append(newFile.Imports, imp) + } + + if err := builder.AddSyntax(newFile); err != nil { + return cue.Value{}, err + } + + v := cuecontext.New().BuildInstance(builder) + if v.Err() != nil { + return cue.Value{}, v.Err() + } + + return v, nil +} + // LookupByScript reports the value by cue script. func (val *Value) LookupByScript(script string) (*Value, error) { var outputKey = "zz_output__" diff --git a/pkg/cue/model/value/value_test.go b/pkg/cue/model/value/value_test.go index df9505e..07c138e 100644 --- a/pkg/cue/model/value/value_test.go +++ b/pkg/cue/model/value/value_test.go @@ -710,70 +710,6 @@ bottom: _|_ r.Error(err) } -func TestProcessScript(t *testing.T) { - testCases := []struct { - src string - expect string - err string - }{ - { - src: `parameter: { - check: "status==\"ready\"" -} - -wait: { - status: "ready" - continue: script(parameter.check) -}`, - expect: `parameter: { - check: "status==\"ready\"" -} -wait: { - status: "ready" - continue: true -} -`, - }, - { - src: `parameter: { - check: "status==\"ready\"" -} - -wait: { - status: "ready" - continue: script("") -}`, - expect: ``, - err: "script parameter error", - }, - { - src: `parameter: { - check: "status=\"ready\"" -} - -wait: { - status: "ready" - continue: script(parameter.check) -}`, - expect: ``, - err: "script value(status=\"ready\") is invalid CueLang", - }, - } - - for _, tCase := range testCases { - r := require.New(t) - v, err := NewValue(tCase.src, nil, "", ProcessScript) - if tCase.err != "" { - r.Equal(err.Error(), tCase.err) - continue - } - r.NoError(err) - s, err := v.String() - r.NoError(err) - r.Equal(s, tCase.expect) - } -} - func TestLookupByScript(t *testing.T) { testCases := []struct { src string diff --git a/pkg/debug/context.go b/pkg/debug/context.go index f5cd1ca..c90a35f 100644 --- a/pkg/debug/context.go +++ b/pkg/debug/context.go @@ -20,34 +20,34 @@ import ( "context" "fmt" + "cuelang.org/go/cue" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kubevela/workflow/pkg/cue/model/value" + "github.com/kubevela/pkg/cue/util" + "github.com/kubevela/pkg/util/singleton" wfTypes "github.com/kubevela/workflow/pkg/types" ) // ContextImpl is workflow debug context interface type ContextImpl interface { - Set(v *value.Value) error + Set(v cue.Value) error } // Context is debug context. type Context struct { - cli client.Client instance *wfTypes.WorkflowInstance id string } // Set sets debug content into context -func (d *Context) Set(v *value.Value) error { - data, err := v.String() +func (d *Context) Set(v cue.Value) error { + data, err := util.ToString(v) if err != nil { return err } - err = setStore(context.Background(), d.cli, d.instance, d.id, data) + err = setStore(context.Background(), d.instance, d.id, data) if err != nil { return err } @@ -55,8 +55,9 @@ func (d *Context) Set(v *value.Value) error { return nil } -func setStore(ctx context.Context, cli client.Client, instance *wfTypes.WorkflowInstance, id, data string) error { +func setStore(ctx context.Context, instance *wfTypes.WorkflowInstance, id, data string) error { cm := &corev1.ConfigMap{} + cli := singleton.KubeClient.Get() if err := cli.Get(ctx, types.NamespacedName{ Namespace: instance.Namespace, Name: GenerateContextName(instance.Name, id, string(instance.UID)), @@ -87,9 +88,8 @@ func setStore(ctx context.Context, cli client.Client, instance *wfTypes.Workflow } // NewContext new workflow context without initialize data. -func NewContext(cli client.Client, instance *wfTypes.WorkflowInstance, id string) ContextImpl { +func NewContext(instance *wfTypes.WorkflowInstance, id string) ContextImpl { return &Context{ - cli: cli, instance: instance, id: id, } diff --git a/pkg/debug/context_test.go b/pkg/debug/context_test.go index 84eab7c..ab74bea 100644 --- a/pkg/debug/context_test.go +++ b/pkg/debug/context_test.go @@ -20,6 +20,7 @@ import ( "context" "testing" + "cuelang.org/go/cue/cuecontext" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -27,13 +28,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kubevela/workflow/pkg/cue/model/value" + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/pkg/types" ) func TestSetContext(t *testing.T) { r := require.New(t) - cli := newCliForTest(&corev1.ConfigMap{ + newCliForTest(&corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: GenerateContextName("test", "step1", "123456"), }, @@ -41,34 +42,29 @@ func TestSetContext(t *testing.T) { "debug": "test", }, }) + cuectx := cuecontext.New() // test update - debugCtx := NewContext(cli, &types.WorkflowInstance{ + debugCtx := NewContext(&types.WorkflowInstance{ WorkflowMeta: types.WorkflowMeta{ Name: "test", }, }, "step1") - v, err := value.NewValue(` -test: test -`, nil, "") - r.NoError(err) - err = debugCtx.Set(v) + v := cuectx.CompileString(`test: "test"`) + err := debugCtx.Set(v) r.NoError(err) // test create - debugCtx = NewContext(cli, &types.WorkflowInstance{ + debugCtx = NewContext(&types.WorkflowInstance{ WorkflowMeta: types.WorkflowMeta{ Name: "test", }, }, "step2") - v, err = value.NewValue(` -test: test -`, nil, "") - r.NoError(err) + v = cuectx.CompileString(`test2: "test2"`) err = debugCtx.Set(v) r.NoError(err) } -func newCliForTest(wfCm *corev1.ConfigMap) *test.MockClient { - return &test.MockClient{ +func newCliForTest(wfCm *corev1.ConfigMap) { + cli := &test.MockClient{ MockGet: func(ctx context.Context, key client.ObjectKey, obj client.Object) error { o, ok := obj.(*corev1.ConfigMap) if ok { @@ -98,4 +94,5 @@ func newCliForTest(wfCm *corev1.ConfigMap) *test.MockClient { return nil }, } + singleton.KubeClient.Set(cli) } diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go new file mode 100644 index 0000000..5ca6d71 --- /dev/null +++ b/pkg/errors/errors.go @@ -0,0 +1,36 @@ +/* +Copyright 2023 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package errors + +// ActionType is the type of action +type ActionType string + +const ( + // ActionSuspend is the action type of suspend + ActionSuspend ActionType = "suspend" + // ActionTerminate is the action type of terminate + ActionTerminate ActionType = "terminate" + // ActionWait is the action type of wait + ActionWait ActionType = "wait" +) + +// GenericActionError is the error type of action +type GenericActionError ActionType + +func (e GenericActionError) Error() string { + return "" +} diff --git a/pkg/executor/options.go b/pkg/executor/options.go new file mode 100644 index 0000000..36ae2df --- /dev/null +++ b/pkg/executor/options.go @@ -0,0 +1,53 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package executor + +import ( + "github.com/kubevela/pkg/cue/cuex" + "github.com/kubevela/workflow/pkg/types" +) + +// Option is the option of executor +type Option interface { + ApplyTo(*workflowExecutor) +} + +type withCompiler struct { + compiler *cuex.Compiler +} + +func (w *withCompiler) ApplyTo(e *workflowExecutor) { + e.compiler = w.compiler +} + +// WithCompiler set the cue compiler +func WithCompiler(compiler *cuex.Compiler) Option { + return &withCompiler{compiler: compiler} +} + +type withStatusPatcher struct { + patcher types.StatusPatcher +} + +func (w *withStatusPatcher) ApplyTo(e *workflowExecutor) { + e.patcher = w.patcher +} + +// WithStatusPatcher set the status patcher +func WithStatusPatcher(patcher types.StatusPatcher) Option { + return &withStatusPatcher{patcher: patcher} +} diff --git a/pkg/executor/suit_test.go b/pkg/executor/suit_test.go index 754f411..56df74c 100644 --- a/pkg/executor/suit_test.go +++ b/pkg/executor/suit_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + "github.com/kubevela/pkg/util/singleton" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -64,6 +65,7 @@ var _ = BeforeSuite(func(done Done) { k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient).ToNot(BeNil()) + singleton.KubeClient.Set(k8sClient) close(done) }, 60) diff --git a/pkg/executor/workflow.go b/pkg/executor/workflow.go index 054c1b0..99594a4 100644 --- a/pkg/executor/workflow.go +++ b/pkg/executor/workflow.go @@ -23,22 +23,22 @@ import ( "sync" "time" + "cuelang.org/go/cue" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/util/feature" - "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/kubevela/pkg/cue/cuex" monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/debug" "github.com/kubevela/workflow/pkg/features" "github.com/kubevela/workflow/pkg/hooks" "github.com/kubevela/workflow/pkg/monitor/metrics" - "github.com/kubevela/workflow/pkg/providers/workspace" + "github.com/kubevela/workflow/pkg/providers" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" ) @@ -59,18 +59,31 @@ const ( type workflowExecutor struct { instance *types.WorkflowInstance - cli client.Client wfCtx wfContext.Context patcher types.StatusPatcher + compiler *cuex.Compiler } // New returns a Workflow Executor implementation. -func New(instance *types.WorkflowInstance, cli client.Client, patcher types.StatusPatcher) WorkflowExecutor { - return &workflowExecutor{ - instance: instance, - cli: cli, - patcher: patcher, - } +func New(instance *types.WorkflowInstance, options ...Option) WorkflowExecutor { + executor := &workflowExecutor{instance: instance} + for _, opt := range options { + opt.ApplyTo(executor) + } + if executor.compiler == nil { + executor.compiler = providers.NewCompiler(nil) + // v, err := executor.compiler.CompileString(context.Background(), `import ( + // "vela/op" + // ) + // a: op.#Suspend & {}`) + // if err != nil { + // panic(err) + // } + // if v.Err() != nil { + // panic(v.Err()) + // } + } + return executor } // InitializeWorkflowInstance init workflow instance @@ -204,13 +217,13 @@ func newEngine(ctx monitorContext.Context, wfCtx wfContext.Context, w *workflowE status: wfStatus, instance: w.instance, wfCtx: wfCtx, - cli: w.cli, debug: w.instance.Debug, stepStatus: stepStatus, stepDependsOn: stepDependsOn, stepTimeout: make(map[string]time.Time), taskRunners: taskRunners, statusPatcher: w.patcher, + compiler: w.compiler, } } @@ -268,7 +281,8 @@ func handleSuspendBackoffTime(wfCtx wfContext.Context, step v1alpha1.WorkflowSte } } - if ts := wfCtx.GetMutableValue(status.ID, workspace.ResumeTimeStamp); ts != "" { + //FIXME: + if ts := wfCtx.GetMutableValue(status.ID, "resumeTimeStamp"); ts != "" { t, err := time.Parse(time.RFC3339, ts) if err != nil { return min @@ -324,14 +338,14 @@ func (w *workflowExecutor) makeContext(ctx context.Context, name string) (wfCont ctx = request.WithUser(ctx, nil) status := &w.instance.Status if status.ContextBackend != nil { - wfCtx, err := wfContext.LoadContext(w.cli, w.instance.Namespace, w.instance.Name, w.instance.Status.ContextBackend.Name) + wfCtx, err := wfContext.LoadContext(ctx, w.instance.Namespace, w.instance.Name, w.instance.Status.ContextBackend.Name) if err != nil { return nil, errors.WithMessage(err, "load context") } return wfCtx, nil } - wfCtx, err := wfContext.NewContext(ctx, w.cli, w.instance.Namespace, name, w.instance.ChildOwnerReferences) + wfCtx, err := wfContext.NewContext(ctx, w.instance.Namespace, name, w.instance.ChildOwnerReferences) if err != nil { return nil, errors.WithMessage(err, "new context") } @@ -548,7 +562,7 @@ func (e *engine) steps(ctx monitorContext.Context, taskRunners []types.TaskRunne if err := e.updateStepStatus(ctx, status); err != nil { return err } - if err := handleBackoffTimes(wfCtx, status, false); err != nil { + if err := handleBackoffTimes(ctx, wfCtx, status, false); err != nil { return err } if dag { @@ -557,7 +571,7 @@ func (e *engine) steps(ctx monitorContext.Context, taskRunners []types.TaskRunne return nil } // clear the backoff time when the step is finished - if err := handleBackoffTimes(wfCtx, status, true); err != nil { + if err := handleBackoffTimes(ctx, wfCtx, status, true); err != nil { return err } if err := e.updateStepStatus(ctx, status); err != nil { @@ -583,6 +597,7 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v }, StepStatus: e.stepStatus, Engine: e, + Compiler: e.compiler, PreCheckHooks: []types.TaskPreCheckHook{ func(step v1alpha1.WorkflowStep, options *types.PreCheckOptions) (*types.PreCheckResult, error) { if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { @@ -599,7 +614,11 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v case "": return &types.PreCheckResult{Skip: skipExecutionOfNextStep(dependsOnPhase, len(step.DependsOn) > 0)}, nil default: - ifValue, err := custom.ValidateIfValue(e.wfCtx, step, e.stepStatus, options) + basicVal := cue.Value{} + if options != nil { + basicVal = options.BasicValue + } + ifValue, err := custom.ValidateIfValue(e.wfCtx, step, e.stepStatus, basicVal) if err != nil { return &types.PreCheckResult{Skip: true}, err } @@ -632,8 +651,8 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v PostStopHooks: []types.TaskPostStopHook{hooks.Output}, } if e.debug { - options.Debug = func(id string, v *value.Value) error { - debugContext := debug.NewContext(e.cli, e.instance, id) + options.Debug = func(id string, v cue.Value) error { + debugContext := debug.NewContext(e.instance, id) if err := debugContext.Set(v); err != nil { return err } @@ -651,13 +670,13 @@ type engine struct { status *v1alpha1.WorkflowRunStatus wfCtx wfContext.Context instance *types.WorkflowInstance - cli client.Client parentRunner string stepStatus map[string]v1alpha1.StepStatus stepTimeout map[string]time.Time stepDependsOn map[string][]string taskRunners []types.TaskRunner statusPatcher types.StatusPatcher + compiler *cuex.Compiler } func (e *engine) finishStep(operation *types.Operation) { @@ -816,7 +835,7 @@ func skipExecutionOfNextStep(phase v1alpha1.WorkflowStepPhase, dependsOn bool) b return phase != v1alpha1.WorkflowStepPhaseSucceeded && phase != v1alpha1.WorkflowStepPhaseSkipped } -func handleBackoffTimes(wfCtx wfContext.Context, status v1alpha1.StepStatus, clear bool) error { +func handleBackoffTimes(ctx context.Context, wfCtx wfContext.Context, status v1alpha1.StepStatus, clear bool) error { if clear { wfCtx.DeleteValueInMemory(types.ContextPrefixBackoffTimes, status.ID) wfCtx.DeleteValueInMemory(types.ContextPrefixBackoffReason, status.ID) @@ -827,7 +846,7 @@ func handleBackoffTimes(wfCtx wfContext.Context, status v1alpha1.StepStatus, cle } wfCtx.IncreaseCountValueInMemory(types.ContextPrefixBackoffTimes, status.ID) } - if err := wfCtx.Commit(); err != nil { + if err := wfCtx.Commit(ctx); err != nil { return errors.WithMessage(err, "commit workflow context") } return nil diff --git a/pkg/executor/workflow_test.go b/pkg/executor/workflow_test.go index 01cf1e7..10de0a1 100644 --- a/pkg/executor/workflow_test.go +++ b/pkg/executor/workflow_test.go @@ -23,6 +23,7 @@ import ( "testing" "time" + "cuelang.org/go/cue/cuecontext" "github.com/google/go-cmp/cmp" "github.com/kubevela/pkg/util/slices" . "github.com/onsi/ginkgo" @@ -40,10 +41,8 @@ import ( monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/features" - "github.com/kubevela/workflow/pkg/providers/workspace" "github.com/kubevela/workflow/pkg/tasks/builtin" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" @@ -94,7 +93,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateExecuting)) @@ -143,7 +142,7 @@ var _ = Describe("Test Workflow", func() { }) instance.Status = v1alpha1.WorkflowRunStatus{} - wf = New(instance, k8sClient, nil) + wf = New(instance) state, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSucceeded)) @@ -205,7 +204,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -272,7 +271,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateExecuting)) @@ -357,7 +356,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending)) @@ -449,7 +448,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending)) @@ -540,7 +539,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) state, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending)) @@ -628,7 +627,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -715,7 +714,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -799,7 +798,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -862,7 +861,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf = New(instance, k8sClient, nil) + wf = New(instance) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") state, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -917,7 +916,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending)) @@ -970,7 +969,7 @@ var _ = Describe("Test Workflow", func() { Steps: v1alpha1.WorkflowModeDAG, } ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) state, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending)) @@ -1042,7 +1041,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateFailed)) @@ -1138,7 +1137,7 @@ var _ = Describe("Test Workflow", func() { Steps: v1alpha1.WorkflowModeDAG, } ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) state, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateFailed)) @@ -1236,7 +1235,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSucceeded)) @@ -1323,7 +1322,7 @@ var _ = Describe("Test Workflow", func() { Steps: v1alpha1.WorkflowModeDAG, } ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) state, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSucceeded)) @@ -1408,7 +1407,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -1500,7 +1499,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -1550,10 +1549,10 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) _, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) - wfCtx, err := wfContext.LoadContext(k8sClient, instance.Namespace, instance.Name, instance.Status.ContextBackend.Name) + wfCtx, err := wfContext.LoadContext(ctx, instance.Namespace, instance.Name, instance.Status.ContextBackend.Name) Expect(err).ToNot(HaveOccurred()) e := &engine{ status: &instance.Status, @@ -1588,7 +1587,7 @@ var _ = Describe("Test Workflow", func() { wfContext.CleanupMemoryStore(instance.Name, instance.Namespace) _, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) - wfCtx, err = wfContext.LoadContext(k8sClient, instance.Namespace, instance.Name, instance.Status.ContextBackend.Name) + wfCtx, err = wfContext.LoadContext(ctx, instance.Namespace, instance.Name, instance.Status.ContextBackend.Name) Expect(err).ToNot(HaveOccurred()) e = &engine{ status: &instance.Status, @@ -1609,7 +1608,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) _, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) _, err = wf.ExecuteRunners(ctx, runners) @@ -1635,7 +1634,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) _, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) _, err = wf.ExecuteRunners(ctx, runners) @@ -1653,7 +1652,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) _, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) _, err = wf.ExecuteRunners(ctx, runners) @@ -1671,7 +1670,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) _, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) _, err = wf.ExecuteRunners(ctx, runners) @@ -1690,7 +1689,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) _, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) _, err = wf.ExecuteRunners(ctx, runners) @@ -1708,7 +1707,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) _, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) _, err = wf.ExecuteRunners(ctx, runners) @@ -1726,7 +1725,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx = monitorContext.NewTraceContext(context.Background(), "test-app") - wf = New(instance, k8sClient, nil) + wf = New(instance) _, err = wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(int(math.Ceil(wf.GetSuspendBackoffWaitTime().Seconds()))).Should(Equal(0)) @@ -1754,7 +1753,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSuspending)) @@ -1856,7 +1855,7 @@ var _ = Describe("Test Workflow", func() { }, }, }) - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -1910,7 +1909,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateTerminated)) @@ -1968,7 +1967,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateTerminated)) @@ -2026,7 +2025,7 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).To(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateExecuting)) @@ -2047,7 +2046,7 @@ var _ = Describe("Test Workflow", func() { It("skip workflow", func() { instance, runners := makeTestCase([]v1alpha1.WorkflowStep{}) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateSucceeded)) @@ -2078,7 +2077,7 @@ var _ = Describe("Test Workflow", func() { instance.Mode = &v1alpha1.WorkflowExecuteMode{ Steps: v1alpha1.WorkflowModeDAG, } - wf := New(instance, k8sClient, nil) + wf := New(instance) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) @@ -2166,16 +2165,16 @@ var _ = Describe("Test Workflow", func() { }, }) ctx := monitorContext.NewTraceContext(context.Background(), "test-app") - wf := New(instance, k8sClient, nil) + wf := New(instance) state, err := wf.ExecuteRunners(ctx, runners) Expect(err).ToNot(HaveOccurred()) Expect(state).Should(BeEquivalentTo(v1alpha1.WorkflowStateExecuting)) Expect(instance.Status.Steps[0].Phase).Should(BeEquivalentTo(v1alpha1.WorkflowStepPhaseRunning)) - wfCtx, err := wfContext.LoadContext(k8sClient, instance.Namespace, instance.Name, instance.Status.ContextBackend.Name) + wfCtx, err := wfContext.LoadContext(ctx, instance.Namespace, instance.Name, instance.Status.ContextBackend.Name) Expect(err).ToNot(HaveOccurred()) v, err := wfCtx.GetVar("saved") Expect(err).ToNot(HaveOccurred()) - saved, err := v.CueValue().Bool() + saved, err := v.Bool() Expect(err).ToNot(HaveOccurred()) Expect(saved).Should(BeEquivalentTo(true)) }) @@ -2230,7 +2229,7 @@ func makeRunner(step v1alpha1.WorkflowStep, subTaskRunners []types.TaskRunner) t _ = json.Unmarshal(b, &v) if v["duration"] != "" { d, _ := time.ParseDuration(v["duration"]) - ctx.SetMutableValue(time.Now().Add(d).Format(time.RFC3339), step.Name, workspace.ResumeTimeStamp) + ctx.SetMutableValue(time.Now().Add(d).Format(time.RFC3339), step.Name, "resumeTimeStamp") } } return v1alpha1.StepStatus{ @@ -2255,10 +2254,7 @@ func makeRunner(step v1alpha1.WorkflowStep, subTaskRunners []types.TaskRunner) t } case "success": run = func(ctx wfContext.Context, options *types.TaskRunOptions) (v1alpha1.StepStatus, *types.Operation, error) { - v, err := value.NewValue(`"app"`, nil, "") - if err != nil { - return v1alpha1.StepStatus{}, nil, err - } + v := cuecontext.New().CompileString(`"app"`) if err := ctx.SetVar(v, "test"); err != nil { return v1alpha1.StepStatus{}, nil, err } @@ -2297,7 +2293,7 @@ func makeRunner(step v1alpha1.WorkflowStep, subTaskRunners []types.TaskRunner) t } case "wait-with-set-var": run = func(ctx wfContext.Context, options *types.TaskRunOptions) (v1alpha1.StepStatus, *types.Operation, error) { - v, _ := value.NewValue(`saved: true`, nil, "") + v := cuecontext.New().CompileString(`saved: true`) err := ctx.SetVar(v) return v1alpha1.StepStatus{ Name: step.Name, @@ -2377,15 +2373,14 @@ func (tr *testTaskRunner) Run(ctx wfContext.Context, options *types.TaskRunOptio resetter := tr.fillContext(logCtx, options.PCtx) defer resetter(options.PCtx) - basicVal, basicTemplate, err := custom.MakeBasicValue(ctx, "", options.PCtx) + basicVal, err := custom.MakeBasicValue(logCtx, nil, options.PCtx) if err != nil { return v1alpha1.StepStatus{}, nil, err } if tr.step.Type != "step-group" && options != nil { for _, hook := range options.PreCheckHooks { result, err := hook(tr.step, &types.PreCheckOptions{ - BasicTemplate: basicTemplate, - BasicValue: basicVal, + BasicValue: basicVal, }) if err != nil { return v1alpha1.StepStatus{ diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 429375f..96ee6f8 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -28,19 +28,12 @@ import ( monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/pkg/util/rand" - "github.com/oam-dev/kubevela/pkg/config/provider" - "github.com/kubevela/workflow/api/v1alpha1" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/executor" "github.com/kubevela/workflow/pkg/monitor/metrics" - "github.com/kubevela/workflow/pkg/providers" - "github.com/kubevela/workflow/pkg/providers/email" - "github.com/kubevela/workflow/pkg/providers/http" - "github.com/kubevela/workflow/pkg/providers/kube" - metrics2 "github.com/kubevela/workflow/pkg/providers/metrics" - "github.com/kubevela/workflow/pkg/providers/util" - "github.com/kubevela/workflow/pkg/providers/workspace" + + // providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/tasks" "github.com/kubevela/workflow/pkg/tasks/template" "github.com/kubevela/workflow/pkg/types" @@ -58,9 +51,8 @@ func GenerateRunners(ctx monitorContext.Context, instance *types.WorkflowInstanc var tasks []types.TaskRunner for _, step := range instance.Steps { opt := &types.TaskGeneratorOptions{ - ID: generateStepID(instance.Status, step.Name), - PackageDiscover: options.PackageDiscover, - ProcessContext: options.ProcessCtx, + ID: generateStepID(instance.Status, step.Name), + ProcessContext: options.ProcessCtx, } for typ, convertor := range options.StepConvertor { if step.Type == typ { @@ -141,33 +133,16 @@ func GenerateWorkflowInstance(ctx context.Context, cli client.Client, run *v1alp return instance, nil } -func initStepGeneratorOptions(ctx monitorContext.Context, instance *types.WorkflowInstance, options types.StepGeneratorOptions) types.StepGeneratorOptions { //nolint:revive,unused - if options.Providers == nil { - options.Providers = providers.NewProviders() - } +func initStepGeneratorOptions(ctx monitorContext.Context, instance *types.WorkflowInstance, options types.StepGeneratorOptions) types.StepGeneratorOptions { if options.ProcessCtx == nil { options.ProcessCtx = process.NewContext(generateContextDataFromWorkflowRun(instance)) } - installBuiltinProviders(instance, options.Client, options.Providers, options.ProcessCtx) if options.TemplateLoader == nil { - options.TemplateLoader = template.NewWorkflowStepTemplateLoader(options.Client) + options.TemplateLoader = template.NewWorkflowStepTemplateLoader() } return options } -func installBuiltinProviders(instance *types.WorkflowInstance, client client.Client, providerHandlers types.Providers, pCtx process.Context) { - workspace.Install(providerHandlers, pCtx) - email.Install(providerHandlers) - util.Install(providerHandlers, pCtx) - http.Install(providerHandlers, client, instance.Namespace) - provider.Install(providerHandlers, client, nil) - metrics2.Install(providerHandlers) - kube.Install(providerHandlers, client, map[string]string{ - types.LabelWorkflowRunName: instance.Name, - types.LabelWorkflowRunNamespace: instance.Namespace, - }, nil) -} - func generateTaskRunner(ctx context.Context, instance *types.WorkflowInstance, step v1alpha1.WorkflowStep, @@ -181,9 +156,8 @@ func generateTaskRunner(ctx context.Context, WorkflowStepBase: subStep, } o := &types.TaskGeneratorOptions{ - ID: generateSubStepID(instance.Status, subStep.Name, step.Name), - PackageDiscover: options.PackageDiscover, - ProcessContext: options.ProcessContext, + ID: generateSubStepID(instance.Status, subStep.Name, step.Name), + ProcessContext: options.ProcessContext, } for typ, convertor := range stepOptions.StepConvertor { if subStep.Type == typ { diff --git a/pkg/generator/generator_test.go b/pkg/generator/generator_test.go index c3f4897..f81593f 100644 --- a/pkg/generator/generator_test.go +++ b/pkg/generator/generator_test.go @@ -86,7 +86,7 @@ var _ = Describe("Test workflow step runner generator", func() { instance, err := GenerateWorkflowInstance(ctx, k8sClient, wr) Expect(err).Should(BeNil()) ctx := monitorContext.NewTraceContext(ctx, "test-wr") - runners, err := GenerateRunners(ctx, instance, types.StepGeneratorOptions{Client: k8sClient}) + runners, err := GenerateRunners(ctx, instance, types.StepGeneratorOptions{}) Expect(err).Should(BeNil()) Expect(len(runners)).Should(BeEquivalentTo(1)) Expect(runners[0].Name()).Should(BeEquivalentTo("step-1")) @@ -128,7 +128,7 @@ var _ = Describe("Test workflow step runner generator", func() { ctx := monitorContext.NewTraceContext(ctx, "test-wr-sub") instance, err := GenerateWorkflowInstance(ctx, k8sClient, wr) Expect(err).Should(BeNil()) - runners, err := GenerateRunners(ctx, instance, types.StepGeneratorOptions{Client: k8sClient}) + runners, err := GenerateRunners(ctx, instance, types.StepGeneratorOptions{}) Expect(err).Should(BeNil()) Expect(len(runners)).Should(BeEquivalentTo(1)) Expect(runners[0].Name()).Should(BeEquivalentTo("step-1")) diff --git a/pkg/generator/suit_test.go b/pkg/generator/suit_test.go index af436ad..67dfce0 100644 --- a/pkg/generator/suit_test.go +++ b/pkg/generator/suit_test.go @@ -20,6 +20,7 @@ import ( "testing" "time" + "github.com/kubevela/pkg/util/singleton" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -64,6 +65,7 @@ var _ = BeforeSuite(func(done Done) { k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient).ToNot(BeNil()) + singleton.KubeClient.Set(k8sClient) close(done) }, 60) diff --git a/pkg/hooks/data_passing.go b/pkg/hooks/data_passing.go index 737e538..c6f4bc6 100644 --- a/pkg/hooks/data_passing.go +++ b/pkg/hooks/data_passing.go @@ -21,6 +21,7 @@ import ( "fmt" "strings" + "cuelang.org/go/cue" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/runtime" @@ -31,43 +32,45 @@ import ( ) // Input set data to parameter. -func Input(ctx wfContext.Context, paramValue *value.Value, step v1alpha1.WorkflowStep) error { +func Input(ctx wfContext.Context, paramValue cue.Value, step v1alpha1.WorkflowStep) (cue.Value, error) { + filledVal := paramValue for _, input := range step.Inputs { inputValue, err := ctx.GetVar(strings.Split(input.From, ".")...) if err != nil { - inputValue, err = paramValue.LookupByScript(input.From) + inputValue, err = value.LookupValueByScript(paramValue, input.From) if err != nil { - return errors.WithMessagef(err, "get input from [%s]", input.From) + return filledVal, errors.WithMessagef(err, "get input from [%s]", input.From) } } if input.ParameterKey != "" { - if err := paramValue.SetValueByScript(inputValue, strings.Join([]string{"parameter", input.ParameterKey}, ".")); err != nil || paramValue.Error() != nil { + filledVal, err = value.SetValueByScript(paramValue, inputValue, strings.Join([]string{"parameter", input.ParameterKey}, ".")) + if err != nil || filledVal.Err() != nil { if err != nil { - return err + return paramValue, err } - if paramValue.Error() != nil { - return paramValue.Error() + if filledVal.Err() != nil { + return filledVal, filledVal.Err() } } } } - return nil + return filledVal, nil } // Output get data from task value. -func Output(ctx wfContext.Context, taskValue *value.Value, step v1alpha1.WorkflowStep, status v1alpha1.StepStatus, stepStatus map[string]v1alpha1.StepStatus) error { +func Output(ctx wfContext.Context, taskValue cue.Value, step v1alpha1.WorkflowStep, status v1alpha1.StepStatus, stepStatus map[string]v1alpha1.StepStatus) error { errMsg := "" if wfTypes.IsStepFinish(status.Phase, status.Reason) { SetAdditionalNameInStatus(stepStatus, step.Name, step.Properties, status) for _, output := range step.Outputs { - v, err := taskValue.LookupByScript(output.ValueFrom) + v, err := value.LookupValueByScript(taskValue, output.ValueFrom) // if the error is not nil and the step is not skipped, return the error if err != nil && status.Phase != v1alpha1.WorkflowStepPhaseSkipped { errMsg += fmt.Sprintf("failed to get output from %s: %s\n", output.ValueFrom, err.Error()) } // if the error is not nil, set the value to null - if err != nil || v.Error() != nil { - v, _ = taskValue.MakeValue("null") + if err != nil || v.Err() != nil { + v = taskValue.Context().CompileString("null") } if err := ctx.SetVar(v, output.Name); err != nil { errMsg += fmt.Sprintf("failed to set output %s: %s\n", output.Name, err.Error()) diff --git a/pkg/hooks/data_passing_test.go b/pkg/hooks/data_passing_test.go index c16a724..dae8c1e 100644 --- a/pkg/hooks/data_passing_test.go +++ b/pkg/hooks/data_passing_test.go @@ -20,26 +20,26 @@ import ( "context" "testing" + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" "github.com/crossplane/crossplane-runtime/pkg/test" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" ) func TestInput(t *testing.T) { wfCtx := mockContext(t) r := require.New(t) - paramValue, err := wfCtx.MakeParameter(`"name": "foo"`) + cuectx := cuecontext.New() + paramValue := cuectx.CompileString(`"name": "foo"`) + err := wfCtx.SetVar(cuectx.CompileString(`score: 99`), "foo") r.NoError(err) - score, err := paramValue.MakeValue(`score: 99`) - r.NoError(err) - err = wfCtx.SetVar(score, "foo") - r.NoError(err) - err = Input(wfCtx, paramValue, v1alpha1.WorkflowStep{ + val, err := Input(wfCtx, paramValue, v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ DependsOn: []string{"mystep"}, Inputs: v1alpha1.StepInputs{{ @@ -49,16 +49,15 @@ func TestInput(t *testing.T) { }, }) r.NoError(err) - result, err := paramValue.LookupValue("parameter", "myscore") + result := val.LookupPath(cue.ParsePath("parameter.myscore")) + resultInt, err := result.Int64() r.NoError(err) - s, err := result.String() - r.NoError(err) - r.Equal(s, `99 -`) + r.Equal(int(resultInt), 99) + // test set value - paramValue, err = wfCtx.MakeParameter(`parameter: {myscore: "test"}`) + paramValue = cuectx.CompileString(`parameter: {myscore: "test"}`) r.NoError(err) - err = Input(wfCtx, paramValue, v1alpha1.WorkflowStep{ + val, err = Input(wfCtx, paramValue, v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ DependsOn: []string{"mystep"}, Inputs: v1alpha1.StepInputs{{ @@ -68,15 +67,12 @@ func TestInput(t *testing.T) { }, }) r.NoError(err) - result, err = paramValue.LookupValue("parameter", "myscore") + result = val.LookupPath(cue.ParsePath("parameter.myscore")) + resultInt, err = result.Int64() r.NoError(err) - s, err = result.String() - r.NoError(err) - r.Equal(s, `99 -`) - paramValue, err = wfCtx.MakeParameter(`context: {name: "test"}`) - r.NoError(err) - err = Input(wfCtx, paramValue, v1alpha1.WorkflowStep{ + r.Equal(int(resultInt), 99) + paramValue = cuectx.CompileString(`context: {name: "test"}`) + val, err = Input(wfCtx, paramValue, v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ Inputs: v1alpha1.StepInputs{{ From: "context.name", @@ -85,23 +81,20 @@ func TestInput(t *testing.T) { }, }) r.NoError(err) - result, err = paramValue.LookupValue("parameter", "contextname") + result = val.LookupPath(cue.ParsePath("parameter.contextname")) r.NoError(err) - s, err = result.String() + s, err := result.String() r.NoError(err) - r.Equal(s, `"test" -`) + r.Equal(s, "test") } func TestOutput(t *testing.T) { wfCtx := mockContext(t) r := require.New(t) - taskValue, err := value.NewValue(` -output: score: 99 -`, nil, "") - r.NoError(err) + cuectx := cuecontext.New() + taskValue := cuectx.CompileString(`output: score: 99`) stepStatus := make(map[string]v1alpha1.StepStatus) - err = Output(wfCtx, taskValue, v1alpha1.WorkflowStep{ + err := Output(wfCtx, taskValue, v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ Properties: &runtime.RawExtension{ Raw: []byte("{\"name\":\"mystep\"}"), @@ -117,10 +110,9 @@ output: score: 99 r.NoError(err) result, err := wfCtx.GetVar("myscore") r.NoError(err) - s, err := result.String() + resultInt, err := result.Int64() r.NoError(err) - r.Equal(s, `99 -`) + r.Equal(int(resultInt), 99) r.Equal(stepStatus["mystep"].Phase, v1alpha1.WorkflowStepPhaseSucceeded) } @@ -136,7 +128,8 @@ func mockContext(t *testing.T) wfContext.Context { return nil }, } - wfCtx, err := wfContext.NewContext(context.Background(), cli, "default", "v1", nil) + singleton.KubeClient.Set(cli) + wfCtx, err := wfContext.NewContext(context.Background(), "default", "v1", nil) require.NoError(t, err) return wfCtx } diff --git a/pkg/providers/compiler.go b/pkg/providers/compiler.go new file mode 100644 index 0000000..acdf5e5 --- /dev/null +++ b/pkg/providers/compiler.go @@ -0,0 +1,44 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package providers + +import ( + "github.com/kubevela/pkg/cue/cuex" + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + "github.com/kubevela/pkg/util/runtime" + + "github.com/kubevela/workflow/pkg/providers/legacy" + providertypes "github.com/kubevela/workflow/pkg/providers/types" +) + +const ( + // LegacyProviderName is the name of legacy provider + LegacyProviderName = "op" +) + +var defaultCompiler *cuex.Compiler + +// NewCompiler create a cuex compiler +func NewCompiler(kubeHandlers *providertypes.KubeHandlers) *cuex.Compiler { + if defaultCompiler == nil { + defaultCompiler = cuex.NewCompilerWithInternalPackages( + // legacy packages + runtime.Must(cuexruntime.NewInternalPackage(LegacyProviderName, legacy.GetLegacyTemplate(), legacy.GetLegacyProviders(kubeHandlers))), + ) + } + return defaultCompiler +} diff --git a/pkg/providers/kube/handle_test.go b/pkg/providers/kube/handle_test.go deleted file mode 100644 index 5d428cd..0000000 --- a/pkg/providers/kube/handle_test.go +++ /dev/null @@ -1,582 +0,0 @@ -/* -Copyright 2021 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package kube - -import ( - "context" - "encoding/json" - "fmt" - "testing" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - corev1 "k8s.io/api/core/v1" - crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/yaml" - - monitorContext "github.com/kubevela/pkg/monitor/context" - - wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/cue/packages" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var scheme = runtime.NewScheme() -var pd *packages.PackageDiscover -var p *provider - -func TestProvider(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Test Definition Suite") -} - -var _ = BeforeSuite(func(done Done) { - By("Bootstrapping test environment") - testEnv = &envtest.Environment{ - ControlPlaneStartTimeout: time.Minute, - ControlPlaneStopTimeout: time.Minute, - UseExistingCluster: pointer.BoolPtr(false), - } - var err error - cfg, err = testEnv.Start() - Expect(err).ToNot(HaveOccurred()) - Expect(cfg).ToNot(BeNil()) - Expect(clientgoscheme.AddToScheme(scheme)).Should(BeNil()) - Expect(crdv1.AddToScheme(scheme)).Should(BeNil()) - // +kubebuilder:scaffold:scheme - By("Create the k8s client") - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).ToNot(HaveOccurred()) - Expect(k8sClient).ToNot(BeNil()) - pd, err = packages.NewPackageDiscover(cfg) - Expect(err).ToNot(HaveOccurred()) - - d := &dispatcher{ - cli: k8sClient, - } - p = &provider{ - cli: k8sClient, - handlers: Handlers{ - Apply: d.apply, - Delete: d.delete, - }, - labels: map[string]string{ - "hello": "world", - }, - } - close(done) -}, 120) - -var _ = AfterSuite(func() { - By("Tearing down the test environment") - err := testEnv.Stop() - Expect(err).ToNot(HaveOccurred()) -}) - -var _ = Describe("Test Workflow Provider Kube", func() { - It("apply and read", func() { - ctx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - - v, err := value.NewValue(fmt.Sprintf(` -value:{ - %s - metadata: name: "app" - metadata: labels: { - "test": "test" - } -} -cluster: "" -`, componentStr), nil, "") - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.Apply(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - // test patch - v, err = value.NewValue(fmt.Sprintf(` - value:{ - %s - metadata: name: "app" - } - cluster: "" - `, componentStr), nil, "") - Expect(err).ToNot(HaveOccurred()) - err = p.Apply(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - workload := &corev1.Pod{} - Eventually(func() error { - return k8sClient.Get(context.Background(), client.ObjectKey{ - Namespace: "default", - Name: "app", - }, workload) - }, time.Second*2, time.Millisecond*300).Should(BeNil()) - Expect(len(workload.GetLabels())).To(Equal(2)) - - v, err = value.NewValue(fmt.Sprintf(` -value: { -%s -metadata: name: "app" -} -cluster: "" -`, componentStr), nil, "") - Expect(err).ToNot(HaveOccurred()) - err = p.Read(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - result, err := v.LookupValue("value") - Expect(err).ToNot(HaveOccurred()) - - expected := new(unstructured.Unstructured) - ev, err := result.MakeValue(expectedCue) - Expect(err).ToNot(HaveOccurred()) - err = ev.UnmarshalTo(expected) - Expect(err).ToNot(HaveOccurred()) - - err = result.FillObject(expected.Object) - Expect(err).ToNot(HaveOccurred()) - }) - - It("patch & apply", func() { - ctx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - - v, err := value.NewValue(fmt.Sprintf(` -value:{ - %s - metadata: name: "test-app-1" - metadata: labels: { - "test": "test" - } -} -cluster: "" -`, componentStr), nil, "") - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.Apply(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - - v, err = value.NewValue(` -value: { - apiVersion: "v1" - kind: "Pod" - metadata: name: "test-app-1" -} -cluster: "" -patch: { - metadata: name: "test-app-1" - spec: { - containers: [{ - // +patchStrategy=retainKeys - image: "nginx:notfound" - }] - } -}`, nil, "") - Expect(err).ToNot(HaveOccurred()) - err = p.Patch(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - - pod := &corev1.Pod{} - Expect(err).ToNot(HaveOccurred()) - Eventually(func() error { - return k8sClient.Get(context.Background(), client.ObjectKey{ - Namespace: "default", - Name: "test-app-1", - }, pod) - }, time.Second*2, time.Millisecond*300).Should(BeNil()) - Expect(pod.Name).To(Equal("test-app-1")) - Expect(pod.Spec.Containers[0].Image).To(Equal("nginx:notfound")) - }) - - It("list", func() { - ctx := context.Background() - for i := 2; i >= 0; i-- { - err := k8sClient.Create(ctx, &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("test-%v", i), - Namespace: "default", - Labels: map[string]string{ - "test": "test", - "index": fmt.Sprintf("test-%v", i), - }, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: fmt.Sprintf("test-%v", i), - Image: "busybox", - }, - }, - }, - }) - Expect(err).ToNot(HaveOccurred()) - } - - By("List pods with labels test=test") - v, err := value.NewValue(` -resource: { -apiVersion: "v1" -kind: "Pod" -} -filter: { -namespace: "default" -matchingLabels: { -test: "test" -} -} -cluster: "" -`, nil, "") - Expect(err).ToNot(HaveOccurred()) - wfCtx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.List(mCtx, wfCtx, v, nil) - Expect(err).ToNot(HaveOccurred()) - result, err := v.LookupValue("list") - Expect(err).ToNot(HaveOccurred()) - expected := &metav1.PartialObjectMetadataList{} - err = result.UnmarshalTo(expected) - Expect(err).ToNot(HaveOccurred()) - Expect(len(expected.Items)).Should(Equal(4)) - - By("List pods with labels index=test-1") - v, err = value.NewValue(` -resource: { -apiVersion: "v1" -kind: "Pod" -} -filter: { -matchingLabels: { -index: "test-1" -} -} -cluster: "" -`, nil, "") - Expect(err).ToNot(HaveOccurred()) - err = p.List(mCtx, wfCtx, v, nil) - Expect(err).ToNot(HaveOccurred()) - result, err = v.LookupValue("list") - Expect(err).ToNot(HaveOccurred()) - expected = &metav1.PartialObjectMetadataList{} - err = result.UnmarshalTo(expected) - Expect(err).ToNot(HaveOccurred()) - Expect(len(expected.Items)).Should(Equal(1)) - }) - - It("delete", func() { - ctx := context.Background() - err := k8sClient.Create(ctx, &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test", - Namespace: "default", - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: "test", - Image: "busybox", - }, - }, - }, - }) - Expect(err).ToNot(HaveOccurred()) - err = k8sClient.Get(ctx, types.NamespacedName{ - Name: "test", - Namespace: "default", - }, &corev1.Pod{}) - Expect(err).ToNot(HaveOccurred()) - - v, err := value.NewValue(` -value: { -apiVersion: "v1" -kind: "Pod" -metadata: { -name: "test" -namespace: "default" -} -} -cluster: "" -`, nil, "") - Expect(err).ToNot(HaveOccurred()) - wfCtx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.Delete(mCtx, wfCtx, v, nil) - Expect(err).ToNot(HaveOccurred()) - err = k8sClient.Get(ctx, types.NamespacedName{ - Name: "test", - Namespace: "default", - }, &corev1.Pod{}) - Expect(err).To(HaveOccurred()) - Expect(errors.IsNotFound(err)).Should(Equal(true)) - }) - - It("delete with labels", func() { - ctx := context.Background() - err := k8sClient.Create(ctx, &corev1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test", - Namespace: "default", - Labels: map[string]string{ - "test.oam.dev": "true", - }, - }, - Spec: corev1.PodSpec{ - Containers: []corev1.Container{ - { - Name: "test", - Image: "busybox", - }, - }, - }, - }) - Expect(err).ToNot(HaveOccurred()) - err = k8sClient.Get(ctx, types.NamespacedName{ - Name: "test", - Namespace: "default", - }, &corev1.Pod{}) - Expect(err).ToNot(HaveOccurred()) - - v, err := value.NewValue(` -value: { -apiVersion: "v1" -kind: "Pod" -metadata: { - namespace: "default" -} -} -filter: { - namespace: "default" - matchingLabels: { - "test.oam.dev": "true" - } -} -cluster: "" -`, nil, "") - Expect(err).ToNot(HaveOccurred()) - wfCtx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.Delete(mCtx, wfCtx, v, nil) - Expect(err).ToNot(HaveOccurred()) - err = k8sClient.Get(ctx, types.NamespacedName{ - Name: "test", - Namespace: "default", - }, &corev1.Pod{}) - Expect(err).To(HaveOccurred()) - Expect(errors.IsNotFound(err)).Should(Equal(true)) - }) - - It("apply parallel", func() { - ctx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - - v, err := value.NewValue(fmt.Sprintf(` -value:[ - { - %s - metadata: name: "app1" - }, - { - %s - metadata: name: "app1" - } -] -cluster: "" -`, componentStr, componentStr), nil, "") - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.ApplyInParallel(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - }) - - It("test error case", func() { - ctx, err := newWorkflowContextForTest() - Expect(err).ToNot(HaveOccurred()) - - v, err := value.NewValue(` -value: { - kind: "Pod" - apiVersion: "v1" - spec: close({kind: 12}) -}`, nil, "") - Expect(err).ToNot(HaveOccurred()) - mCtx := monitorContext.NewTraceContext(context.Background(), "") - err = p.Apply(mCtx, ctx, v, nil) - Expect(err).To(HaveOccurred()) - - v, _ = value.NewValue(` -value: { - kind: "Pod" - apiVersion: "v1" -} -patch: _|_ -`, nil, "") - err = p.Apply(mCtx, ctx, v, nil) - Expect(err).To(HaveOccurred()) - - v, err = value.NewValue(` -value: { - metadata: { - name: "app-xx" - namespace: "default" - } - kind: "Pod" - apiVersion: "v1" -} -cluster: "test" -`, nil, "") - Expect(err).ToNot(HaveOccurred()) - err = p.Read(mCtx, ctx, v, nil) - Expect(err).ToNot(HaveOccurred()) - errV, err := v.Field("err") - Expect(err).ToNot(HaveOccurred()) - Expect(errV.Exists()).Should(BeTrue()) - - v, err = value.NewValue(` -val: { - metadata: { - name: "app-xx" - namespace: "default" - } - kind: "Pod" - apiVersion: "v1" -} -`, nil, "") - Expect(err).ToNot(HaveOccurred()) - err = p.Read(mCtx, ctx, v, nil) - Expect(err).To(HaveOccurred()) - err = p.Apply(mCtx, ctx, v, nil) - Expect(err).To(HaveOccurred()) - }) -}) - -func newWorkflowContextForTest() (wfContext.Context, error) { - cm := corev1.ConfigMap{} - - testCaseJson, err := yaml.YAMLToJSON([]byte(testCaseYaml)) - if err != nil { - return nil, err - } - err = json.Unmarshal(testCaseJson, &cm) - if err != nil { - return nil, err - } - - wfCtx := new(wfContext.WorkflowContext) - err = wfCtx.LoadFromConfigMap(cm) - return wfCtx, err -} - -var ( - componentStr = `apiVersion: "v1" -kind: "Pod" -metadata: { - labels: { - app: "nginx" - } -} -spec: { - containers: [{ - env: [{ - name: "APP" - value: "nginx" - }] - image: "nginx:1.14.2" - imagePullPolicy: "IfNotPresent" - name: "main" - ports: [{ - containerPort: 8080 - protocol: "TCP" - }] - }] -}` - testCaseYaml = `apiVersion: v1 -data: - test: "" -kind: ConfigMap -metadata: - name: app-v1 -` - expectedCue = `status: { - phase: "Pending" - qosClass: "BestEffort" -} -apiVersion: "v1" -kind: "Pod" -metadata: { - name: "app" - labels: { - app: "nginx" - } - namespace: "default" -} -spec: { - containers: [{ - name: "main" - env: [{ - name: "APP" - value: "nginx" - }] - image: "nginx:1.14.2" - imagePullPolicy: "IfNotPresent" - ports: [{ - containerPort: 8080 - protocol: "TCP" - }] - resources: {} - terminationMessagePath: "/dev/termination-log" - terminationMessagePolicy: "File" - }] - dnsPolicy: "ClusterFirst" - enableServiceLinks: true - preemptionPolicy: "PreemptLowerPriority" - priority: 0 - restartPolicy: "Always" - schedulerName: "default-scheduler" - securityContext: {} - terminationGracePeriodSeconds: 30 - tolerations: [{ - effect: "NoExecute" - key: "node.kubernetes.io/not-ready" - operator: "Exists" - tolerationSeconds: 300 - }, { - effect: "NoExecute" - key: "node.kubernetes.io/unreachable" - operator: "Exists" - tolerationSeconds: 300 - }] -}` -) diff --git a/pkg/providers/legacy/email/email.cue b/pkg/providers/legacy/email/email.cue new file mode 100644 index 0000000..85f4555 --- /dev/null +++ b/pkg/providers/legacy/email/email.cue @@ -0,0 +1,31 @@ +// email.cue + +#SendEmail: { + #do: "send" + #provider: "op" + + // +usage=The info of the sender + from: { + // +usage=The address of the sender + address: string + // +usage=The alias of the sender + alias?: string + // +usage=The password of the sender + password: string + // +usage=The host of the sender server + host: string + // +usage=The port of the sender server + port: int + } + // +usgae=The email address list of the recievers + to: [...string] + // +usage=The content of the email + content: { + // +usage=The subject of the email + subject: string + // +usage=The body of the email + body: string + } + stepID: context.stepSessionID + ... +} diff --git a/pkg/providers/email/send.go b/pkg/providers/legacy/email/email.go similarity index 51% rename from pkg/providers/email/send.go rename to pkg/providers/legacy/email/email.go index 26e2d1a..9a2e027 100644 --- a/pkg/providers/email/send.go +++ b/pkg/providers/legacy/email/email.go @@ -17,15 +17,18 @@ limitations under the License. package email import ( + "context" + _ "embed" "fmt" "sync" "gopkg.in/gomail.v2" - monitorContext "github.com/kubevela/pkg/monitor/context" + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" - wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" + "github.com/kubevela/workflow/pkg/cue/model" + "github.com/kubevela/workflow/pkg/errors" + providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) @@ -34,10 +37,8 @@ const ( ProviderName = "email" ) -type provider struct { -} - -type sender struct { +// Sender is the sender of email +type Sender struct { Address string `json:"address"` Alias string `json:"alias,omitempty"` Password string `json:"password"` @@ -45,75 +46,55 @@ type sender struct { Port int `json:"port"` } -type content struct { +// Content is the content of email +type Content struct { Subject string `json:"subject"` Body string `json:"body"` } +// MailVars . +type MailVars struct { + From Sender `json:"from"` + To []string `json:"to"` + Content Content `json:"content"` +} + +// MailParams . +type MailParams = types.LegacyParams[MailVars] + var emailRoutine sync.Map // Send sends email -func (h *provider) Send(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - stepID, err := v.LookupValue("stepID") - if err != nil { - return err - } - id, err := stepID.String() - if err != nil { - return err - } +func Send(ctx context.Context, params *MailParams) (*any, error) { + pCtx := params.ProcessContext + act := params.Action + id := fmt.Sprint(pCtx.GetData(model.ContextStepSessionID)) routine, ok := emailRoutine.Load(id) if ok { switch routine { case "success": emailRoutine.Delete(id) - return nil + return nil, nil case "initializing", "sending": act.Wait("wait for the email") - return nil + return nil, errors.GenericActionError(errors.ActionWait) default: emailRoutine.Delete(id) - return fmt.Errorf("failed to send email: %v", routine) + return nil, fmt.Errorf("failed to send email: %v", routine) } } else { emailRoutine.Store(id, "initializing") } - s, err := v.LookupValue("from") - if err != nil { - return err - } - - senderValue := &sender{} - if err := s.UnmarshalTo(senderValue); err != nil { - return err - } - - r, err := v.LookupValue("to") - if err != nil { - return err - } - receiverValue := &[]string{} - if err := r.UnmarshalTo(receiverValue); err != nil { - return err - } - - c, err := v.LookupValue("content") - if err != nil { - return err - } - contentValue := &content{} - if err := c.UnmarshalTo(contentValue); err != nil { - return err - } - + sender := params.Params.From + content := params.Params.Content m := gomail.NewMessage() - m.SetAddressHeader("From", senderValue.Address, senderValue.Alias) - m.SetHeader("To", *receiverValue...) - m.SetHeader("Subject", contentValue.Subject) - m.SetBody("text/html", contentValue.Body) + m.SetAddressHeader("From", sender.Address, sender.Alias) + m.SetHeader("To", params.Params.To...) + m.SetHeader("Subject", content.Subject) + m.SetBody("text/html", content.Body) - dial := gomail.NewDialer(senderValue.Host, senderValue.Port, senderValue.Address, senderValue.Password) + dial := gomail.NewDialer(sender.Host, sender.Port, sender.Address, sender.Password) go func() { if routine, ok := emailRoutine.Load(id); ok && routine == "initializing" { emailRoutine.Store(id, "sending") @@ -125,13 +106,20 @@ func (h *provider) Send(ctx monitorContext.Context, wfCtx wfContext.Context, v * } }() act.Wait("wait for the email") - return nil + return nil, errors.GenericActionError(errors.ActionWait) } -// Install register handlers to provider discover. -func Install(p types.Providers) { - prd := &provider{} - p.Register(ProviderName, map[string]types.Handler{ - "send": prd.Send, - }) +//go:embed email.cue +var template string + +// GetTemplate returns the template +func GetTemplate() string { + return template +} + +// GetProviders returns the provider +func GetProviders() map[string]cuexruntime.ProviderFn { + return map[string]cuexruntime.ProviderFn{ + "send": providertypes.LegacyGenericProviderFn[MailVars, any](Send), + } } diff --git a/pkg/providers/email/send_test.go b/pkg/providers/legacy/email/email_test.go similarity index 51% rename from pkg/providers/email/send_test.go rename to pkg/providers/legacy/email/email_test.go index a747a34..7c209ea 100644 --- a/pkg/providers/email/send_test.go +++ b/pkg/providers/legacy/email/email_test.go @@ -17,6 +17,7 @@ limitations under the License. package email import ( + "context" "errors" "fmt" "reflect" @@ -27,86 +28,56 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/gomail.v2" - "github.com/kubevela/workflow/pkg/cue/model/value" + "github.com/kubevela/workflow/pkg/cue/model" + "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/mock" - "github.com/kubevela/workflow/pkg/providers" + "github.com/kubevela/workflow/pkg/types" ) func TestSendEmail(t *testing.T) { + ctx := context.Background() var dial *gomail.Dialer + pCtx := process.NewContext(process.ContextData{}) + pCtx.PushData(model.ContextStepSessionID, "test-id") + act := &mock.Action{} + testCases := map[string]struct { + vars MailVars from string expectedErr error errMsg string }{ "success": { - from: ` -from: { -address: "kubevela@gmail.com" -alias: "kubevela-bot" -password: "pwd" -host: "smtp.test.com" -port: 465 -} -to: ["user1@gmail.com", "user2@gmail.com"] -content: { -subject: "Subject" -body: "Test body." -} -stepID: "success" -`, - }, - "no-step-id": { - from: ``, - expectedErr: errors.New("failed to lookup value: var(path=stepID) not exist"), - }, - "no-sender": { - from: `stepID:"no-sender"`, - expectedErr: errors.New("failed to lookup value: var(path=from) not exist"), - }, - "no-receiver": { - from: ` -from: { -address: "kubevela@gmail.com" -alias: "kubevela-bot" -password: "pwd" -host: "smtp.test.com" -port: 465 -} -stepID: "no-receiver" -`, - expectedErr: errors.New("failed to lookup value: var(path=to) not exist"), - }, - "no-content": { - from: ` -from: { -address: "kubevela@gmail.com" -alias: "kubevela-bot" -password: "pwd" -host: "smtp.test.com" -port: 465 -} -to: ["user1@gmail.com", "user2@gmail.com"] -stepID: "no-content" -`, - expectedErr: errors.New("failed to lookup value: var(path=content) not exist"), + vars: MailVars{ + From: Sender{ + Address: "kubevela@gmail.com", + Alias: "kubevela-bot", + Password: "pwd", + Host: "smtp.test.com", + Port: 465, + }, + To: []string{"user1@gmail.com", "user2@gmail.com"}, + Content: Content{ + Subject: "Subject", + Body: "Test body.", + }, + }, }, "send-fail": { - from: ` -from: { -address: "kubevela@gmail.com" -alias: "kubevela-bot" -password: "pwd" -host: "smtp.test.com" -port: 465 -} -to: ["user1@gmail.com", "user2@gmail.com"] -content: { -subject: "Subject" -body: "Test body." -} -stepID: "send-fail" -`, + vars: MailVars{ + From: Sender{ + Address: "kubevela@gmail.com", + Alias: "kubevela-bot", + Password: "pwd", + Host: "smtp.test.com", + Port: 465, + }, + To: []string{"user1@gmail.com", "user2@gmail.com"}, + Content: Content{ + Subject: "fail", + Body: "Test body.", + }, + }, errMsg: "fail to send", }, } @@ -120,8 +91,6 @@ stepID: "send-fail" }) defer patch.Reset() - act := &mock.Action{} - if tc.errMsg != "" { patch.Reset() patch = ApplyMethod(reflect.TypeOf(dial), "DialAndSend", func(_ *gomail.Dialer, _ ...*gomail.Message) error { @@ -129,10 +98,13 @@ stepID: "send-fail" }) defer patch.Reset() } - v, err := value.NewValue(tc.from, nil, "") - r.NoError(err) - prd := &provider{} - err = prd.Send(nil, nil, v, act) + _, err := Send(ctx, &MailParams{ + Params: tc.vars, + RuntimeParams: types.RuntimeParams{ + ProcessContext: pCtx, + Action: act, + }, + }) if tc.expectedErr != nil { r.Equal(tc.expectedErr.Error(), err.Error()) return @@ -142,7 +114,13 @@ stepID: "send-fail" // mock reconcile time.Sleep(time.Second) - err = prd.Send(nil, nil, v, act) + _, err = Send(ctx, &MailParams{ + Params: tc.vars, + RuntimeParams: types.RuntimeParams{ + ProcessContext: pCtx, + Action: act, + }, + }) if tc.errMsg != "" { r.Equal(fmt.Errorf("failed to send email: %s", tc.errMsg), err) return @@ -151,12 +129,3 @@ stepID: "send-fail" }) } } - -func TestInstall(t *testing.T) { - p := providers.NewProviders() - Install(p) - h, ok := p.GetHandler("email", "send") - r := require.New(t) - r.Equal(ok, true) - r.Equal(h != nil, true) -} diff --git a/pkg/providers/legacy/http/http.cue b/pkg/providers/legacy/http/http.cue new file mode 100644 index 0000000..566674e --- /dev/null +++ b/pkg/providers/legacy/http/http.cue @@ -0,0 +1,54 @@ +// http.cue + +#HTTPDo: { + #do: "do" + #provider: "op" + + // +usage=The method of HTTP request + method: *"GET" | "POST" | "PUT" | "DELETE" + // +usage=The url to request + url: string + // +usage=The request config + request?: { + // +usage=The timeout of this request + timeout?: string + // +usage=The request body + body?: string + // +usage=The header of the request + header?: [string]: string + // +usage=The trailer of the request + trailer?: [string]: string + // +usage=The rate limiter of the request + ratelimiter?: { + limit: int + period: string + } + ... + } + // +usgae=The tls config of the request + tls_config?: { + secret: string + namespace: context.namespace + } + // +usage=The response of the request will be filled in this field after the action is executed + response: { + // +usage=The body of the response + body: string + // +usage=The header of the response + header?: [string]: [...string] + // +usage=The trailer of the response + trailer?: [string]: [...string] + // +usage=The status code of the response + statusCode: int + ... + } + ... +} + +#HTTPGet: #HTTPDo & {method: "GET"} + +#HTTPPost: #HTTPDo & {method: "POST"} + +#HTTPPut: #HTTPDo & {method: "PUT"} + +#HTTPDelete: #HTTPDo & {method: "DELETE"} diff --git a/pkg/providers/legacy/http/http.go b/pkg/providers/legacy/http/http.go new file mode 100644 index 0000000..29719ee --- /dev/null +++ b/pkg/providers/legacy/http/http.go @@ -0,0 +1,239 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package http + +import ( + "context" + "crypto/tls" + "crypto/x509" + _ "embed" + "encoding/base64" + "fmt" + "io" + "net/http" + "strings" + "time" + + "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + "github.com/kubevela/pkg/util/singleton" + + "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" + providertypes "github.com/kubevela/workflow/pkg/providers/types" + "github.com/kubevela/workflow/pkg/types" +) + +const ( + // ProviderName is provider name for install. + ProviderName = "http" +) + +var ( + rateLimiter *ratelimiter.RateLimiter +) + +func init() { + rateLimiter = ratelimiter.NewRateLimiter(128) +} + +// Request . +type Request struct { + Timeout string `json:"timeout,omitempty"` + Body string `json:"body,omitempty"` + Header map[string]string `json:"header,omitempty"` + Trailer map[string]string `json:"trailer,omitempty"` + RateLimiter *RateLimiter `json:"rateLimiter,omitempty"` +} + +// RateLimiter . +type RateLimiter struct { + Limit int `json:"limit"` + Period string `json:"period"` +} + +// TLSConfig . +type TLSConfig struct { + Secret string `json:"secret"` + Namespace string `json:"namespace"` +} + +// RequestVars is the vars for http request +type RequestVars struct { + Method string `json:"method"` + URL string `json:"url"` + Request *Request `json:"request,omitempty"` + TLSConfig *TLSConfig `json:"tls_config,omitempty"` +} + +// ResponseVars is the vars for http response +type ResponseVars struct { + Body string `json:"body"` + Header http.Header `json:"header,omitempty"` + Trailer http.Header `json:"trailer,omitempty"` + StatusCode int `json:"statusCode"` +} + +// DoParams is the params for http request +type DoParams = types.LegacyParams[RequestVars] + +// Do process http request. +func Do(ctx context.Context, params *DoParams) (*ResponseVars, error) { + return runHTTP(ctx, params) +} + +func runHTTP(ctx context.Context, params *DoParams) (*ResponseVars, error) { + var ( + err error + header, trailer http.Header + reader io.Reader + ) + defaultClient := &http.Client{ + Transport: http.DefaultTransport, + Timeout: time.Second * 3, + } + method := params.Params.Method + url := params.Params.URL + if request := params.Params.Request; request != nil { + if request.Timeout != "" { + timeout, err := time.ParseDuration(request.Timeout) + if err != nil { + return nil, fmt.Errorf("invalid timeout %s: %w", timeout, err) + } + defaultClient.Timeout = timeout + } + if request.RateLimiter != nil { + period, err := time.ParseDuration(request.RateLimiter.Period) + if err != nil { + return nil, fmt.Errorf("invalid period %s: %w", period, err) + } + if !rateLimiter.Allow(fmt.Sprintf("%s-%s", method, strings.Split(url, "?")[0]), request.RateLimiter.Limit, period) { + return nil, errors.New("request exceeds the rate limiter") + } + } + reader = strings.NewReader(request.Body) + header = parseHeaders(request.Header) + trailer = parseHeaders(request.Trailer) + } + if len(header) == 0 { + header = map[string][]string{} + header.Set("Content-Type", "application/json") + } + + req, err := http.NewRequestWithContext(context.Background(), method, url, reader) + if err != nil { + return nil, err + } + req.Header = header + req.Trailer = trailer + + if params.Params.TLSConfig != nil { + if tr, err := getTransport(ctx, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil { + defaultClient.Transport = tr + } + } + + resp, err := defaultClient.Do(req) + if err != nil { + return nil, err + } + //nolint:errcheck + defer resp.Body.Close() + b, _ := io.ReadAll(resp.Body) + // parse response body and headers + return &ResponseVars{ + Body: string(b), + Header: resp.Header, + Trailer: resp.Trailer, + StatusCode: resp.StatusCode, + }, nil +} + +func getTransport(ctx context.Context, secretName, ns string) (http.RoundTripper, error) { + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + NextProtos: []string{"http/1.1"}, + }, + } + objectKey := client.ObjectKey{ + Namespace: ns, + Name: secretName, + } + index := strings.Index(secretName, "/") + if index > 0 { + objectKey.Namespace = secretName[:index-1] + objectKey.Name = secretName[index:] + } + secret := new(v1.Secret) + if err := singleton.KubeClient.Get().Get(ctx, objectKey, secret); err != nil { + return nil, err + } + if ca, ok := secret.Data["ca.crt"]; ok { + caData, err := base64.StdEncoding.DecodeString(string(ca)) + if err != nil { + return nil, err + } + pool := x509.NewCertPool() + pool.AppendCertsFromPEM(caData) + tr.TLSClientConfig.RootCAs = pool + } + var err error + var certData, keyData []byte + if clientCert, ok := secret.Data["client.crt"]; ok { + certData, err = base64.StdEncoding.DecodeString(string(clientCert)) + if err != nil { + return nil, err + } + } + if clientKey, ok := secret.Data["client.key"]; ok { + keyData, err = base64.StdEncoding.DecodeString(string(clientKey)) + if err != nil { + return nil, err + } + } + cliCrt, err := tls.X509KeyPair(certData, keyData) + if err != nil { + return nil, errors.WithMessage(err, "parse client keypair") + } + tr.TLSClientConfig.Certificates = []tls.Certificate{cliCrt} + return tr, nil +} + +func parseHeaders(obj map[string]string) http.Header { + h := http.Header{} + for k, v := range obj { + h.Add(k, v) + } + return h +} + +//go:embed http.cue +var template string + +// GetTemplate returns the cue template +func GetTemplate() string { + return template +} + +// GetProviders returns the providers +func GetProviders() map[string]cuexruntime.ProviderFn { + return map[string]cuexruntime.ProviderFn{ + "do": providertypes.LegacyGenericProviderFn[RequestVars, ResponseVars](Do), + } +} diff --git a/pkg/providers/http/do_test.go b/pkg/providers/legacy/http/http_test.go similarity index 54% rename from pkg/providers/http/do_test.go rename to pkg/providers/legacy/http/http_test.go index 861811a..30cbd75 100644 --- a/pkg/providers/http/do_test.go +++ b/pkg/providers/legacy/http/http_test.go @@ -35,12 +35,10 @@ import ( v1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - monitorContext "github.com/kubevela/pkg/monitor/context" - + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/providers" - "github.com/kubevela/workflow/pkg/providers/http/ratelimiter" - "github.com/kubevela/workflow/pkg/providers/http/testdata" + "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" + "github.com/kubevela/workflow/pkg/providers/legacy/http/testdata" ) func TestHttpDo(t *testing.T) { @@ -49,208 +47,186 @@ func TestHttpDo(t *testing.T) { defer func() { close(shutdown) }() - ctx := monitorContext.NewTraceContext(context.Background(), "") - baseTemplate := ` - url: string - request?: close({ - timeout?: string - body?: string - header?: [string]: string - trailer?: [string]: string - ratelimiter?: { - limit: int - period: string - } - }) - response: close({ - body: string - header?: [string]: [...string] - trailer?: [string]: [...string] - statusCode: int - }) -` + ctx := context.Background() + testCases := map[string]struct { - request string - expectedBody string - expectedErr string - statusCode int + request RequestVars + expected ResponseVars + expectedErr string }{ "hello": { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/hello" -request: { - timeout: "2s" -}`, - expectedBody: `hello`, - statusCode: 200, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/hello", + Request: &Request{ + Timeout: "2s", + }, + }, + expected: ResponseVars{ + Body: "hello", + StatusCode: 200, + }, }, "echo": { - request: baseTemplate + ` -method: "POST" -url: "http://127.0.0.1:1229/echo" -request:{ - body: "I am vela" - header: "Content-Type": "text/plain; charset=utf-8" -}`, - expectedBody: `I am vela`, - statusCode: 200, + request: RequestVars{ + Method: "POST", + URL: "http://127.0.0.1:1229/echo", + Request: &Request{ + Body: "I am vela", + Header: map[string]string{ + "Content-Type": "text/plain; charset=utf-8", + }, + }, + }, + expected: ResponseVars{ + Body: "I am vela", + StatusCode: 200, + }, }, "json": { - request: ` -import ("encoding/json") -foo: { - name: "foo" - score: 100 -} - -method: "POST" -url: "http://127.0.0.1:1229/echo" -request:{ - body: json.Marshal(foo) - header: "Content-Type": "application/json; charset=utf-8" -}` + baseTemplate, - expectedBody: `{"name":"foo","score":100}`, - statusCode: 200, + request: RequestVars{ + Method: "POST", + URL: "http://127.0.0.1:1229/echo", + Request: &Request{ + Body: `{"name":"foo","score":100}`, + Header: map[string]string{ + "Content-Type": "text/plain; charset=utf-8", + }, + }, + }, + expected: ResponseVars{ + Body: `{"name":"foo","score":100}`, + StatusCode: 200, + }, }, "timeout": { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/timeout" -request: { - timeout: "1s" -}`, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/timeout", + Request: &Request{ + Timeout: "1s", + }, + }, + expected: ResponseVars{ + Body: `{"name":"foo","score":100}`, + StatusCode: 200, + }, expectedErr: "context deadline exceeded", }, "not-timeout": { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/timeout" -request: { - timeout: "3s" -}`, - expectedBody: `hello`, - statusCode: 200, - }, - "invalid-timeout": { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/timeout" -request: { - timeout: "test" -}`, - expectedErr: "invalid duration", + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/timeout", + Request: &Request{ + Timeout: "3s", + }, + }, + expected: ResponseVars{ + Body: "hello", + StatusCode: 200, + }, }, "notfound": { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/notfound" -`, - statusCode: 404, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/notfound", + Request: &Request{ + Timeout: "1s", + }, + }, + expected: ResponseVars{ + StatusCode: 404, + }, }, } - for tName, tCase := range testCases { + for tName, tc := range testCases { r := require.New(t) - v, err := value.NewValue(tCase.request, nil, "") - r.NoError(err, tName) - prd := &provider{} - err = prd.Do(ctx, nil, v, nil) - if tCase.expectedErr != "" { + res, err := Do(ctx, &DoParams{ + Params: tc.request, + }) + if tc.expectedErr != "" { r.Error(err) - r.Contains(err.Error(), tCase.expectedErr) + r.Contains(err.Error(), tc.expectedErr) continue } r.NoError(err, tName) - body, err := v.LookupValue("response", "body") - r.NoError(err, tName) - ret, err := body.CueValue().String() - r.NoError(err) - r.Equal(ret, tCase.expectedBody, tName) - code, err := v.LookupValue("response", "statusCode") - r.NoError(err, tName) - sc, err := code.CueValue().Int64() - r.NoError(err) - r.Equal(tCase.statusCode, int(sc), tName) + r.Equal(res.Body, tc.expected.Body, tName) + r.Equal(res.StatusCode, tc.expected.StatusCode, tName) } // test ratelimiter rateLimiter = ratelimiter.NewRateLimiter(1) limiterTestCases := []struct { - request string + request RequestVars expectedErr string }{ { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/hello" -request: { - ratelimiter: { - limit: 1 - period: "1m" - } -}`}, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/hello", + Request: &Request{ + RateLimiter: &RateLimiter{ + Limit: 1, + Period: "1m", + }, + }, + }, + }, { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/hello?query=1" -request: { - ratelimiter: { - limit: 1 - period: "1m" - } -}`, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/hello?query=1", + Request: &Request{ + RateLimiter: &RateLimiter{ + Limit: 1, + Period: "1m", + }, + }, + }, expectedErr: "request exceeds the rate limiter", }, { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/echo" -request: { - ratelimiter: { - limit: 1 - period: "1m" - } -}`, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/echo", + Request: &Request{ + RateLimiter: &RateLimiter{ + Limit: 1, + Period: "1m", + }, + }, + }, }, { - request: baseTemplate + ` -method: "GET" -url: "http://127.0.0.1:1229/hello?query=2" -request: { - ratelimiter: { - limit: 1 - period: "1m" - } -}`, + request: RequestVars{ + Method: "GET", + URL: "http://127.0.0.1:1229/hello?query=2", + Request: &Request{ + RateLimiter: &RateLimiter{ + Limit: 1, + Period: "1m", + }, + }, + }, }, } - for tName, tCase := range limiterTestCases { + for tName, tc := range limiterTestCases { r := require.New(t) - v, err := value.NewValue(tCase.request, nil, "") - r.NoError(err, tName) - prd := &provider{} - err = prd.Do(ctx, nil, v, nil) - if tCase.expectedErr != "" { + _, err := Do(ctx, &DoParams{ + Params: tc.request, + }) + if tc.expectedErr != "" { r.Error(err) - r.Contains(err.Error(), tCase.expectedErr) + r.Contains(err.Error(), tc.expectedErr) continue } r.NoError(err, tName) } } -func TestInstall(t *testing.T) { - r := require.New(t) - p := providers.NewProviders() - Install(p, nil, "") - h, ok := p.GetHandler("http", "do") - r.Equal(ok, true) - r.Equal(h != nil, true) -} - func runMockServer(shutdown chan struct{}) { http.HandleFunc("/timeout", func(w http.ResponseWriter, req *http.Request) { time.Sleep(time.Second * 2) @@ -286,7 +262,7 @@ func runMockServer(shutdown chan struct{}) { } func TestHTTPSDo(t *testing.T) { - ctx := monitorContext.NewTraceContext(context.Background(), "") + ctx := context.Background() s := newMockHttpsServer() defer s.Close() cli := &test.MockClient{ @@ -302,6 +278,7 @@ func TestHTTPSDo(t *testing.T) { return nil }, } + singleton.KubeClient.Set(cli) r := require.New(t) v, err := value.NewValue(` method: "GET" @@ -309,8 +286,16 @@ url: "https://127.0.0.1:8443/api/v1/token?val=test-token" `, nil, "") r.NoError(err) r.NoError(v.FillObject("certs", "tls_config", "secret")) - prd := &provider{cli, "default"} - err = prd.Do(ctx, nil, v, nil) + _, err = Do(ctx, &DoParams{ + Params: RequestVars{ + Method: "GET", + URL: "https://127.0.0.1:8443/api/v1/token?val=test-token", + TLSConfig: &TLSConfig{ + Secret: "certs", + Namespace: "default", + }, + }, + }) r.NoError(err) } diff --git a/pkg/providers/http/ratelimiter/ratelimiter.go b/pkg/providers/legacy/http/ratelimiter/ratelimiter.go similarity index 100% rename from pkg/providers/http/ratelimiter/ratelimiter.go rename to pkg/providers/legacy/http/ratelimiter/ratelimiter.go diff --git a/pkg/providers/http/ratelimiter/ratelimiter_test.go b/pkg/providers/legacy/http/ratelimiter/ratelimiter_test.go similarity index 100% rename from pkg/providers/http/ratelimiter/ratelimiter_test.go rename to pkg/providers/legacy/http/ratelimiter/ratelimiter_test.go diff --git a/pkg/providers/http/testdata/certs.go b/pkg/providers/legacy/http/testdata/certs.go similarity index 100% rename from pkg/providers/http/testdata/certs.go rename to pkg/providers/legacy/http/testdata/certs.go diff --git a/pkg/providers/legacy/kube/kube.cue b/pkg/providers/legacy/kube/kube.cue new file mode 100644 index 0000000..66b56dd --- /dev/null +++ b/pkg/providers/legacy/kube/kube.cue @@ -0,0 +1,106 @@ +// kube.cue + +#Apply: { + #do: "apply" + #provider: "op" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to apply + value: {...} + // +usage=The patcher that will be applied to the resource, you can define the strategy of list merge through comments. Reference doc here: https://kubevela.io/docs/platform-engineers/traits/patch-trait#patch-in-workflow-step + patch?: {...} + ... +} + +#Patch: { + #do: "patch" + #provider: "op" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to patch, we'll first get the resource from the cluster, then apply the patcher to it + value: {...} + // +usage=The patcher that will be applied to the resource, you can define the strategy of list merge through comments. Reference doc here: https://kubevela.io/docs/platform-engineers/traits/patch-trait#patch-in-workflow-step + patch: {...} + // +usage=The resource after applied will be filled in this field after the action is executed + result?: {...} + ... +} + +#ApplyInParallel: { + #do: "apply-in-parallel" + #provider: "op" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resources to apply in parallel + value: [...{...}] + ... +} + +#Read: { + #do: "read" + #provider: "op" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to read, this field will be filled with the resource read from the cluster after the action is executed + value: {...} + ... +} + +#List: { + #do: "list" + #provider: "op" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to list + resource: { + // +usage=The api version of the resource + apiVersion: string + // +usage=The kind of the resource + kind: string + } + // +usage=The filter to list the resources + filter?: { + // +usage=The namespace to list the resources + namespace: *"" | string + // +usage=The label selector to filter the resources + matchingLabels?: {...} + } + // +usage=The listed resources will be filled in this field after the action is executed + list?: {...} + ... +} + +#Delete: { + #do: "delete" + #provider: "op" + + // +usage=The cluster to use + cluster: *"" | string + // +usage=The resource to delete + value: { + // +usage=The api version of the resource + apiVersion: string + // +usage=The kind of the resource + kind: string + // +usage=The metadata of the resource + metadata: { + // +usage=The name of the resource + name?: string + // +usage=The namespace of the resource + namespace: *"default" | string + } + } + // +usage=The filter to delete the resources + filter?: { + // +usage=The namespace to list the resources + namespace?: string + // +usage=The label selector to filter the resources + matchingLabels?: {...} + } + ... +} diff --git a/pkg/providers/legacy/kube/kube.go b/pkg/providers/legacy/kube/kube.go new file mode 100644 index 0000000..78c9b2f --- /dev/null +++ b/pkg/providers/legacy/kube/kube.go @@ -0,0 +1,331 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kube + +import ( + "context" + _ "embed" + "encoding/json" + + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + ktypes "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + "github.com/kubevela/pkg/multicluster" + "github.com/kubevela/pkg/util/k8s" + "github.com/kubevela/pkg/util/k8s/patch" + "github.com/kubevela/pkg/util/singleton" + + "github.com/kubevela/workflow/pkg/cue/model" + providertypes "github.com/kubevela/workflow/pkg/providers/types" + "github.com/kubevela/workflow/pkg/types" +) + +const ( + // AnnoWorkflowLastAppliedConfig is the annotation for last applied config + AnnoWorkflowLastAppliedConfig = "workflow.oam.dev/last-applied-configuration" + // AnnoWorkflowLastAppliedTime is annotation for last applied time + AnnoWorkflowLastAppliedTime = "workflow.oam.dev/last-applied-time" +) + +type provider struct { + handlers providertypes.KubeHandlers +} + +const ( + // WorkflowResourceCreator is the creator name of workflow resource + WorkflowResourceCreator string = "workflow" +) + +func handleContext(ctx context.Context, cluster string) context.Context { + return multicluster.WithCluster(ctx, cluster) +} + +func apply(ctx context.Context, cluster, owner string, workloads ...*unstructured.Unstructured) error { + cli := singleton.KubeClient.Get() + for _, workload := range workloads { + existing := new(unstructured.Unstructured) + existing.GetObjectKind().SetGroupVersionKind(workload.GetObjectKind().GroupVersionKind()) + if err := cli.Get(ctx, ktypes.NamespacedName{ + Namespace: workload.GetNamespace(), + Name: workload.GetName(), + }, existing); err != nil { + if errors.IsNotFound(err) { + // TODO: make the annotation optional + b, err := workload.MarshalJSON() + if err != nil { + return err + } + if err := k8s.AddAnnotation(workload, AnnoWorkflowLastAppliedConfig, string(b)); err != nil { + return err + } + if err := cli.Create(ctx, workload); err != nil { + return err + } + } else { + return err + } + } else { + patcher, err := patch.ThreeWayMergePatch(existing, workload, &patch.PatchAction{ + UpdateAnno: true, + AnnoLastAppliedConfig: AnnoWorkflowLastAppliedConfig, + AnnoLastAppliedTime: AnnoWorkflowLastAppliedTime, + }) + if err != nil { + return err + } + if err := cli.Patch(ctx, workload, patcher); err != nil { + return err + } + } + } + return nil +} + +func delete(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error { + return singleton.KubeClient.Get().Delete(ctx, manifest) +} + +// ListFilter filter for list resources +type ListFilter struct { + Namespace string `json:"namespace,omitempty"` + MatchingLabels map[string]string `json:"matchingLabels,omitempty"` +} + +// ResourceVars . +type ResourceVars struct { + Resource *unstructured.Unstructured `json:"value"` + Filter *ListFilter `json:"filter,omitempty"` + Cluster string `json:"cluster,omitempty"` +} + +// ResourceReturns . +type ResourceReturns struct { + Resource *unstructured.Unstructured `json:"value"` + Error error `json:"err,omitempty"` +} + +// ResourceParams . +type ResourceParams = types.LegacyParams[ResourceVars] + +// Apply create or update CR in cluster. +func (h *provider) Apply(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { + workload := params.Params.Resource + if workload.GetNamespace() == "" { + workload.SetNamespace("default") + } + for k, v := range params.RuntimeParams.Labels { + if err := k8s.AddLabel(workload, k, v); err != nil { + return nil, err + } + } + deployCtx := handleContext(ctx, params.Params.Cluster) + if err := h.handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { + return nil, err + } + return &ResourceReturns{ + Resource: workload, + }, nil +} + +// ApplyInParallelVars . +type ApplyInParallelVars struct { + Resources []*unstructured.Unstructured `json:"value"` + Cluster string `json:"cluster,omitempty"` +} + +// ApplyInParallelReturns . +type ApplyInParallelReturns struct { + Resource []*unstructured.Unstructured `json:"value"` +} + +// ApplyInParallelParams . +type ApplyInParallelParams = types.LegacyParams[ApplyInParallelVars] + +// ApplyInParallel create or update CRs in parallel. +func (h *provider) ApplyInParallel(ctx context.Context, params *ApplyInParallelParams) (*ApplyInParallelReturns, error) { + workloads := params.Params.Resources + for i := range workloads { + if workloads[i].GetNamespace() == "" { + workloads[i].SetNamespace("default") + } + } + deployCtx := handleContext(ctx, params.Params.Cluster) + if err := h.handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workloads...); err != nil { + return nil, err + } + return &ApplyInParallelReturns{ + Resource: workloads, + }, nil +} + +// Patch patch CR in cluster. +func (h *provider) Patch(ctx context.Context, params *types.LegacyParams[cue.Value]) (cue.Value, error) { + val := params.Params.LookupPath(cue.ParsePath("value")) + obj := new(unstructured.Unstructured) + b, err := val.MarshalJSON() + if err != nil { + return cue.Value{}, err + } + if err := json.Unmarshal(b, obj); err != nil { + return cue.Value{}, err + } + key := client.ObjectKeyFromObject(obj) + if key.Namespace == "" { + key.Namespace = "default" + } + cluster, err := params.Params.LookupPath(cue.ParsePath("cluster")).String() + if err != nil { + return cue.Value{}, err + } + multiCtx := handleContext(ctx, cluster) + if err := singleton.KubeClient.Get().Get(multiCtx, key, obj); err != nil { + return cue.Value{}, err + } + baseVal := cuecontext.New().CompileString("").FillPath(cue.ParsePath(""), obj) + patcher := params.Params.LookupPath(cue.ParsePath("patch")) + + base, err := model.NewBase(baseVal) + if err != nil { + return cue.Value{}, err + } + if err := base.Unify(patcher); err != nil { + return cue.Value{}, err + } + workload, err := base.Unstructured() + if err != nil { + return cue.Value{}, err + } + for k, v := range params.RuntimeParams.Labels { + if err := k8s.AddLabel(workload, k, v); err != nil { + return cue.Value{}, err + } + } + if err := h.handlers.Apply(multiCtx, cluster, WorkflowResourceCreator, workload); err != nil { + return cue.Value{}, err + } + return params.Params.FillPath(cue.ParsePath("result"), workload), nil +} + +// Read get CR from cluster. +func (h *provider) Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { + workload := params.Params.Resource + key := client.ObjectKeyFromObject(workload) + if key.Namespace == "" { + key.Namespace = "default" + } + readCtx := handleContext(ctx, params.Params.Cluster) + if err := singleton.KubeClient.Get().Get(readCtx, key, workload); err != nil { + return &ResourceReturns{ + Error: err, + }, nil + } + return &ResourceReturns{ + Resource: workload, + }, nil +} + +// ListReturns . +type ListReturns struct { + Resources *unstructured.UnstructuredList `json:"list"` + Error error `json:"err,omitempty"` +} + +// List lists CRs from cluster. +func (h *provider) List(ctx context.Context, params *ResourceParams) (*ListReturns, error) { + workload := params.Params.Resource + list := &unstructured.UnstructuredList{Object: map[string]interface{}{ + "kind": workload.GetKind(), + "apiVersion": workload.GetAPIVersion(), + }} + + filter := params.Params.Filter + listOpts := []client.ListOption{ + client.InNamespace(filter.Namespace), + client.MatchingLabels(filter.MatchingLabels), + } + readCtx := handleContext(ctx, params.Params.Cluster) + if err := singleton.KubeClient.Get().List(readCtx, list, listOpts...); err != nil { + return &ListReturns{ + Error: err, + }, nil + } + return &ListReturns{ + Resources: list, + }, nil +} + +// Delete deletes CR from cluster. +func (h *provider) Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { + workload := params.Params.Resource + deleteCtx := handleContext(ctx, params.Params.Cluster) + + if filter := params.Params.Filter; filter != nil { + labelSelector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{MatchLabels: filter.MatchingLabels}) + if err != nil { + return nil, err + } + if err := singleton.KubeClient.Get().DeleteAllOf(deleteCtx, workload, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: filter.Namespace, LabelSelector: labelSelector}}); err != nil { + return &ResourceReturns{ + Error: err, + }, nil + } + return nil, nil + } + + if err := h.handlers.Delete(deleteCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { + return &ResourceReturns{ + Error: err, + }, nil + } + + return nil, nil +} + +//go:embed kube.cue +var template string + +// GetTemplate get kube template. +func GetTemplate() string { + return template +} + +// GetProviders get kube providers. +func GetProviders(handlers *providertypes.KubeHandlers) map[string]cuexruntime.ProviderFn { + if handlers == nil { + handlers = &providertypes.KubeHandlers{ + Apply: apply, + Delete: delete, + } + } + prd := &provider{ + handlers: *handlers, + } + return map[string]cuexruntime.ProviderFn{ + "apply": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](prd.Apply), + "apply-in-parallel": providertypes.LegacyGenericProviderFn[ApplyInParallelVars, ApplyInParallelReturns](prd.ApplyInParallel), + "read": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](prd.Read), + "list": providertypes.LegacyGenericProviderFn[ResourceVars, ListReturns](prd.List), + "delete": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](prd.Delete), + "patch": providertypes.LegacyNativeProviderFn(prd.Patch), + } +} diff --git a/pkg/providers/legacy/kube/kube_test.go b/pkg/providers/legacy/kube/kube_test.go new file mode 100644 index 0000000..e84e3b3 --- /dev/null +++ b/pkg/providers/legacy/kube/kube_test.go @@ -0,0 +1,436 @@ +/* +Copyright 2021 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kube + +import ( + "context" + "fmt" + "testing" + "time" + + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + corev1 "k8s.io/api/core/v1" + crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + k8stypes "k8s.io/apimachinery/pkg/types" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + "k8s.io/client-go/rest" + "k8s.io/utils/pointer" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/envtest" + + "github.com/kubevela/pkg/util/singleton" + + "github.com/kubevela/workflow/pkg/cue/packages" + providertypes "github.com/kubevela/workflow/pkg/providers/types" + "github.com/kubevela/workflow/pkg/types" +) + +// These tests use Ginkgo (BDD-style Go testing framework). Refer to +// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. + +var cfg *rest.Config +var k8sClient client.Client +var testEnv *envtest.Environment +var scheme = runtime.NewScheme() +var pd *packages.PackageDiscover +var p *provider + +func TestProvider(t *testing.T) { + RegisterFailHandler(Fail) + + RunSpecs(t, "Test Definition Suite") +} + +var _ = BeforeSuite(func(done Done) { + By("Bootstrapping test environment") + testEnv = &envtest.Environment{ + ControlPlaneStartTimeout: time.Minute, + ControlPlaneStopTimeout: time.Minute, + UseExistingCluster: pointer.BoolPtr(false), + } + var err error + cfg, err = testEnv.Start() + Expect(err).ToNot(HaveOccurred()) + Expect(cfg).ToNot(BeNil()) + Expect(clientgoscheme.AddToScheme(scheme)).Should(BeNil()) + Expect(crdv1.AddToScheme(scheme)).Should(BeNil()) + // +kubebuilder:scaffold:scheme + By("Create the k8s client") + k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) + Expect(err).ToNot(HaveOccurred()) + Expect(k8sClient).ToNot(BeNil()) + pd, err = packages.NewPackageDiscover(cfg) + Expect(err).ToNot(HaveOccurred()) + + singleton.KubeClient.Set(k8sClient) + p = &provider{ + handlers: providertypes.KubeHandlers{ + Apply: apply, + Delete: delete, + }, + } + close(done) +}, 120) + +var _ = AfterSuite(func() { + By("Tearing down the test environment") + err := testEnv.Stop() + Expect(err).ToNot(HaveOccurred()) +}) + +var _ = Describe("Test Workflow Provider Kube", func() { + It("apply and read", func() { + ctx := context.Background() + ctx = providertypes.WithLabelParams(ctx, map[string]string{ + "hello": "world", + }) + un := testUnstructured.DeepCopy() + un.SetName("app") + un.SetLabels(map[string]string{ + "test": "test", + }) + res, err := p.Apply(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: un, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(res.Resource.GetLabels()).Should(Equal(un.GetLabels())) + workload := &corev1.Pod{} + Eventually(func() error { + return k8sClient.Get(context.Background(), client.ObjectKey{ + Namespace: "default", + Name: "app", + }, workload) + }, time.Second*2, time.Millisecond*300).Should(BeNil()) + Expect(workload.GetLabels()).Should(Equal(map[string]string{ + "test": "test", + "hello": "world", + })) + + res, err = p.Read(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + "metadata": map[string]interface{}{ + "name": "app", + }, + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(res.Error).Should(BeNil()) + Expect(res.Resource.GetLabels()).Should(Equal(map[string]string{ + "test": "test", + "hello": "world", + })) + }) + + It("patch & apply", func() { + ctx := context.Background() + + un := testUnstructured + un.SetName("test-app-1") + un.SetLabels(map[string]string{ + "test": "test", + }) + _, err := p.Apply(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &un, + }, + }) + Expect(err).ToNot(HaveOccurred()) + + v := cuecontext.New().CompileString(` +value: { + apiVersion: "v1" + kind: "Pod" + metadata: name: "test-app-1" +} +cluster: "" +patch: { + metadata: name: "test-app-1" + spec: { + containers: [{ + // +patchStrategy=retainKeys + image: "nginx:notfound" + }] + } +} +`) + _, err = p.Patch(ctx, &types.LegacyParams[cue.Value]{ + Params: v, + }) + Expect(err).ToNot(HaveOccurred()) + + pod := &corev1.Pod{} + Expect(err).ToNot(HaveOccurred()) + Eventually(func() error { + return k8sClient.Get(context.Background(), client.ObjectKey{ + Namespace: "default", + Name: "test-app-1", + }, pod) + }, time.Second*2, time.Millisecond*300).Should(BeNil()) + Expect(pod.Name).To(Equal("test-app-1")) + Expect(pod.Spec.Containers[0].Image).To(Equal("nginx:notfound")) + }) + + It("list", func() { + ctx := context.Background() + for i := 2; i >= 0; i-- { + err := k8sClient.Create(ctx, &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("test-%v", i), + Namespace: "default", + Labels: map[string]string{ + "test": "test", + "index": fmt.Sprintf("test-%v", i), + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: fmt.Sprintf("test-%v", i), + Image: "busybox", + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + } + + By("List pods with labels test=test") + res, err := p.List(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + }, + }, + Filter: &ListFilter{ + Namespace: "default", + MatchingLabels: map[string]string{ + "test": "test", + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(len(res.Resources.Items)).Should(Equal(5)) + + By("List pods with labels index=test-1") + res, err = p.List(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + }, + }, + Filter: &ListFilter{ + MatchingLabels: map[string]string{ + "index": "test-1", + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(len(res.Resources.Items)).Should(Equal(1)) + }) + + It("delete", func() { + ctx := context.Background() + err := k8sClient.Create(ctx, &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "test", + Image: "busybox", + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + err = k8sClient.Get(ctx, k8stypes.NamespacedName{ + Name: "test", + Namespace: "default", + }, &corev1.Pod{}) + Expect(err).ToNot(HaveOccurred()) + + _, err = p.Delete(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + "metadata": map[string]interface{}{ + "name": "test", + "namespace": "default", + }, + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + err = k8sClient.Get(ctx, k8stypes.NamespacedName{ + Name: "test", + Namespace: "default", + }, &corev1.Pod{}) + Expect(err).To(HaveOccurred()) + Expect(errors.IsNotFound(err)).Should(Equal(true)) + }) + + It("delete with labels", func() { + ctx := context.Background() + err := k8sClient.Create(ctx, &corev1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + Namespace: "default", + Labels: map[string]string{ + "test.oam.dev": "true", + }, + }, + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "test", + Image: "busybox", + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + err = k8sClient.Get(ctx, k8stypes.NamespacedName{ + Name: "test", + Namespace: "default", + }, &corev1.Pod{}) + Expect(err).ToNot(HaveOccurred()) + + _, err = p.Delete(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + "metadata": map[string]interface{}{ + "namespace": "default", + }, + }, + }, + Filter: &ListFilter{ + Namespace: "default", + MatchingLabels: map[string]string{ + "test.oam.dev": "true", + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + err = k8sClient.Get(ctx, k8stypes.NamespacedName{ + Name: "test", + Namespace: "default", + }, &corev1.Pod{}) + Expect(err).To(HaveOccurred()) + Expect(errors.IsNotFound(err)).Should(Equal(true)) + }) + + It("apply parallel", func() { + un1 := testUnstructured.DeepCopy() + un1.SetName("app1") + un2 := testUnstructured.DeepCopy() + un2.SetName("app2") + ctx := context.Background() + _, err := p.ApplyInParallel(ctx, &ApplyInParallelParams{ + Params: ApplyInParallelVars{ + Resources: []*unstructured.Unstructured{un1, un2}, + }, + }) + Expect(err).ToNot(HaveOccurred()) + pod := &corev1.Pod{} + Eventually(func() error { + return k8sClient.Get(context.Background(), client.ObjectKey{ + Namespace: "default", + Name: "app1", + }, pod) + }, time.Second*2, time.Millisecond*300).Should(BeNil()) + Eventually(func() error { + return k8sClient.Get(context.Background(), client.ObjectKey{ + Namespace: "default", + Name: "app2", + }, pod) + }, time.Second*2, time.Millisecond*300).Should(BeNil()) + }) + + It("test error case", func() { + ctx := context.Background() + res, err := p.Read(ctx, &ResourceParams{ + Params: ResourceVars{ + Resource: &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + "metadata": map[string]interface{}{ + "name": "not-exist", + }, + }, + }, + }, + }) + Expect(err).ToNot(HaveOccurred()) + Expect(res.Error).ShouldNot(BeNil()) + }) +}) + +var ( + testUnstructured = unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Pod", + "metadata": map[string]interface{}{}, + "spec": map[string]interface{}{ + "containers": []interface{}{ + map[string]interface{}{ + "name": "main", + "image": "nginx:1.14.2", + "env": []interface{}{ + map[string]interface{}{ + "name": "APP", + "value": "nginx", + }, + }, + }, + }, + }, + }, + } +) diff --git a/pkg/providers/legacy/legacy.go b/pkg/providers/legacy/legacy.go new file mode 100644 index 0000000..d12d387 --- /dev/null +++ b/pkg/providers/legacy/legacy.go @@ -0,0 +1,39 @@ +package legacy + +import ( + "strings" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + + "github.com/kubevela/workflow/pkg/providers/legacy/email" + "github.com/kubevela/workflow/pkg/providers/legacy/http" + "github.com/kubevela/workflow/pkg/providers/legacy/kube" + "github.com/kubevela/workflow/pkg/providers/legacy/metrics" + "github.com/kubevela/workflow/pkg/providers/legacy/util" + "github.com/kubevela/workflow/pkg/providers/legacy/workspace" + providertypes "github.com/kubevela/workflow/pkg/providers/types" +) + +func registerProviders(providers map[string]cuexruntime.ProviderFn, new map[string]cuexruntime.ProviderFn) map[string]cuexruntime.ProviderFn { + for k, v := range new { + providers[k] = v + } + return providers +} + +// GetLegacyProviders get legacy providers +func GetLegacyProviders(handlers *providertypes.KubeHandlers) map[string]cuexruntime.ProviderFn { + providers := make(map[string]cuexruntime.ProviderFn, 0) + registerProviders(providers, email.GetProviders()) + registerProviders(providers, http.GetProviders()) + registerProviders(providers, kube.GetProviders(handlers)) + registerProviders(providers, metrics.GetProviders()) + registerProviders(providers, util.GetProviders()) + registerProviders(providers, workspace.GetProviders()) + return providers +} + +// GetLegacyTemplate get legacy template +func GetLegacyTemplate() string { + return strings.Join([]string{email.GetTemplate(), http.GetTemplate(), kube.GetTemplate(), metrics.GetTemplate(), util.GetTemplate(), workspace.GetTemplate()}, "\n") +} diff --git a/pkg/providers/legacy/metrics/metrics.cue b/pkg/providers/legacy/metrics/metrics.cue new file mode 100644 index 0000000..c0a7f5d --- /dev/null +++ b/pkg/providers/legacy/metrics/metrics.cue @@ -0,0 +1,13 @@ +// metrics.cue + +#PromCheck: { + #do: "promCheck" + #provider: "op" + + query: string + metricEndpoint: *"http://prometheus-server.o11y-system.svc:9090" | string + condition: string + failDuration: *"2m" | string + duration: *"5m" | string + ... +} diff --git a/pkg/providers/legacy/metrics/prom_check.go b/pkg/providers/legacy/metrics/prom_check.go new file mode 100644 index 0000000..4babe98 --- /dev/null +++ b/pkg/providers/legacy/metrics/prom_check.go @@ -0,0 +1,216 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "context" + _ "embed" + "fmt" + "strconv" + "time" + + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" + "github.com/prometheus/client_golang/api" + v1 "github.com/prometheus/client_golang/api/prometheus/v1" + prommodel "github.com/prometheus/common/model" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + + wfContext "github.com/kubevela/workflow/pkg/context" + "github.com/kubevela/workflow/pkg/cue/model" + providertypes "github.com/kubevela/workflow/pkg/providers/types" + "github.com/kubevela/workflow/pkg/types" +) + +const ( + // ProviderName is provider name for install. + ProviderName = "metrics" +) + +// PromVars . +type PromVars struct { + Query string `json:"query"` + MetricEndpoint string `json:"metricEndpoint"` + Condition string `json:"condition"` + Duration string `json:"duration"` + FailDuration string `json:"failDuration"` +} + +// PromReturns . +type PromReturns struct { + Message string `json:"message,omitempty"` + Failed bool `json:"failed"` + Result bool `json:"result"` +} + +// PromParams . +type PromParams = types.LegacyParams[PromVars] + +// PromCheck do health check from metrics from prometheus +func PromCheck(ctx context.Context, params *PromParams) (*PromReturns, error) { + pCtx := params.ProcessContext + wfCtx := params.WorkflowContext + stepID := fmt.Sprint(pCtx.GetData(model.ContextStepSessionID)) + + valueStr, err := getQueryResult(ctx, params.Params) + if err != nil { + return nil, err + } + + res, err := compareValueWithCondition(ctx, valueStr, params.Params) + if err != nil { + return nil, err + } + + if res { + // meet the condition + return handleSuccessCompare(wfCtx, stepID, valueStr, params.Params) + } + return handleFailCompare(wfCtx, stepID, valueStr, params.Params) +} + +func handleSuccessCompare(wfCtx wfContext.Context, stepID, valueStr string, vars PromVars) (*PromReturns, error) { + // clean up fail timeStamp + setMetricsStatusTime(wfCtx, stepID, "fail", 0) + + st := getMetricsStatusTime(wfCtx, stepID, "success") + if st == 0 { + // first success + setMetricsStatusTime(wfCtx, stepID, "success", time.Now().Unix()) + return &PromReturns{ + Result: false, + Failed: false, + Message: fmt.Sprintf("The healthy condition should be %s, and the query result is %s, indicating success.", vars.Condition, valueStr), + }, nil + } + successTime := time.Unix(st, 0) + duration, err := time.ParseDuration(vars.Duration) + if err != nil { + return nil, fmt.Errorf("failed to parse duration %s: %w", vars.Duration, err) + } + if successTime.Add(duration).Before(time.Now()) { + return &PromReturns{ + Result: true, + Failed: false, + Message: "The metric check has passed successfully.", + }, nil + } + return &PromReturns{ + Result: false, + Failed: false, + Message: fmt.Sprintf("The healthy condition should be %s, and the query result is %s, indicating success. The success has persisted for %s, with success duration being %s.", vars.Condition, valueStr, time.Since(successTime).String(), vars.Duration), + }, nil +} + +func handleFailCompare(wfCtx wfContext.Context, stepID, valueStr string, vars PromVars) (*PromReturns, error) { + // clean up success timeStamp + setMetricsStatusTime(wfCtx, stepID, "success", 0) + ft := getMetricsStatusTime(wfCtx, stepID, "") + + if ft == 0 { + // first failed + return &PromReturns{ + Result: false, + Failed: false, + Message: fmt.Sprintf("The healthy condition should be %s, but the query result is %s, indicating failure, with the failure duration being %s. This is first failed checking.", vars.Condition, valueStr, vars.FailDuration), + }, nil + } + + failTime := time.Unix(ft, 0) + duration, err := time.ParseDuration(vars.FailDuration) + if err != nil { + return nil, fmt.Errorf("failed to parse duration %s: %w", vars.FailDuration, err) + } + if failTime.Add(duration).Before(time.Now()) { + return &PromReturns{ + Result: false, + Failed: true, + Message: fmt.Sprintf("The healthy condition should be %s, but the query result is %s, indicating failure. The failure has persisted for %s, with the failure duration being %s. The check has terminated.", vars.Condition, valueStr, time.Since(failTime).String(), vars.FailDuration), + }, nil + } + return &PromReturns{ + Result: false, + Failed: false, + Message: fmt.Sprintf("The healthy condition should be %s, but the query result is %s, indicating failure. The failure has persisted for %s, with the failure duration being %s.", vars.Condition, valueStr, time.Since(failTime).String(), vars.FailDuration), + }, nil +} + +func getQueryResult(ctx context.Context, vars PromVars) (string, error) { + c, err := api.NewClient(api.Config{ + Address: vars.MetricEndpoint, + }) + if err != nil { + return "", err + } + promCli := v1.NewAPI(c) + resp, _, err := promCli.Query(ctx, vars.Query, time.Now()) + if err != nil { + return "", err + } + + var valueStr string + switch v := resp.(type) { + case *prommodel.Scalar: + valueStr = v.Value.String() + case prommodel.Vector: + if len(v) != 1 { + return "", fmt.Errorf(fmt.Sprintf("ehe query is returning %d results when it should only return one. Please review the query to identify and fix the issue", len(v))) + } + valueStr = v[0].Value.String() + default: + return "", fmt.Errorf("cannot handle the not query value") + } + return valueStr, nil +} + +func compareValueWithCondition(ctx context.Context, valueStr string, vars PromVars) (bool, error) { + template := fmt.Sprintf("if: %s %s", valueStr, vars.Condition) + res, err := cuecontext.New().CompileString(template).LookupPath(cue.ParsePath("if")).Bool() + if err != nil { + return false, err + } + return res, nil +} + +func setMetricsStatusTime(wfCtx wfContext.Context, stepID string, status string, time int64) { + wfCtx.SetMutableValue(strconv.FormatInt(time, 10), stepID, "metrics", status, "time") +} + +func getMetricsStatusTime(wfCtx wfContext.Context, stepID string, status string) int64 { + str := wfCtx.GetMutableValue(stepID, "metrics", status, "time") + if len(str) == 0 { + return 0 + } + t, _ := strconv.ParseInt(str, 10, 64) + return t +} + +//go:embed metrics.cue +var template string + +// GetTemplate returns the metrics template +func GetTemplate() string { + return template +} + +// GetProviders returns the metrics provider +func GetProviders() map[string]cuexruntime.ProviderFn { + return map[string]cuexruntime.ProviderFn{ + "promCheck": providertypes.LegacyGenericProviderFn[PromVars, PromReturns](PromCheck), + } +} diff --git a/pkg/providers/metrics/prom_check_test.go b/pkg/providers/legacy/metrics/prom_check_test.go similarity index 65% rename from pkg/providers/metrics/prom_check_test.go rename to pkg/providers/legacy/metrics/prom_check_test.go index 1c4efce..6e093c7 100644 --- a/pkg/providers/metrics/prom_check_test.go +++ b/pkg/providers/legacy/metrics/prom_check_test.go @@ -23,27 +23,21 @@ import ( "time" "github.com/crossplane/crossplane-runtime/pkg/test" + "github.com/stretchr/testify/require" + "sigs.k8s.io/controller-runtime/pkg/client" + + "github.com/kubevela/pkg/util/singleton" - monitorContext "github.com/kubevela/pkg/monitor/context" context2 "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/stretchr/testify/assert" - "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/kubevela/workflow/pkg/cue/model" + "github.com/kubevela/workflow/pkg/cue/process" + "github.com/kubevela/workflow/pkg/types" ) func TestMetricCheck(t *testing.T) { srv := runMockPrometheusServer() // no lint - - v, err := value.NewValue(` - metricEndpoint: "http://127.0.0.1:18089" - query: "sum(nginx_ingress_controller_requests{host=\"canary-demo.com\",status=\"200\"})" - duration: "4s" - failDuration: "2s" - condition: ">=3" - stepID: "123456"`, nil, "") - assert.NoError(t, err) - prd := &provider{} - ctx := monitorContext.NewTraceContext(context.Background(), "") + r := require.New(t) + ctx := context.Background() cli := &test.MockClient{ MockCreate: func(ctx context.Context, obj client.Object, opts ...client.CreateOption) error { return nil @@ -55,16 +49,27 @@ func TestMetricCheck(t *testing.T) { return nil }, } - wfCtx, err := context2.NewContext(context.Background(), cli, "default", "v1", nil) - assert.NoError(t, err) - err = prd.PromCheck(ctx, wfCtx, v, nil) - assert.NoError(t, err) - res, err := v.GetBool("result") - assert.NoError(t, err) - assert.Equal(t, res, false) - message, err := v.GetString("message") - assert.NoError(t, err) - assert.Equal(t, message, "The healthy condition should be >=3, and the query result is 10, indicating success.") + singleton.KubeClient.Set(cli) + wfCtx, err := context2.NewContext(context.Background(), "default", "v1", nil) + r.NoError(err) + pCtx := process.NewContext(process.ContextData{}) + pCtx.PushData(model.ContextStepSessionID, "test-id") + res, err := PromCheck(ctx, &PromParams{ + Params: PromVars{ + MetricEndpoint: "http://127.0.0.1:18089", + Query: "sum(nginx_ingress_controller_requests{host=\"canary-demo.com\",status=\"200\"})", + Duration: "4s", + FailDuration: "2s", + Condition: ">=3", + }, + RuntimeParams: types.RuntimeParams{ + WorkflowContext: wfCtx, + ProcessContext: pCtx, + }, + }) + r.NoError(err) + r.Equal(res.Result, false) + r.Equal(res.Message, "The healthy condition should be >=3, and the query result is 10, indicating success.") if err := srv.Close(); err != nil { fmt.Printf("Server shutdown error: %v\n", err) } diff --git a/pkg/providers/legacy/util/util.cue b/pkg/providers/legacy/util/util.cue new file mode 100644 index 0000000..5ee1f73 --- /dev/null +++ b/pkg/providers/legacy/util/util.cue @@ -0,0 +1,46 @@ +// util.cue + +#PatchK8sObject: { + #do: "patch-k8s-object" + #provider: "op" + value: {...} + patch: {...} + result: {...} + ... +} + +#ConvertString: { + #do: "string" + #provider: "op" + + bt: bytes + str?: string + ... +} + +#Log: { + #do: "log" + #provider: "op" + + // +usage=The data to print in the controller logs + data?: {...} | string + // +usage=The log level of the data + level: *3 | int + // +usage=The log source of this step. You can specify it from a url or resources. Note that if you set source in multiple op.#Log, only the latest one will work + source?: close({ + // +usage=Specify the log source url of this step + url: string + }) | close({ + // +usage=Specify the log resources of this step + resources?: [...{ + // +usage=Specify the name of the resource + name?: string + // +usage=Specify the cluster of the resource + cluster?: string + // +usage=Specify the namespace of the resource + namespace?: string + // +usage=Specify the label selector of the resource + labelSelector?: {...} + }] + }) +} diff --git a/pkg/providers/legacy/util/util.go b/pkg/providers/legacy/util/util.go new file mode 100644 index 0000000..e8bfa01 --- /dev/null +++ b/pkg/providers/legacy/util/util.go @@ -0,0 +1,194 @@ +/* + Copyright 2022. The KubeVela Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package util + +import ( + "context" + _ "embed" + "encoding/json" + "fmt" + + "cuelang.org/go/cue" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/klog/v2" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + utilruntime "github.com/kubevela/pkg/util/runtime" + + "github.com/kubevela/workflow/pkg/cue/model" + "github.com/kubevela/workflow/pkg/cue/process" + providertypes "github.com/kubevela/workflow/pkg/providers/types" + "github.com/kubevela/workflow/pkg/types" +) + +// PatchVars is the vars for patch +type PatchVars struct { + Resource cue.Value `json:"value"` + Patch cue.Value `json:"patch"` +} + +// PatchResult is the result for patch +type PatchResult struct { + Result *unstructured.Unstructured `json:"result,omitempty"` + Error string `json:"err"` +} + +// PatchK8sObject patch k8s object +func PatchK8sObject(ctx context.Context, params *types.LegacyParams[cue.Value]) (cue.Value, error) { + base, err := model.NewBase(params.Params.LookupPath(cue.ParsePath("value"))) + if err != nil { + return cue.Value{}, err + } + if err = base.Unify(params.Params.LookupPath(cue.ParsePath("patch"))); err != nil { + return params.Params.FillPath(cue.ParsePath("err"), err.Error()), nil + } + + workload, err := base.Compile() + if err != nil { + return params.Params.FillPath(cue.ParsePath("err"), err.Error()), nil + } + return params.Params.FillPath(cue.ParsePath("result"), params.Params.Context().CompileBytes(workload)), nil +} + +// StringVars . +type StringVars struct { + Byte []byte `json:"bt"` +} + +// StringReturns . +type StringReturns struct { + String string `json:"str"` +} + +// StringParams . +type StringParams = types.LegacyParams[StringVars] + +// String convert byte to string +func String(ctx context.Context, params *StringParams) (*StringReturns, error) { + return &StringReturns{ + String: string(params.Params.Byte), + }, nil +} + +// Resource is the log resources +type Resource struct { + Name string `json:"name,omitempty"` + Namespace string `json:"namespace,omitempty"` + Cluster string `json:"cluster,omitempty"` + LabelSelector map[string]string `json:"labelSelector,omitempty"` +} + +// LogSource is the source of the log +type LogSource struct { + URL string `json:"url,omitempty"` + Resources []Resource `json:"resources,omitempty"` +} + +// LogConfig is the config of the log +type LogConfig struct { + Data bool `json:"data,omitempty"` + Source *LogSource `json:"source,omitempty"` +} + +// LogVars is the vars for log +type LogVars struct { + Data any `json:"data,omitempty"` + Level int `json:"level"` + Source *LogSource `json:"source,omitempty"` +} + +// LogParams . +type LogParams = types.LegacyParams[LogVars] + +// Log print cue value in log +func Log(ctx context.Context, params *LogParams) (*any, error) { + pCtx := params.ProcessContext + stepName := fmt.Sprint(pCtx.GetData(model.ContextStepName)) + wfCtx := params.WorkflowContext + config := make(map[string]LogConfig) + c := wfCtx.GetMutableValue(types.ContextKeyLogConfig) + if c != "" { + if err := json.Unmarshal([]byte(c), &config); err != nil { + return nil, err + } + } + + stepConfig := config[stepName] + data := params.Params.Data + if !utilruntime.IsNil(data) { + stepConfig.Data = true + if err := printDataInLog(ctx, data, params.Params.Level, pCtx); err != nil { + return nil, err + } + } + if source := params.Params.Source; source != nil { + if stepConfig.Source == nil { + stepConfig.Source = &LogSource{} + } + if source.URL != "" { + stepConfig.Source.URL = source.URL + } + if len(source.Resources) != 0 { + stepConfig.Source.Resources = source.Resources + } + } + config[stepName] = stepConfig + b, err := json.Marshal(config) + if err != nil { + return nil, err + } + wfCtx.SetMutableValue(string(b), types.ContextKeyLogConfig) + return nil, nil +} + +func printDataInLog(ctx context.Context, data any, level int, pCtx process.Context) error { + var message string + switch v := data.(type) { + case string: + message = v + default: + b, err := json.Marshal(data) + if err != nil { + return err + } + message = string(b) + } + klog.V(klog.Level(level)).InfoS(message, + model.ContextName, fmt.Sprint(pCtx.GetData(model.ContextName)), + model.ContextNamespace, fmt.Sprint(pCtx.GetData(model.ContextNamespace)), + model.ContextStepName, fmt.Sprint(pCtx.GetData(model.ContextStepName)), + model.ContextStepSessionID, fmt.Sprint(pCtx.GetData(model.ContextStepSessionID)), + ) + return nil +} + +//go:embed util.cue +var template string + +// GetTemplate return the template +func GetTemplate() string { + return template +} + +// GetProviders return the provider +func GetProviders() map[string]cuexruntime.ProviderFn { + return map[string]cuexruntime.ProviderFn{ + "patch-k8s-object": providertypes.LegacyNativeProviderFn(PatchK8sObject), + "string": providertypes.LegacyGenericProviderFn[StringVars, StringReturns](String), + "log": providertypes.LegacyGenericProviderFn[LogVars, any](Log), + } +} diff --git a/pkg/providers/util/util_test.go b/pkg/providers/legacy/util/util_test.go similarity index 62% rename from pkg/providers/util/util_test.go rename to pkg/providers/legacy/util/util_test.go index 4fd5f6b..d12935d 100644 --- a/pkg/providers/util/util_test.go +++ b/pkg/providers/legacy/util/util_test.go @@ -19,24 +19,25 @@ package util import ( "context" "encoding/json" - "errors" "fmt" "testing" + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/yaml" - monitorContext "github.com/kubevela/pkg/monitor/context" - + "github.com/kubevela/pkg/cue/util" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" - "github.com/kubevela/workflow/pkg/providers" + "github.com/kubevela/workflow/pkg/types" ) func TestPatchK8sObject(t *testing.T) { + ctx := context.Background() + cuectx := cuecontext.New() testcases := map[string]struct { value string expectedErr error @@ -59,19 +60,14 @@ patch: { "test-label": "true" } } -} -`, +}`, expectedErr: nil, - patchResult: ` -apiVersion: "apps/v1" + patchResult: `apiVersion: "apps/v1" kind: "Deployment" -spec: template: metadata: { - labels: { - "oam.dev/name": "test" - "test-label": "true" - } -} -`, +spec: template: metadata: labels: { + "oam.dev/name": "test" + "test-label": "true" +}`, }, "test patch k8s object with patchKey": { value: ` @@ -95,22 +91,17 @@ patch: { }] }] } -} -`, +}`, expectedErr: nil, - patchResult: ` -apiVersion: "apps/v1" + patchResult: `apiVersion: "apps/v1" kind: "Deployment" -spec: template: spec: { - containers: [{ - name: "test" - env: [{ - name: "test-env" - value: "test-value" - }] +spec: template: spec: containers: [{ + name: "test" + env: [{ + name: "test-env" + value: "test-value" }] -} -`, +}]`, }, "test patch k8s object with patchStrategy": { value: ` @@ -129,151 +120,145 @@ patch: { } `, expectedErr: nil, - patchResult: ` -apiVersion: "apps/v1" + patchResult: `apiVersion: "apps/v1" kind: "Deployment" -spec: template: metadata: { - name: "test-patchStrategy" -} -`, +spec: template: metadata: name: "test-patchStrategy"`, }, } for name, tc := range testcases { t.Run(name, func(t *testing.T) { r := require.New(t) - v, err := value.NewValue(tc.value, nil, "") - r.NoError(err) - prd := &provider{} - err = prd.PatchK8sObject(nil, nil, v, nil) + res, err := PatchK8sObject(ctx, &types.LegacyParams[cue.Value]{ + Params: cuectx.CompileString(tc.value), + }) if tc.expectedErr != nil { r.Equal(tc.expectedErr.Error(), err.Error()) return } r.NoError(err) - result, err := v.LookupValue("result") - r.NoError(err) - var patchResult map[string]interface{} - r.NoError(result.UnmarshalTo(&patchResult)) - var expectResult map[string]interface{} - resultValue, err := value.NewValue(tc.patchResult, nil, "") + s, err := util.ToString(res.LookupPath(cue.ParsePath("result"))) r.NoError(err) - r.NoError(resultValue.UnmarshalTo(&expectResult)) - r.Equal(expectResult, patchResult) + r.Equal(tc.patchResult, s) }) } } func TestConvertString(t *testing.T) { + ctx := context.Background() testCases := map[string]struct { - from string - expected string - expectedErr error + from []byte + expected string }{ "success": { - from: `bt: 'test'`, + from: []byte("test"), expected: "test", }, - "fail": { - from: `bt: 123`, - expectedErr: errors.New("bt: cannot use value 123 (type int) as (string|bytes)"), - }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { r := require.New(t) - v, err := value.NewValue(tc.from, nil, "") - r.NoError(err) - prd := &provider{} - err = prd.String(nil, nil, v, nil) - if tc.expectedErr != nil { - r.Equal(tc.expectedErr.Error(), err.Error()) - return - } - r.NoError(err) - expected, err := v.LookupValue("str") + res, err := String(ctx, &StringParams{ + Params: StringVars{ + Byte: []byte(tc.from), + }, + }) r.NoError(err) - ret, err := expected.CueValue().String() - r.NoError(err) - r.Equal(ret, tc.expected) + r.Equal(tc.expected, res.String) }) } } func TestLog(t *testing.T) { + ctx := context.Background() wfCtx := newWorkflowContextForTest(t) pCtx := process.NewContext(process.ContextData{}) pCtx.PushData(model.ContextStepName, "test-step") - prd := &provider{pCtx: pCtx} - logCtx := monitorContext.NewTraceContext(context.Background(), "") testCases := []struct { - value string + value LogVars expected string expectedErr string }{ { - value: `data: "test"`, + value: LogVars{ + Data: "test", + }, expected: `{"test-step":{"data":true}}`, }, { - value: ` -data: { - message: "test" -} -level: 3`, + value: LogVars{ + Data: map[string]string{ + "message": "test", + }, + Level: 3, + }, expected: `{"test-step":{"data":true}}`, }, { - value: `test: ""`, + value: LogVars{ + Data: map[string]string{ + "test": "", + }, + }, expected: `{"test-step":{"data":true}}`, }, { - value: ` -source: { - url: "https://kubevela.io" -} -`, + value: LogVars{ + Source: &LogSource{ + URL: "https://kubevela.io", + }, + }, expected: `{"test-step":{"data":true,"source":{"url":"https://kubevela.io"}}}`, }, { - value: ` -source: { - resources: [{ - labelSelector: {"test": "test"} - }] -} -`, + value: LogVars{ + Source: &LogSource{ + Resources: []Resource{ + { + LabelSelector: map[string]string{ + "test": "test", + }, + }, + }, + }, + }, expected: `{"test-step":{"data":true,"source":{"url":"https://kubevela.io","resources":[{"labelSelector":{"test":"test"}}]}}}`, }, { - value: ` -source: { - resources: [{ - name: "test" - namespace: "test" - cluster: "test" - }] -} -`, + value: LogVars{ + Source: &LogSource{ + Resources: []Resource{ + { + Name: "test", + Namespace: "test", + Cluster: "test", + }, + }, + }, + }, expected: `{"test-step":{"data":true,"source":{"url":"https://kubevela.io","resources":[{"name":"test","namespace":"test","cluster":"test"}]}}}`, }, { - value: ` -source: { - url: "https://kubevela.com" -} -`, + value: LogVars{ + Source: &LogSource{ + URL: "https://kubevela.com", + }, + }, expected: `{"test-step":{"data":true,"source":{"url":"https://kubevela.com","resources":[{"name":"test","namespace":"test","cluster":"test"}]}}}`, }, } for i, tc := range testCases { t.Run(fmt.Sprint(i), func(t *testing.T) { r := require.New(t) - v, err := value.NewValue(tc.value, nil, "") - r.NoError(err) - err = prd.Log(logCtx, wfCtx, v, nil) + _, err := Log(ctx, &LogParams{ + Params: tc.value, + RuntimeParams: types.RuntimeParams{ + ProcessContext: pCtx, + WorkflowContext: wfCtx, + }, + }) if tc.expectedErr != "" { r.Contains(err.Error(), tc.expectedErr) return @@ -287,16 +272,16 @@ source: { } } -func TestInstall(t *testing.T) { - p := providers.NewProviders() - pCtx := process.NewContext(process.ContextData{}) - pCtx.PushData(model.ContextStepName, "test-step") - Install(p, pCtx) - h, ok := p.GetHandler("util", "string") - r := require.New(t) - r.Equal(ok, true) - r.Equal(h != nil, true) -} +// func TestInstall(t *testing.T) { +// p := providers.NewProviders() +// pCtx := process.NewContext(process.ContextData{}) +// pCtx.PushData(model.ContextStepName, "test-step") +// Install(p, pCtx) +// h, ok := p.GetHandler("util", "string") +// r := require.New(t) +// r.Equal(ok, true) +// r.Equal(h != nil, true) +// } func newWorkflowContextForTest(t *testing.T) wfContext.Context { cm := corev1.ConfigMap{} @@ -307,7 +292,7 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context { r.NoError(err) wfCtx := new(wfContext.WorkflowContext) - err = wfCtx.LoadFromConfigMap(cm) + err = wfCtx.LoadFromConfigMap(context.Background(), cm) r.NoError(err) return wfCtx } diff --git a/pkg/providers/legacy/workspace/workspace.cue b/pkg/providers/legacy/workspace/workspace.cue new file mode 100644 index 0000000..67620a6 --- /dev/null +++ b/pkg/providers/legacy/workspace/workspace.cue @@ -0,0 +1,59 @@ +// workspace.cue + +#DoVar: { + #do: "var" + #provider: "op" + + // +usage=The method to call on the variable + method: *"Get" | "Put" + // +usage=The path to the variable + path: string + // +usage=The value of the variable + value?: _ +} + +#ConditionalWait: { + #do: "wait" + #provider: "op" + + // +usage=If continue is false, the step will wait for continue to be true. + continue: *false | bool + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. + message?: string +} + +#Suspend: { + #do: "suspend" + #provider: "op" + + // +usage=Specify the wait duration time to resume automaticlly such as "30s", "1min" or "2m15s" + duration?: string + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. + message?: string +} + +#Break: { + #do: "break" + #provider: "op" + + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. + message?: string +} + +#Fail: { + #do: "fail" + #provider: "op" + + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. + message?: string +} + +#Message: { + #do: "message" + #provider: "op" + + // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. + message?: string +} + +context: _ diff --git a/pkg/providers/legacy/workspace/workspace.go b/pkg/providers/legacy/workspace/workspace.go new file mode 100644 index 0000000..2bdf88a --- /dev/null +++ b/pkg/providers/legacy/workspace/workspace.go @@ -0,0 +1,211 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package workspace + +import ( + "context" + _ "embed" + "encoding/json" + "fmt" + "strings" + "time" + + "cuelang.org/go/cue/cuecontext" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + + "github.com/kubevela/workflow/api/v1alpha1" + "github.com/kubevela/workflow/pkg/cue/model" + "github.com/kubevela/workflow/pkg/errors" + providertypes "github.com/kubevela/workflow/pkg/providers/types" + "github.com/kubevela/workflow/pkg/types" +) + +const ( + // ProviderName is provider name. + ProviderName = "builtin" + // ResumeTimeStamp is resume time stamp. + ResumeTimeStamp = "resumeTimeStamp" + // SuspendTimeStamp is suspend time stamp. + SuspendTimeStamp = "suspendTimeStamp" +) + +// VarVars . +type VarVars struct { + Method string `json:"method"` + Path string `json:"path"` + Value any `json:"value"` +} + +// VarReturns . +type VarReturns struct { + Value any `json:"value"` +} + +// VarParams . +type VarParams = types.LegacyParams[VarVars] + +// DoVar get & put variable from context. +func DoVar(ctx context.Context, params *VarParams) (*VarReturns, error) { + wfCtx := params.RuntimeParams.WorkflowContext + path := params.Params.Path + + switch params.Params.Method { + case "Get": + value, err := wfCtx.GetVar(strings.Split(path, ".")...) + if err != nil { + return nil, err + } + b, err := value.MarshalJSON() + if err != nil { + return nil, err + } + var v any + if err := json.Unmarshal(b, &v); err != nil { + return nil, err + } + return &VarReturns{ + Value: v, + }, nil + case "Put": + b, err := json.Marshal(params.Params.Value) + if err != nil { + return nil, err + } + if err := wfCtx.SetVar(cuecontext.New().CompileBytes(b), strings.Split(path, ".")...); err != nil { + return nil, err + } + return nil, nil + } + return nil, nil +} + +// ActionVars . +type ActionVars struct { + Message string `json:"message,omitempty"` +} + +// ActionParams . +type ActionParams = types.LegacyParams[ActionVars] + +// WaitVars . +type WaitVars struct { + Continue bool `json:"continue"` + ActionVars +} + +// WaitParams . +type WaitParams = types.LegacyParams[WaitVars] + +// Wait let workflow wait. +func Wait(ctx context.Context, params *WaitParams) (*any, error) { + if params.Params.Continue { + return nil, nil + } + params.Action.Wait(params.Params.Message) + return nil, errors.GenericActionError(errors.ActionWait) +} + +// Break let workflow terminate. +func Break(ctx context.Context, params *ActionParams) (*any, error) { + params.Action.Terminate(params.Params.Message) + return nil, errors.GenericActionError(errors.ActionTerminate) +} + +// Fail let the step fail, its status is failed and reason is Action +func Fail(ctx context.Context, params *ActionParams) (*any, error) { + params.Action.Fail(params.Params.Message) + return nil, errors.GenericActionError(errors.ActionTerminate) +} + +// SuspendVars . +type SuspendVars struct { + Duration string `json:"duration,omitempty"` + ActionVars +} + +// SuspendParams . +type SuspendParams = types.LegacyParams[SuspendVars] + +// Suspend let the step suspend, its status is suspending and reason is Suspend +func Suspend(ctx context.Context, params *SuspendParams) (*any, error) { + pCtx := params.ProcessContext + wfCtx := params.WorkflowContext + act := params.Action + stepID := fmt.Sprint(pCtx.GetData(model.ContextStepSessionID)) + timestamp := wfCtx.GetMutableValue(stepID, ResumeTimeStamp) + + var msg string + if msg == "" { + msg = fmt.Sprintf("Suspended by field %s", params.FieldLabel) + } + if timestamp != "" { + t, err := time.Parse(time.RFC3339, timestamp) + if err != nil { + return nil, fmt.Errorf("failed to parse timestamp %s: %w", timestamp, err) + } + if time.Now().After(t) { + act.Resume("") + return nil, nil + } + act.Suspend(msg) + return nil, errors.GenericActionError(errors.ActionSuspend) + } + if params.Params.Duration != "" { + d, err := time.ParseDuration(params.Params.Duration) + if err != nil { + return nil, fmt.Errorf("failed to parse duration %s: %w", params.Params.Duration, err) + } + wfCtx.SetMutableValue(time.Now().Add(d).Format(time.RFC3339), stepID, ResumeTimeStamp) + } + if ts := wfCtx.GetMutableValue(stepID, params.FieldLabel, SuspendTimeStamp); ts != "" { + if act.GetStatus().Phase == v1alpha1.WorkflowStepPhaseRunning { + // if it is already suspended before and has been resumed, we should not suspend it again. + return nil, nil + } + } else { + wfCtx.SetMutableValue(time.Now().Format(time.RFC3339), stepID, params.FieldLabel, SuspendTimeStamp) + } + act.Suspend(msg) + return nil, errors.GenericActionError(errors.ActionSuspend) +} + +// Message writes message to step status, note that the message will be overwritten by the next message. +func Message(ctx context.Context, params *ActionParams) (*any, error) { + params.Action.Message(params.Params.Message) + return nil, nil +} + +//go:embed workspace.cue +var template string + +// GetTemplate returns the cue template. +func GetTemplate() string { + return template +} + +// GetProviders returns the cue providers. +func GetProviders() map[string]cuexruntime.ProviderFn { + return map[string]cuexruntime.ProviderFn{ + "wait": providertypes.LegacyGenericProviderFn[WaitVars, any](Wait), + "break": providertypes.LegacyGenericProviderFn[ActionVars, any](Break), + "fail": providertypes.LegacyGenericProviderFn[ActionVars, any](Fail), + "message": providertypes.LegacyGenericProviderFn[ActionVars, any](Message), + "var": providertypes.LegacyGenericProviderFn[VarVars, VarReturns](DoVar), + "suspend": providertypes.LegacyGenericProviderFn[SuspendVars, any](Suspend), + } +} diff --git a/pkg/providers/workspace/workspace_test.go b/pkg/providers/legacy/workspace/workspace_test.go similarity index 56% rename from pkg/providers/workspace/workspace_test.go rename to pkg/providers/legacy/workspace/workspace_test.go index 49835fb..691ef7f 100644 --- a/pkg/providers/workspace/workspace_test.go +++ b/pkg/providers/legacy/workspace/workspace_test.go @@ -17,6 +17,7 @@ limitations under the License. package workspace import ( + "context" "encoding/json" "testing" "time" @@ -27,198 +28,189 @@ import ( "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" + "github.com/kubevela/workflow/pkg/errors" + "github.com/kubevela/workflow/pkg/types" "github.com/stretchr/testify/require" ) func TestProvider_DoVar(t *testing.T) { wfCtx := newWorkflowContextForTest(t) - p := &provider{} r := require.New(t) - - v, err := value.NewValue(` -method: "Put" -path: "clusterIP" -value: "1.1.1.1" -`, nil, "") - r.NoError(err) - err = p.DoVar(nil, wfCtx, v, &mockAction{}) + ctx := context.Background() + + _, err := DoVar(ctx, &VarParams{ + Params: VarVars{ + Method: "Put", + Path: "clusterIP", + Value: "1.1.1.1", + }, + RuntimeParams: types.RuntimeParams{ + WorkflowContext: wfCtx, + }, + }) r.NoError(err) varV, err := wfCtx.GetVar("clusterIP") r.NoError(err) - s, err := varV.CueValue().String() + s, err := varV.String() r.NoError(err) r.Equal(s, "1.1.1.1") - v, err = value.NewValue(` -method: "Get" -path: "clusterIP" -`, nil, "") - r.NoError(err) - err = p.DoVar(nil, wfCtx, v, &mockAction{}) - r.NoError(err) - varV, err = v.LookupValue("value") - r.NoError(err) - s, err = varV.CueValue().String() - r.NoError(err) - r.Equal(s, "1.1.1.1") - - errCases := []string{` -value: "1.1.1.1" -`, ` -method: "Get" -`, ` -path: "ClusterIP" -`, ` -method: "Put" -path: "ClusterIP" -`} - - for _, tCase := range errCases { - v, err = value.NewValue(tCase, nil, "") - r.NoError(err) - err = p.DoVar(nil, wfCtx, v, &mockAction{}) - r.Error(err) - } + res, err := DoVar(ctx, &VarParams{ + Params: VarVars{ + Method: "Get", + Path: "clusterIP", + }, + RuntimeParams: types.RuntimeParams{ + WorkflowContext: wfCtx, + }, + }) + r.NoError(err) + r.Equal(res.Value, "1.1.1.1") } func TestProvider_Wait(t *testing.T) { - wfCtx := newWorkflowContextForTest(t) - p := &provider{} + ctx := context.Background() r := require.New(t) act := &mockAction{} - v, err := value.NewValue(` -continue: 100!=100 -message: "test log" -`, nil, "") - r.NoError(err) - err = p.Wait(nil, wfCtx, v, act) - r.NoError(err) + + _, err := Wait(ctx, &WaitParams{ + Params: WaitVars{ + Continue: false, + ActionVars: ActionVars{ + Message: "test log", + }, + }, + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) + _, ok := err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.wait, true) r.Equal(act.msg, "test log") act = &mockAction{} - v, err = value.NewValue(` -continue: 100==100 -message: "not invalid" -`, nil, "") - r.NoError(err) - err = p.Wait(nil, wfCtx, v, act) + _, err = Wait(ctx, &WaitParams{ + Params: WaitVars{ + Continue: true, + ActionVars: ActionVars{ + Message: "omit msg", + }, + }, + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) r.NoError(err) r.Equal(act.wait, false) r.Equal(act.msg, "") - - act = &mockAction{} - v, err = value.NewValue(` -continue: bool -message: string -`, nil, "") - r.NoError(err) - err = p.Wait(nil, wfCtx, v, act) - r.NoError(err) - r.Equal(act.wait, true) - - act = &mockAction{} - v, err = value.NewValue(``, nil, "") - r.NoError(err) - err = p.Wait(nil, wfCtx, v, act) - r.NoError(err) - r.Equal(act.wait, true) } func TestProvider_Break(t *testing.T) { - wfCtx := newWorkflowContextForTest(t) - p := &provider{} + ctx := context.Background() r := require.New(t) act := &mockAction{} - err := p.Break(nil, wfCtx, nil, act) - r.NoError(err) + _, err := Break(ctx, &ActionParams{ + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) + _, ok := err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.terminate, true) act = &mockAction{} - v, err := value.NewValue(` -message: "terminate" -`, nil, "") - r.NoError(err) - err = p.Break(nil, wfCtx, v, act) - r.NoError(err) + _, err = Break(ctx, &ActionParams{ + Params: ActionVars{ + Message: "terminate", + }, + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) + _, ok = err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.terminate, true) r.Equal(act.msg, "terminate") } func TestProvider_Suspend(t *testing.T) { wfCtx := newWorkflowContextForTest(t) + ctx := context.Background() pCtx := process.NewContext(process.ContextData{}) pCtx.PushData(model.ContextStepSessionID, "test-id") - p := &provider{pCtx: pCtx} r := require.New(t) act := &mockAction{} - v, err := value.NewValue(` -duration: "1s" -`, nil, "") - r.NoError(err) - err = p.Suspend(nil, wfCtx, v, act) - r.NoError(err) + + params := &SuspendParams{ + Params: SuspendVars{ + Duration: "1s", + }, + RuntimeParams: types.RuntimeParams{ + Action: act, + WorkflowContext: wfCtx, + ProcessContext: pCtx, + }, + } + _, err := Suspend(ctx, params) + _, ok := err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.suspend, true) r.Equal(act.msg, "Suspended by field ") // test second time to check if the suspend is resumed in 1s - err = p.Suspend(nil, wfCtx, v, act) - r.NoError(err) + _, err = Suspend(ctx, params) + _, ok = err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.suspend, true) time.Sleep(time.Second) - err = p.Suspend(nil, wfCtx, v, act) + _, err = Suspend(ctx, params) r.NoError(err) r.Equal(act.suspend, false) } func TestProvider_Fail(t *testing.T) { - wfCtx := newWorkflowContextForTest(t) - p := &provider{} + ctx := context.Background() r := require.New(t) act := &mockAction{} - err := p.Fail(nil, wfCtx, nil, act) - r.NoError(err) + _, err := Fail(ctx, &ActionParams{ + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) + _, ok := err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.terminate, true) act = &mockAction{} - v, err := value.NewValue(` -message: "fail" -`, nil, "") - r.NoError(err) - err = p.Fail(nil, wfCtx, v, act) - r.NoError(err) + _, err = Fail(ctx, &ActionParams{ + Params: ActionVars{ + Message: "fail", + }, + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) + _, ok = err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.terminate, true) r.Equal(act.msg, "fail") } func TestProvider_Message(t *testing.T) { - wfCtx := newWorkflowContextForTest(t) - p := &provider{} + ctx := context.Background() r := require.New(t) act := &mockAction{} - v, err := value.NewValue(` -message: "test" -`, nil, "") - r.NoError(err) - err = p.Message(nil, wfCtx, nil, act) - r.NoError(err) - r.Equal(act.msg, "") - err = p.Message(nil, wfCtx, v, act) - r.NoError(err) - r.Equal(act.msg, "test") - err = p.Message(nil, wfCtx, nil, act) + _, err := Message(ctx, &ActionParams{ + Params: ActionVars{ + Message: "test", + }, + RuntimeParams: types.RuntimeParams{ + Action: act, + }, + }) r.NoError(err) r.Equal(act.msg, "test") - - act = &mockAction{} - v, err = value.NewValue(` -message: "fail" -`, nil, "") - r.NoError(err) - err = p.Fail(nil, wfCtx, v, act) - r.NoError(err) - r.Equal(act.msg, "fail") } type mockAction struct { @@ -280,7 +272,7 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context { r.NoError(err) wfCtx := new(wfContext.WorkflowContext) - err = wfCtx.LoadFromConfigMap(cm) + err = wfCtx.LoadFromConfigMap(context.Background(), cm) r.NoError(err) return wfCtx } diff --git a/pkg/providers/providers.go b/pkg/providers/providers.go deleted file mode 100644 index f0ecc96..0000000 --- a/pkg/providers/providers.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package providers - -import ( - "sync" - - "github.com/kubevela/workflow/pkg/types" -) - -type providers struct { - l sync.RWMutex - m map[string]map[string]types.Handler - force bool -} - -// GetHandler get handler by provider name and handle name. -func (p *providers) GetHandler(providerName, handleName string) (types.Handler, bool) { - p.l.RLock() - defer p.l.RUnlock() - provider, ok := p.m[providerName] - if !ok { - return nil, false - } - h, ok := provider[handleName] - return h, ok -} - -// Register install provider. -func (p *providers) Register(provider string, m map[string]types.Handler) { - p.l.Lock() - defer p.l.Unlock() - if p.force { - p.m[provider] = m - return - } - if _, ok := p.m[provider]; !ok { - p.m[provider] = m - } -} - -// NewProviders will create provider discover. -func NewProviders() types.Providers { - return &providers{m: map[string]map[string]types.Handler{}} -} diff --git a/pkg/providers/providers_test.go b/pkg/providers/providers_test.go deleted file mode 100644 index f0a9ea6..0000000 --- a/pkg/providers/providers_test.go +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package providers - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/kubevela/workflow/pkg/types" -) - -func TestProvers(t *testing.T) { - p := NewProviders() - r := require.New(t) - p.Register("test", map[string]types.Handler{ - "foo": nil, - "crazy": nil, - }) - - _, found := p.GetHandler("test", "foo") - r.Equal(found, true) - _, found = p.GetHandler("test", "crazy") - r.Equal(found, true) - _, found = p.GetHandler("staging", "crazy") - r.Equal(found, false) - _, found = p.GetHandler("test", "fly") - r.Equal(found, false) -} diff --git a/pkg/providers/types/types.go b/pkg/providers/types/types.go new file mode 100644 index 0000000..cbedfbb --- /dev/null +++ b/pkg/providers/types/types.go @@ -0,0 +1,115 @@ +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package types + +import ( + "context" + "encoding/json" + + "cuelang.org/go/cue" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + + wfContext "github.com/kubevela/workflow/pkg/context" + "github.com/kubevela/workflow/pkg/cue/process" + "github.com/kubevela/workflow/pkg/types" +) + +type contextKey string + +const ( + workflowContextKey contextKey = "workflowContext" + processContextKey contextKey = "processContext" + actionKey contextKey = "action" + labelsKey contextKey = "labels" +) + +// LegacyGenericProviderFn is the legacy provider function +type LegacyGenericProviderFn[T any, U any] func(context.Context, *types.LegacyParams[T]) (*U, error) + +// Call marshal value into json and decode into underlying function input +// parameters, then fill back the returned output value +func (fn LegacyGenericProviderFn[T, U]) Call(ctx context.Context, value cue.Value) (cue.Value, error) { + params := new(T) + bs, err := value.MarshalJSON() + if err != nil { + return value, err + } + if err = json.Unmarshal(bs, params); err != nil { + return value, err + } + runtimeParams := RuntimeParamsFrom(ctx) + label, _ := value.Label() + runtimeParams.FieldLabel = label + ret, err := fn(ctx, &types.LegacyParams[T]{Params: *params, RuntimeParams: runtimeParams}) + if err != nil { + return value, err + } + return value.FillPath(cue.ParsePath(""), ret), nil +} + +// LegacyNativeProviderFn is the legacy native provider function +type LegacyNativeProviderFn func(context.Context, *types.LegacyParams[cue.Value]) (cue.Value, error) + +// Call marshal value into json and decode into underlying function input +// parameters, then fill back the returned output value +func (fn LegacyNativeProviderFn) Call(ctx context.Context, value cue.Value) (cue.Value, error) { + runtimeParams := RuntimeParamsFrom(ctx) + return fn(ctx, &types.LegacyParams[cue.Value]{Params: value, RuntimeParams: runtimeParams}) +} + +// WithLabelParams returns a copy of parent in which the labels value is set +func WithLabelParams(parent context.Context, labels map[string]string) context.Context { + return context.WithValue(parent, labelsKey, labels) +} + +// WithRuntimeParams returns a copy of parent in which the runtime params value is set +func WithRuntimeParams(parent context.Context, params types.RuntimeParams) context.Context { + ctx := context.WithValue(parent, workflowContextKey, params.WorkflowContext) + ctx = context.WithValue(ctx, processContextKey, params.ProcessContext) + ctx = context.WithValue(ctx, actionKey, params.Action) + return ctx +} + +// RuntimeParamsFrom returns the runtime params value stored in ctx, if any. +func RuntimeParamsFrom(ctx context.Context) types.RuntimeParams { + params := types.RuntimeParams{} + if wfCtx, ok := ctx.Value(workflowContextKey).(wfContext.Context); ok { + params.WorkflowContext = wfCtx + } + if pCtx, ok := ctx.Value(processContextKey).(process.Context); ok { + params.ProcessContext = pCtx + } + if action, ok := ctx.Value(actionKey).(types.Action); ok { + params.Action = action + } + if labels, ok := ctx.Value(labelsKey).(map[string]string); ok { + params.Labels = labels + } + return params +} + +// Dispatcher is a client for apply resources. +type Dispatcher func(ctx context.Context, cluster, owner string, manifests ...*unstructured.Unstructured) error + +// Deleter is a client for delete resources. +type Deleter func(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error + +// KubeHandlers handles resources. +type KubeHandlers struct { + Apply Dispatcher + Delete Deleter +} diff --git a/pkg/tasks/builtin/step_group.go b/pkg/tasks/builtin/step_group.go index 117a619..f81238f 100644 --- a/pkg/tasks/builtin/step_group.go +++ b/pkg/tasks/builtin/step_group.go @@ -20,13 +20,12 @@ import ( "context" "fmt" + "cuelang.org/go/cue" monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/pkg/util/slices" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" @@ -40,7 +39,6 @@ func StepGroup(step v1alpha1.WorkflowStep, opt *types.TaskGeneratorOptions) (typ step: step, subTaskRunners: opt.SubTaskRunners, mode: opt.SubStepExecuteMode, - pd: opt.PackageDiscover, pCtx: opt.ProcessContext, }, nil } @@ -50,7 +48,6 @@ type stepGroupTaskRunner struct { name string step v1alpha1.WorkflowStep subTaskRunners []types.TaskRunner - pd *packages.PackageDiscover pCtx process.Context mode v1alpha1.WorkflowMode } @@ -64,7 +61,7 @@ func (tr *stepGroupTaskRunner) Name() string { func (tr *stepGroupTaskRunner) Pending(ctx monitorContext.Context, wfCtx wfContext.Context, stepStatus map[string]v1alpha1.StepStatus) (bool, v1alpha1.StepStatus) { resetter := tr.FillContextData(ctx, tr.pCtx) defer resetter(tr.pCtx) - basicVal, _, _ := custom.MakeBasicValue(wfCtx, "", tr.pCtx) + basicVal, _ := custom.MakeBasicValue(ctx, nil, tr.pCtx) return custom.CheckPending(wfCtx, tr.step, tr.id, stepStatus, basicVal) } @@ -86,7 +83,7 @@ func (tr *stepGroupTaskRunner) Run(ctx wfContext.Context, options *types.TaskRun tracer := options.GetTracer(tr.id, tr.step).AddTag("step_name", tr.name, "step_type", types.WorkflowStepTypeStepGroup) resetter := tr.FillContextData(tracer, tr.pCtx) defer resetter(tr.pCtx) - basicVal, basicTemplate, err := custom.MakeBasicValue(ctx, "", tr.pCtx) + basicVal, err := custom.MakeBasicValue(tracer, nil, tr.pCtx) if err != nil { return status, nil, err } @@ -94,9 +91,7 @@ func (tr *stepGroupTaskRunner) Run(ctx wfContext.Context, options *types.TaskRun for _, hook := range options.PreCheckHooks { result, err := hook(tr.step, &types.PreCheckOptions{ - PackageDiscover: tr.pd, - BasicTemplate: basicTemplate, - BasicValue: basicVal, + BasicValue: basicVal, }) if err != nil { status.Phase = v1alpha1.WorkflowStepPhaseSkipped @@ -200,7 +195,7 @@ func getStepGroupStatus(status v1alpha1.StepStatus, stepStatus v1alpha1.Workflow return status, operation } -func handleOutput(ctx wfContext.Context, stepStatus *v1alpha1.StepStatus, operations *types.Operation, step v1alpha1.WorkflowStep, postStopHooks []types.TaskPostStopHook, basicVal *value.Value) { +func handleOutput(ctx wfContext.Context, stepStatus *v1alpha1.StepStatus, operations *types.Operation, step v1alpha1.WorkflowStep, postStopHooks []types.TaskPostStopHook, basicVal cue.Value) { if len(step.Outputs) > 0 { for _, hook := range postStopHooks { if err := hook(ctx, basicVal, step, *stepStatus, nil); err != nil { diff --git a/pkg/tasks/builtin/step_group_test.go b/pkg/tasks/builtin/step_group_test.go index 7decfa4..0e88375 100644 --- a/pkg/tasks/builtin/step_group_test.go +++ b/pkg/tasks/builtin/step_group_test.go @@ -208,7 +208,7 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context { r.NoError(err) wfCtx := new(wfContext.WorkflowContext) - err = wfCtx.LoadFromConfigMap(cm) + err = wfCtx.LoadFromConfigMap(context.Background(), cm) r.NoError(err) return wfCtx } diff --git a/pkg/tasks/custom/action.go b/pkg/tasks/custom/action.go new file mode 100644 index 0000000..b9020c2 --- /dev/null +++ b/pkg/tasks/custom/action.go @@ -0,0 +1,166 @@ +package custom + +/* +Copyright 2022 The KubeVela Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import ( + "github.com/kubevela/pkg/cue/cuex" + + monitorContext "github.com/kubevela/pkg/monitor/context" + "github.com/kubevela/workflow/api/v1alpha1" + wfContext "github.com/kubevela/workflow/pkg/context" + "github.com/kubevela/workflow/pkg/errors" + "github.com/kubevela/workflow/pkg/types" +) + +// ResolveActionBreak resolve action break error +func ResolveActionBreak(err error) error { + fc, ok := err.(cuex.FunctionCallError) + if !ok { + return err + } + if _, ok := fc.Err.(errors.GenericActionError); ok { + return nil + } + return err +} + +type executor struct { + wfStatus v1alpha1.StepStatus + stepStatus v1alpha1.StepStatus + suspend bool + terminated bool + failedAfterRetries bool + wait bool + skip bool + + tracer monitorContext.Context +} + +// Suspend let workflow pause. +func (exec *executor) Suspend(message string) { + if exec.wfStatus.Phase == v1alpha1.WorkflowStepPhaseFailed { + return + } + exec.suspend = true + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSuspending + if message != "" { + exec.wfStatus.Message = message + } + exec.wfStatus.Reason = types.StatusReasonSuspend +} + +// Resume let workflow resume. +func (exec *executor) Resume(message string) { + exec.suspend = false + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSucceeded + if message != "" { + exec.wfStatus.Message = message + } +} + +// Terminate let workflow terminate. +func (exec *executor) Terminate(message string) { + exec.terminated = true + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSucceeded + if message != "" { + exec.wfStatus.Message = message + } + exec.wfStatus.Reason = types.StatusReasonTerminate +} + +// Wait let workflow wait. +func (exec *executor) Wait(message string) { + exec.wait = true + if exec.wfStatus.Phase != v1alpha1.WorkflowStepPhaseFailed { + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseRunning + exec.wfStatus.Reason = types.StatusReasonWait + if message != "" { + exec.wfStatus.Message = message + } + } +} + +// Fail let the step fail, its status is failed and reason is Action +func (exec *executor) Fail(message string) { + exec.terminated = true + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseFailed + exec.wfStatus.Reason = types.StatusReasonAction + if message != "" { + exec.wfStatus.Message = message + } +} + +// Message writes message to step status, note that the message will be overwritten by the next message. +func (exec *executor) Message(message string) { + if message != "" { + exec.wfStatus.Message = message + } +} + +func (exec *executor) Skip(message string) { + exec.skip = true + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSkipped + exec.wfStatus.Reason = types.StatusReasonSkip + exec.wfStatus.Message = message +} + +func (exec *executor) GetStatus() v1alpha1.StepStatus { + return exec.stepStatus +} + +func (exec *executor) timeout(message string) { + exec.terminated = true + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseFailed + exec.wfStatus.Reason = types.StatusReasonTimeout + exec.wfStatus.Message = message +} + +func (exec *executor) err(ctx wfContext.Context, wait bool, err error, reason string) { + exec.wait = wait + exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseFailed + exec.wfStatus.Message = err.Error() + if exec.wfStatus.Reason == "" { + exec.wfStatus.Reason = reason + if reason != types.StatusReasonExecute { + exec.terminated = true + } + } + exec.checkErrorTimes(ctx) +} + +func (exec *executor) checkErrorTimes(ctx wfContext.Context) { + times := ctx.IncreaseCountValueInMemory(types.ContextPrefixFailedTimes, exec.wfStatus.ID) + if times >= types.MaxWorkflowStepErrorRetryTimes { + exec.wait = false + exec.failedAfterRetries = true + exec.wfStatus.Reason = types.StatusReasonFailedAfterRetries + } +} + +func (exec *executor) operation() *types.Operation { + return &types.Operation{ + Suspend: exec.suspend, + Terminated: exec.terminated, + Waiting: exec.wait, + Skip: exec.skip, + FailedAfterRetries: exec.failedAfterRetries, + } +} + +func (exec *executor) status() v1alpha1.StepStatus { + return exec.wfStatus +} diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index 2406fb8..fb61d66 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -23,18 +23,22 @@ import ( "strings" "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" + "github.com/pkg/errors" + "k8s.io/apimachinery/pkg/runtime" + + "github.com/kubevela/pkg/cue/cuex" + "github.com/kubevela/pkg/cue/util" monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/pkg/util/slices" - "github.com/pkg/errors" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/cue/model/sets" "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/hooks" + providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) @@ -44,8 +48,6 @@ type LoadTaskTemplate func(ctx context.Context, name string) (string, error) // TaskLoader is a client that get taskGenerator. type TaskLoader struct { loadTemplate func(ctx context.Context, name string) (string, error) - pd *packages.PackageDiscover - handlers types.Providers runOptionsProcess func(*types.TaskRunOptions) logLevel int } @@ -95,7 +97,6 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error Phase: v1alpha1.WorkflowStepPhaseSucceeded, } exec := &executor{ - handlers: t.handlers, wfStatus: initialStatus, stepStatus: initialStatus, } @@ -112,11 +113,6 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error } } - paramsStr, err := GetParameterTemplate(wfStep) - if err != nil { - return nil, err - } - tRunner := new(taskRunner) tRunner.name = wfStep.Name tRunner.checkPending = func(ctx monitorContext.Context, wfCtx wfContext.Context, stepStatus map[string]v1alpha1.StepStatus) (bool, v1alpha1.StepStatus) { @@ -124,9 +120,11 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error if t.runOptionsProcess != nil { t.runOptionsProcess(options) } + resetter := tRunner.fillContext(ctx, options.PCtx) defer resetter(options.PCtx) - basicVal, _, _ := MakeBasicValue(wfCtx, paramsStr, options.PCtx) + basicVal, _ := MakeBasicValue(ctx, wfStep.Properties, options.PCtx) + return CheckPending(wfCtx, wfStep, exec.wfStatus.ID, stepStatus, basicVal) } tRunner.fillContext = func(ctx monitorContext.Context, processCtx process.Context) types.ContextDataResetter { @@ -145,7 +143,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error ) } } - tRunner.run = func(ctx wfContext.Context, options *types.TaskRunOptions) (stepStatus v1alpha1.StepStatus, operations *types.Operation, rErr error) { + tRunner.run = func(wfCtx wfContext.Context, options *types.TaskRunOptions) (stepStatus v1alpha1.StepStatus, operations *types.Operation, rErr error) { if options.GetTracer == nil { options.GetTracer = func(id string, step v1alpha1.WorkflowStep) monitorContext.Context { //nolint:revive,unused return monitorContext.NewTraceContext(context.Background(), "") @@ -153,6 +151,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error } tracer := options.GetTracer(exec.wfStatus.ID, wfStep).AddTag("step_name", wfStep.Name, "step_type", wfStep.Type) tracer.V(t.logLevel) + exec.tracer = tracer defer func() { tracer.Commit(string(exec.status().Phase)) }() @@ -160,28 +159,31 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error if t.runOptionsProcess != nil { t.runOptionsProcess(options) } - resetter := tRunner.fillContext(tracer, options.PCtx) defer resetter(options.PCtx) - basicVal, basicTemplate, err := MakeBasicValue(ctx, paramsStr, options.PCtx) + + ctx := providertypes.WithRuntimeParams(tracer.GetContext(), types.RuntimeParams{ + WorkflowContext: wfCtx, + ProcessContext: options.PCtx, + Action: exec, + }) + + basicVal, err := MakeBasicValue(tracer, wfStep.Properties, options.PCtx) if err != nil { tracer.Error(err, "make context parameter") return v1alpha1.StepStatus{}, nil, errors.WithMessage(err, "make context parameter") } - var taskv *value.Value + var taskv cue.Value defer func() { if r := recover(); r != nil { - exec.err(ctx, false, fmt.Errorf("invalid cue task for evaluation: %v", r), types.StatusReasonRendering) + exec.err(wfCtx, false, fmt.Errorf("invalid cue task for evaluation: %v", r), types.StatusReasonRendering) stepStatus = exec.status() operations = exec.operation() return } - if taskv == nil { - taskv, err = value.NewValue(strings.Join([]string{templ, basicTemplate}, "\n"), t.pd, "", value.ProcessScript, value.TagFieldOrder) - if err != nil { - return - } + if taskv == (cue.Value{}) { + taskv = basicVal.FillPath(cue.ParsePath(""), templ) } if options.Debug != nil { if err := options.Debug(exec.wfStatus.ID, taskv); err != nil { @@ -189,7 +191,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error } } for _, hook := range options.PostStopHooks { - if err := hook(ctx, taskv, wfStep, exec.status(), options.StepStatus); err != nil { + if err := hook(wfCtx, taskv, wfStep, exec.status(), options.StepStatus); err != nil { exec.wfStatus.Message = err.Error() stepStatus = exec.status() operations = exec.operation() @@ -199,11 +201,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error }() for _, hook := range options.PreCheckHooks { - result, err := hook(wfStep, &types.PreCheckOptions{ - PackageDiscover: t.pd, - BasicTemplate: basicTemplate, - BasicValue: basicVal, - }) + result, err := hook(wfStep, &types.PreCheckOptions{BasicValue: basicVal}) if err != nil { tracer.Error(err, "do preCheckHook") exec.Skip(fmt.Sprintf("pre check error: %s", err.Error())) @@ -219,38 +217,34 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error } for _, hook := range options.PreStartHooks { - if err := hook(ctx, basicVal, wfStep); err != nil { + if basicVal, err = hook(wfCtx, basicVal, wfStep); err != nil { tracer.Error(err, "do preStartHook") - exec.err(ctx, false, err, types.StatusReasonInput) + exec.err(wfCtx, false, err, types.StatusReasonInput) return exec.status(), exec.operation(), nil } } - // refresh the basic template to get inputs value involved - basicTemplate, err = basicVal.String() - if err != nil { - exec.err(ctx, false, err, types.StatusReasonParameter) - return exec.status(), exec.operation(), nil - } - if status, ok := options.StepStatus[wfStep.Name]; ok { exec.stepStatus = status } - taskv, err = value.NewValue(strings.Join([]string{templ, basicTemplate}, "\n"), t.pd, "", value.ProcessScript, value.TagFieldOrder) + basicTempl, err := util.ToString(basicVal) if err != nil { - exec.err(ctx, false, err, types.StatusReasonRendering) + exec.err(wfCtx, false, err, types.StatusReasonRendering) return exec.status(), exec.operation(), nil } - - exec.tracer = tracer - if debugLog(taskv) { - exec.printStep("workflowStepStart", "workflow", "", taskv) - defer exec.printStep("workflowStepEnd", "workflow", "", taskv) + taskv, err = options.Compiler.CompileString(ctx, strings.Join([]string{templ, basicTempl}, "\n")) + if err != nil { + // resolve the action break error + if resolvedErr := ResolveActionBreak(err); resolvedErr != nil { + tracer.Error(resolvedErr, "do steps") + exec.err(wfCtx, true, resolvedErr, types.StatusReasonExecute) + return exec.status(), exec.operation(), nil + } } - if err := exec.doSteps(tracer, ctx, taskv); err != nil { - tracer.Error(err, "do steps") - exec.err(ctx, true, err, types.StatusReasonExecute) + if exec.stepStatus.Phase == v1alpha1.WorkflowStepPhaseSucceeded && taskv.Err() != nil { + tracer.Error(taskv.Err(), "do steps") + exec.err(wfCtx, true, taskv.Err(), types.StatusReasonExecute) return exec.status(), exec.operation(), nil } @@ -261,25 +255,21 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error } // ValidateIfValue validates the if value -func ValidateIfValue(ctx wfContext.Context, step v1alpha1.WorkflowStep, stepStatus map[string]v1alpha1.StepStatus, options *types.PreCheckOptions) (bool, error) { - if options == nil { - options = &types.PreCheckOptions{} - } - template := fmt.Sprintf("if: %s", step.If) - value, err := buildValueForStatus(ctx, step, template, stepStatus, options) - if err != nil { - return false, errors.WithMessage(err, "invalid if value") - } - check, err := value.GetBool("if") +func ValidateIfValue(ctx wfContext.Context, step v1alpha1.WorkflowStep, stepStatus map[string]v1alpha1.StepStatus, basicVal cue.Value) (bool, error) { + s, _ := util.ToString(basicVal) + template := fmt.Sprintf("if: %s\n%s\n%s\n%s", step.If, getInputsTemplate(ctx, step, basicVal), buildValueForStatus(ctx, step, stepStatus), s) + v := cuecontext.New().CompileString(template).LookupPath(cue.ParsePath("if")) + if v.Err() != nil { + return false, errors.WithMessage(v.Err(), "invalid if value") + } + check, err := v.Bool() if err != nil { return false, err } return check, nil } -func buildValueForStatus(ctx wfContext.Context, step v1alpha1.WorkflowStep, template string, stepStatus map[string]v1alpha1.StepStatus, options *types.PreCheckOptions) (*value.Value, error) { - inputsTemplate := getInputsTemplate(ctx, step, options.BasicValue) - statusTemplate := "\n" +func buildValueForStatus(ctx wfContext.Context, step v1alpha1.WorkflowStep, stepStatus map[string]v1alpha1.StepStatus) string { statusMap := make(map[string]interface{}) for name, ss := range stepStatus { abbrStatus := struct { @@ -301,36 +291,23 @@ func buildValueForStatus(ctx wfContext.Context, step v1alpha1.WorkflowStep, temp } statusMap[name] = abbrStatus } - status, err := json.Marshal(statusMap) - if err != nil { - return nil, err - } - statusTemplate = strings.Join([]string{statusTemplate, fmt.Sprintf("status: %s\n", status), options.BasicTemplate, inputsTemplate}, "\n") - v, err := value.NewValue(template+"\n"+statusTemplate, options.PackageDiscover, "") - if err != nil { - return nil, err - } - if v.Error() != nil { - return nil, v.Error() - } - return v, nil + b, _ := json.Marshal(statusMap) + return fmt.Sprintf("status: %s", string(b)) } // MakeBasicValue makes basic value -func MakeBasicValue(wfCtx wfContext.Context, parameterTemplate string, pCtx process.Context) (*value.Value, string, error) { - paramStr := model.ParameterFieldName + ": {}\n" - if parameterTemplate != "" { - paramStr = fmt.Sprintf(model.ParameterFieldName+": {%s}\n", parameterTemplate) - } - template := strings.Join([]string{getContextTemplate(pCtx), paramStr}, "\n") - v, err := wfCtx.MakeParameter(template) +func MakeBasicValue(ctx monitorContext.Context, properties *runtime.RawExtension, pCtx process.Context) (cue.Value, error) { + // use default compiler to compile the basic value without providers + v, err := cuex.DefaultCompiler.Get().CompileStringWithOptions(ctx, getContextTemplate(pCtx), cuex.WithExtraData( + model.ParameterFieldName, properties, + ), cuex.DisableResolveProviderFunctions{}) if err != nil { - return nil, "", err + return cue.Value{}, err } - if v.Error() != nil { - return nil, "", v.Error() + if v.Err() != nil { + return cue.Value{}, v.Err() } - return v, template, nil + return v, nil } func getContextTemplate(pCtx process.Context) string { @@ -342,296 +319,32 @@ func getContextTemplate(pCtx process.Context) string { if err != nil { return "" } - contextTempl += "\n" + c - return contextTempl + return c } -// GetParameterTemplate gets parameter template -func GetParameterTemplate(step v1alpha1.WorkflowStep) (string, error) { - if step.Properties != nil && len(step.Properties.Raw) > 0 { - params := map[string]interface{}{} - bt, err := step.Properties.MarshalJSON() - if err != nil { - return "", err - } - if err := json.Unmarshal(bt, ¶ms); err != nil { - return "", err - } - b, err := json.Marshal(params) - if err != nil { - return "", err - } - return string(b), nil - } - return "", nil -} - -func getInputsTemplate(ctx wfContext.Context, step v1alpha1.WorkflowStep, basicVal *value.Value) string { +func getInputsTemplate(ctx wfContext.Context, step v1alpha1.WorkflowStep, basicVal cue.Value) string { var inputsTempl string for _, input := range step.Inputs { - inputValue, err := ctx.GetVar(strings.Split(input.From, ".")...) + inputValue, err := ctx.GetVar(input.From) if err != nil { - if basicVal == nil { - continue - } - inputValue, err = basicVal.LookupValue(input.From) - if err != nil { + inputValue = basicVal.LookupPath(value.FieldPath(input.From)) + if !inputValue.Exists() { continue } } - s, err := inputValue.String() + s, err := util.ToString(inputValue) if err != nil { continue } - inputsTempl += fmt.Sprintf("\ninputs: \"%s\": {\n%s\n}", input.From, s) + inputsTempl += fmt.Sprintf("\n\"%s\": {\n%s\n}", input.From, s) } - return inputsTempl -} - -type executor struct { - handlers types.Providers - - wfStatus v1alpha1.StepStatus - stepStatus v1alpha1.StepStatus - suspend bool - terminated bool - failedAfterRetries bool - wait bool - skip bool - - tracer monitorContext.Context -} - -// Suspend let workflow pause. -func (exec *executor) Suspend(message string) { - if exec.wfStatus.Phase == v1alpha1.WorkflowStepPhaseFailed { - return - } - exec.suspend = true - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSuspending - if message != "" { - exec.wfStatus.Message = message - } - exec.wfStatus.Reason = types.StatusReasonSuspend -} - -// Resume let workflow resume. -func (exec *executor) Resume(message string) { - exec.suspend = false - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSucceeded - if message != "" { - exec.wfStatus.Message = message - } -} - -// Terminate let workflow terminate. -func (exec *executor) Terminate(message string) { - exec.terminated = true - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSucceeded - if message != "" { - exec.wfStatus.Message = message - } - exec.wfStatus.Reason = types.StatusReasonTerminate -} - -// Wait let workflow wait. -func (exec *executor) Wait(message string) { - exec.wait = true - if exec.wfStatus.Phase != v1alpha1.WorkflowStepPhaseFailed { - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseRunning - exec.wfStatus.Reason = types.StatusReasonWait - if message != "" { - exec.wfStatus.Message = message - } - } -} - -// Fail let the step fail, its status is failed and reason is Action -func (exec *executor) Fail(message string) { - exec.terminated = true - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseFailed - exec.wfStatus.Reason = types.StatusReasonAction - if message != "" { - exec.wfStatus.Message = message - } -} - -// Message writes message to step status, note that the message will be overwritten by the next message. -func (exec *executor) Message(message string) { - if message != "" { - exec.wfStatus.Message = message - } -} - -func (exec *executor) Skip(message string) { - exec.skip = true - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseSkipped - exec.wfStatus.Reason = types.StatusReasonSkip - exec.wfStatus.Message = message -} - -func (exec *executor) GetStatus() v1alpha1.StepStatus { - return exec.stepStatus -} - -func (exec *executor) timeout(message string) { - exec.terminated = true - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseFailed - exec.wfStatus.Reason = types.StatusReasonTimeout - exec.wfStatus.Message = message -} - -func (exec *executor) err(ctx wfContext.Context, wait bool, err error, reason string) { - exec.wait = wait - exec.wfStatus.Phase = v1alpha1.WorkflowStepPhaseFailed - exec.wfStatus.Message = err.Error() - if exec.wfStatus.Reason == "" { - exec.wfStatus.Reason = reason - if reason != types.StatusReasonExecute { - exec.terminated = true - } - } - exec.checkErrorTimes(ctx) -} - -func (exec *executor) checkErrorTimes(ctx wfContext.Context) { - times := ctx.IncreaseCountValueInMemory(types.ContextPrefixFailedTimes, exec.wfStatus.ID) - if times >= types.MaxWorkflowStepErrorRetryTimes { - exec.wait = false - exec.failedAfterRetries = true - exec.wfStatus.Reason = types.StatusReasonFailedAfterRetries - } -} - -func (exec *executor) operation() *types.Operation { - return &types.Operation{ - Suspend: exec.suspend, - Terminated: exec.terminated, - Waiting: exec.wait, - Skip: exec.skip, - FailedAfterRetries: exec.failedAfterRetries, - } -} - -func (exec *executor) status() v1alpha1.StepStatus { - return exec.wfStatus -} - -func (exec *executor) printStep(phase string, provider string, do string, v *value.Value) { - msg, _ := v.String() - exec.tracer.Info("cue eval: "+msg, "phase", phase, "provider", provider, "do", do) -} - -// Handle process task-step value by provider and do. -func (exec *executor) Handle(ctx monitorContext.Context, wfCtx wfContext.Context, provider string, do string, v *value.Value) error { - if debugLog(v) { - exec.printStep("stepStart", provider, do, v) - defer exec.printStep("stepEnd", provider, do, v) - } - h, exist := exec.handlers.GetHandler(provider, do) - if !exist { - return errors.Errorf("handler not found") - } - return h(ctx, wfCtx, v, exec) -} - -func (exec *executor) doSteps(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value) error { - do := OpTpy(v) - if do != "" && do != "steps" { - provider := opProvider(v) - if err := exec.Handle(ctx, wfCtx, provider, do, v); err != nil { - return errors.WithMessagef(err, "run step(provider=%s,do=%s)", provider, do) - } - return nil - } - return v.StepByFields(func(fieldName string, in *value.Value) (bool, error) { - if in.CueValue().IncompleteKind() == cue.BottomKind { - errInfo, err := sets.ToString(in.CueValue()) - if err != nil { - errInfo = "value is _|_" - } - return true, errors.New(errInfo + "(bottom kind)") - } - if retErr := in.CueValue().Err(); retErr != nil { - errInfo, err := sets.ToString(in.CueValue()) - if err == nil { - retErr = errors.WithMessage(retErr, errInfo) - } - return false, retErr - } - - if isStepList(fieldName) { - return false, in.StepByList(func(name string, item *value.Value) (bool, error) { //nolint:revive,unused - do := OpTpy(item) - if do == "" { - return false, nil - } - return false, exec.doSteps(ctx, wfCtx, item) - }) - } - do := OpTpy(in) - if do == "" { - return false, nil - } - if do == "steps" { - if err := exec.doSteps(ctx, wfCtx, in); err != nil { - return false, err - } - } else { - provider := opProvider(in) - if err := exec.Handle(ctx, wfCtx, provider, do, in); err != nil { - return false, errors.WithMessagef(err, "run step(provider=%s,do=%s)", provider, do) - } - } - - if exec.suspend || exec.terminated || exec.wait { - return true, nil - } - return false, nil - }) -} - -func isStepList(fieldName string) bool { - if fieldName == "#up" { - return true - } - return strings.HasPrefix(fieldName, "#up_") -} - -func debugLog(v *value.Value) bool { - debug, _ := v.CueValue().LookupPath(value.FieldPath("#debug")).Bool() - return debug -} - -// OpTpy get label do -func OpTpy(v *value.Value) string { - return getLabel(v, "#do") -} - -func opProvider(v *value.Value) string { - provider := getLabel(v, "#provider") - if provider == "" { - provider = "builtin" - } - return provider -} - -func getLabel(v *value.Value, label string) string { - do, err := v.Field(label) - if err == nil && do.Exists() { - if str, err := do.String(); err == nil { - return str - } - } - return "" + return fmt.Sprintf("inputs: {%s\n}", inputsTempl) } // NewTaskLoader create a tasks loader. -func NewTaskLoader(lt LoadTaskTemplate, pkgDiscover *packages.PackageDiscover, handlers types.Providers, logLevel int, pCtx process.Context) *TaskLoader { +func NewTaskLoader(lt LoadTaskTemplate, logLevel int, pCtx process.Context) *TaskLoader { return &TaskLoader{ loadTemplate: lt, - pd: pkgDiscover, - handlers: handlers, runOptionsProcess: func(options *types.TaskRunOptions) { if len(options.PreStartHooks) == 0 { options.PreStartHooks = append(options.PreStartHooks, hooks.Input) @@ -646,7 +359,7 @@ func NewTaskLoader(lt LoadTaskTemplate, pkgDiscover *packages.PackageDiscover, h } // CheckPending checks whether to pending task run -func CheckPending(ctx wfContext.Context, step v1alpha1.WorkflowStep, id string, stepStatus map[string]v1alpha1.StepStatus, basicValue *value.Value) (bool, v1alpha1.StepStatus) { +func CheckPending(ctx wfContext.Context, step v1alpha1.WorkflowStep, id string, stepStatus map[string]v1alpha1.StepStatus, basicValue cue.Value) (bool, v1alpha1.StepStatus) { pStatus := v1alpha1.StepStatus{ Phase: v1alpha1.WorkflowStepPhasePending, Type: step.Type, @@ -666,11 +379,7 @@ func CheckPending(ctx wfContext.Context, step v1alpha1.WorkflowStep, id string, for _, input := range step.Inputs { pStatus.Message = fmt.Sprintf("Pending on Input: %s", input.From) if _, err := ctx.GetVar(strings.Split(input.From, ".")...); err != nil { - if basicValue == nil { - return true, pStatus - } - _, err = basicValue.LookupValue(input.From) - if err != nil { + if v := basicValue.LookupPath(cue.ParsePath(input.From)); !v.Exists() { return true, pStatus } } diff --git a/pkg/tasks/custom/task_test.go b/pkg/tasks/custom/task_test.go index 2e3fb42..632b2b9 100644 --- a/pkg/tasks/custom/task_test.go +++ b/pkg/tasks/custom/task_test.go @@ -22,8 +22,9 @@ import ( "fmt" "testing" + "cuelang.org/go/cue" + "cuelang.org/go/cue/cuecontext" "github.com/crossplane/crossplane-runtime/pkg/test" - monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/pkg/errors" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -31,62 +32,68 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/yaml" + "github.com/kubevela/pkg/cue/cuex" + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + monitorContext "github.com/kubevela/pkg/monitor/context" + pkgruntime "github.com/kubevela/pkg/util/runtime" + "github.com/kubevela/pkg/util/singleton" + "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" - "github.com/kubevela/workflow/pkg/providers" + providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) func TestTaskLoader(t *testing.T) { wfCtx := newWorkflowContextForTest(t) r := require.New(t) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "output": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - ip, _ := v.MakeValue(` -myIP: value: "1.1.1.1" -`) - return v.FillObject(ip) - }, - "input": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - val, err := v.LookupValue("set", "prefixIP") - r.NoError(err) - str, err := val.CueValue().String() - r.NoError(err) - r.Equal(str, "1.1.1.1") - return nil - }, - "wait": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - act.Wait("I am waiting") - return nil - }, - "terminate": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - act.Terminate("I am terminated") - return nil - }, - "suspend": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - act.Terminate("I am suspended") - return nil - }, - "resume": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - act.Terminate("I am resumed") - return nil - }, - "executeFailed": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return errors.New("execute error") - }, - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return nil - }, - }) + compiler := cuex.NewCompilerWithInternalPackages( + pkgruntime.Must(cuexruntime.NewInternalPackage("test", "", map[string]cuexruntime.ProviderFn{ + "output": cuexruntime.NativeProviderFn(func(ctx context.Context, v cue.Value) (cue.Value, error) { + return v.FillPath(cue.ParsePath("myIP.value"), "1.1.1.1"), nil + }), + "input": cuexruntime.NativeProviderFn(func(ctx context.Context, v cue.Value) (cue.Value, error) { + val := v.LookupPath(cue.ParsePath("set.prefixIP")) + str, err := val.String() + r.NoError(err) + r.Equal(str, "1.1.1.1") + return v, nil + }), + "templateError": cuexruntime.NativeProviderFn(func(ctx context.Context, v cue.Value) (cue.Value, error) { + return v.Context().CompileString("output: xxx"), nil + }), + "wait": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + val.RuntimeParams.Action.Wait("I am waiting") + return nil, nil + }), + "terminate": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + val.RuntimeParams.Action.Terminate("I am terminated") + return nil, nil + }), + "suspend": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + val.RuntimeParams.Action.Suspend("I am suspended") + return nil, nil + }), + "resume": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + val.RuntimeParams.Action.Resume("I am resumed") + return nil, nil + }), + "executeFailed": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + return nil, errors.New("execute error") + }), + "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + return nil, nil + }), + }, + )), + ) pCtx := process.NewContext(process.ContextData{ Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, nil, discover, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) steps := []v1alpha1.WorkflowStep{ { @@ -135,8 +142,8 @@ myIP: value: "1.1.1.1" }, { WorkflowStepBase: v1alpha1.WorkflowStepBase{ - Name: "steps", - Type: "steps", + Name: "ok", + Type: "ok", }, }, } @@ -146,7 +153,9 @@ myIP: value: "1.1.1.1" r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) r.NoError(err) - status, action, err := run.Run(wfCtx, &types.TaskRunOptions{}) + status, action, err := run.Run(wfCtx, &types.TaskRunOptions{ + Compiler: compiler, + }) r.NoError(err) if step.Name == "wait" { r.Equal(status.Phase, v1alpha1.WorkflowStepPhaseRunning) @@ -178,36 +187,37 @@ myIP: value: "1.1.1.1" func TestErrCases(t *testing.T) { wfCtx := newWorkflowContextForTest(t) r := require.New(t) - closeVar, err := value.NewValue(` -close({ - x: 100 -}) -`, nil, "", value.TagFieldOrder) + closeVar := cuecontext.New().CompileString(` + close({ + x: 100 + }) + `) + err := wfCtx.SetVar(closeVar, "score") r.NoError(err) - err = wfCtx.SetVar(closeVar, "score") - r.NoError(err) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "input": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - val, err := v.LookupValue("prefixIP") - r.NoError(err) - str, err := val.CueValue().String() - r.NoError(err) - r.Equal(str, "1.1.1.1") - return nil - }, - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return nil - }, - "error": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return errors.New("mock error") + compiler := cuex.NewCompilerWithInternalPackages( + // legacy packages + pkgruntime.Must(cuexruntime.NewInternalPackage("test", "", map[string]cuexruntime.ProviderFn{ + "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + return nil, nil + }), + "error": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + return nil, errors.New("mock error") + }), + "input": cuexruntime.NativeProviderFn(func(ctx context.Context, v cue.Value) (cue.Value, error) { + val := v.LookupPath(cue.ParsePath("set.prefixIP")) + str, err := val.String() + r.NoError(err) + r.Equal(str, "1.1.1.1") + return v, nil + }), }, - }) + )), + ) pCtx := process.NewContext(process.ContextData{ Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, nil, discover, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) steps := []v1alpha1.WorkflowStep{ { @@ -267,7 +277,7 @@ close({ r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) r.NoError(err) - status, operation, _ := run.Run(wfCtx, &types.TaskRunOptions{}) + status, operation, _ := run.Run(wfCtx, &types.TaskRunOptions{Compiler: compiler}) switch step.Name { case "input-replace": r.Equal(status.Message, "") @@ -287,13 +297,13 @@ close({ wfContext.CleanupMemoryStore("app-v1", "default") newCtx := newWorkflowContextForTest(t) for i := 0; i < types.MaxWorkflowStepErrorRetryTimes; i++ { - status, operation, err = run.Run(newCtx, &types.TaskRunOptions{}) + status, operation, err = run.Run(newCtx, &types.TaskRunOptions{Compiler: compiler}) r.NoError(err) r.Equal(operation.Waiting, true) r.Equal(operation.FailedAfterRetries, false) r.Equal(status.Phase, v1alpha1.WorkflowStepPhaseFailed) } - status, operation, err = run.Run(newCtx, &types.TaskRunOptions{}) + status, operation, err = run.Run(newCtx, &types.TaskRunOptions{Compiler: compiler}) r.NoError(err) r.Equal(operation.Waiting, false) r.Equal(operation.FailedAfterRetries, true) @@ -306,148 +316,142 @@ close({ } } -func TestSteps(t *testing.T) { - - var ( - echo string - mockErr = errors.New("mock error") - ) - - wfCtx := newWorkflowContextForTest(t) - r := require.New(t) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - echo = echo + "ok" - return nil - }, - "error": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return mockErr - }, - }) - exec := &executor{ - handlers: discover, - } - - testCases := []struct { - base string - expected string - hasErr bool - }{ - { - base: ` -process: { - #provider: "test" - #do: "ok" -} - -#up: [process] -`, - expected: "okok", - }, - { - base: ` -process: { - #provider: "test" - #do: "ok" -} - -#up: [process,{ - #do: "steps" - p1: process - #up: [process] -}] -`, - expected: "okokokok", - }, - { - base: ` -process: { - #provider: "test" - #do: "ok" -} - -#up: [process,{ - p1: process - #up: [process] -}] -`, - expected: "okok", - }, - { - base: ` -process: { - #provider: "test" - #do: "ok" -} - -#up: [process,{ - #do: "steps" - err: { - #provider: "test" - #do: "error" - } @step(1) - #up: [{},process] @step(2) -}] -`, - expected: "okok", - hasErr: true, - }, - - { - base: ` - #provider: "test" - #do: "ok" -`, - expected: "ok", - }, - { - base: ` -process: { - #provider: "test" - #do: "ok" - err: true -} - -if process.err { - err: { - #provider: "test" - #do: "error" - } -} - -apply: { - #provider: "test" - #do: "ok" -} - -#up: [process,{}] -`, - expected: "ok", - hasErr: true, - }, - } - - for i, tc := range testCases { - echo = "" - v, err := value.NewValue(tc.base, nil, "", value.TagFieldOrder) - r.NoError(err) - err = exec.doSteps(nil, wfCtx, v) - r.Equal(err != nil, tc.hasErr) - r.Equal(tc.expected, echo, i) - } - -} +// func TestSteps(t *testing.T) { + +// var ( +// echo string +// mockErr = errors.New("mock error") +// ) + +// wfCtx := newWorkflowContextForTest(t) +// r := require.New(t) +// discover := providers.NewProviders() +// discover.Register("test", map[string]types.Handler{ +// "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { +// echo = echo + "ok" +// return nil +// }, +// "error": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { +// return mockErr +// }, +// }) +// exec := &executor{ +// handlers: discover, +// } + +// testCases := []struct { +// base string +// expected string +// hasErr bool +// }{ +// { +// base: ` +// process: { +// #provider: "test" +// #do: "ok" +// } + +// #up: [process] +// `, +// expected: "okok", +// }, +// { +// base: ` +// process: { +// #provider: "test" +// #do: "ok" +// } + +// #up: [process,{ +// #do: "steps" +// p1: process +// #up: [process] +// }] +// `, +// expected: "okokokok", +// }, +// { +// base: ` +// process: { +// #provider: "test" +// #do: "ok" +// } + +// #up: [process,{ +// p1: process +// #up: [process] +// }] +// `, +// expected: "okok", +// }, +// { +// base: ` +// process: { +// #provider: "test" +// #do: "ok" +// } + +// #up: [process,{ +// #do: "steps" +// err: { +// #provider: "test" +// #do: "error" +// } @step(1) +// #up: [{},process] @step(2) +// }] +// `, +// expected: "okok", +// hasErr: true, +// }, + +// { +// base: ` +// #provider: "test" +// #do: "ok" +// `, +// expected: "ok", +// }, +// { +// base: ` +// process: { +// #provider: "test" +// #do: "ok" +// err: true +// } + +// if process.err { +// err: { +// #provider: "test" +// #do: "error" +// } +// } + +// apply: { +// #provider: "test" +// #do: "ok" +// } + +// #up: [process,{}] +// `, +// expected: "ok", +// hasErr: true, +// }, +// } + +// for i, tc := range testCases { +// echo = "" +// v, err := value.NewValue(tc.base, nil, "", value.TagFieldOrder) +// r.NoError(err) +// err = exec.doSteps(nil, wfCtx, v) +// r.Equal(err != nil, tc.hasErr) +// r.Equal(tc.expected, echo, i) +// } + +// } func TestPendingInputCheck(t *testing.T) { wfCtx := newWorkflowContextForTest(t) r := require.New(t) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return nil - }, - }) step := v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ Name: "pending", @@ -462,7 +466,7 @@ func TestPendingInputCheck(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, nil, discover, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) @@ -470,9 +474,7 @@ func TestPendingInputCheck(t *testing.T) { logCtx := monitorContext.NewTraceContext(context.Background(), "test-app") p, _ := run.Pending(logCtx, wfCtx, nil) r.Equal(p, true) - score, err := value.NewValue(` -100 -`, nil, "") + score := cuecontext.New().CompileString(`100`) r.NoError(err) err = wfCtx.SetVar(score, "score") r.NoError(err) @@ -483,12 +485,6 @@ func TestPendingInputCheck(t *testing.T) { func TestPendingDependsOnCheck(t *testing.T) { wfCtx := newWorkflowContextForTest(t) r := require.New(t) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return nil - }, - }) step := v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ Name: "pending", @@ -500,7 +496,7 @@ func TestPendingDependsOnCheck(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, nil, discover, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) @@ -519,12 +515,6 @@ func TestPendingDependsOnCheck(t *testing.T) { func TestSkip(t *testing.T) { r := require.New(t) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return nil - }, - }) step := v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ Name: "skip", @@ -535,7 +525,7 @@ func TestSkip(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, nil, discover, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) runner, err := gen(step, &types.TaskGeneratorOptions{}) @@ -556,12 +546,14 @@ func TestSkip(t *testing.T) { func TestTimeout(t *testing.T) { r := require.New(t) - discover := providers.NewProviders() - discover.Register("test", map[string]types.Handler{ - "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { - return nil - }, - }) + compiler := cuex.NewCompilerWithInternalPackages( + // legacy packages + pkgruntime.Must(cuexruntime.NewInternalPackage("test", "", map[string]cuexruntime.ProviderFn{ + "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + return nil, nil + }), + })), + ) step := v1alpha1.WorkflowStep{ WorkflowStepBase: v1alpha1.WorkflowStepBase{ Name: "timeout", @@ -572,7 +564,7 @@ func TestTimeout(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, nil, discover, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) runner, err := gen(step, &types.TaskGeneratorOptions{}) @@ -584,6 +576,7 @@ func TestTimeout(t *testing.T) { return &types.PreCheckResult{Timeout: true}, nil }, }, + Compiler: compiler, }) r.NoError(err) r.Equal(status.Phase, v1alpha1.WorkflowStepPhaseFailed) @@ -597,8 +590,10 @@ func TestValidateIfValue(t *testing.T) { Namespace: "default", Data: map[string]interface{}{"arr": []string{"a", "b"}}, }) - basicVal, basicTemplate, err := MakeBasicValue(ctx, `key: "value"`, pCtx) + r := require.New(t) + logCtx := monitorContext.NewTraceContext(context.Background(), "test-app") + basicVal, err := MakeBasicValue(logCtx, &runtime.RawExtension{Raw: []byte(`{"key": "value"}`)}, pCtx) r.NoError(err) testCases := []struct { @@ -703,7 +698,7 @@ func TestValidateIfValue(t *testing.T) { }, }, }, - expectedErr: "not found", + expectedErr: "invalid if value", expected: false, }, { @@ -759,10 +754,7 @@ func TestValidateIfValue(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { r := require.New(t) - v, err := ValidateIfValue(ctx, tc.step, tc.status, &types.PreCheckOptions{ - BasicTemplate: basicTemplate, - BasicValue: basicVal, - }) + v, err := ValidateIfValue(ctx, tc.step, tc.status, basicVal) if tc.expectedErr != "" { r.Contains(err.Error(), tc.expectedErr) r.Equal(v, false) @@ -794,12 +786,13 @@ func newWorkflowContextForTest(t *testing.T) wfContext.Context { return nil }, } - wfCtx, err := wfContext.NewContext(context.Background(), cli, "default", "app-v1", nil) - r.NoError(err) - v, err := value.NewValue(`"yes"`, nil, "") + singleton.KubeClient.Set(cli) + wfCtx, err := wfContext.NewContext(context.Background(), "default", "app-v1", nil) r.NoError(err) + cuectx := cuecontext.New() + v := cuectx.CompileString(`"yes"`) r.NoError(wfCtx.SetVar(v, "test")) - v, err = value.NewValue(`{hello: "world"}`, nil, "") + v = cuectx.CompileString(`{hello: "world"}`) r.NoError(err) r.NoError(wfCtx.SetVar(v, "test-struct")) return wfCtx @@ -819,33 +812,9 @@ name: context.name switch name { case "output": return fmt.Sprintf(templ+`myIP: process.myIP`, "output"), nil - case "input": - return fmt.Sprintf(templ, "input"), nil - case "wait": - return fmt.Sprintf(templ, "wait"), nil - case "terminate": - return fmt.Sprintf(templ, "terminate"), nil - case "templateError": - return ` -output: xx -`, nil - case "executeFailed": - return fmt.Sprintf(templ, "executeFailed"), nil - case "ok": - return fmt.Sprintf(templ, "ok"), nil - case "error": - return fmt.Sprintf(templ, "error"), nil - case "steps": - return ` -#do: "steps" -ok: { - #provider: "test" - #do: "ok" -} -`, nil + default: + return fmt.Sprintf(templ, name), nil } - - return "", nil } var ( diff --git a/pkg/tasks/discover.go b/pkg/tasks/discover.go index ab6deac..28e8480 100644 --- a/pkg/tasks/discover.go +++ b/pkg/tasks/discover.go @@ -39,7 +39,7 @@ func NewTaskDiscover(ctx monitorContext.Context, options types.StepGeneratorOpti builtin: map[string]types.TaskGenerator{ types.WorkflowStepTypeStepGroup: builtin.StepGroup, }, - customTaskDiscover: custom.NewTaskLoader(options.TemplateLoader.LoadTemplate, options.PackageDiscover, options.Providers, options.LogLevel, options.ProcessCtx), + customTaskDiscover: custom.NewTaskLoader(options.TemplateLoader.LoadTemplate, options.LogLevel, options.ProcessCtx), } } diff --git a/pkg/tasks/discover_test.go b/pkg/tasks/discover_test.go index f77bb9a..75c4430 100644 --- a/pkg/tasks/discover_test.go +++ b/pkg/tasks/discover_test.go @@ -52,7 +52,7 @@ func TestDiscover(t *testing.T) { builtin: map[string]types.TaskGenerator{ "stepGroup": builtin.StepGroup, }, - customTaskDiscover: custom.NewTaskLoader(loadTemplate, nil, nil, 0, pCtx), + customTaskDiscover: custom.NewTaskLoader(loadTemplate, 0, pCtx), } _, err := discover.GetTaskGenerator(context.Background(), "stepGroup") diff --git a/pkg/tasks/template/load.go b/pkg/tasks/template/load.go index 2ba473f..92617c1 100644 --- a/pkg/tasks/template/load.go +++ b/pkg/tasks/template/load.go @@ -21,12 +21,12 @@ import ( "embed" "fmt" + "github.com/kubevela/pkg/util/singleton" "github.com/pkg/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" ) var ( @@ -77,11 +77,9 @@ func (loader *WorkflowStepLoader) LoadTemplate(ctx context.Context, name string) } // NewWorkflowStepTemplateLoader create a task template loader. -func NewWorkflowStepTemplateLoader(client client.Client) Loader { +func NewWorkflowStepTemplateLoader() Loader { return &WorkflowStepLoader{ - loadDefinition: func(ctx context.Context, capName string) (string, error) { - return getDefinitionTemplate(ctx, client, capName) - }, + loadDefinition: getDefinitionTemplate, } } @@ -95,11 +93,12 @@ type def struct { } `json:"spec,omitempty"` } -func getDefinitionTemplate(ctx context.Context, cli client.Client, definitionName string) (string, error) { +func getDefinitionTemplate(ctx context.Context, definitionName string) (string, error) { const ( definitionAPIVersion = "core.oam.dev/v1beta1" kindWorkflowStepDefinition = "WorkflowStepDefinition" ) + cli := singleton.KubeClient.Get() definition := &unstructured.Unstructured{} definition.SetAPIVersion(definitionAPIVersion) definition.SetKind(kindWorkflowStepDefinition) diff --git a/pkg/tasks/template/load_test.go b/pkg/tasks/template/load_test.go index c74f584..5d89be7 100644 --- a/pkg/tasks/template/load_test.go +++ b/pkg/tasks/template/load_test.go @@ -23,6 +23,7 @@ import ( "testing" "github.com/crossplane/crossplane-runtime/pkg/test" + "github.com/kubevela/pkg/util/singleton" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/controller-runtime/pkg/client" @@ -48,7 +49,8 @@ func TestLoad(t *testing.T) { return nil }, } - loader := NewWorkflowStepTemplateLoader(cli) + singleton.KubeClient.Set(cli) + loader := NewWorkflowStepTemplateLoader() r := require.New(t) tmpl, err := loader.LoadTemplate(context.Background(), "builtin-apply-component") diff --git a/pkg/types/types.go b/pkg/types/types.go index 50bd508..4453bb8 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -23,19 +23,33 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apiserver/pkg/util/feature" - "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/kubevela/pkg/cue/cuex" monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/features" "github.com/kubevela/workflow/pkg/tasks/template" ) +// RuntimeParams is the runtime parameters of a provider. +type RuntimeParams struct { + WorkflowContext wfContext.Context + ProcessContext process.Context + Action Action + FieldLabel string + Labels map[string]string +} + +// LegacyParams is the legacy input parameters of a provider. +type LegacyParams[T any] struct { + Params T + RuntimeParams +} + // WorkflowInstance is the instance for workflow engine to execute type WorkflowInstance struct { WorkflowMeta @@ -91,9 +105,10 @@ type TaskRunOptions struct { PostStopHooks []TaskPostStopHook GetTracer func(id string, step v1alpha1.WorkflowStep) monitorContext.Context RunSteps func(isDag bool, runners ...TaskRunner) (*v1alpha1.WorkflowRunStatus, error) - Debug func(step string, v *value.Value) error + Debug func(step string, v cue.Value) error StepStatus map[string]v1alpha1.StepStatus Engine Engine + Compiler *cuex.Compiler } // PreCheckResult is the result of pre check. @@ -104,9 +119,7 @@ type PreCheckResult struct { // PreCheckOptions is the options for pre check. type PreCheckOptions struct { - PackageDiscover *packages.PackageDiscover - BasicTemplate string - BasicValue *value.Value + BasicValue cue.Value } // StatusPatcher is the interface to patch status @@ -116,10 +129,10 @@ type StatusPatcher func(ctx context.Context, status *v1alpha1.WorkflowRunStatus, type TaskPreCheckHook func(step v1alpha1.WorkflowStep, options *PreCheckOptions) (*PreCheckResult, error) // TaskPreStartHook run before task execution. -type TaskPreStartHook func(ctx wfContext.Context, paramValue *value.Value, step v1alpha1.WorkflowStep) error +type TaskPreStartHook func(ctx wfContext.Context, paramValue cue.Value, step v1alpha1.WorkflowStep) (cue.Value, error) // TaskPostStopHook run after task execution. -type TaskPostStopHook func(ctx wfContext.Context, taskValue *value.Value, step v1alpha1.WorkflowStep, status v1alpha1.StepStatus, stepStatus map[string]v1alpha1.StepStatus) error +type TaskPostStopHook func(ctx wfContext.Context, taskValue cue.Value, step v1alpha1.WorkflowStep, status v1alpha1.StepStatus, stepStatus map[string]v1alpha1.StepStatus) error // Operation is workflow operation object. type Operation struct { @@ -140,28 +153,16 @@ type TaskGeneratorOptions struct { StepConvertor func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error) SubTaskRunners []TaskRunner SubStepExecuteMode v1alpha1.WorkflowMode - PackageDiscover *packages.PackageDiscover ProcessContext process.Context } -// Handler is provider's processing method. -type Handler func(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act Action) error - -// Providers is provider discover interface. -type Providers interface { - GetHandler(provider, name string) (Handler, bool) - Register(provider string, m map[string]Handler) -} - // StepGeneratorOptions is the options for generate step. type StepGeneratorOptions struct { - Providers Providers - PackageDiscover *packages.PackageDiscover - ProcessCtx process.Context - TemplateLoader template.Loader - Client client.Client - StepConvertor map[string]func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error) - LogLevel int + Compiler cuex.Compiler + ProcessCtx process.Context + TemplateLoader template.Loader + StepConvertor map[string]func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error) + LogLevel int } // Action is that workflow provider can do. diff --git a/pkg/utils/main_test.go b/pkg/utils/main_test.go index 18f266e..e611818 100644 --- a/pkg/utils/main_test.go +++ b/pkg/utils/main_test.go @@ -23,6 +23,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/api/v1alpha1" ) @@ -34,5 +35,6 @@ func TestMain(m *testing.M) { sc := scheme.Scheme _ = v1alpha1.AddToScheme(sc) cli = fake.NewFakeClientWithScheme(sc) + singleton.KubeClient.Set(cli) m.Run() } diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 762712e..13b8cdc 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -23,6 +23,7 @@ import ( "io" "net/http" + "cuelang.org/go/cue" "github.com/kubevela/pkg/multicluster" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,29 +31,28 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/types" ) // GetDataFromContext get data from workflow context -func GetDataFromContext(ctx context.Context, cli client.Client, ctxName, name, ns string, paths ...string) (*value.Value, error) { //nolint:revive,unused - wfCtx, err := wfContext.LoadContext(cli, ns, name, ctxName) +func GetDataFromContext(ctx context.Context, ctxName, name, ns string, paths ...string) (cue.Value, error) { + wfCtx, err := wfContext.LoadContext(ctx, ns, name, ctxName) if err != nil { - return nil, err + return cue.Value{}, err } v, err := wfCtx.GetVar(paths...) if err != nil { - return nil, err + return cue.Value{}, err } - if v.Error() != nil { - return nil, v.Error() + if v.Err() != nil { + return cue.Value{}, v.Err() } return v, nil } // GetLogConfigFromStep get log config from step -func GetLogConfigFromStep(ctx context.Context, cli client.Client, ctxName, name, ns, step string) (*types.LogConfig, error) { //nolint:revive,unused - wfCtx, err := wfContext.LoadContext(cli, ns, name, ctxName) +func GetLogConfigFromStep(ctx context.Context, ctxName, name, ns, step string) (*types.LogConfig, error) { + wfCtx, err := wfContext.LoadContext(ctx, ns, name, ctxName) if err != nil { return nil, err } diff --git a/pkg/utils/utils_test.go b/pkg/utils/utils_test.go index a4ac59e..b0aa25a 100644 --- a/pkg/utils/utils_test.go +++ b/pkg/utils/utils_test.go @@ -71,19 +71,19 @@ func TestGetWorkflowContextData(t *testing.T) { "path not found": { name: "workflow-test-context", paths: "not-found", - expectedErr: "not exist", + expectedErr: "not found", }, } for name, tc := range testCases { t.Run(name, func(t *testing.T) { r := require.New(t) - v, err := GetDataFromContext(ctx, cli, tc.name, tc.name, "default", tc.paths) + v, err := GetDataFromContext(ctx, tc.name, tc.name, "default", tc.paths) if tc.expectedErr != "" { r.Contains(err.Error(), tc.expectedErr) return } r.NoError(err) - s, err := sets.ToString(v.CueValue()) + s, err := sets.ToString(v) r.NoError(err) r.Equal(tc.expected, s) }) @@ -157,7 +157,7 @@ func TestGetStepLogConfig(t *testing.T) { r.NoError(err) }() } - v, err := GetLogConfigFromStep(ctx, cli, tc.name, tc.name, "default", tc.step) + v, err := GetLogConfigFromStep(ctx, tc.name, tc.name, "default", tc.step) if tc.expectedErr != "" { r.Contains(err.Error(), tc.expectedErr) return diff --git a/pkg/webhook/v1alpha1/workflowrun/validating_handler.go b/pkg/webhook/v1alpha1/workflowrun/validating_handler.go index cdb84ab..da9ceac 100644 --- a/pkg/webhook/v1alpha1/workflowrun/validating_handler.go +++ b/pkg/webhook/v1alpha1/workflowrun/validating_handler.go @@ -105,5 +105,5 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a // RegisterValidatingHandler will register application validate handler to the webhook func RegisterValidatingHandler(mgr manager.Manager, args controllers.Args) { server := mgr.GetWebhookServer() - server.Register("/validating-core-oam-dev-v1alpha1-workflowruns", &webhook.Admission{Handler: &ValidatingHandler{pd: args.PackageDiscover}}) + server.Register("/validating-core-oam-dev-v1alpha1-workflowruns", &webhook.Admission{Handler: &ValidatingHandler{}}) } From ee515a70097a33cc3c5926f5af1b1c8e5f2ebf31 Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 25 Apr 2023 11:26:27 +0800 Subject: [PATCH 02/17] use singelton for compiler Signed-off-by: FogDong --- go.mod | 1 - go.sum | 2 - pkg/cue/README.md | 1 - pkg/cue/model/value/error.go | 29 - pkg/cue/model/value/value.go | 619 +-------- pkg/cue/model/value/value_test.go | 1132 ++--------------- pkg/cue/package_suit_test.go | 675 ---------- pkg/cue/packages/package.go | 465 ------- pkg/cue/packages/package_test.go | 639 ---------- pkg/cue/suit_test.go | 79 -- pkg/cue/utils.go | 93 -- pkg/cue/utils_test.go | 155 --- pkg/errors/errors.go | 10 + pkg/executor/workflow.go | 16 +- pkg/generator/generator.go | 1 - pkg/providers/compiler.go | 21 +- pkg/providers/legacy/email/email.go | 3 +- pkg/providers/legacy/email/email_test.go | 6 +- pkg/providers/legacy/http/http.go | 3 +- pkg/providers/legacy/http/http_test.go | 9 +- pkg/providers/legacy/kube/kube.go | 66 +- pkg/providers/legacy/kube/kube_test.go | 45 +- pkg/providers/legacy/legacy.go | 5 +- pkg/providers/legacy/metrics/prom_check.go | 3 +- .../legacy/metrics/prom_check_test.go | 4 +- pkg/providers/legacy/util/util.go | 6 +- pkg/providers/legacy/util/util_test.go | 6 +- pkg/providers/legacy/workspace/workspace.go | 9 +- .../legacy/workspace/workspace_test.go | 24 +- pkg/providers/types/types.go | 58 +- pkg/tasks/custom/task.go | 2 +- pkg/tasks/custom/task_test.go | 151 +-- pkg/types/types.go | 17 - pkg/utils/operation.go | 11 +- .../v1alpha1/workflowrun/suite_test.go | 10 +- .../workflowrun/validating_handler.go | 2 - 36 files changed, 257 insertions(+), 4121 deletions(-) delete mode 100644 pkg/cue/model/value/error.go delete mode 100644 pkg/cue/package_suit_test.go delete mode 100644 pkg/cue/packages/package.go delete mode 100644 pkg/cue/packages/package_test.go delete mode 100644 pkg/cue/suit_test.go delete mode 100644 pkg/cue/utils.go delete mode 100644 pkg/cue/utils_test.go diff --git a/go.mod b/go.mod index ff40d30..1824e18 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( github.com/agiledragon/gomonkey/v2 v2.4.0 github.com/aliyun/aliyun-log-go-sdk v0.1.38 github.com/crossplane/crossplane-runtime v0.19.2 - github.com/cue-exp/kubevelafix v0.0.0-20220922150317-aead819d979d github.com/evanphx/json-patch v5.6.0+incompatible github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da github.com/google/go-cmp v0.5.9 diff --git a/go.sum b/go.sum index 901e2f9..2870a2c 100644 --- a/go.sum +++ b/go.sum @@ -154,8 +154,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crossplane/crossplane-runtime v0.19.2 h1:9qBnhpqKN4x6apF2siaQ6PvgxqBXbGcKmgeD8mSIDO8= github.com/crossplane/crossplane-runtime v0.19.2/go.mod h1:OJQ1NxtQK2ZTRmvtnQPoy8LsXsARTnVydRVDQEgIuz4= -github.com/cue-exp/kubevelafix v0.0.0-20220922150317-aead819d979d h1:VNJA1nSKA8Xna5wjUIMItHlWmEej8Bb9fZ3vCNtIAX0= -github.com/cue-exp/kubevelafix v0.0.0-20220922150317-aead819d979d/go.mod h1:SyTryzw/zYJIogw3H2IRcYdV5gsSoVMJiKGElcQK09I= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/pkg/cue/README.md b/pkg/cue/README.md index 9ede780..a888547 100644 --- a/pkg/cue/README.md +++ b/pkg/cue/README.md @@ -7,4 +7,3 @@ The following packages need to be tested without external/tool dependencies, So - github.com/kubevela/workflow/pkg/cue/model/sets - github.com/kubevela/workflow/pkg/cue/process - github.com/kubevela/workflow/pkg/cue/task -- github.com/kubevela/workflow/pkg/cue/packages diff --git a/pkg/cue/model/value/error.go b/pkg/cue/model/value/error.go deleted file mode 100644 index f55e9d0..0000000 --- a/pkg/cue/model/value/error.go +++ /dev/null @@ -1,29 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package value - -import ( - "fmt" -) - -// LookUpNotFoundErr is the error type of lookup -type LookUpNotFoundErr string - -// Error . -func (e LookUpNotFoundErr) Error() string { - return fmt.Sprintf("failed to lookup value: var(path=%s) not exist", string(e)) -} diff --git a/pkg/cue/model/value/value.go b/pkg/cue/model/value/value.go index e0f50d1..dce0a7c 100644 --- a/pkg/cue/model/value/value.go +++ b/pkg/cue/model/value/value.go @@ -17,9 +17,7 @@ limitations under the License. package value import ( - "encoding/json" "fmt" - "sort" "strconv" "strings" @@ -29,260 +27,16 @@ import ( "cuelang.org/go/cue/cuecontext" "cuelang.org/go/cue/format" "cuelang.org/go/cue/parser" - "github.com/cue-exp/kubevelafix" "github.com/pkg/errors" "github.com/kubevela/pkg/cue/util" "github.com/kubevela/workflow/pkg/cue/model/sets" - "github.com/kubevela/workflow/pkg/cue/packages" - "github.com/kubevela/workflow/pkg/stdlib" + workflowerrors "github.com/kubevela/workflow/pkg/errors" ) // DefaultPackageHeader describes the default package header for CUE files. const DefaultPackageHeader = "package main\n" -// Value is an object with cue.context and vendors -type Value struct { - v cue.Value - r *cue.Context - field string - addImports func(instance *build.Instance) error -} - -// String return value's cue format string -func (val *Value) String(opts ...func(node ast.Node) ast.Node) (string, error) { - opts = append(opts, sets.OptBytesToString) - return sets.ToString(val.v, opts...) -} - -// Error return value's error information. -func (val *Value) Error() error { - v := val.CueValue() - if !v.Exists() { - return errors.New("empty value") - } - if err := val.v.Err(); err != nil { - return err - } - var gerr error - v.Walk(func(value cue.Value) bool { - if err := value.Eval().Err(); err != nil { - gerr = err - return false - } - return true - }, nil) - return gerr -} - -// UnmarshalTo unmarshal value into golang object -func (val *Value) UnmarshalTo(x interface{}) error { - data, err := val.v.MarshalJSON() - if err != nil { - return err - } - return json.Unmarshal(data, x) -} - -// SubstituteInStruct substitute expr in struct lit value -// nolint:staticcheck -func (val *Value) SubstituteInStruct(expr ast.Expr, key string) error { - node := val.CueValue().Syntax(cue.ResolveReferences(true)) - x, ok := node.(*ast.StructLit) - if !ok { - return errors.New("value is not a struct lit") - } - for i := range x.Elts { - if field, ok := x.Elts[i].(*ast.Field); ok { - if strings.Trim(sets.LabelStr(field.Label), `"`) == strings.Trim(key, `"`) { - x.Elts[i].(*ast.Field).Value = expr - b, err := format.Node(node) - if err != nil { - return err - } - val.v = val.r.CompileBytes(b) - return nil - } - } - } - return errors.New("key not found in struct") -} - -// FieldName return value's field name -func (val *Value) FieldName() string { - return val.field -} - -// NewValue new a value -func NewValue(s string, pd *packages.PackageDiscover, tagTempl string, opts ...func(*ast.File) error) (*Value, error) { - builder := &build.Instance{} - - file, err := parser.ParseFile("-", s, parser.ParseComments) - if err != nil { - return nil, err - } - file = kubevelafix.Fix(file).(*ast.File) - for _, opt := range opts { - if err := opt(file); err != nil { - return nil, err - } - } - if err := builder.AddSyntax(file); err != nil { - return nil, err - } - return newValue(builder, pd, tagTempl) -} - -// NewValueWithInstance new value with instance -func NewValueWithInstance(instance *build.Instance, pd *packages.PackageDiscover, tagTempl string) (*Value, error) { - return newValue(instance, pd, tagTempl) -} - -func newValue(builder *build.Instance, pd *packages.PackageDiscover, tagTempl string) (*Value, error) { - addImports := func(inst *build.Instance) error { - if pd != nil { - pd.ImportBuiltinPackagesFor(inst) - } - if err := stdlib.AddImportsFor(inst, tagTempl); err != nil { - return err - } - return nil - } - - if err := addImports(builder); err != nil { - return nil, err - } - - r := cuecontext.New() - inst := r.BuildInstance(builder) - val := new(Value) - val.r = r - val.v = inst - val.addImports = addImports - // do not check val.Err() error here, because the value may be filled later - return val, nil -} - -// AddFile add file to the instance -func AddFile(bi *build.Instance, filename string, src interface{}) error { - if filename == "" { - filename = "-" - } - file, err := parser.ParseFile(filename, src, parser.ParseComments) - file = kubevelafix.Fix(file).(*ast.File) - if err != nil { - return err - } - if err := bi.AddSyntax(file); err != nil { - return err - } - return nil -} - -// TagFieldOrder add step tag. -func TagFieldOrder(root *ast.File) error { - i := 0 - vs := &visitor{ - r: map[string]struct{}{}, - } - for _, decl := range root.Decls { - vs.addAttrForExpr(decl, &i) - } - return nil -} - -type visitor struct { - r map[string]struct{} -} - -func (vs *visitor) done(name string) { - vs.r[name] = struct{}{} -} - -func (vs *visitor) shouldDo(name string) bool { - _, ok := vs.r[name] - return !ok -} -func (vs *visitor) addAttrForExpr(node ast.Node, index *int) { - switch v := node.(type) { - case *ast.Comprehension: - st := v.Value.(*ast.StructLit) - for _, elt := range st.Elts { - vs.addAttrForExpr(elt, index) - } - case *ast.Field: - basic, ok := v.Label.(*ast.Ident) - if !ok { - return - } - if !vs.shouldDo(basic.Name) { - return - } - if v.Attrs == nil { - *index++ - vs.done(basic.Name) - v.Attrs = []*ast.Attribute{ - {Text: fmt.Sprintf("@step(%d)", *index)}, - } - } - } -} - -// MakeValue generate an value with same runtime -func (val *Value) MakeValue(s string) (*Value, error) { - builder := &build.Instance{} - file, err := parser.ParseFile("-", s, parser.ParseComments) - if err != nil { - return nil, err - } - if err := builder.AddSyntax(file); err != nil { - return nil, err - } - if err := val.addImports(builder); err != nil { - return nil, err - } - inst := val.r.BuildInstance(builder) - v := new(Value) - v.r = val.r - v.v = inst - v.addImports = val.addImports - if v.Error() != nil { - return nil, v.Error() - } - return v, nil -} - -func (val *Value) makeValueWithFile(files ...*ast.File) (*Value, error) { - builder := &build.Instance{} - newFile := &ast.File{} - imports := map[string]*ast.ImportSpec{} - for _, f := range files { - for _, importSpec := range f.Imports { - if _, ok := imports[importSpec.Name.String()]; !ok { - imports[importSpec.Name.String()] = importSpec - } - } - newFile.Decls = append(newFile.Decls, f.Decls...) - } - - for _, imp := range imports { - newFile.Imports = append(newFile.Imports, imp) - } - - if err := builder.AddSyntax(newFile); err != nil { - return nil, err - } - if err := val.addImports(builder); err != nil { - return nil, err - } - inst := val.r.BuildInstance(builder) - v := new(Value) - v.r = val.r - v.v = inst - v.addImports = val.addImports - return v, nil -} - // FillRaw unify the value with the cue format string x at the given path. func FillRaw(val cue.Value, x string, paths ...string) (cue.Value, error) { file, err := parser.ParseFile("-", x, parser.ParseComments) @@ -297,36 +51,6 @@ func FillRaw(val cue.Value, x string, paths ...string) (cue.Value, error) { return v, nil } -// FillRaw unify the value with the cue format string x at the given path. -func (val *Value) FillRaw(x string, paths ...string) error { - file, err := parser.ParseFile("-", x, parser.ParseComments) - if err != nil { - return err - } - xInst := val.r.BuildFile(file) - v := val.v.FillPath(FieldPath(paths...), xInst) - if v.Err() != nil { - return v.Err() - } - val.v = v - return nil -} - -// FillValueByScript unify the value x at the given script path. -func (val *Value) FillValueByScript(x *Value, path string) error { - f, err := sets.OpenListLit(val.v) - if err != nil { - return err - } - v := val.r.BuildFile(f) - newV := v.FillPath(FieldPath(path), x.v) - if err := newV.Err(); err != nil { - return err - } - val.v = newV - return nil -} - func setValue(orig ast.Node, expr ast.Expr, selectors []cue.Selector) error { if len(selectors) == 0 { return nil @@ -399,85 +123,6 @@ func SetValueByScript(base, v cue.Value, path ...string) (cue.Value, error) { return base.Context().CompileBytes(b), nil } -// SetValueByScript set the value v at the given script path. -// nolint:staticcheck -func (val *Value) SetValueByScript(v *Value, path ...string) error { - cuepath := FieldPath(path...) - selectors := cuepath.Selectors() - node := val.CueValue().Syntax(cue.ResolveReferences(true)) - if err := setValue(node, v.CueValue().Syntax(cue.ResolveReferences(true)).(ast.Expr), selectors); err != nil { - return err - } - b, err := format.Node(node) - if err != nil { - return err - } - val.v = val.r.CompileBytes(b) - return nil -} - -// CueValue return cue.Value -func (val *Value) CueValue() cue.Value { - return val.v -} - -// FillObject unify the value with object x at the given path. -func (val *Value) FillObject(x interface{}, paths ...string) error { - insert := x - if v, ok := x.(*Value); ok { - if v.r != val.r { - return errors.New("filled value not created with same Runtime") - } - insert = v.v - } - newV := val.v.FillPath(FieldPath(paths...), insert) - // do not check newV.Err() error here, because the value may be filled later - val.v = newV - return nil -} - -// SetObject set the value with object x at the given path. -func (val *Value) SetObject(x interface{}, paths ...string) error { - insert := &Value{ - r: val.r, - } - switch v := x.(type) { - case *Value: - if v.r != val.r { - return errors.New("filled value not created with same Runtime") - } - insert.v = v.v - case ast.Expr: - cueV := val.r.BuildExpr(v) - insert.v = cueV - default: - return fmt.Errorf("not support type %T", x) - } - return val.SetValueByScript(insert, paths...) -} - -// LookupValue reports the value at a path starting from val -func (val *Value) LookupValue(paths ...string) (*Value, error) { - v := val.v.LookupPath(FieldPath(paths...)) - if !v.Exists() { - return nil, errors.Errorf("failed to lookup value: var(path=%s) not exist", strings.Join(paths, ".")) - } - var field string - if len(paths) > 0 { - index := len(paths) - 1 - if index < 0 { - index = 0 - } - field = paths[index] - } - return &Value{ - v: v, - r: val.r, - field: field, - addImports: val.addImports, - }, nil -} - func isScript(content string) (bool, error) { content = strings.TrimSpace(content) scriptFile, err := parser.ParseFile("-", content, parser.ParseComments) @@ -521,7 +166,7 @@ func LookupValueByScript(val cue.Value, script string) (cue.Value, error) { if !isScriptPath { v := val.LookupPath(cue.ParsePath(script)) if !v.Exists() { - return cue.Value{}, LookUpNotFoundErr(script) + return cue.Value{}, workflowerrors.LookUpNotFoundErr(script) } } @@ -544,7 +189,7 @@ func LookupValueByScript(val cue.Value, script string) (cue.Value, error) { v := newV.LookupPath(cue.ParsePath(outputKey)) if !v.Exists() { - return cue.Value{}, LookUpNotFoundErr(outputKey) + return cue.Value{}, workflowerrors.LookUpNotFoundErr(outputKey) } return v, nil } @@ -578,46 +223,6 @@ func makeValueWithFiles(files ...*ast.File) (cue.Value, error) { return v, nil } -// LookupByScript reports the value by cue script. -func (val *Value) LookupByScript(script string) (*Value, error) { - var outputKey = "zz_output__" - script = strings.TrimSpace(script) - scriptFile, err := parser.ParseFile("-", script, parser.ParseComments) - if err != nil { - return nil, errors.WithMessage(err, "parse script") - } - isScriptPath, err := isScript(script) - if err != nil { - return nil, err - } - - if !isScriptPath { - return val.LookupValue(script) - } - - raw, err := val.String() - if err != nil { - return nil, err - } - - rawFile, err := parser.ParseFile("-", raw, parser.ParseComments) - if err != nil { - return nil, errors.WithMessage(err, "parse script") - } - - behindKey(scriptFile, outputKey) - - newV, err := val.makeValueWithFile(rawFile, scriptFile) - if err != nil { - return nil, err - } - if newV.Error() != nil { - return nil, newV.Error() - } - - return newV.LookupValue(outputKey) -} - func behindKey(file *ast.File, key string) { var ( implDecls []ast.Decl @@ -652,224 +257,6 @@ func behindKey(file *ast.File, key string) { } -type field struct { - Name string - Value *Value - no int64 -} - -// StepByList process item in list. -func (val *Value) StepByList(handle func(name string, in *Value) (bool, error)) error { - iter, err := val.CueValue().List() - if err != nil { - return err - } - for iter.Next() { - stop, err := handle(iter.Label(), &Value{ - v: iter.Value(), - r: val.r, - field: iter.Label(), - addImports: val.addImports, - }) - if err != nil { - return err - } - if stop { - return nil - } - } - return nil -} - -// StepByFields process the fields in order -func (val *Value) StepByFields(handle func(name string, in *Value) (bool, error)) error { - iter := steps(val) - for iter.next() { - iter.do(handle) - } - return iter.err -} - -type stepsIterator struct { - queue []*field - index int - target *Value - err error - stopped bool -} - -func steps(v *Value) *stepsIterator { - return &stepsIterator{ - target: v, - } -} - -func (iter *stepsIterator) next() bool { - if iter.stopped { - return false - } - if iter.err != nil { - return false - } - if iter.queue != nil { - iter.index++ - } - iter.assemble() - return iter.index <= len(iter.queue)-1 -} - -func (iter *stepsIterator) assemble() { - filters := map[string]struct{}{} - for _, item := range iter.queue { - filters[item.Name] = struct{}{} - } - cueIter, err := iter.target.v.Fields(cue.Definitions(true), cue.Hidden(true), cue.All()) - if err != nil { - iter.err = err - return - } - var addFields []*field - for cueIter.Next() { - val := cueIter.Value() - name := cueIter.Label() - if val.IncompleteKind() == cue.TopKind { - continue - } - attr := val.Attribute("step") - no, err := attr.Int(0) - if err != nil { - no = 100 - if name == "#do" || name == "#provider" { - no = 0 - } - } - if _, ok := filters[name]; !ok { - addFields = append(addFields, &field{ - Name: name, - no: no, - }) - } - } - - suffixItems := addFields - suffixItems = append(suffixItems, iter.queue[iter.index:]...) - sort.Sort(sortFields(suffixItems)) - iter.queue = append(iter.queue[:iter.index], suffixItems...) -} - -func (iter *stepsIterator) value() *Value { - v := iter.target.v.LookupPath(FieldPath(iter.name())) - return &Value{ - r: iter.target.r, - v: v, - field: iter.name(), - addImports: iter.target.addImports, - } -} - -func (iter *stepsIterator) name() string { - return iter.queue[iter.index].Name -} - -func (iter *stepsIterator) do(handle func(name string, in *Value) (bool, error)) { - if iter.err != nil { - return - } - v := iter.value() - v.field = iter.name() - stopped, err := handle(iter.name(), v) - if err != nil { - iter.err = err - return - } - iter.stopped = stopped - if !isDef(iter.name()) { - if err := iter.target.FillObject(v, iter.name()); err != nil { - iter.err = err - return - } - } -} - -type sortFields []*field - -func (sf sortFields) Len() int { - return len(sf) -} -func (sf sortFields) Less(i, j int) bool { - return sf[i].no < sf[j].no -} - -func (sf sortFields) Swap(i, j int) { - sf[i], sf[j] = sf[j], sf[i] -} - -// Field return the cue value corresponding to the specified field -func (val *Value) Field(label string) (cue.Value, error) { - v := val.v.LookupPath(cue.ParsePath(label)) - if !v.Exists() { - return v, errors.Errorf("label %s not found", label) - } - - if v.IncompleteKind() == cue.BottomKind { - return v, errors.Errorf("label %s's value not computed", label) - } - return v, nil -} - -// GetString get the string value at a path starting from v. -func (val *Value) GetString(paths ...string) (string, error) { - v, err := val.LookupValue(paths...) - if err != nil { - return "", err - } - return v.CueValue().String() -} - -// GetStringSlice get string slice from val -func (val *Value) GetStringSlice(paths ...string) ([]string, error) { - v, err := val.LookupValue(paths...) - if err != nil { - return nil, err - } - var s []string - err = v.UnmarshalTo(&s) - return s, err -} - -// GetInt64 get the int value at a path starting from v. -func (val *Value) GetInt64(paths ...string) (int64, error) { - v, err := val.LookupValue(paths...) - if err != nil { - return 0, err - } - return v.CueValue().Int64() -} - -// GetBool get the int value at a path starting from v. -func (val *Value) GetBool(paths ...string) (bool, error) { - v, err := val.LookupValue(paths...) - if err != nil { - return false, err - } - return v.CueValue().Bool() -} - -// OpenCompleteValue make that the complete value can be modified. -func (val *Value) OpenCompleteValue() error { - newS, err := sets.OpenBaiscLit(val.CueValue()) - if err != nil { - return err - } - - v := cuecontext.New().BuildFile(newS) - val.v = v - return nil -} -func isDef(s string) bool { - return strings.HasPrefix(s, "#") -} - // makePath creates a Path from a sequence of string. func makePath(paths ...string) string { mergedPath := "" diff --git a/pkg/cue/model/value/value_test.go b/pkg/cue/model/value/value_test.go index 07c138e..1dadee1 100644 --- a/pkg/cue/model/value/value_test.go +++ b/pkg/cue/model/value/value_test.go @@ -17,16 +17,13 @@ limitations under the License. package value import ( - "encoding/json" "fmt" "testing" "cuelang.org/go/cue" - "cuelang.org/go/cue/format" - cuejson "cuelang.org/go/pkg/encoding/json" - "github.com/kubevela/workflow/pkg/cue/model/sets" + "cuelang.org/go/cue/cuecontext" + "github.com/kubevela/pkg/cue/util" - "github.com/pkg/errors" "github.com/stretchr/testify/require" ) @@ -42,25 +39,8 @@ object: { } } ` - testVal1, err := NewValue(src, nil, "") - r.NoError(err) - err = testVal1.FillObject(12, "object", "x") - r.NoError(err) - err = testVal1.FillObject("y_string", "object", "y") - r.NoError(err) - z, err := testVal1.MakeValue(` -z: { - provider: string - do: "apply" -} -`) - r.NoError(err) - err = z.FillObject("kube", "z", "provider") - r.NoError(err) - err = testVal1.FillObject(z, "object") - r.NoError(err) - val1String, err := testVal1.String() - r.NoError(err) + cuectx := cuecontext.New() + testVal1 := cuectx.CompileString(src) expectedValString := `object: { x: 12 @@ -69,351 +49,14 @@ z: { provider: "kube" do: "apply" } -} -` - r.Equal(val1String, expectedValString) - - testVal2, err := NewValue(src, nil, "") - r.NoError(err) - err = testVal2.FillRaw(expectedValString) +}` + res, err := FillRaw(testVal1, expectedValString, "") r.NoError(err) - val2String, err := testVal1.String() + val2String, err := util.ToString(res) r.NoError(err) r.Equal(val2String, expectedValString) } -func TestStepByFields(t *testing.T) { - testCases := []struct { - base string - expected string - }{ - {base: ` -step1: {} -step2: {prefix: step1.value} -step3: {prefix: step2.value} -step4: {prefix: step3.value} -if step4.value > 100 { - step5: {prefix: step4.value} -} -`, - expected: `step1: { - value: 100 -} -step2: { - prefix: 100 - value: 101 -} -step3: { - prefix: 101 - value: 102 -} -step5: { - prefix: 103 - value: 104 -} -step4: { - prefix: 102 - value: 103 -} -`}, - - {base: ` -step1: {} -step2: {prefix: step1.value} -if step2.value > 100 { - step2_3: {prefix: step2.value} -} -step3: {prefix: step2.value} -`, - expected: `step1: { - value: 100 -} -step2: { - prefix: 100 - value: 101 -} -step2_3: { - prefix: 101 - value: 102 -} -step3: { - prefix: 101 - value: 103 -} -`}, - } - - for _, tCase := range testCases { - r := require.New(t) - val, err := NewValue(tCase.base, nil, "") - r.NoError(err) - number := 99 - err = val.StepByFields(func(_ string, in *Value) (bool, error) { - number++ - return false, in.FillObject(map[string]interface{}{ - "value": number, - }) - }) - r.NoError(err) - str, err := val.String() - r.NoError(err) - r.Equal(str, tCase.expected) - } - - r := require.New(t) - caseSkip := ` -step1: "1" -step2: "2" -step3: "3" -` - val, err := NewValue(caseSkip, nil, "") - r.NoError(err) - inc := 0 - err = val.StepByFields(func(_ string, in *Value) (bool, error) { - inc++ - s, err := in.CueValue().String() - r.NoError(err) - if s == "2" { - return true, nil - } - return false, nil - }) - r.NoError(err) - r.Equal(inc, 2) - - inc = 0 - err = val.StepByFields(func(_ string, in *Value) (bool, error) { - inc++ - s, err := in.CueValue().String() - r.NoError(err) - if s == "2" { - return false, errors.New("mock error") - } - return false, nil - }) - r.Error(err) - r.Equal(inc, 2) - - inc = 0 - err = val.StepByFields(func(_ string, in *Value) (bool, error) { - inc++ - s, err := in.CueValue().String() - r.NoError(err) - if s == "2" { - v, err := NewValue("v: 33", nil, "") - r.NoError(err) - *in = *v - } - return false, nil - }) - r.Error(err) - r.Equal(inc, 2) -} - -func TestStepWithTag(t *testing.T) { - testCases := []struct { - base string - expected string - }{ - {base: ` -step1: {} -step2: {prefix: step1.value} -step3: {prefix: step2.value} -step4: {prefix: step3.value} -if step4.value > 100 { - step5: {} -} -step5: { - value: *100|int -} -`, - expected: `step1: { - value: 100 -} @step(1) -step2: { - prefix: 100 - value: 101 -} @step(2) -step3: { - prefix: 101 - value: 102 -} @step(3) -step4: { - prefix: 102 - value: 103 -} @step(4) -step5: { - value: 104 -} @step(5) -`}, {base: ` -step1: {} -step2: {prefix: step1.value} -if step2.value > 100 { - step2_3: {prefix: step2.value} -} -step3: {prefix: step2.value} -step4: {prefix: step3.value} -`, - expected: `step1: { - value: 100 -} @step(1) -step2: { - prefix: 100 - value: 101 -} @step(2) -step3: { - prefix: 101 - value: 103 -} @step(4) -step2_3: { - prefix: 101 - value: 102 -} @step(3) -step4: { - prefix: 103 - value: 104 -} @step(5) -`}, {base: ` -step2: {prefix: step1.value} @step(2) -step1: {} @step(1) -step3: {prefix: step2.value} @step(4) -if step2.value > 100 { - step2_3: {prefix: step2.value} @step(3) -} -`, - expected: `step2: { - prefix: 100 - value: 101 -} @step(2) -step1: { - value: 100 -} @step(1) -step2_3: { - prefix: 101 - value: 102 -} @step(3) -step3: { - prefix: 101 - value: 103 -} @step(4) -`}, - - {base: ` -step2: {prefix: step1.value} -step1: {} @step(-1) -if step2.value > 100 { - step2_3: {prefix: step2.value} -} -step3: {prefix: step2.value} -`, - expected: `step2: { - prefix: 100 - value: 101 -} @step(1) -step1: { - value: 100 -} @step(-1) -step2_3: { - prefix: 101 - value: 102 -} @step(2) -step3: { - prefix: 101 - value: 103 -} @step(3) -`}} - - for i, tCase := range testCases { - r := require.New(t) - val, err := NewValue(tCase.base, nil, "", TagFieldOrder) - r.NoError(err) - number := 99 - err = val.StepByFields(func(name string, in *Value) (bool, error) { - number++ - return false, in.FillObject(map[string]interface{}{ - "value": number, - }) - }) - r.NoError(err) - str, err := sets.ToString(val.CueValue()) - r.NoError(err) - r.Equal(str, tCase.expected, fmt.Sprintf("testPatch for case(no:%d) %s", i, str)) - } -} - -func TestUnmarshal(t *testing.T) { - case1 := ` -provider: "kube" -do: "apply" -` - out := struct { - Provider string `json:"provider"` - Do string `json:"do"` - }{} - - r := require.New(t) - val, err := NewValue(case1, nil, "") - r.NoError(err) - err = val.UnmarshalTo(&out) - r.NoError(err) - r.Equal(out.Provider, "kube") - r.Equal(out.Do, "apply") - - bt, err := val.CueValue().MarshalJSON() - r.NoError(err) - expectedJson, err := json.Marshal(out) - r.NoError(err) - r.Equal(string(bt), string(expectedJson)) - - caseIncomplete := ` -provider: string -do: string -` - val, err = NewValue(caseIncomplete, nil, "") - r.NoError(err) - err = val.UnmarshalTo(&out) - r.Error(err) -} - -func TestStepByList(t *testing.T) { - r := require.New(t) - base := `[{step: 1},{step: 2}]` - v, err := NewValue(base, nil, "") - r.NoError(err) - var i int64 - err = v.StepByList(func(name string, in *Value) (bool, error) { - i++ - num, err := in.CueValue().LookupPath(FieldPath("step")).Int64() - r.NoError(err) - r.Equal(num, i) - return false, nil - }) - r.NoError(err) - - i = 0 - err = v.StepByList(func(_ string, _ *Value) (bool, error) { - i++ - return true, nil - }) - r.NoError(err) - r.Equal(i, int64(1)) - - i = 0 - err = v.StepByList(func(_ string, _ *Value) (bool, error) { - i++ - return false, errors.New("mock error") - }) - r.Equal(err.Error(), "mock error") - r.Equal(i, int64(1)) - - notListV, err := NewValue(`{}`, nil, "") - r.NoError(err) - err = notListV.StepByList(func(_ string, _ *Value) (bool, error) { - return false, nil - }) - r.Error(err) -} - func TestFieldPath(t *testing.T) { testCases := []struct { paths []string @@ -465,570 +108,44 @@ func TestFieldPath(t *testing.T) { } } -func TestValueFix(t *testing.T) { - testCases := []struct { - original string - expected string - }{ - { - original: ` -parameter: test: _ -// comment -y: { - for k, v in parameter.test.p { - "\(k)": v - } -}`, - expected: `{ - parameter: { - test: _ - } - // comment - y: { - for k, v in *parameter.test.p | {} { - "\(k)": v - } - } -}`, - }, - } - for i, tc := range testCases { - t.Run(fmt.Sprint(i), func(t *testing.T) { - r := require.New(t) - v, err := NewValue(tc.original, nil, "") - r.NoError(err) - b, err := format.Node(v.CueValue().Syntax(cue.Docs(true))) - r.NoError(err) - r.Equal(tc.expected, string(b)) - }) - } -} - -func TestValue(t *testing.T) { - - // Test NewValue with wrong cue format. - caseError := ` -provider: xxx -` - r := require.New(t) - val, err := NewValue(caseError, nil, "") - r.NoError(err) - r.Error(val.Error()) - - val, err = NewValue(":", nil, "") - r.Error(err) - r.Equal(val == nil, true) - - // Test make error by Fill with wrong cue format. - caseOk := ` -provider: "kube" -do: "apply" -` - val, err = NewValue(caseOk, nil, "") - r.NoError(err) - originCue := val.CueValue() - - _, err = val.MakeValue(caseError) - r.Error(err) - _, err = val.MakeValue(":") - r.Error(err) - _, err = val.MakeValue("test: _|_") - r.Error(err) - err = val.FillRaw(caseError) - r.Error(err) - r.Equal(originCue, val.CueValue()) - cv, err := NewValue(caseOk, nil, "") - r.NoError(err) - err = val.FillObject(cv) - r.Error(err) - r.Equal(originCue, val.CueValue()) - - // Test make error by Fill with cue eval error. - caseClose := ` -close({provider: int}) -` - err = val.FillRaw(caseClose) - r.Error(err) - r.Equal(originCue, val.CueValue()) - cv, err = val.MakeValue(caseClose) - r.NoError(err) - err = val.FillObject(cv) - r.NoError(err) - r.Error(val.Error()) - - _, err = val.LookupValue("abc") - r.Error(err) - - providerValue, err := val.LookupValue("provider") - r.NoError(err) - err = providerValue.StepByFields(func(_ string, in *Value) (bool, error) { - return false, nil - }) - r.Error(err) - - openSt := ` -#X: {...} -x: #X & { - name: "xxx" - age: 12 -} -` - val, err = NewValue(openSt, nil, "") - r.NoError(err) - x, _ := val.LookupValue("x") - xs, _ := x.String() - _, err = val.MakeValue(xs) - r.NoError(err) -} - -func TestLookupValue(t *testing.T) { - testCases := []struct { - name string - str string - paths []string - }{ - { - name: "def", - str: ` -#x: "v" -`, - paths: []string{"#x"}, - }, - { - name: "def in def", - str: ` -#x: { - #y: "v" -} -`, - paths: []string{"#x", "#y"}, - }, - { - name: "num", - str: ` -"1": { - "2": "v" -} -`, - paths: []string{"1", "2"}, - }, - { - name: "invalid", - str: ` -"a-b": { - "b-c": "v" -} -`, - paths: []string{"a-b", "b-c"}, - }, - { - name: "concrete path", - str: ` -a: { - "b-c": "v" -} -`, - paths: []string{`a["b-c"]`}, - }, - { - name: "concrete path with num", - str: ` -a: [ - { - key: "v" - } -] -`, - paths: []string{`a[0].key`}, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - r := require.New(t) - v, err := NewValue(tc.str, nil, "") - r.NoError(err) - result, err := v.LookupValue(tc.paths...) - r.NoError(err) - r.NoError(result.Error()) - s, err := sets.ToString(result.v) - r.Equal(s, `"v" -`) - r.NoError(err) - }) - } -} - -func TestValueError(t *testing.T) { - caseOk := ` -provider: "kube" -do: "apply" -` - r := require.New(t) - val, err := NewValue(caseOk, nil, "") - r.NoError(err) - err = val.FillRaw(` -provider: "conflict"`) - r.Error(err) - - val, err = NewValue(caseOk, nil, "") - r.NoError(err) - err = val.FillObject(map[string]string{ - "provider": "abc", - }) - r.NoError(err) - r.Error(val.Error()) -} - -func TestField(t *testing.T) { - caseSrc := ` -name: "foo" -#name: "fly" -#age: 100 -bottom: _|_ -` - r := require.New(t) - val, err := NewValue(caseSrc, nil, "") - r.NoError(err) - - name, err := val.Field("name") - r.NoError(err) - nameValue, err := name.String() - r.NoError(err) - r.Equal(nameValue, "foo") - - dname, err := val.Field("#name") - r.NoError(err) - nameValue, err = dname.String() - r.NoError(err) - r.Equal(nameValue, "fly") - - _, err = val.Field("age") - r.Error(err) - - _, err = val.Field("bottom") - r.Error(err) -} - -func TestLookupByScript(t *testing.T) { - testCases := []struct { - src string - script string - expect string - }{ - { - src: ` -traits: { - ingress: { - // +patchKey=name - test: [{name: "main", image: "busybox"}] - } -} -`, - script: `traits["ingress"]`, - expect: `// +patchKey=name -test: [{ - name: "main" - image: "busybox" -}] -`, - }, - { - src: ` -apply: containers: [{name: "main", image: "busybox"}] -`, - script: `apply.containers[0].image`, - expect: `"busybox" -`, - }, - { - src: ` -apply: workload: name: "main" -`, - script: ` -apply.workload.name`, - expect: `"main" -`, - }, - { - src: ` -apply: arr: ["abc","def"] -`, - script: ` -import "strings" -strings.Join(apply.arr,".")+"$"`, - expect: `"abc.def$" -`, - }, - } - - for _, tCase := range testCases { - r := require.New(t) - srcV, err := NewValue(tCase.src, nil, "") - r.NoError(err) - v, err := srcV.LookupByScript(tCase.script) - r.NoError(err) - result, _ := v.String() - r.Equal(tCase.expect, result) - } - - errorCases := []struct { - src string - script string - err string - }{ - { - src: ` - op: string - op: "help" -`, - script: `op(1`, - err: "parse script: expected ')', found 'EOF'", - }, - { - src: ` - op: string - op: "help" -`, - script: `oss`, - err: "failed to lookup value: var(path=oss) not exist", - }, - } - - for _, tCase := range errorCases { - r := require.New(t) - srcV, err := NewValue(tCase.src, nil, "") - r.NoError(err) - _, err = srcV.LookupByScript(tCase.script) - r.Error(err, tCase.err) - r.Equal(err.Error(), tCase.err) - } -} - -func TestGet(t *testing.T) { - caseOk := ` -strKey: "xxx" -intKey: 100 -boolKey: true -` - r := require.New(t) - val, err := NewValue(caseOk, nil, "") - r.NoError(err) - - str, err := val.GetString("strKey") - r.NoError(err) - r.Equal(str, "xxx") - // err case - _, err = val.GetInt64("strKey") - r.Error(err) - - intv, err := val.GetInt64("intKey") - r.NoError(err) - r.Equal(intv, int64(100)) - // err case - _, err = val.GetBool("intKey") - r.Error(err) - - ok, err := val.GetBool("boolKey") - r.NoError(err) - r.Equal(ok, true) - // err case - _, err = val.GetString("boolKey") - r.Error(err) -} - -func TestImports(t *testing.T) { - cont := ` -context: stepSessionID: "3w9qkdgn5w"` - v, err := NewValue(` -import ( - "vela/custom" -) - -id: custom.context.stepSessionID - -`+cont, nil, cont) - r := require.New(t) - r.NoError(err) - id, err := v.GetString("id") - r.NoError(err) - r.Equal(id, "3w9qkdgn5w") -} - -func TestOpenCompleteValue(t *testing.T) { - v, err := NewValue(` -x: 10 -y: "100" -`, nil, "") - r := require.New(t) - r.NoError(err) - err = v.OpenCompleteValue() - r.NoError(err) - s, err := v.String() - r.NoError(err) - r.Equal(s, `x: *10 | _ -y: *"100" | _ -`) -} - -func TestFillByScript(t *testing.T) { - testCases := []struct { - name string - raw string - path string - v string - expected string - }{ - { - name: "insert array", - raw: `a: ["hello"]`, - path: "a[1]", - v: `"world"`, - expected: `a: ["hello", "world", ...] -`}, - { - name: "insert array", - raw: `a: b: [{x: 100},...]`, - path: "a.b[1]", - v: `{name: "foo"}`, - expected: `a: { - b: [{ - x: 100 - }, { - name: "foo" - }, ...] -} -`}, - { - name: "insert array to array", - raw: ` -a: b: c: [{x: 100}, {x: 101}, {x: 102}]`, - path: "a.b.c[0].value", - v: `"foo"`, - expected: `a: { - b: { - c: [{ - x: 100 - value: "foo" - }, { - x: 101 - }, { - x: 102 - }, ...] - } -} -`, - }, - { - name: "insert nest array ", - raw: `a: b: [{x: y:[{name: "key"}]}]`, - path: "a.b[0].x.y[0].value", - v: `"foo"`, - expected: `a: { - b: [{ - x: { - y: [{ - name: "key" - value: "foo" - }, ...] - } - }, ...] -} -`, - }, - { - name: "insert without array", - raw: `a: b: [{x: y:[{name: "key"}]}]`, - path: "a.c.x", - v: `"foo"`, - expected: `a: { - b: [{ - x: { - y: [{ - name: "key" - }, ...] - } - }, ...] - c: { - x: "foo" - } -} -`, - }, - { - name: "path with string index", - raw: `a: b: [{x: y:[{name: "key"}]}]`, - path: "a.c[\"x\"]", - v: `"foo"`, - expected: `a: { - b: [{ - x: { - y: [{ - name: "key" - }, ...] - } - }, ...] - c: { - x: "foo" - } -} -`, - }, - } - - for _, tCase := range testCases { - r := require.New(t) - v, err := NewValue(tCase.raw, nil, "") - r.NoError(err) - val, err := v.MakeValue(tCase.v) - r.NoError(err) - err = v.FillValueByScript(val, tCase.path) - r.NoError(err) - s, err := v.String() - r.NoError(err) - r.Equal(s, tCase.expected, tCase.name) - } - - errCases := []struct { - name string - raw string - path string - v string - err string - }{ - { - name: "invalid path", - raw: `a: b: [{x: 100},...]`, - path: "a.b[1]+1", - v: `{name: "foo"}`, - err: "invalid path: invalid label a.b[1]+1 ", - }, - { - name: "invalid path [float]", - raw: `a: b: [{x: 100},...]`, - path: "a.b[0.1]", - v: `{name: "foo"}`, - err: "invalid path: invalid literal 0.1", - }, - { - name: "conflict merge", - raw: `a: b: [{x: y:[{name: "key"}]}]`, - path: "a.b[0].x.y[0].name", - v: `"foo"`, - err: "a.b.0.x.y.0.name: conflicting values \"foo\" and \"key\"", - }, - } - - for _, errCase := range errCases { - r := require.New(t) - v, err := NewValue(errCase.raw, nil, "") - r.NoError(err) - errV, err := v.MakeValue(errCase.v) - r.NoError(err) - err = v.FillValueByScript(errV, errCase.path) - r.Equal(errCase.err, err.Error()) - } -} +// func TestValueFix(t *testing.T) { +// testCases := []struct { +// original string +// expected string +// }{ +// { +// original: ` +// parameter: test: _ +// // comment +// y: { +// for k, v in parameter.test.p { +// "\(k)": v +// } +// }`, +// expected: `{ +// parameter: { +// test: _ +// } +// // comment +// y: { +// for k, v in *parameter.test.p | {} { +// "\(k)": v +// } +// } +// }`, +// }, +// } +// for i, tc := range testCases { +// t.Run(fmt.Sprint(i), func(t *testing.T) { +// r := require.New(t) +// v, err := NewValue(tc.original, nil, "") +// r.NoError(err) +// b, err := format.Node(v.CueValue().Syntax(cue.Docs(true))) +// r.NoError(err) +// r.Equal(tc.expected, string(b)) +// }) +// } +// } func TestSetByScript(t *testing.T) { testCases := []struct { @@ -1039,87 +156,64 @@ func TestSetByScript(t *testing.T) { expected string }{ { - name: "insert array", - raw: `a: ["hello"]`, - path: "a[0]", - v: `"world"`, - expected: `a: ["world"] -`}, + name: "insert array", + raw: `a: ["hello"]`, + path: "a[0]", + v: `"world"`, + expected: `a: ["world"]`}, { - name: "insert array2", - raw: `a: ["hello"]`, - path: "a[1]", - v: `"world"`, - expected: `a: ["hello", "world"] -`}, + name: "insert array2", + raw: `a: ["hello"]`, + path: "a[1]", + v: `"world"`, + expected: `a: ["hello", "world"]`}, { name: "insert array3", raw: `a: b: [{x: 100}]`, path: "a.b[0]", v: `{name: "foo"}`, - expected: `a: { - b: [{ - name: "foo" - }] -} -`}, + expected: `a: b: [{ + name: "foo" +}]`}, { - name: "insert struct", - raw: `a: {b: "hello"}`, - path: "a.b", - v: `"world"`, - expected: `a: { - b: "world" -} -`}, + name: "insert struct", + raw: `a: {b: "hello"}`, + path: "a.b", + v: `"world"`, + expected: `a: b: "world"`}, { name: "insert struct2", raw: `a: {b: "hello"}, c: {d: "world"}`, path: "c.d", v: `"hello"`, - expected: `a: { - b: "hello" -} -c: { - d: "hello" -} -`}, + expected: `a: b: "hello" +c: d: "hello"`}, { name: "insert array to array", raw: ` a: b: c: [{x: 100}, {x: 101}, {x: 102}]`, path: "a.b.c[0].value", v: `"foo"`, - expected: `a: { - b: { - c: [{ - x: 100 - value: "foo" - }, { - x: 101 - }, { - x: 102 - }] - } -} -`, + expected: `a: b: c: [{ + x: 100 + value: "foo" +}, { + x: 101 +}, { + x: 102 +}]`, }, { name: "insert nest array ", raw: `a: b: [{x: y:[{name: "key"}]}]`, path: "a.b[0].x.y[0].value", v: `"foo"`, - expected: `a: { - b: [{ - x: { - y: [{ - name: "key" - value: "foo" - }] - } + expected: `a: b: [{ + x: y: [{ + name: "key" + value: "foo" }] -} -`, +}]`, }, { name: "insert without array", @@ -1128,17 +222,12 @@ a: b: c: [{x: 100}, {x: 101}, {x: 102}]`, v: `"foo"`, expected: `a: { b: [{ - x: { - y: [{ - name: "key" - }] - } + x: y: [{ + name: "key" + }] }] - c: { - x: "foo" - } -} -`, + c: x: "foo" +}`, }, { name: "path with string index", @@ -1147,59 +236,24 @@ a: b: c: [{x: 100}, {x: 101}, {x: 102}]`, v: `"foo"`, expected: `a: { b: [{ - x: { - y: [{ - name: "key" - }] - } + x: y: [{ + name: "key" + }] }] - c: { - x: "foo" - } -} -`, + c: x: "foo" +}`, }, } for _, tCase := range testCases { r := require.New(t) - v, err := NewValue(tCase.raw, nil, "") - r.NoError(err) - val, err := v.MakeValue(tCase.v) - r.NoError(err) - err = v.SetValueByScript(val, tCase.path) + cuectx := cuecontext.New() + base := cuectx.CompileString(tCase.raw) + new := cuectx.CompileString(tCase.v) + res, err := SetValueByScript(base, new, tCase.path) r.NoError(err, tCase.name) - s, err := v.String() + s, err := util.ToString(res) r.NoError(err) r.Equal(s, tCase.expected, tCase.name) } } - -func TestSubstituteInStruct(t *testing.T) { - base := ` -value: { - a: 1 -} -` - r := require.New(t) - val, err := NewValue(base, nil, "") - r.NoError(err) - expr, err := cuejson.Unmarshal([]byte(`{"b": 2}`)) - r.NoError(err) - err = val.SubstituteInStruct(expr, "value") - r.NoError(err) - s, err := val.String() - r.NoError(err) - r.Equal(s, `value: { - b: 2 -} -`) - err = val.SubstituteInStruct(expr, "notfound") - r.Error(err) - - errBase := `1` - val1, err := NewValue(errBase, nil, "") - r.NoError(err) - err = val1.SubstituteInStruct(expr, "value") - r.Error(err) -} diff --git a/pkg/cue/package_suit_test.go b/pkg/cue/package_suit_test.go deleted file mode 100644 index c43842c..0000000 --- a/pkg/cue/package_suit_test.go +++ /dev/null @@ -1,675 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cue - -import ( - "context" - "errors" - "strings" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "cuelang.org/go/cue/build" - "github.com/google/go-cmp/cmp" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - appsv1 "k8s.io/api/apps/v1" - batchv1 "k8s.io/api/batch/v1" - certificatesv1beta1 "k8s.io/api/certificates/v1beta1" - coordinationv1 "k8s.io/api/coordination/v1" - corev1 "k8s.io/api/core/v1" - discoveryv1beta1 "k8s.io/api/discovery/v1beta1" - networkingv1 "k8s.io/api/networking/v1" - policyv1beta1 "k8s.io/api/policy/v1beta1" - rbacv1 "k8s.io/api/rbac/v1" - crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/pointer" - - "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/utils" -) - -var _ = Describe("Package discovery resources for definition from K8s APIServer", func() { - PIt("check that all built-in k8s resource are registered", func() { - var localSchemeBuilder = runtime.SchemeBuilder{ - admissionregistrationv1.AddToScheme, - appsv1.AddToScheme, - batchv1.AddToScheme, - certificatesv1beta1.AddToScheme, - coordinationv1.AddToScheme, - corev1.AddToScheme, - discoveryv1beta1.AddToScheme, - networkingv1.AddToScheme, - policyv1beta1.AddToScheme, - rbacv1.AddToScheme, - } - - var localScheme = runtime.NewScheme() - err := localSchemeBuilder.AddToScheme(localScheme) - Expect(err).Should(BeNil()) - types := localScheme.AllKnownTypes() - for typ := range types { - if strings.HasSuffix(typ.Kind, "List") { - continue - } - if strings.HasSuffix(typ.Kind, "Options") { - continue - } - switch typ.Kind { - case "WatchEvent": - continue - case "APIGroup", "APIVersions": - continue - case "RangeAllocation", "ComponentStatus", "Status": - continue - case "SerializedReference", "EndpointSlice": - continue - case "PodStatusResult", "EphemeralContainers": - continue - } - - Expect(pd.Exist(metav1.GroupVersionKind{ - Group: typ.Group, - Version: typ.Version, - Kind: typ.Kind, - })).Should(BeTrue(), typ.String()) - } - }) - - // nolint:staticcheck - PIt("discovery built-in k8s resource with kube prefix", func() { - - By("test ingress in kube package") - bi := build.NewContext().NewInstance("", nil) - err := bi.AddFile("-", ` -import ( - kube "kube/networking.k8s.io/v1beta1" -) -output: kube.#Ingress -output: { - apiVersion: "networking.k8s.io/v1beta1" - kind: "Ingress" - metadata: name: "myapp" - spec: { - rules: [{ - host: parameter.domain - http: { - paths: [ - for k, v in parameter.http { - path: k - backend: { - serviceName: "myname" - servicePort: v - } - }, - ] - } - }] - } -} -parameter: { - domain: "abc.com" - http: { - "/": 80 - } -}`) - Expect(err).ToNot(HaveOccurred()) - inst, err := pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err := model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err := base.Unstructured() - Expect(err).Should(BeNil()) - - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Ingress", - "apiVersion": "networking.k8s.io/v1beta1", - "metadata": map[string]interface{}{"name": "myapp"}, - "spec": map[string]interface{}{ - "rules": []interface{}{ - map[string]interface{}{ - "host": "abc.com", - "http": map[string]interface{}{ - "paths": []interface{}{ - map[string]interface{}{ - "path": "/", - "backend": map[string]interface{}{ - "serviceName": "myname", - "servicePort": int64(80), - }}}}}}}}, - })).Should(BeEquivalentTo("")) - By("test Invalid Import path") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - kube "kube/networking.k8s.io/v1" -) -output: kube.#Deployment -output: { - metadata: { - "name": parameter.name - } - spec: template: spec: { - containers: [{ - name:"invalid-path", - image: parameter.image - }] - } -} - -parameter: { - name: "myapp" - image: "nginx" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - _, err = model.NewBase(inst.Lookup("output")) - Expect(err).ShouldNot(BeNil()) - Expect(err.Error()).Should(Equal("_|_ // undefined field \"#Deployment\"")) - - By("test Deployment in kube package") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - kube "kube/apps/v1" -) -output: kube.#Deployment -output: { - metadata: { - "name": parameter.name - } - spec: template: spec: { - containers: [{ - name:"test", - image: parameter.image - }] - } -} -parameter: { - name: "myapp" - image: "nginx" -}`) - Expect(err).ShouldNot(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Deployment", - "apiVersion": "apps/v1", - "metadata": map[string]interface{}{"name": "myapp"}, - "spec": map[string]interface{}{ - "selector": map[string]interface{}{}, - "template": map[string]interface{}{ - "spec": map[string]interface{}{ - "containers": []interface{}{ - map[string]interface{}{ - "name": "test", - "image": "nginx"}}}}}}, - })).Should(BeEquivalentTo("")) - - By("test Secret in kube package") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - kube "kube/v1" -) -output: kube.#Secret -output: { - metadata: { - "name": parameter.name - } - type:"kubevela" -} -parameter: { - name: "myapp" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Secret", - "apiVersion": "v1", - "metadata": map[string]interface{}{"name": "myapp"}, - "type": "kubevela"}})).Should(BeEquivalentTo("")) - - By("test Service in kube package") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - kube "kube/v1" -) -output: kube.#Service -output: { - metadata: { - "name": parameter.name - } - spec: type: "ClusterIP", -} -parameter: { - name: "myapp" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Service", - "apiVersion": "v1", - "metadata": map[string]interface{}{"name": "myapp"}, - "spec": map[string]interface{}{ - "type": "ClusterIP"}}, - })).Should(BeEquivalentTo("")) - Expect(pd.Exist(metav1.GroupVersionKind{ - Group: "", - Version: "v1", - Kind: "Service", - })).Should(Equal(true)) - - By("Check newly added CRD refreshed and could be used in CUE package") - crd1 := crdv1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "foo.example.com", - }, - Spec: crdv1.CustomResourceDefinitionSpec{ - Group: "example.com", - Names: crdv1.CustomResourceDefinitionNames{ - Kind: "Foo", - ListKind: "FooList", - Plural: "foo", - Singular: "foo", - }, - Versions: []crdv1.CustomResourceDefinitionVersion{{ - Name: "v1", - Served: true, - Storage: true, - Subresources: &crdv1.CustomResourceSubresources{Status: &crdv1.CustomResourceSubresourceStatus{}}, - Schema: &crdv1.CustomResourceValidation{ - OpenAPIV3Schema: &crdv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]crdv1.JSONSchemaProps{ - "spec": { - Type: "object", - XPreserveUnknownFields: pointer.BoolPtr(true), - Properties: map[string]crdv1.JSONSchemaProps{ - "key": {Type: "string"}, - }}, - "status": { - Type: "object", - XPreserveUnknownFields: pointer.BoolPtr(true), - Properties: map[string]crdv1.JSONSchemaProps{ - "key": {Type: "string"}, - "app-hash": {Type: "string"}, - }}}}}}, - }, - Scope: crdv1.NamespaceScoped, - }, - } - Expect(k8sClient.Create(context.Background(), &crd1)).Should(SatisfyAny(BeNil(), &utils.AlreadyExistMatcher{})) - - Expect(pd.Exist(metav1.GroupVersionKind{ - Group: "example.com", - Version: "v1", - Kind: "Foo", - })).Should(Equal(false)) - - By("test new added CRD in kube package") - Eventually(func() error { - if err := pd.RefreshKubePackagesFromCluster(); err != nil { - return err - } - if !pd.Exist(metav1.GroupVersionKind{ - Group: "example.com", - Version: "v1", - Kind: "Foo", - }) { - return errors.New("crd(example.com/v1.Foo) not register to openAPI") - } - return nil - }, time.Second*30, time.Millisecond*300).Should(BeNil()) - - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - kv1 "kube/example.com/v1" -) -output: kv1.#Foo -output: { - spec: key: "test1" - status: key: "test2" -} -`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Foo", - "apiVersion": "example.com/v1", - "spec": map[string]interface{}{ - "key": "test1"}, - "status": map[string]interface{}{ - "key": "test2"}}, - })).Should(BeEquivalentTo("")) - - }) - - // nolint:staticcheck - PIt("discovery built-in k8s resource with third-party path", func() { - - By("test ingress in kube package") - bi := build.NewContext().NewInstance("", nil) - err := bi.AddFile("-", ` -import ( - network "k8s.io/networking/v1beta1" -) -output: network.#Ingress -output: { - metadata: name: "myapp" - spec: { - rules: [{ - host: parameter.domain - http: { - paths: [ - for k, v in parameter.http { - path: k - backend: { - serviceName: "myname" - servicePort: v - } - }, - ] - } - }] - } -} -parameter: { - domain: "abc.com" - http: { - "/": 80 - } -}`) - Expect(err).ToNot(HaveOccurred()) - inst, err := pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err := model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err := base.Unstructured() - Expect(err).Should(BeNil()) - - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Ingress", - "apiVersion": "networking.k8s.io/v1beta1", - "metadata": map[string]interface{}{"name": "myapp"}, - "spec": map[string]interface{}{ - "rules": []interface{}{ - map[string]interface{}{ - "host": "abc.com", - "http": map[string]interface{}{ - "paths": []interface{}{ - map[string]interface{}{ - "path": "/", - "backend": map[string]interface{}{ - "serviceName": "myname", - "servicePort": int64(80), - }}}}}}}}, - })).Should(BeEquivalentTo("")) - By("test Invalid Import path") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - "k8s.io/networking/v1" -) -output: v1.#Deployment -output: { - metadata: { - "name": parameter.name - } - spec: template: spec: { - containers: [{ - name:"invalid-path", - image: parameter.image - }] - } -} - -parameter: { - name: "myapp" - image: "nginx" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - _, err = model.NewBase(inst.Lookup("output")) - Expect(err).ShouldNot(BeNil()) - Expect(err.Error()).Should(Equal("_|_ // undefined field \"#Deployment\"")) - - By("test Deployment in kube package") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - apps "k8s.io/apps/v1" -) -output: apps.#Deployment -output: { - metadata: { - "name": parameter.name - } - spec: template: spec: { - containers: [{ - name:"test", - image: parameter.image - }] - } -} -parameter: { - name: "myapp" - image: "nginx" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Deployment", - "apiVersion": "apps/v1", - "metadata": map[string]interface{}{"name": "myapp"}, - "spec": map[string]interface{}{ - "selector": map[string]interface{}{}, - "template": map[string]interface{}{ - "spec": map[string]interface{}{ - "containers": []interface{}{ - map[string]interface{}{ - "name": "test", - "image": "nginx"}}}}}}, - })).Should(BeEquivalentTo("")) - - By("test Secret in kube package") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - "k8s.io/core/v1" -) -output: v1.#Secret -output: { - metadata: { - "name": parameter.name - } - type:"kubevela" -} -parameter: { - name: "myapp" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Secret", - "apiVersion": "v1", - "metadata": map[string]interface{}{"name": "myapp"}, - "type": "kubevela"}})).Should(BeEquivalentTo("")) - - By("test Service in kube package") - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - "k8s.io/core/v1" -) -output: v1.#Service -output: { - metadata: { - "name": parameter.name - } - spec: type: "ClusterIP", -} -parameter: { - name: "myapp" -}`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Service", - "apiVersion": "v1", - "metadata": map[string]interface{}{"name": "myapp"}, - "spec": map[string]interface{}{ - "type": "ClusterIP"}}, - })).Should(BeEquivalentTo("")) - Expect(pd.Exist(metav1.GroupVersionKind{ - Group: "", - Version: "v1", - Kind: "Service", - })).Should(Equal(true)) - - By("Check newly added CRD refreshed and could be used in CUE package") - crd1 := crdv1.CustomResourceDefinition{ - ObjectMeta: metav1.ObjectMeta{ - Name: "bar.example.com", - }, - Spec: crdv1.CustomResourceDefinitionSpec{ - Group: "example.com", - Names: crdv1.CustomResourceDefinitionNames{ - Kind: "Bar", - ListKind: "BarList", - Plural: "bar", - Singular: "bar", - }, - Versions: []crdv1.CustomResourceDefinitionVersion{{ - Name: "v1", - Served: true, - Storage: true, - Subresources: &crdv1.CustomResourceSubresources{Status: &crdv1.CustomResourceSubresourceStatus{}}, - Schema: &crdv1.CustomResourceValidation{ - OpenAPIV3Schema: &crdv1.JSONSchemaProps{ - Type: "object", - Properties: map[string]crdv1.JSONSchemaProps{ - "spec": { - Type: "object", - XPreserveUnknownFields: pointer.BoolPtr(true), - Properties: map[string]crdv1.JSONSchemaProps{ - "key": {Type: "string"}, - }}, - "status": { - Type: "object", - XPreserveUnknownFields: pointer.BoolPtr(true), - Properties: map[string]crdv1.JSONSchemaProps{ - "key": {Type: "string"}, - "app-hash": {Type: "string"}, - }}}}}}, - }, - Scope: crdv1.NamespaceScoped, - }, - } - Expect(k8sClient.Create(context.Background(), &crd1)).Should(SatisfyAny(BeNil(), &utils.AlreadyExistMatcher{})) - - Expect(pd.Exist(metav1.GroupVersionKind{ - Group: "example.com", - Version: "v1", - Kind: "Bar", - })).Should(Equal(false)) - - By("test new added CRD in kube package") - Eventually(func() error { - if err := pd.RefreshKubePackagesFromCluster(); err != nil { - return err - } - if !pd.Exist(metav1.GroupVersionKind{ - Group: "example.com", - Version: "v1", - Kind: "Bar", - }) { - return errors.New("crd(example.com/v1.Bar) not register to openAPI") - } - return nil - }, time.Second*30, time.Millisecond*300).Should(BeNil()) - - bi = build.NewContext().NewInstance("", nil) - err = bi.AddFile("-", ` -import ( - ev1 "example.com/v1" -) -output: ev1.#Bar -output: { - spec: key: "test1" - status: key: "test2" -} -`) - Expect(err).Should(BeNil()) - inst, err = pd.ImportPackagesAndBuildInstance(bi) - Expect(err).Should(BeNil()) - base, err = model.NewBase(inst.Lookup("output")) - Expect(err).Should(BeNil()) - data, err = base.Unstructured() - Expect(err).Should(BeNil()) - Expect(cmp.Diff(data, &unstructured.Unstructured{Object: map[string]interface{}{ - "kind": "Bar", - "apiVersion": "example.com/v1", - "spec": map[string]interface{}{ - "key": "test1"}, - "status": map[string]interface{}{ - "key": "test2"}}, - })).Should(BeEquivalentTo("")) - }) -}) diff --git a/pkg/cue/packages/package.go b/pkg/cue/packages/package.go deleted file mode 100644 index d121045..0000000 --- a/pkg/cue/packages/package.go +++ /dev/null @@ -1,465 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package packages - -import ( - "fmt" - "path/filepath" - "strings" - "sync" - "time" - - "cuelang.org/go/cue" - "cuelang.org/go/cue/ast" - "cuelang.org/go/cue/build" - "cuelang.org/go/cue/cuecontext" - "cuelang.org/go/cue/parser" - "cuelang.org/go/cue/token" - "cuelang.org/go/encoding/jsonschema" - "github.com/pkg/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/serializer" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - - "github.com/kubevela/workflow/pkg/stdlib" -) - -const ( - // BuiltinPackageDomain Specify the domain of the built-in package - BuiltinPackageDomain = "kube" - // K8sResourcePrefix Indicates that the definition comes from kubernetes - K8sResourcePrefix = "io_k8s_api_" - - // ParseJSONSchemaErr describes the error that occurs when cue parses json - ParseJSONSchemaErr ParseErrType = "parse json schema of k8s crds error" -) - -// PackageDiscover defines the inner CUE packages loaded from K8s cluster -type PackageDiscover struct { - velaBuiltinPackages []*build.Instance - pkgKinds map[string][]VersionKind - mutex sync.RWMutex - client *rest.RESTClient -} - -// VersionKind contains the resource metadata and reference name -type VersionKind struct { - DefinitionName string - APIVersion string - Kind string -} - -// ParseErrType represents the type of CUEParseError -type ParseErrType string - -// CUEParseError describes an error when CUE parse error -type CUEParseError struct { - err error - errType ParseErrType -} - -// Error implements the Error interface. -func (cueErr CUEParseError) Error() string { - return fmt.Sprintf("%s: %s", cueErr.errType, cueErr.err.Error()) -} - -// IsCUEParseErr returns true if the specified error is CUEParseError type. -func IsCUEParseErr(err error) bool { - return errors.As(err, &CUEParseError{}) -} - -// NewPackageDiscover will create a PackageDiscover client with the K8s config file. -func NewPackageDiscover(config *rest.Config) (*PackageDiscover, error) { - client, err := getClusterOpenAPIClient(config) - if err != nil { - return nil, err - } - pd := &PackageDiscover{ - client: client, - pkgKinds: make(map[string][]VersionKind), - } - if err = pd.RefreshKubePackagesFromCluster(); err != nil { - return pd, err - } - return pd, nil -} - -// ImportBuiltinPackagesFor will add KubeVela built-in packages into your CUE instance -func (pd *PackageDiscover) ImportBuiltinPackagesFor(bi *build.Instance) { - pd.mutex.RLock() - defer pd.mutex.RUnlock() - bi.Imports = append(bi.Imports, pd.velaBuiltinPackages...) -} - -// ImportPackagesAndBuildInstance Combine import built-in packages and build cue template together to avoid data race -// nolint:staticcheck -func (pd *PackageDiscover) ImportPackagesAndBuildInstance(bi *build.Instance) (inst *cue.Instance, err error) { - var r cue.Runtime - if pd == nil { - return r.Build(bi) - } - pd.ImportBuiltinPackagesFor(bi) - if err := stdlib.AddImportsFor(bi, ""); err != nil { - return nil, err - } - pd.mutex.Lock() - defer pd.mutex.Unlock() - return r.Build(bi) -} - -// ImportPackagesAndBuildValue Combine import built-in packages and build cue template together to avoid data race -func (pd *PackageDiscover) ImportPackagesAndBuildValue(bi *build.Instance) (val cue.Value, err error) { - cuectx := cuecontext.New() - if pd == nil { - return cuectx.BuildInstance(bi), nil - } - pd.ImportBuiltinPackagesFor(bi) - if err := stdlib.AddImportsFor(bi, ""); err != nil { - return cue.Value{}, err - } - pd.mutex.Lock() - defer pd.mutex.Unlock() - return cuectx.BuildInstance(bi), nil -} - -// ListPackageKinds list packages and their kinds -func (pd *PackageDiscover) ListPackageKinds() map[string][]VersionKind { - pd.mutex.RLock() - defer pd.mutex.RUnlock() - return pd.pkgKinds -} - -// RefreshKubePackagesFromCluster will use K8s client to load/refresh all K8s open API as a reference kube package using in template -func (pd *PackageDiscover) RefreshKubePackagesFromCluster() error { - return nil - // body, err := pd.client.Get().AbsPath("/openapi/v2").Do(context.Background()).Raw() - // if err != nil { - // return err - // } - // return pd.addKubeCUEPackagesFromCluster(string(body)) -} - -// Exist checks if the GVK exists in the built-in packages -func (pd *PackageDiscover) Exist(gvk metav1.GroupVersionKind) bool { - dgvk := convert2DGVK(gvk) - // package name equals to importPath - importPath := genStandardPkgName(dgvk) - pd.mutex.RLock() - defer pd.mutex.RUnlock() - pkgKinds, ok := pd.pkgKinds[importPath] - if !ok { - pkgKinds = pd.pkgKinds[genOpenPkgName(dgvk)] - } - for _, v := range pkgKinds { - if v.Kind == dgvk.Kind { - return true - } - } - return false -} - -// mount will mount the new parsed package into PackageDiscover built-in packages -func (pd *PackageDiscover) mount(pkg *pkgInstance, pkgKinds []VersionKind) { - pd.mutex.Lock() - defer pd.mutex.Unlock() - if pkgKinds == nil { - pkgKinds = []VersionKind{} - } - for i, p := range pd.velaBuiltinPackages { - if p.ImportPath == pkg.ImportPath { - pd.pkgKinds[pkg.ImportPath] = pkgKinds - pd.velaBuiltinPackages[i] = pkg.Instance - return - } - } - pd.pkgKinds[pkg.ImportPath] = pkgKinds - pd.velaBuiltinPackages = append(pd.velaBuiltinPackages, pkg.Instance) -} - -func (pd *PackageDiscover) pkgBuild(packages map[string]*pkgInstance, pkgName string, - dGVK domainGroupVersionKind, def string, kubePkg *pkgInstance, groupKinds map[string][]VersionKind) error { - pkg, ok := packages[pkgName] - if !ok { - pkg = newPackage(pkgName) - pkg.Imports = []*build.Instance{kubePkg.Instance} - } - - mykinds := groupKinds[pkgName] - mykinds = append(mykinds, VersionKind{ - APIVersion: dGVK.APIVersion, - Kind: dGVK.Kind, - DefinitionName: "#" + dGVK.Kind, - }) - - file, err := parser.ParseFile(dGVK.reverseString(), def) - if err != nil { - return err - } - if err := pkg.AddSyntax(file); err != nil { - return err - } - - packages[pkgName] = pkg - groupKinds[pkgName] = mykinds - return nil -} - -func (pd *PackageDiscover) addKubeCUEPackagesFromCluster(apiSchema string) error { - file, err := parser.ParseFile("-", apiSchema) - if err != nil { - return err - } - oaInst := cuecontext.New().BuildFile(file) - if err != nil { - return err - } - dgvkMapper := make(map[string]domainGroupVersionKind) - pathValue := oaInst.LookupPath(cue.ParsePath("paths")) - if pathValue.Exists() { - iter, err := pathValue.Fields() - if err != nil { - return err - } - for iter.Next() { - gvk := iter.Value().LookupPath(cue.ParsePath("post[\"x-kubernetes-group-version-kind\"]")) - if gvk.Exists() { - if v, err := getDGVK(gvk); err == nil { - dgvkMapper[v.reverseString()] = v - } - } - } - } - oaFile, err := jsonschema.Extract(oaInst, &jsonschema.Config{ - Root: "#/definitions", - Map: openAPIMapping(dgvkMapper), - }) - if err != nil { - return CUEParseError{ - err: err, - errType: ParseJSONSchemaErr, - } - } - kubePkg := newPackage("kube") - kubePkg.processOpenAPIFile(oaFile) - if err := kubePkg.AddSyntax(oaFile); err != nil { - return err - } - packages := make(map[string]*pkgInstance) - groupKinds := make(map[string][]VersionKind) - - for k := range dgvkMapper { - v := dgvkMapper[k] - apiVersion := v.APIVersion - def := fmt.Sprintf(` -import "kube" - -#%s: kube.%s & { -kind: "%s" -apiVersion: "%s", -}`, v.Kind, k, v.Kind, apiVersion) - - if err := pd.pkgBuild(packages, genStandardPkgName(v), v, def, kubePkg, groupKinds); err != nil { - return err - } - if err := pd.pkgBuild(packages, genOpenPkgName(v), v, def, kubePkg, groupKinds); err != nil { - return err - } - } - for name, pkg := range packages { - pd.mount(pkg, groupKinds[name]) - } - return nil -} - -func genOpenPkgName(v domainGroupVersionKind) string { - return BuiltinPackageDomain + "/" + v.APIVersion -} - -func genStandardPkgName(v domainGroupVersionKind) string { - res := []string{v.Group, v.Version} - if v.Domain != "" { - res = []string{v.Domain, v.Group, v.Version} - } - - return strings.Join(res, "/") -} - -func setDiscoveryDefaults(config *rest.Config) { - config.APIPath = "" - config.GroupVersion = nil - if config.Timeout == 0 { - config.Timeout = 32 * time.Second - } - if config.Burst == 0 && config.QPS < 100 { - // discovery is expected to be bursty, increase the default burst - // to accommodate looking up resource info for many API groups. - // matches burst set by ConfigFlags#ToDiscoveryClient(). - // see https://issue.k8s.io/86149 - config.Burst = 100 - } - codec := runtime.NoopEncoder{Decoder: clientgoscheme.Codecs.UniversalDecoder()} - config.NegotiatedSerializer = serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{Serializer: codec}) - if len(config.UserAgent) == 0 { - config.UserAgent = rest.DefaultKubernetesUserAgent() - } -} - -func getClusterOpenAPIClient(config *rest.Config) (*rest.RESTClient, error) { - copyConfig := *config - setDiscoveryDefaults(©Config) - return rest.UnversionedRESTClientFor(©Config) -} - -func openAPIMapping(dgvkMapper map[string]domainGroupVersionKind) func(pos token.Pos, a []string) ([]ast.Label, error) { - return func(pos token.Pos, a []string) ([]ast.Label, error) { - if len(a) < 2 { - return nil, errors.New("openAPIMapping format invalid") - } - - name := strings.ReplaceAll(a[1], ".", "_") - name = strings.ReplaceAll(name, "-", "_") - if _, ok := dgvkMapper[name]; !ok && strings.HasPrefix(name, K8sResourcePrefix) { - trimName := strings.TrimPrefix(name, K8sResourcePrefix) - if v, ok := dgvkMapper[trimName]; ok { - v.Domain = "k8s.io" - dgvkMapper[name] = v - delete(dgvkMapper, trimName) - } - } - - if strings.HasSuffix(a[1], ".JSONSchemaProps") && pos != token.NoPos { - return []ast.Label{ast.NewIdent("_")}, nil - } - - return []ast.Label{ast.NewIdent(name)}, nil - } - -} - -type domainGroupVersionKind struct { - Domain string - Group string - Version string - Kind string - APIVersion string -} - -func (dgvk domainGroupVersionKind) reverseString() string { - var s = []string{dgvk.Kind, dgvk.Version} - s = append(s, strings.Split(dgvk.Group, ".")...) - domain := dgvk.Domain - if domain == "k8s.io" { - domain = "api.k8s.io" - } - - if domain != "" { - s = append(s, strings.Split(domain, ".")...) - } - - for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { - s[i], s[j] = s[j], s[i] - } - return strings.ReplaceAll(strings.Join(s, "_"), "-", "_") -} - -type pkgInstance struct { - *build.Instance -} - -func newPackage(name string) *pkgInstance { - return &pkgInstance{ - &build.Instance{ - PkgName: filepath.Base(name), - ImportPath: name, - }, - } -} - -func (pkg *pkgInstance) processOpenAPIFile(f *ast.File) { - ast.Walk(f, func(node ast.Node) bool { - if st, ok := node.(*ast.StructLit); ok { - hasEllipsis := false - for index, elt := range st.Elts { - if _, isEllipsis := elt.(*ast.Ellipsis); isEllipsis { - if hasEllipsis { - st.Elts = st.Elts[:index] - return true - } - if index > 0 { - st.Elts = st.Elts[:index] - return true - } - hasEllipsis = true - } - } - } - return true - }, nil) - - for _, decl := range f.Decls { - if field, ok := decl.(*ast.Field); ok { - if val, ok := field.Value.(*ast.Ident); ok && val.Name == "string" { - field.Value = ast.NewBinExpr(token.OR, ast.NewIdent("int"), ast.NewIdent("string")) - } - } - } -} - -func getDGVK(v cue.Value) (ret domainGroupVersionKind, err error) { - gvk := metav1.GroupVersionKind{} - gvk.Group, err = v.LookupPath(cue.ParsePath("group")).String() - if err != nil { - return - } - gvk.Version, err = v.LookupPath(cue.ParsePath("version")).String() - if err != nil { - return - } - - gvk.Kind, err = v.LookupPath(cue.ParsePath("kind")).String() - if err != nil { - return - } - - ret = convert2DGVK(gvk) - return -} - -func convert2DGVK(gvk metav1.GroupVersionKind) domainGroupVersionKind { - ret := domainGroupVersionKind{ - Version: gvk.Version, - Kind: gvk.Kind, - APIVersion: gvk.Version, - } - if gvk.Group == "" { - ret.Group = "core" - ret.Domain = "k8s.io" - } else { - ret.APIVersion = gvk.Group + "/" + ret.APIVersion - sv := strings.Split(gvk.Group, ".") - // Domain must contain dot - if len(sv) > 2 { - ret.Domain = strings.Join(sv[1:], ".") - ret.Group = sv[0] - } else { - ret.Group = gvk.Group - } - } - return ret -} diff --git a/pkg/cue/packages/package_test.go b/pkg/cue/packages/package_test.go deleted file mode 100644 index 8824244..0000000 --- a/pkg/cue/packages/package_test.go +++ /dev/null @@ -1,639 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package packages - -import ( - "fmt" - "testing" - - "cuelang.org/go/cue" - "cuelang.org/go/cue/build" - "cuelang.org/go/cue/cuecontext" - "cuelang.org/go/cue/parser" - "cuelang.org/go/cue/token" - "github.com/stretchr/testify/require" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - - "github.com/kubevela/workflow/pkg/cue/model" -) - -func TestPackage(t *testing.T) { - var openAPISchema = ` -{ - "paths": { - "paths...": { - "post":{ - "x-kubernetes-group-version-kind": { - "group": "apps.test.io", - "kind": "Bucket", - "version": "v1" - } - } - } - }, - "definitions":{ - "io.test.apps.v1.Bucket":{ - "properties":{ - "apiVersion": {"type": "string"} - "kind": {"type": "string"} - "acl":{ - "default":"private", - "enum":[ - "public-read-write", - "public-read", - "private" - ], - "type":"string" - }, - "dataRedundancyType":{ - "default":"LRS", - "enum":[ - "LRS", - "ZRS" - ], - "type":"string" - }, - "dataSourceRef":{ - "properties":{ - "dsPath":{ - "type":"string" - } - }, - "required":[ - "dsPath" - ], - "type":"object" - }, - "importRef":{ - "properties":{ - "importKey":{ - "type":"string" - } - }, - "required":[ - "importKey" - ], - "type":"object" - }, - "output":{ - "additionalProperties":{ - "oneOf":[ - { - "properties":{ - "outRef":{ - "type":"string" - } - }, - "required":[ - "outRef" - ] - }, - { - "properties":{ - "valueRef":{ - "description":"Example: demoVpc.vpcId", - "type":"string" - } - }, - "required":[ - "valueRef" - ] - } - ], - "type":"object" - }, - "properties":{ - "bucketName":{ - "properties":{ - "outRef":{ - "enum":[ - "self.name" - ], - "type":"string" - } - }, - "required":[ - "outRef" - ], - "type":"object" - }, - "extranetEndpoint":{ - "properties":{ - "outRef":{ - "enum":[ - "self.state.extranetEndpoint" - ], - "type":"string" - } - }, - "required":[ - "outRef" - ], - "type":"object" - }, - "intranetEndpoint":{ - "properties":{ - "outRef":{ - "enum":[ - "self.state.intranetEndpoint" - ], - "type":"string" - } - }, - "required":[ - "outRef" - ], - "type":"object" - }, - "masterUserId":{ - "properties":{ - "outRef":{ - "enum":[ - "self.state.masterUserId" - ], - "type":"string" - } - }, - "required":[ - "outRef" - ], - "type":"object" - } - }, - "required":[ - "bucketName", - "extranetEndpoint", - "intranetEndpoint", - "masterUserId" - ], - "type":"object" - }, - "profile":{ - "properties":{ - "baasRepo":{ - "oneOf":[ - { - "type":"string" - }, - { - "properties":{ - "valueRef":{ - "description":"Example: demoVpc.vpcId", - "type":"string" - } - }, - "required":[ - "valueRef" - ], - "type":"object" - } - ] - }, - "cloudProduct":{ - "enum":[ - "AliCloudOSS" - ], - "type":"string" - }, - "endpoint":{ - "oneOf":[ - { - "type":"string" - }, - { - "properties":{ - "valueRef":{ - "description":"Example: demoVpc.vpcId", - "type":"string" - } - }, - "required":[ - "valueRef" - ], - "type":"object" - } - ] - }, - "envType":{ - "oneOf":[ - { - "enum":[ - "testing", - "product" - ] - }, - { - "properties":{ - "valueRef":{ - "description":"Example: demoVpc.vpcId", - "type":"string" - } - }, - "required":[ - "valueRef" - ], - "type":"object" - } - ] - }, - "provider":{ - "enum":[ - "alicloud" - ], - "type":"string" - }, - "region":{ - "oneOf":[ - { - "type":"string" - }, - { - "properties":{ - "valueRef":{ - "description":"Example: demoVpc.vpcId", - "type":"string" - } - }, - "required":[ - "valueRef" - ], - "type":"object" - } - ] - }, - "serviceAccount":{ - "oneOf":[ - { - "type":"string" - }, - { - "properties":{ - "valueRef":{ - "description":"Example: demoVpc.vpcId", - "type":"string" - } - }, - "required":[ - "valueRef" - ], - "type":"object" - } - ] - } - }, - "required":[ - "cloudProduct", - "provider", - "baasRepo", - "region" - ], - "type":"object" - }, - "storageClass":{ - "default":"Standard", - "enum":[ - "Standard", - "IA", - "Archive", - "ColdArchive" - ], - "type":"string" - }, - "type":{ - "enum":[ - "alicloud_oss_bucket" - ], - "type":"string" - } - }, - "required":[ - "type", - "output", - "profile", - "acl" - ], - "type":"object" - } - } -} -` - r := require.New(t) - mypd := &PackageDiscover{pkgKinds: make(map[string][]VersionKind)} - err := mypd.addKubeCUEPackagesFromCluster(openAPISchema) - r.NoError(err) - expectPkgKinds := map[string][]VersionKind{ - "test.io/apps/v1": []VersionKind{{ - DefinitionName: "#Bucket", - APIVersion: "apps.test.io/v1", - Kind: "Bucket", - }}, - "kube/apps.test.io/v1": []VersionKind{{ - DefinitionName: "#Bucket", - APIVersion: "apps.test.io/v1", - Kind: "Bucket", - }}, - } - r.Equal(mypd.ListPackageKinds(), expectPkgKinds) - - // TODO: fix losing close struct in cue - exceptObj := `output: { - apiVersion: "apps.test.io/v1" - kind: "Bucket" - acl: *"private" | "public-read" | "public-read-write" - dataRedundancyType?: "LRS" | "ZRS" | *"LRS" - dataSourceRef?: { - dsPath: string - } - importRef?: { - importKey: string - } - output: { - bucketName: { - outRef: "self.name" - } - extranetEndpoint: { - outRef: "self.state.extranetEndpoint" - } - intranetEndpoint: { - outRef: "self.state.intranetEndpoint" - } - masterUserId: { - outRef: "self.state.masterUserId" - } - } - profile: { - baasRepo: string | { - // Example: demoVpc.vpcId - valueRef: string - } - cloudProduct: "AliCloudOSS" - endpoint?: string | { - // Example: demoVpc.vpcId - valueRef: string - } - envType?: "testing" | "product" | { - // Example: demoVpc.vpcId - valueRef: string - } - provider: "alicloud" - region: string | { - // Example: demoVpc.vpcId - valueRef: string - } - serviceAccount?: string | { - // Example: demoVpc.vpcId - valueRef: string - } - } - storageClass?: "Standard" | "IA" | "Archive" | "ColdArchive" | *"Standard" - type: "alicloud_oss_bucket" -} -` - bi := build.NewContext().NewInstance("", nil) - file, err := parser.ParseFile("-", ` -import "test.io/apps/v1" -output: v1.#Bucket -`) - r.NoError(err) - err = bi.AddSyntax(file) - r.NoError(err) - inst, err := mypd.ImportPackagesAndBuildValue(bi) - r.NoError(err) - base, err := model.NewBase(inst) - r.NoError(err) - s, err := base.String() - r.NoError(err) - r.Equal(s, exceptObj) - - bi = build.NewContext().NewInstance("", nil) - file, err = parser.ParseFile("-", ` -import "kube/apps.test.io/v1" -output: v1.#Bucket -`) - r.NoError(err) - err = bi.AddSyntax(file) - r.NoError(err) - inst, err = mypd.ImportPackagesAndBuildValue(bi) - r.NoError(err) - base, err = model.NewBase(inst) - r.NoError(err) - s, err = base.String() - r.NoError(err) - r.Equal(s, exceptObj) -} - -func TestProcessFile(t *testing.T) { - srcTmpl := ` -#Definition: { - kind?: string - apiVersion?: string - metadata: { - name: string - ... - } - ... -} -` - r := require.New(t) - file, err := parser.ParseFile("-", srcTmpl) - r.NoError(err) - testPkg := newPackage("foo") - testPkg.processOpenAPIFile(file) - cuectx := cuecontext.New() - inst := cuectx.BuildFile(file) - - testCasesInst := cuectx.CompileString(` -#Definition: {} -case1: #Definition & {additionalProperty: "test"} - -case2: #Definition & { - metadata: { - additionalProperty: "test" - } -} -`) - retInst := inst.FillPath(cue.ParsePath(""), testCasesInst.Value()) - r.Error(retInst.LookupPath(cue.ParsePath("case1")).Err(), "case1.additionalProperty: field not allowed") - r.Error(retInst.LookupPath(cue.ParsePath("case2.metadata")).Err(), "case2.metadata.additionalProperty: field not allowed") -} - -func TestMount(t *testing.T) { - mypd := &PackageDiscover{pkgKinds: make(map[string][]VersionKind)} - testPkg := newPackage("foo") - mypd.mount(testPkg, []VersionKind{}) - r := require.New(t) - r.Equal(len(mypd.velaBuiltinPackages), 1) - mypd.mount(testPkg, []VersionKind{}) - r.Equal(len(mypd.velaBuiltinPackages), 1) - r.Equal(mypd.velaBuiltinPackages[0], testPkg.Instance) -} - -func TestGetDGVK(t *testing.T) { - srcTmpl := ` -{ - "x-kubernetes-group-version-kind": { - "group": "apps.test.io", - "kind": "Foo", - "version": "v1" - } -} -` - r := require.New(t) - file, err := parser.ParseFile("-", srcTmpl) - r.NoError(err) - inst := cuecontext.New().BuildFile(file) - gvk, err := getDGVK(inst.Value().LookupPath(cue.ParsePath("\"x-kubernetes-group-version-kind\""))) - r.NoError(err) - r.Equal(gvk, domainGroupVersionKind{ - Domain: "test.io", - Group: "apps", - Version: "v1", - Kind: "Foo", - APIVersion: "apps.test.io/v1", - }) - - srcTmpl = ` -{ - "x-kubernetes-group-version-kind": { - "group": "test.io", - "kind": "Foo", - "version": "v1" - } -} -` - inst = cuecontext.New().CompileString(srcTmpl) - gvk, err = getDGVK(inst.LookupPath(cue.ParsePath("\"x-kubernetes-group-version-kind\""))) - r.NoError(err) - r.Equal(gvk, domainGroupVersionKind{ - Group: "test.io", - Version: "v1", - Kind: "Foo", - APIVersion: "test.io/v1", - }) -} - -func TestOpenAPIMapping(t *testing.T) { - testCases := []struct { - input []string - pos token.Pos - result string - errMsg string - }{ - { - input: []string{"definitions", "io.k8s.api.discovery.v1beta1.Endpoint"}, - pos: token.NoPos, - result: "[io_k8s_api_discovery_v1beta1_Endpoint]", - }, - { - input: []string{"definitions", "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.JSONSchemaProps"}, - pos: token.NoPos.Add(1), - result: "[_]", - }, - { - input: []string{"definitions", "io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.JSONSchemaProps"}, - pos: token.NoPos, - result: "[io_k8s_apiextensions_apiserver_pkg_apis_apiextensions_v1_JSONSchemaProps]", - }, - { - input: []string{"definitions"}, - pos: token.NoPos, - errMsg: "openAPIMapping format invalid", - }, - } - - emptyMapper := make(map[string]domainGroupVersionKind) - for _, tCase := range testCases { - r := require.New(t) - labels, err := openAPIMapping(emptyMapper)(tCase.pos, tCase.input) - if tCase.errMsg != "" { - r.Error(err, tCase.errMsg) - continue - } - r.NoError(err) - r.Equal(len(labels), 1) - r.Equal(tCase.result, fmt.Sprint(labels)) - } -} - -func TestGeneratePkgName(t *testing.T) { - testCases := []struct { - dgvk domainGroupVersionKind - sdPkgName string - openPkgName string - }{ - { - dgvk: domainGroupVersionKind{ - Domain: "k8s.io", - Group: "networking", - Version: "v1", - Kind: "Ingress", - }, - sdPkgName: "k8s.io/networking/v1", - openPkgName: "kube/networking.k8s.io", - }, - { - dgvk: domainGroupVersionKind{ - Group: "example.com", - Version: "v1", - Kind: "Sls", - }, - sdPkgName: "example.com/v1", - openPkgName: "kube/example.com/v1", - }, - } - - for _, tCase := range testCases { - r := require.New(t) - r.Equal(genStandardPkgName(tCase.dgvk), tCase.sdPkgName) - } -} - -func TestReverseString(t *testing.T) { - testCases := []struct { - gvr metav1.GroupVersionKind - reverseString string - }{ - { - gvr: metav1.GroupVersionKind{ - Group: "networking.k8s.io", - Version: "v1", - Kind: "NetworkPolicy", - }, - reverseString: "io_k8s_api_networking_v1_NetworkPolicy", - }, - { - gvr: metav1.GroupVersionKind{ - Group: "example.com", - Version: "v1", - Kind: "Sls", - }, - reverseString: "com_example_v1_Sls", - }, - { - gvr: metav1.GroupVersionKind{ - Version: "v1", - Kind: "Pod", - }, - reverseString: "io_k8s_api_core_v1_Pod", - }, - } - - for _, tCase := range testCases { - r := require.New(t) - r.Equal(convert2DGVK(tCase.gvr).reverseString(), tCase.reverseString) - } -} diff --git a/pkg/cue/suit_test.go b/pkg/cue/suit_test.go deleted file mode 100644 index ed6088a..0000000 --- a/pkg/cue/suit_test.go +++ /dev/null @@ -1,79 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cue - -import ( - "testing" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/apimachinery/pkg/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - "k8s.io/client-go/rest" - "k8s.io/utils/pointer" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/envtest" - - "github.com/kubevela/workflow/pkg/cue/packages" -) - -// These tests use Ginkgo (BDD-style Go testing framework). Refer to -// http://onsi.github.io/ginkgo/ to learn more about Ginkgo. - -var cfg *rest.Config -var k8sClient client.Client -var testEnv *envtest.Environment -var scheme = runtime.NewScheme() -var pd *packages.PackageDiscover - -func TestDefinition(t *testing.T) { - RegisterFailHandler(Fail) - - RunSpecs(t, "Test Definition Suite") -} - -var _ = BeforeSuite(func(done Done) { - By("Bootstrapping test environment") - testEnv = &envtest.Environment{ - ControlPlaneStartTimeout: time.Minute, - ControlPlaneStopTimeout: time.Minute, - UseExistingCluster: pointer.BoolPtr(false), - } - var err error - cfg, err = testEnv.Start() - Expect(err).ToNot(HaveOccurred()) - Expect(cfg).ToNot(BeNil()) - Expect(clientgoscheme.AddToScheme(scheme)).Should(BeNil()) - Expect(crdv1.AddToScheme(scheme)).Should(BeNil()) - // +kubebuilder:scaffold:scheme - By("Create the k8s client") - k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) - Expect(err).ToNot(HaveOccurred()) - Expect(k8sClient).ToNot(BeNil()) - pd, err = packages.NewPackageDiscover(cfg) - Expect(err).ToNot(HaveOccurred()) - - close(done) -}, 60) - -var _ = AfterSuite(func() { - By("Tearing down the test environment") - err := testEnv.Stop() - Expect(err).ToNot(HaveOccurred()) -}) diff --git a/pkg/cue/utils.go b/pkg/cue/utils.go deleted file mode 100644 index 6999bd1..0000000 --- a/pkg/cue/utils.go +++ /dev/null @@ -1,93 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cue - -import ( - "bytes" - - "cuelang.org/go/pkg/encoding/json" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - - "github.com/kubevela/workflow/pkg/cue/model/value" -) - -// int data can evaluate with number in CUE, so it's OK if we convert the original float type data to int -func isIntegral(val float64) bool { - return val == float64(int(val)) -} - -// IntifyValues will make values to int. -// JSON marshalling of user values will put integer into float, -// we have to change it back so that CUE check will succeed. -func IntifyValues(raw interface{}) interface{} { - switch v := raw.(type) { - case map[string]interface{}: - return intifyMap(v) - case []interface{}: - return intifyList(v) - case float64: - if isIntegral(v) { - return int(v) - } - return v - default: - return raw - } -} - -func intifyList(l []interface{}) interface{} { - l2 := make([]interface{}, 0, len(l)) - for _, v := range l { - l2 = append(l2, IntifyValues(v)) - } - return l2 -} - -func intifyMap(m map[string]interface{}) interface{} { - m2 := make(map[string]interface{}, len(m)) - for k, v := range m { - m2[k] = IntifyValues(v) - } - return m2 -} - -// FillUnstructuredObject fill runtime.Unstructured to *value.Value -func FillUnstructuredObject(v *value.Value, obj runtime.Unstructured, paths ...string) error { - var buf bytes.Buffer - if err := unstructured.UnstructuredJSONScheme.Encode(obj, &buf); err != nil { - return v.FillObject(err.Error(), "err") - } - expr, err := json.Unmarshal(buf.Bytes()) - if err != nil { - return v.FillObject(err.Error(), "err") - } - return v.FillObject(expr, paths...) -} - -// SetUnstructuredObject set runtime.Unstructured to *value.Value -func SetUnstructuredObject(v *value.Value, obj runtime.Unstructured, path string) error { - var buf bytes.Buffer - if err := unstructured.UnstructuredJSONScheme.Encode(obj, &buf); err != nil { - return v.FillObject(err.Error(), "err") - } - expr, err := json.Unmarshal(buf.Bytes()) - if err != nil { - return v.FillObject(err.Error(), "err") - } - return v.SetObject(expr, path) -} diff --git a/pkg/cue/utils_test.go b/pkg/cue/utils_test.go deleted file mode 100644 index 4d755a2..0000000 --- a/pkg/cue/utils_test.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package cue - -import ( - "testing" - - "github.com/stretchr/testify/require" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - - "github.com/kubevela/workflow/pkg/cue/model/value" -) - -func TestIntifyValues(t *testing.T) { - testcases := map[string]struct { - input interface{} - output interface{} - }{ - "default case": { - input: "string", - output: "string", - }, - "float64": { - input: float64(1), - output: 1, - }, - "array": { - input: []interface{}{float64(1), float64(2)}, - output: []interface{}{1, 2}, - }, - "map": { - input: map[string]interface{}{"a": float64(1), "b": float64(2)}, - output: map[string]interface{}{"a": 1, "b": 2}, - }, - } - for name, testcase := range testcases { - t.Run(name, func(t *testing.T) { - r := require.New(t) - result := IntifyValues(testcase.input) - r.Equal(testcase.output, result) - }) - } -} - -func TestFillUnstructuredObject(t *testing.T) { - testcases := map[string]struct { - obj *unstructured.Unstructured - json string - }{ - "test unstructured object with nil value": { - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "apps/v1", - "kind": "Deployment", - "spec": map[string]interface{}{ - "template": map[string]interface{}{ - "metadata": map[string]interface{}{ - "creationTimestamp": nil, - }, - }, - }, - }, - }, - json: `{"object":{"apiVersion":"apps/v1","kind":"Deployment","spec":{"template":{"metadata":{"creationTimestamp":null}}}}}`, - }, - "test unstructured object without nil value": { - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": map[string]interface{}{ - "creationTimestamp": "2022-05-25T12:07:02Z", - }, - }, - }, - json: `{"object":{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"creationTimestamp":"2022-05-25T12:07:02Z"}}}`, - }, - } - - for name, testcase := range testcases { - t.Run(name, func(t *testing.T) { - r := require.New(t) - value, err := value.NewValue("", nil, "") - r.NoError(err) - err = FillUnstructuredObject(value, testcase.obj, "object") - r.NoError(err) - json, err := value.CueValue().MarshalJSON() - r.NoError(err) - r.Equal(testcase.json, string(json)) - }) - } -} - -func TestSubstituteUnstructuredObject(t *testing.T) { - testcases := map[string]struct { - obj *unstructured.Unstructured - json string - }{ - "test unstructured object with nil value": { - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "apps/v1", - "kind": "Deployment", - "spec": map[string]interface{}{ - "template": map[string]interface{}{ - "metadata": map[string]interface{}{ - "creationTimestamp": nil, - }, - }, - }, - }, - }, - json: `{"object":{"apiVersion":"apps/v1","kind":"Deployment","spec":{"template":{"metadata":{"creationTimestamp":null}}}}}`, - }, - "test unstructured object without nil value": { - obj: &unstructured.Unstructured{ - Object: map[string]interface{}{ - "apiVersion": "apps/v1", - "kind": "Deployment", - "metadata": map[string]interface{}{ - "creationTimestamp": "2022-05-25T12:07:02Z", - }, - }, - }, - json: `{"object":{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"creationTimestamp":"2022-05-25T12:07:02Z"}}}`, - }, - } - - for name, testcase := range testcases { - t.Run(name, func(t *testing.T) { - r := require.New(t) - value, err := value.NewValue(`object:{"test": "test"}`, nil, "") - r.NoError(err) - err = SetUnstructuredObject(value, testcase.obj, "object") - r.NoError(err) - json, err := value.CueValue().MarshalJSON() - r.NoError(err) - r.Equal(testcase.json, string(json)) - }) - } -} diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index 5ca6d71..2c70a77 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -16,6 +16,8 @@ limitations under the License. package errors +import "fmt" + // ActionType is the type of action type ActionType string @@ -34,3 +36,11 @@ type GenericActionError ActionType func (e GenericActionError) Error() string { return "" } + +// LookUpNotFoundErr is the error type of lookup +type LookUpNotFoundErr string + +// Error . +func (e LookUpNotFoundErr) Error() string { + return fmt.Sprintf("failed to lookup value: var(path=%s) not exist", string(e)) +} diff --git a/pkg/executor/workflow.go b/pkg/executor/workflow.go index 99594a4..61cc27a 100644 --- a/pkg/executor/workflow.go +++ b/pkg/executor/workflow.go @@ -39,6 +39,7 @@ import ( "github.com/kubevela/workflow/pkg/hooks" "github.com/kubevela/workflow/pkg/monitor/metrics" "github.com/kubevela/workflow/pkg/providers" + "github.com/kubevela/workflow/pkg/providers/legacy/workspace" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" ) @@ -71,17 +72,7 @@ func New(instance *types.WorkflowInstance, options ...Option) WorkflowExecutor { opt.ApplyTo(executor) } if executor.compiler == nil { - executor.compiler = providers.NewCompiler(nil) - // v, err := executor.compiler.CompileString(context.Background(), `import ( - // "vela/op" - // ) - // a: op.#Suspend & {}`) - // if err != nil { - // panic(err) - // } - // if v.Err() != nil { - // panic(v.Err()) - // } + executor.compiler = providers.Compiler.Get() } return executor } @@ -281,8 +272,7 @@ func handleSuspendBackoffTime(wfCtx wfContext.Context, step v1alpha1.WorkflowSte } } - //FIXME: - if ts := wfCtx.GetMutableValue(status.ID, "resumeTimeStamp"); ts != "" { + if ts := wfCtx.GetMutableValue(status.ID, workspace.ResumeTimeStamp); ts != "" { t, err := time.Parse(time.RFC3339, ts) if err != nil { return min diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 96ee6f8..ee7bcd3 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -33,7 +33,6 @@ import ( "github.com/kubevela/workflow/pkg/executor" "github.com/kubevela/workflow/pkg/monitor/metrics" - // providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/tasks" "github.com/kubevela/workflow/pkg/tasks/template" "github.com/kubevela/workflow/pkg/types" diff --git a/pkg/providers/compiler.go b/pkg/providers/compiler.go index acdf5e5..b5e8bf3 100644 --- a/pkg/providers/compiler.go +++ b/pkg/providers/compiler.go @@ -20,9 +20,9 @@ import ( "github.com/kubevela/pkg/cue/cuex" cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" "github.com/kubevela/pkg/util/runtime" + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/pkg/providers/legacy" - providertypes "github.com/kubevela/workflow/pkg/providers/types" ) const ( @@ -30,15 +30,10 @@ const ( LegacyProviderName = "op" ) -var defaultCompiler *cuex.Compiler - -// NewCompiler create a cuex compiler -func NewCompiler(kubeHandlers *providertypes.KubeHandlers) *cuex.Compiler { - if defaultCompiler == nil { - defaultCompiler = cuex.NewCompilerWithInternalPackages( - // legacy packages - runtime.Must(cuexruntime.NewInternalPackage(LegacyProviderName, legacy.GetLegacyTemplate(), legacy.GetLegacyProviders(kubeHandlers))), - ) - } - return defaultCompiler -} +// Compiler is the workflow default compiler +var Compiler = singleton.NewSingletonE[*cuex.Compiler](func() (*cuex.Compiler, error) { + return cuex.NewCompilerWithInternalPackages( + // legacy packages + runtime.Must(cuexruntime.NewInternalPackage(LegacyProviderName, legacy.GetLegacyTemplate(), legacy.GetLegacyProviders())), + ), nil +}) diff --git a/pkg/providers/legacy/email/email.go b/pkg/providers/legacy/email/email.go index 9a2e027..eddac85 100644 --- a/pkg/providers/legacy/email/email.go +++ b/pkg/providers/legacy/email/email.go @@ -29,7 +29,6 @@ import ( "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/errors" providertypes "github.com/kubevela/workflow/pkg/providers/types" - "github.com/kubevela/workflow/pkg/types" ) const ( @@ -60,7 +59,7 @@ type MailVars struct { } // MailParams . -type MailParams = types.LegacyParams[MailVars] +type MailParams = providertypes.LegacyParams[MailVars] var emailRoutine sync.Map diff --git a/pkg/providers/legacy/email/email_test.go b/pkg/providers/legacy/email/email_test.go index 7c209ea..03fb866 100644 --- a/pkg/providers/legacy/email/email_test.go +++ b/pkg/providers/legacy/email/email_test.go @@ -31,7 +31,7 @@ import ( "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/mock" - "github.com/kubevela/workflow/pkg/types" + providertypes "github.com/kubevela/workflow/pkg/providers/types" ) func TestSendEmail(t *testing.T) { @@ -100,7 +100,7 @@ func TestSendEmail(t *testing.T) { } _, err := Send(ctx, &MailParams{ Params: tc.vars, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ ProcessContext: pCtx, Action: act, }, @@ -116,7 +116,7 @@ func TestSendEmail(t *testing.T) { time.Sleep(time.Second) _, err = Send(ctx, &MailParams{ Params: tc.vars, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ ProcessContext: pCtx, Action: act, }, diff --git a/pkg/providers/legacy/http/http.go b/pkg/providers/legacy/http/http.go index 29719ee..2fbfd18 100644 --- a/pkg/providers/legacy/http/http.go +++ b/pkg/providers/legacy/http/http.go @@ -37,7 +37,6 @@ import ( "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" providertypes "github.com/kubevela/workflow/pkg/providers/types" - "github.com/kubevela/workflow/pkg/types" ) const ( @@ -91,7 +90,7 @@ type ResponseVars struct { } // DoParams is the params for http request -type DoParams = types.LegacyParams[RequestVars] +type DoParams = providertypes.LegacyParams[RequestVars] // Do process http request. func Do(ctx context.Context, params *DoParams) (*ResponseVars, error) { diff --git a/pkg/providers/legacy/http/http_test.go b/pkg/providers/legacy/http/http_test.go index 30cbd75..a237e35 100644 --- a/pkg/providers/legacy/http/http_test.go +++ b/pkg/providers/legacy/http/http_test.go @@ -36,7 +36,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kubevela/pkg/util/singleton" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" "github.com/kubevela/workflow/pkg/providers/legacy/http/testdata" ) @@ -280,13 +279,7 @@ func TestHTTPSDo(t *testing.T) { } singleton.KubeClient.Set(cli) r := require.New(t) - v, err := value.NewValue(` -method: "GET" -url: "https://127.0.0.1:8443/api/v1/token?val=test-token" -`, nil, "") - r.NoError(err) - r.NoError(v.FillObject("certs", "tls_config", "secret")) - _, err = Do(ctx, &DoParams{ + _, err := Do(ctx, &DoParams{ Params: RequestVars{ Method: "GET", URL: "https://127.0.0.1:8443/api/v1/token?val=test-token", diff --git a/pkg/providers/legacy/kube/kube.go b/pkg/providers/legacy/kube/kube.go index 78c9b2f..d27c5cb 100644 --- a/pkg/providers/legacy/kube/kube.go +++ b/pkg/providers/legacy/kube/kube.go @@ -37,7 +37,6 @@ import ( "github.com/kubevela/workflow/pkg/cue/model" providertypes "github.com/kubevela/workflow/pkg/providers/types" - "github.com/kubevela/workflow/pkg/types" ) const ( @@ -47,10 +46,6 @@ const ( AnnoWorkflowLastAppliedTime = "workflow.oam.dev/last-applied-time" ) -type provider struct { - handlers providertypes.KubeHandlers -} - const ( // WorkflowResourceCreator is the creator name of workflow resource WorkflowResourceCreator string = "workflow" @@ -125,11 +120,22 @@ type ResourceReturns struct { } // ResourceParams . -type ResourceParams = types.LegacyParams[ResourceVars] +type ResourceParams = providertypes.LegacyParams[ResourceVars] + +func getHandlers(runtimeParams providertypes.RuntimeParams) *providertypes.KubeHandlers { + if runtimeParams.KubeHandlers != nil { + return runtimeParams.KubeHandlers + } + return &providertypes.KubeHandlers{ + Apply: apply, + Delete: delete, + } +} // Apply create or update CR in cluster. -func (h *provider) Apply(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { +func Apply(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { workload := params.Params.Resource + handlers := getHandlers(params.RuntimeParams) if workload.GetNamespace() == "" { workload.SetNamespace("default") } @@ -139,7 +145,7 @@ func (h *provider) Apply(ctx context.Context, params *ResourceParams) (*Resource } } deployCtx := handleContext(ctx, params.Params.Cluster) - if err := h.handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { + if err := handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { return nil, err } return &ResourceReturns{ @@ -159,18 +165,19 @@ type ApplyInParallelReturns struct { } // ApplyInParallelParams . -type ApplyInParallelParams = types.LegacyParams[ApplyInParallelVars] +type ApplyInParallelParams = providertypes.LegacyParams[ApplyInParallelVars] // ApplyInParallel create or update CRs in parallel. -func (h *provider) ApplyInParallel(ctx context.Context, params *ApplyInParallelParams) (*ApplyInParallelReturns, error) { +func ApplyInParallel(ctx context.Context, params *ApplyInParallelParams) (*ApplyInParallelReturns, error) { workloads := params.Params.Resources + handlers := getHandlers(params.RuntimeParams) for i := range workloads { if workloads[i].GetNamespace() == "" { workloads[i].SetNamespace("default") } } deployCtx := handleContext(ctx, params.Params.Cluster) - if err := h.handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workloads...); err != nil { + if err := handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workloads...); err != nil { return nil, err } return &ApplyInParallelReturns{ @@ -179,7 +186,8 @@ func (h *provider) ApplyInParallel(ctx context.Context, params *ApplyInParallelP } // Patch patch CR in cluster. -func (h *provider) Patch(ctx context.Context, params *types.LegacyParams[cue.Value]) (cue.Value, error) { +func Patch(ctx context.Context, params *providertypes.LegacyParams[cue.Value]) (cue.Value, error) { + handlers := getHandlers(params.RuntimeParams) val := params.Params.LookupPath(cue.ParsePath("value")) obj := new(unstructured.Unstructured) b, err := val.MarshalJSON() @@ -220,14 +228,14 @@ func (h *provider) Patch(ctx context.Context, params *types.LegacyParams[cue.Val return cue.Value{}, err } } - if err := h.handlers.Apply(multiCtx, cluster, WorkflowResourceCreator, workload); err != nil { + if err := handlers.Apply(multiCtx, cluster, WorkflowResourceCreator, workload); err != nil { return cue.Value{}, err } return params.Params.FillPath(cue.ParsePath("result"), workload), nil } // Read get CR from cluster. -func (h *provider) Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { +func Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { workload := params.Params.Resource key := client.ObjectKeyFromObject(workload) if key.Namespace == "" { @@ -251,7 +259,7 @@ type ListReturns struct { } // List lists CRs from cluster. -func (h *provider) List(ctx context.Context, params *ResourceParams) (*ListReturns, error) { +func List(ctx context.Context, params *ResourceParams) (*ListReturns, error) { workload := params.Params.Resource list := &unstructured.UnstructuredList{Object: map[string]interface{}{ "kind": workload.GetKind(), @@ -275,8 +283,9 @@ func (h *provider) List(ctx context.Context, params *ResourceParams) (*ListRetur } // Delete deletes CR from cluster. -func (h *provider) Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { +func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) { workload := params.Params.Resource + handlers := getHandlers(params.RuntimeParams) deleteCtx := handleContext(ctx, params.Params.Cluster) if filter := params.Params.Filter; filter != nil { @@ -292,7 +301,7 @@ func (h *provider) Delete(ctx context.Context, params *ResourceParams) (*Resourc return nil, nil } - if err := h.handlers.Delete(deleteCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { + if err := handlers.Delete(deleteCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { return &ResourceReturns{ Error: err, }, nil @@ -310,22 +319,13 @@ func GetTemplate() string { } // GetProviders get kube providers. -func GetProviders(handlers *providertypes.KubeHandlers) map[string]cuexruntime.ProviderFn { - if handlers == nil { - handlers = &providertypes.KubeHandlers{ - Apply: apply, - Delete: delete, - } - } - prd := &provider{ - handlers: *handlers, - } +func GetProviders() map[string]cuexruntime.ProviderFn { return map[string]cuexruntime.ProviderFn{ - "apply": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](prd.Apply), - "apply-in-parallel": providertypes.LegacyGenericProviderFn[ApplyInParallelVars, ApplyInParallelReturns](prd.ApplyInParallel), - "read": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](prd.Read), - "list": providertypes.LegacyGenericProviderFn[ResourceVars, ListReturns](prd.List), - "delete": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](prd.Delete), - "patch": providertypes.LegacyNativeProviderFn(prd.Patch), + "apply": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](Apply), + "apply-in-parallel": providertypes.LegacyGenericProviderFn[ApplyInParallelVars, ApplyInParallelReturns](ApplyInParallel), + "read": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](Read), + "list": providertypes.LegacyGenericProviderFn[ResourceVars, ListReturns](List), + "delete": providertypes.LegacyGenericProviderFn[ResourceVars, ResourceReturns](Delete), + "patch": providertypes.LegacyNativeProviderFn(Patch), } } diff --git a/pkg/providers/legacy/kube/kube_test.go b/pkg/providers/legacy/kube/kube_test.go index e84e3b3..49d77a9 100644 --- a/pkg/providers/legacy/kube/kube_test.go +++ b/pkg/providers/legacy/kube/kube_test.go @@ -42,9 +42,7 @@ import ( "github.com/kubevela/pkg/util/singleton" - "github.com/kubevela/workflow/pkg/cue/packages" providertypes "github.com/kubevela/workflow/pkg/providers/types" - "github.com/kubevela/workflow/pkg/types" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -54,8 +52,6 @@ var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment var scheme = runtime.NewScheme() -var pd *packages.PackageDiscover -var p *provider func TestProvider(t *testing.T) { RegisterFailHandler(Fail) @@ -81,16 +77,8 @@ var _ = BeforeSuite(func(done Done) { k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient).ToNot(BeNil()) - pd, err = packages.NewPackageDiscover(cfg) - Expect(err).ToNot(HaveOccurred()) singleton.KubeClient.Set(k8sClient) - p = &provider{ - handlers: providertypes.KubeHandlers{ - Apply: apply, - Delete: delete, - }, - } close(done) }, 120) @@ -103,18 +91,20 @@ var _ = AfterSuite(func() { var _ = Describe("Test Workflow Provider Kube", func() { It("apply and read", func() { ctx := context.Background() - ctx = providertypes.WithLabelParams(ctx, map[string]string{ - "hello": "world", - }) un := testUnstructured.DeepCopy() un.SetName("app") un.SetLabels(map[string]string{ "test": "test", }) - res, err := p.Apply(ctx, &ResourceParams{ + res, err := Apply(ctx, &ResourceParams{ Params: ResourceVars{ Resource: un, }, + RuntimeParams: providertypes.RuntimeParams{ + Labels: map[string]string{ + "hello": "world", + }, + }, }) Expect(err).ToNot(HaveOccurred()) Expect(res.Resource.GetLabels()).Should(Equal(un.GetLabels())) @@ -130,7 +120,7 @@ var _ = Describe("Test Workflow Provider Kube", func() { "hello": "world", })) - res, err = p.Read(ctx, &ResourceParams{ + res, err = Read(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -142,6 +132,11 @@ var _ = Describe("Test Workflow Provider Kube", func() { }, }, }, + RuntimeParams: providertypes.RuntimeParams{ + Labels: map[string]string{ + "hello": "world", + }, + }, }) Expect(err).ToNot(HaveOccurred()) Expect(res.Error).Should(BeNil()) @@ -159,7 +154,7 @@ var _ = Describe("Test Workflow Provider Kube", func() { un.SetLabels(map[string]string{ "test": "test", }) - _, err := p.Apply(ctx, &ResourceParams{ + _, err := Apply(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &un, }, @@ -183,7 +178,7 @@ patch: { } } `) - _, err = p.Patch(ctx, &types.LegacyParams[cue.Value]{ + _, err = Patch(ctx, &providertypes.LegacyParams[cue.Value]{ Params: v, }) Expect(err).ToNot(HaveOccurred()) @@ -225,7 +220,7 @@ patch: { } By("List pods with labels test=test") - res, err := p.List(ctx, &ResourceParams{ + res, err := List(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -245,7 +240,7 @@ patch: { Expect(len(res.Resources.Items)).Should(Equal(5)) By("List pods with labels index=test-1") - res, err = p.List(ctx, &ResourceParams{ + res, err = List(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -287,7 +282,7 @@ patch: { }, &corev1.Pod{}) Expect(err).ToNot(HaveOccurred()) - _, err = p.Delete(ctx, &ResourceParams{ + _, err = Delete(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -336,7 +331,7 @@ patch: { }, &corev1.Pod{}) Expect(err).ToNot(HaveOccurred()) - _, err = p.Delete(ctx, &ResourceParams{ + _, err = Delete(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &unstructured.Unstructured{ Object: map[string]interface{}{ @@ -370,7 +365,7 @@ patch: { un2 := testUnstructured.DeepCopy() un2.SetName("app2") ctx := context.Background() - _, err := p.ApplyInParallel(ctx, &ApplyInParallelParams{ + _, err := ApplyInParallel(ctx, &ApplyInParallelParams{ Params: ApplyInParallelVars{ Resources: []*unstructured.Unstructured{un1, un2}, }, @@ -393,7 +388,7 @@ patch: { It("test error case", func() { ctx := context.Background() - res, err := p.Read(ctx, &ResourceParams{ + res, err := Read(ctx, &ResourceParams{ Params: ResourceVars{ Resource: &unstructured.Unstructured{ Object: map[string]interface{}{ diff --git a/pkg/providers/legacy/legacy.go b/pkg/providers/legacy/legacy.go index d12d387..43e9001 100644 --- a/pkg/providers/legacy/legacy.go +++ b/pkg/providers/legacy/legacy.go @@ -11,7 +11,6 @@ import ( "github.com/kubevela/workflow/pkg/providers/legacy/metrics" "github.com/kubevela/workflow/pkg/providers/legacy/util" "github.com/kubevela/workflow/pkg/providers/legacy/workspace" - providertypes "github.com/kubevela/workflow/pkg/providers/types" ) func registerProviders(providers map[string]cuexruntime.ProviderFn, new map[string]cuexruntime.ProviderFn) map[string]cuexruntime.ProviderFn { @@ -22,11 +21,11 @@ func registerProviders(providers map[string]cuexruntime.ProviderFn, new map[stri } // GetLegacyProviders get legacy providers -func GetLegacyProviders(handlers *providertypes.KubeHandlers) map[string]cuexruntime.ProviderFn { +func GetLegacyProviders() map[string]cuexruntime.ProviderFn { providers := make(map[string]cuexruntime.ProviderFn, 0) registerProviders(providers, email.GetProviders()) registerProviders(providers, http.GetProviders()) - registerProviders(providers, kube.GetProviders(handlers)) + registerProviders(providers, kube.GetProviders()) registerProviders(providers, metrics.GetProviders()) registerProviders(providers, util.GetProviders()) registerProviders(providers, workspace.GetProviders()) diff --git a/pkg/providers/legacy/metrics/prom_check.go b/pkg/providers/legacy/metrics/prom_check.go index 4babe98..068183c 100644 --- a/pkg/providers/legacy/metrics/prom_check.go +++ b/pkg/providers/legacy/metrics/prom_check.go @@ -34,7 +34,6 @@ import ( wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model" providertypes "github.com/kubevela/workflow/pkg/providers/types" - "github.com/kubevela/workflow/pkg/types" ) const ( @@ -59,7 +58,7 @@ type PromReturns struct { } // PromParams . -type PromParams = types.LegacyParams[PromVars] +type PromParams = providertypes.LegacyParams[PromVars] // PromCheck do health check from metrics from prometheus func PromCheck(ctx context.Context, params *PromParams) (*PromReturns, error) { diff --git a/pkg/providers/legacy/metrics/prom_check_test.go b/pkg/providers/legacy/metrics/prom_check_test.go index 6e093c7..c6967a9 100644 --- a/pkg/providers/legacy/metrics/prom_check_test.go +++ b/pkg/providers/legacy/metrics/prom_check_test.go @@ -31,7 +31,7 @@ import ( context2 "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/cue/process" - "github.com/kubevela/workflow/pkg/types" + providertypes "github.com/kubevela/workflow/pkg/providers/types" ) func TestMetricCheck(t *testing.T) { @@ -62,7 +62,7 @@ func TestMetricCheck(t *testing.T) { FailDuration: "2s", Condition: ">=3", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ WorkflowContext: wfCtx, ProcessContext: pCtx, }, diff --git a/pkg/providers/legacy/util/util.go b/pkg/providers/legacy/util/util.go index e8bfa01..0ce236f 100644 --- a/pkg/providers/legacy/util/util.go +++ b/pkg/providers/legacy/util/util.go @@ -48,7 +48,7 @@ type PatchResult struct { } // PatchK8sObject patch k8s object -func PatchK8sObject(ctx context.Context, params *types.LegacyParams[cue.Value]) (cue.Value, error) { +func PatchK8sObject(ctx context.Context, params *providertypes.LegacyParams[cue.Value]) (cue.Value, error) { base, err := model.NewBase(params.Params.LookupPath(cue.ParsePath("value"))) if err != nil { return cue.Value{}, err @@ -75,7 +75,7 @@ type StringReturns struct { } // StringParams . -type StringParams = types.LegacyParams[StringVars] +type StringParams = providertypes.LegacyParams[StringVars] // String convert byte to string func String(ctx context.Context, params *StringParams) (*StringReturns, error) { @@ -112,7 +112,7 @@ type LogVars struct { } // LogParams . -type LogParams = types.LegacyParams[LogVars] +type LogParams = providertypes.LegacyParams[LogVars] // Log print cue value in log func Log(ctx context.Context, params *LogParams) (*any, error) { diff --git a/pkg/providers/legacy/util/util_test.go b/pkg/providers/legacy/util/util_test.go index d12935d..b36c515 100644 --- a/pkg/providers/legacy/util/util_test.go +++ b/pkg/providers/legacy/util/util_test.go @@ -32,7 +32,7 @@ import ( wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/cue/process" - "github.com/kubevela/workflow/pkg/types" + providertypes "github.com/kubevela/workflow/pkg/providers/types" ) func TestPatchK8sObject(t *testing.T) { @@ -129,7 +129,7 @@ spec: template: metadata: name: "test-patchStrategy"`, for name, tc := range testcases { t.Run(name, func(t *testing.T) { r := require.New(t) - res, err := PatchK8sObject(ctx, &types.LegacyParams[cue.Value]{ + res, err := PatchK8sObject(ctx, &providertypes.LegacyParams[cue.Value]{ Params: cuectx.CompileString(tc.value), }) if tc.expectedErr != nil { @@ -254,7 +254,7 @@ func TestLog(t *testing.T) { r := require.New(t) _, err := Log(ctx, &LogParams{ Params: tc.value, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ ProcessContext: pCtx, WorkflowContext: wfCtx, }, diff --git a/pkg/providers/legacy/workspace/workspace.go b/pkg/providers/legacy/workspace/workspace.go index 2bdf88a..6a70b58 100644 --- a/pkg/providers/legacy/workspace/workspace.go +++ b/pkg/providers/legacy/workspace/workspace.go @@ -32,7 +32,6 @@ import ( "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/errors" providertypes "github.com/kubevela/workflow/pkg/providers/types" - "github.com/kubevela/workflow/pkg/types" ) const ( @@ -57,7 +56,7 @@ type VarReturns struct { } // VarParams . -type VarParams = types.LegacyParams[VarVars] +type VarParams = providertypes.LegacyParams[VarVars] // DoVar get & put variable from context. func DoVar(ctx context.Context, params *VarParams) (*VarReturns, error) { @@ -100,7 +99,7 @@ type ActionVars struct { } // ActionParams . -type ActionParams = types.LegacyParams[ActionVars] +type ActionParams = providertypes.LegacyParams[ActionVars] // WaitVars . type WaitVars struct { @@ -109,7 +108,7 @@ type WaitVars struct { } // WaitParams . -type WaitParams = types.LegacyParams[WaitVars] +type WaitParams = providertypes.LegacyParams[WaitVars] // Wait let workflow wait. func Wait(ctx context.Context, params *WaitParams) (*any, error) { @@ -139,7 +138,7 @@ type SuspendVars struct { } // SuspendParams . -type SuspendParams = types.LegacyParams[SuspendVars] +type SuspendParams = providertypes.LegacyParams[SuspendVars] // Suspend let the step suspend, its status is suspending and reason is Suspend func Suspend(ctx context.Context, params *SuspendParams) (*any, error) { diff --git a/pkg/providers/legacy/workspace/workspace_test.go b/pkg/providers/legacy/workspace/workspace_test.go index 691ef7f..624525e 100644 --- a/pkg/providers/legacy/workspace/workspace_test.go +++ b/pkg/providers/legacy/workspace/workspace_test.go @@ -22,6 +22,7 @@ import ( "testing" "time" + "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/yaml" @@ -30,8 +31,7 @@ import ( "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/errors" - "github.com/kubevela/workflow/pkg/types" - "github.com/stretchr/testify/require" + providertypes "github.com/kubevela/workflow/pkg/providers/types" ) func TestProvider_DoVar(t *testing.T) { @@ -45,7 +45,7 @@ func TestProvider_DoVar(t *testing.T) { Path: "clusterIP", Value: "1.1.1.1", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ WorkflowContext: wfCtx, }, }) @@ -61,7 +61,7 @@ func TestProvider_DoVar(t *testing.T) { Method: "Get", Path: "clusterIP", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ WorkflowContext: wfCtx, }, }) @@ -81,7 +81,7 @@ func TestProvider_Wait(t *testing.T) { Message: "test log", }, }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) @@ -98,7 +98,7 @@ func TestProvider_Wait(t *testing.T) { Message: "omit msg", }, }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) @@ -112,7 +112,7 @@ func TestProvider_Break(t *testing.T) { r := require.New(t) act := &mockAction{} _, err := Break(ctx, &ActionParams{ - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) @@ -125,7 +125,7 @@ func TestProvider_Break(t *testing.T) { Params: ActionVars{ Message: "terminate", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) @@ -147,7 +147,7 @@ func TestProvider_Suspend(t *testing.T) { Params: SuspendVars{ Duration: "1s", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, WorkflowContext: wfCtx, ProcessContext: pCtx, @@ -174,7 +174,7 @@ func TestProvider_Fail(t *testing.T) { r := require.New(t) act := &mockAction{} _, err := Fail(ctx, &ActionParams{ - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) @@ -187,7 +187,7 @@ func TestProvider_Fail(t *testing.T) { Params: ActionVars{ Message: "fail", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) @@ -205,7 +205,7 @@ func TestProvider_Message(t *testing.T) { Params: ActionVars{ Message: "test", }, - RuntimeParams: types.RuntimeParams{ + RuntimeParams: providertypes.RuntimeParams{ Action: act, }, }) diff --git a/pkg/providers/types/types.go b/pkg/providers/types/types.go index cbedfbb..ee864b9 100644 --- a/pkg/providers/types/types.go +++ b/pkg/providers/types/types.go @@ -35,10 +35,39 @@ const ( processContextKey contextKey = "processContext" actionKey contextKey = "action" labelsKey contextKey = "labels" + kubeHandlersKey contextKey = "kubeHandlers" ) +// Dispatcher is a client for apply resources. +type Dispatcher func(ctx context.Context, cluster, owner string, manifests ...*unstructured.Unstructured) error + +// Deleter is a client for delete resources. +type Deleter func(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error + +// KubeHandlers handles resources. +type KubeHandlers struct { + Apply Dispatcher + Delete Deleter +} + +// RuntimeParams is the runtime parameters of a provider. +type RuntimeParams struct { + WorkflowContext wfContext.Context + ProcessContext process.Context + Action types.Action + FieldLabel string + Labels map[string]string + KubeHandlers *KubeHandlers +} + +// LegacyParams is the legacy input parameters of a provider. +type LegacyParams[T any] struct { + Params T + RuntimeParams +} + // LegacyGenericProviderFn is the legacy provider function -type LegacyGenericProviderFn[T any, U any] func(context.Context, *types.LegacyParams[T]) (*U, error) +type LegacyGenericProviderFn[T any, U any] func(context.Context, *LegacyParams[T]) (*U, error) // Call marshal value into json and decode into underlying function input // parameters, then fill back the returned output value @@ -54,7 +83,7 @@ func (fn LegacyGenericProviderFn[T, U]) Call(ctx context.Context, value cue.Valu runtimeParams := RuntimeParamsFrom(ctx) label, _ := value.Label() runtimeParams.FieldLabel = label - ret, err := fn(ctx, &types.LegacyParams[T]{Params: *params, RuntimeParams: runtimeParams}) + ret, err := fn(ctx, &LegacyParams[T]{Params: *params, RuntimeParams: runtimeParams}) if err != nil { return value, err } @@ -62,13 +91,13 @@ func (fn LegacyGenericProviderFn[T, U]) Call(ctx context.Context, value cue.Valu } // LegacyNativeProviderFn is the legacy native provider function -type LegacyNativeProviderFn func(context.Context, *types.LegacyParams[cue.Value]) (cue.Value, error) +type LegacyNativeProviderFn func(context.Context, *LegacyParams[cue.Value]) (cue.Value, error) // Call marshal value into json and decode into underlying function input // parameters, then fill back the returned output value func (fn LegacyNativeProviderFn) Call(ctx context.Context, value cue.Value) (cue.Value, error) { runtimeParams := RuntimeParamsFrom(ctx) - return fn(ctx, &types.LegacyParams[cue.Value]{Params: value, RuntimeParams: runtimeParams}) + return fn(ctx, &LegacyParams[cue.Value]{Params: value, RuntimeParams: runtimeParams}) } // WithLabelParams returns a copy of parent in which the labels value is set @@ -77,7 +106,7 @@ func WithLabelParams(parent context.Context, labels map[string]string) context.C } // WithRuntimeParams returns a copy of parent in which the runtime params value is set -func WithRuntimeParams(parent context.Context, params types.RuntimeParams) context.Context { +func WithRuntimeParams(parent context.Context, params RuntimeParams) context.Context { ctx := context.WithValue(parent, workflowContextKey, params.WorkflowContext) ctx = context.WithValue(ctx, processContextKey, params.ProcessContext) ctx = context.WithValue(ctx, actionKey, params.Action) @@ -85,8 +114,8 @@ func WithRuntimeParams(parent context.Context, params types.RuntimeParams) conte } // RuntimeParamsFrom returns the runtime params value stored in ctx, if any. -func RuntimeParamsFrom(ctx context.Context) types.RuntimeParams { - params := types.RuntimeParams{} +func RuntimeParamsFrom(ctx context.Context) RuntimeParams { + params := RuntimeParams{} if wfCtx, ok := ctx.Value(workflowContextKey).(wfContext.Context); ok { params.WorkflowContext = wfCtx } @@ -99,17 +128,8 @@ func RuntimeParamsFrom(ctx context.Context) types.RuntimeParams { if labels, ok := ctx.Value(labelsKey).(map[string]string); ok { params.Labels = labels } + if kubeHandlers, ok := ctx.Value(kubeHandlersKey).(*KubeHandlers); ok { + params.KubeHandlers = kubeHandlers + } return params } - -// Dispatcher is a client for apply resources. -type Dispatcher func(ctx context.Context, cluster, owner string, manifests ...*unstructured.Unstructured) error - -// Deleter is a client for delete resources. -type Deleter func(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error - -// KubeHandlers handles resources. -type KubeHandlers struct { - Apply Dispatcher - Delete Deleter -} diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index fb61d66..357e7ac 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -162,7 +162,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error resetter := tRunner.fillContext(tracer, options.PCtx) defer resetter(options.PCtx) - ctx := providertypes.WithRuntimeParams(tracer.GetContext(), types.RuntimeParams{ + ctx := providertypes.WithRuntimeParams(tracer.GetContext(), providertypes.RuntimeParams{ WorkflowContext: wfCtx, ProcessContext: options.PCtx, Action: exec, diff --git a/pkg/tasks/custom/task_test.go b/pkg/tasks/custom/task_test.go index 632b2b9..b81f43c 100644 --- a/pkg/tasks/custom/task_test.go +++ b/pkg/tasks/custom/task_test.go @@ -63,26 +63,26 @@ func TestTaskLoader(t *testing.T) { "templateError": cuexruntime.NativeProviderFn(func(ctx context.Context, v cue.Value) (cue.Value, error) { return v.Context().CompileString("output: xxx"), nil }), - "wait": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "wait": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { val.RuntimeParams.Action.Wait("I am waiting") return nil, nil }), - "terminate": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "terminate": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { val.RuntimeParams.Action.Terminate("I am terminated") return nil, nil }), - "suspend": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "suspend": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { val.RuntimeParams.Action.Suspend("I am suspended") return nil, nil }), - "resume": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "resume": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { val.RuntimeParams.Action.Resume("I am resumed") return nil, nil }), - "executeFailed": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "executeFailed": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { return nil, errors.New("execute error") }), - "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { return nil, nil }), }, @@ -197,10 +197,10 @@ func TestErrCases(t *testing.T) { compiler := cuex.NewCompilerWithInternalPackages( // legacy packages pkgruntime.Must(cuexruntime.NewInternalPackage("test", "", map[string]cuexruntime.ProviderFn{ - "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { return nil, nil }), - "error": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "error": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { return nil, errors.New("mock error") }), "input": cuexruntime.NativeProviderFn(func(ctx context.Context, v cue.Value) (cue.Value, error) { @@ -316,139 +316,6 @@ func TestErrCases(t *testing.T) { } } -// func TestSteps(t *testing.T) { - -// var ( -// echo string -// mockErr = errors.New("mock error") -// ) - -// wfCtx := newWorkflowContextForTest(t) -// r := require.New(t) -// discover := providers.NewProviders() -// discover.Register("test", map[string]types.Handler{ -// "ok": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { -// echo = echo + "ok" -// return nil -// }, -// "error": func(mCtx monitorContext.Context, ctx wfContext.Context, v *value.Value, act types.Action) error { -// return mockErr -// }, -// }) -// exec := &executor{ -// handlers: discover, -// } - -// testCases := []struct { -// base string -// expected string -// hasErr bool -// }{ -// { -// base: ` -// process: { -// #provider: "test" -// #do: "ok" -// } - -// #up: [process] -// `, -// expected: "okok", -// }, -// { -// base: ` -// process: { -// #provider: "test" -// #do: "ok" -// } - -// #up: [process,{ -// #do: "steps" -// p1: process -// #up: [process] -// }] -// `, -// expected: "okokokok", -// }, -// { -// base: ` -// process: { -// #provider: "test" -// #do: "ok" -// } - -// #up: [process,{ -// p1: process -// #up: [process] -// }] -// `, -// expected: "okok", -// }, -// { -// base: ` -// process: { -// #provider: "test" -// #do: "ok" -// } - -// #up: [process,{ -// #do: "steps" -// err: { -// #provider: "test" -// #do: "error" -// } @step(1) -// #up: [{},process] @step(2) -// }] -// `, -// expected: "okok", -// hasErr: true, -// }, - -// { -// base: ` -// #provider: "test" -// #do: "ok" -// `, -// expected: "ok", -// }, -// { -// base: ` -// process: { -// #provider: "test" -// #do: "ok" -// err: true -// } - -// if process.err { -// err: { -// #provider: "test" -// #do: "error" -// } -// } - -// apply: { -// #provider: "test" -// #do: "ok" -// } - -// #up: [process,{}] -// `, -// expected: "ok", -// hasErr: true, -// }, -// } - -// for i, tc := range testCases { -// echo = "" -// v, err := value.NewValue(tc.base, nil, "", value.TagFieldOrder) -// r.NoError(err) -// err = exec.doSteps(nil, wfCtx, v) -// r.Equal(err != nil, tc.hasErr) -// r.Equal(tc.expected, echo, i) -// } - -// } - func TestPendingInputCheck(t *testing.T) { wfCtx := newWorkflowContextForTest(t) r := require.New(t) @@ -549,7 +416,7 @@ func TestTimeout(t *testing.T) { compiler := cuex.NewCompilerWithInternalPackages( // legacy packages pkgruntime.Must(cuexruntime.NewInternalPackage("test", "", map[string]cuexruntime.ProviderFn{ - "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *types.LegacyParams[any]) (*any, error) { + "ok": providertypes.LegacyGenericProviderFn[any, any](func(ctx context.Context, val *providertypes.LegacyParams[any]) (*any, error) { return nil, nil }), })), diff --git a/pkg/types/types.go b/pkg/types/types.go index 4453bb8..868afa1 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -29,27 +29,11 @@ import ( "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/features" "github.com/kubevela/workflow/pkg/tasks/template" ) -// RuntimeParams is the runtime parameters of a provider. -type RuntimeParams struct { - WorkflowContext wfContext.Context - ProcessContext process.Context - Action Action - FieldLabel string - Labels map[string]string -} - -// LegacyParams is the legacy input parameters of a provider. -type LegacyParams[T any] struct { - Params T - RuntimeParams -} - // WorkflowInstance is the instance for workflow engine to execute type WorkflowInstance struct { WorkflowMeta @@ -98,7 +82,6 @@ type Engine interface { // TaskRunOptions is the options for task run type TaskRunOptions struct { - Data *value.Value PCtx process.Context PreCheckHooks []TaskPreCheckHook PreStartHooks []TaskPreStartHook diff --git a/pkg/utils/operation.go b/pkg/utils/operation.go index f889784..b56b325 100644 --- a/pkg/utils/operation.go +++ b/pkg/utils/operation.go @@ -24,6 +24,7 @@ import ( "cuelang.org/go/cue" "cuelang.org/go/cue/ast" + "cuelang.org/go/cue/cuecontext" "cuelang.org/go/cue/format" corev1 "k8s.io/api/core/v1" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -34,7 +35,6 @@ import ( "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/model/sets" - "github.com/kubevela/workflow/pkg/cue/model/value" wfTypes "github.com/kubevela/workflow/pkg/types" ) @@ -424,10 +424,7 @@ func CleanStatusFromStep(steps []v1alpha1.WorkflowStep, stepStatus []v1alpha1.Wo return nil, nil, fmt.Errorf("failed step %s not found", stepName) } if contextCM != nil && contextCM.Data != nil { - v, err := value.NewValue(contextCM.Data[wfContext.ConfigMapKeyVars], nil, "") - if err != nil { - return nil, nil, err - } + v := cuecontext.New().CompileString(contextCM.Data[wfContext.ConfigMapKeyVars]) s, err := clearContextVars(steps, v, stepName, dependency) if err != nil { return nil, nil, err @@ -438,7 +435,7 @@ func CleanStatusFromStep(steps []v1alpha1.WorkflowStep, stepStatus []v1alpha1.Wo } // nolint:staticcheck -func clearContextVars(steps []v1alpha1.WorkflowStep, v *value.Value, stepName string, dependency []string) (string, error) { +func clearContextVars(steps []v1alpha1.WorkflowStep, v cue.Value, stepName string, dependency []string) (string, error) { outputs := make([]string, 0) for _, step := range steps { if step.Name == stepName || stringsContain(dependency, step.Name) { @@ -454,7 +451,7 @@ func clearContextVars(steps []v1alpha1.WorkflowStep, v *value.Value, stepName st } } } - node := v.CueValue().Syntax(cue.ResolveReferences(true)) + node := v.Syntax(cue.ResolveReferences(true)) x, ok := node.(*ast.StructLit) if !ok { return "", fmt.Errorf("value is not a struct lit") diff --git a/pkg/webhook/v1alpha1/workflowrun/suite_test.go b/pkg/webhook/v1alpha1/workflowrun/suite_test.go index 3261332..6ac5d6f 100644 --- a/pkg/webhook/v1alpha1/workflowrun/suite_test.go +++ b/pkg/webhook/v1alpha1/workflowrun/suite_test.go @@ -36,7 +36,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/kubevela/workflow/api/v1alpha1" - "github.com/kubevela/workflow/pkg/cue/packages" // +kubebuilder:scaffold:imports ) @@ -48,7 +47,6 @@ var k8sClient client.Client var testEnv *envtest.Environment var testScheme = runtime.NewScheme() var decoder *admission.Decoder -var pd *packages.PackageDiscover var ctx = context.Background() var handler *ValidatingHandler @@ -86,13 +84,7 @@ var _ = BeforeSuite(func(done Done) { Expect(err).ToNot(HaveOccurred()) Expect(k8sClient).ToNot(BeNil()) - pd, err = packages.NewPackageDiscover(cfg) - Expect(err).ToNot(HaveOccurred()) - Expect(pd).ToNot(BeNil()) - - handler = &ValidatingHandler{ - pd: pd, - } + handler = &ValidatingHandler{} decoder, err = admission.NewDecoder(testScheme) Expect(err).Should(BeNil()) diff --git a/pkg/webhook/v1alpha1/workflowrun/validating_handler.go b/pkg/webhook/v1alpha1/workflowrun/validating_handler.go index da9ceac..b9b6d7d 100644 --- a/pkg/webhook/v1alpha1/workflowrun/validating_handler.go +++ b/pkg/webhook/v1alpha1/workflowrun/validating_handler.go @@ -30,7 +30,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/kubevela/workflow/api/v1alpha1" - "github.com/kubevela/workflow/pkg/cue/packages" "github.com/kubevela/workflow/pkg/types" "github.com/kubevela/workflow/controllers" @@ -40,7 +39,6 @@ var _ admission.Handler = &ValidatingHandler{} // ValidatingHandler handles application type ValidatingHandler struct { - pd *packages.PackageDiscover Client client.Client // Decoder decodes objects Decoder *admission.Decoder From 27b2343fbe49f02584f4cd5dd27e0e0f934ad6a7 Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 25 Apr 2023 14:10:14 +0800 Subject: [PATCH 03/17] fix email test casses Signed-off-by: FogDong --- pkg/providers/legacy/email/email.go | 5 +++-- pkg/providers/legacy/email/email_test.go | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/providers/legacy/email/email.go b/pkg/providers/legacy/email/email.go index eddac85..475ccf3 100644 --- a/pkg/providers/legacy/email/email.go +++ b/pkg/providers/legacy/email/email.go @@ -64,7 +64,7 @@ type MailParams = providertypes.LegacyParams[MailVars] var emailRoutine sync.Map // Send sends email -func Send(ctx context.Context, params *MailParams) (*any, error) { +func Send(ctx context.Context, params *MailParams) (res *any, err error) { pCtx := params.ProcessContext act := params.Action id := fmt.Sprint(pCtx.GetData(model.ContextStepSessionID)) @@ -97,8 +97,9 @@ func Send(ctx context.Context, params *MailParams) (*any, error) { go func() { if routine, ok := emailRoutine.Load(id); ok && routine == "initializing" { emailRoutine.Store(id, "sending") - if err := dial.DialAndSend(m); err != nil { + if err = dial.DialAndSend(m); err != nil { emailRoutine.Store(id, err.Error()) + fmt.Println("=========", err.Error()) return } emailRoutine.Store(id, "success") diff --git a/pkg/providers/legacy/email/email_test.go b/pkg/providers/legacy/email/email_test.go index 03fb866..4b2fb0e 100644 --- a/pkg/providers/legacy/email/email_test.go +++ b/pkg/providers/legacy/email/email_test.go @@ -18,7 +18,6 @@ package email import ( "context" - "errors" "fmt" "reflect" "testing" @@ -30,6 +29,7 @@ import ( "github.com/kubevela/workflow/pkg/cue/model" "github.com/kubevela/workflow/pkg/cue/process" + "github.com/kubevela/workflow/pkg/errors" "github.com/kubevela/workflow/pkg/mock" providertypes "github.com/kubevela/workflow/pkg/providers/types" ) @@ -94,7 +94,7 @@ func TestSendEmail(t *testing.T) { if tc.errMsg != "" { patch.Reset() patch = ApplyMethod(reflect.TypeOf(dial), "DialAndSend", func(_ *gomail.Dialer, _ ...*gomail.Message) error { - return errors.New(tc.errMsg) + return fmt.Errorf(tc.errMsg) }) defer patch.Reset() } @@ -109,7 +109,8 @@ func TestSendEmail(t *testing.T) { r.Equal(tc.expectedErr.Error(), err.Error()) return } - r.NoError(err) + _, ok := err.(errors.GenericActionError) + r.Equal(ok, true) r.Equal(act.Phase, "Wait") // mock reconcile @@ -122,10 +123,8 @@ func TestSendEmail(t *testing.T) { }, }) if tc.errMsg != "" { - r.Equal(fmt.Errorf("failed to send email: %s", tc.errMsg), err) - return + r.Contains(err.Error(), tc.errMsg) } - r.NoError(err) }) } } From fa7d99afa5d952089e8f2532be3060579cf1d1eb Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 25 Apr 2023 16:04:34 +0800 Subject: [PATCH 04/17] fix test Signed-off-by: FogDong --- e2e/e2e_suite_test.go | 3 +++ pkg/context/context.go | 7 +------ pkg/providers/legacy/email/email.go | 1 - pkg/tasks/custom/task.go | 3 ++- pkg/types/types.go | 1 - 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/e2e/e2e_suite_test.go b/e2e/e2e_suite_test.go index 9b0741d..9ecfc2f 100644 --- a/e2e/e2e_suite_test.go +++ b/e2e/e2e_suite_test.go @@ -31,6 +31,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/config" + "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/pkg/util/test/definition" "github.com/kubevela/workflow/api/v1alpha1" @@ -58,9 +59,11 @@ var k8sClient client.Client var _ = BeforeSuite(func() { conf, err := config.GetConfig() Expect(err).Should(BeNil()) + singleton.KubeConfig.Set(conf) k8sClient, err = client.New(conf, client.Options{Scheme: scheme}) Expect(err).Should(BeNil()) + singleton.KubeClient.Set(k8sClient) prepareWorkflowDefinitions() }) diff --git a/pkg/context/context.go b/pkg/context/context.go index 3bb8938..aa20aeb 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -33,7 +33,6 @@ import ( "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kubevela/pkg/cue/cuex" "github.com/kubevela/pkg/cue/util" "github.com/kubevela/pkg/util/rand" "github.com/kubevela/pkg/util/singleton" @@ -198,11 +197,7 @@ func (wf *WorkflowContext) LoadFromConfigMap(ctx context.Context, cm corev1.Conf } data := cm.Data - var err error - wf.vars, err = cuex.DefaultCompiler.Get().CompileString(ctx, data[ConfigMapKeyVars]) - if err != nil { - return errors.WithMessage(err, "decode vars") - } + wf.vars = cuecontext.New().CompileString(data[ConfigMapKeyVars]) return nil } diff --git a/pkg/providers/legacy/email/email.go b/pkg/providers/legacy/email/email.go index 475ccf3..a26515c 100644 --- a/pkg/providers/legacy/email/email.go +++ b/pkg/providers/legacy/email/email.go @@ -99,7 +99,6 @@ func Send(ctx context.Context, params *MailParams) (res *any, err error) { emailRoutine.Store(id, "sending") if err = dial.DialAndSend(m); err != nil { emailRoutine.Store(id, err.Error()) - fmt.Println("=========", err.Error()) return } emailRoutine.Store(id, "success") diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index 357e7ac..bea666b 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -38,6 +38,7 @@ import ( "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/hooks" + "github.com/kubevela/workflow/pkg/providers" providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) @@ -298,7 +299,7 @@ func buildValueForStatus(ctx wfContext.Context, step v1alpha1.WorkflowStep, step // MakeBasicValue makes basic value func MakeBasicValue(ctx monitorContext.Context, properties *runtime.RawExtension, pCtx process.Context) (cue.Value, error) { // use default compiler to compile the basic value without providers - v, err := cuex.DefaultCompiler.Get().CompileStringWithOptions(ctx, getContextTemplate(pCtx), cuex.WithExtraData( + v, err := providers.Compiler.Get().CompileStringWithOptions(ctx, getContextTemplate(pCtx), cuex.WithExtraData( model.ParameterFieldName, properties, ), cuex.DisableResolveProviderFunctions{}) if err != nil { diff --git a/pkg/types/types.go b/pkg/types/types.go index 868afa1..250dfcb 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -141,7 +141,6 @@ type TaskGeneratorOptions struct { // StepGeneratorOptions is the options for generate step. type StepGeneratorOptions struct { - Compiler cuex.Compiler ProcessCtx process.Context TemplateLoader template.Loader StepConvertor map[string]func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error) From e47b7e6716dbdd6af458aeee62dc50c7e69bda0f Mon Sep 17 00:00:00 2001 From: FogDong Date: Wed, 26 Apr 2023 11:55:17 +0800 Subject: [PATCH 05/17] add unmarshal to as util func Signed-off-by: FogDong --- pkg/cue/model/value/value.go | 10 +++++++++ pkg/cue/model/value/value_test.go | 35 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/pkg/cue/model/value/value.go b/pkg/cue/model/value/value.go index dce0a7c..9c73fcd 100644 --- a/pkg/cue/model/value/value.go +++ b/pkg/cue/model/value/value.go @@ -17,6 +17,7 @@ limitations under the License. package value import ( + "encoding/json" "fmt" "strconv" "strings" @@ -301,3 +302,12 @@ func FieldPath(paths ...string) cue.Path { } return cue.ParsePath(s) } + +// UnmarshalTo unmarshal value into golang object +func UnmarshalTo(val cue.Value, x interface{}) error { + data, err := val.MarshalJSON() + if err != nil { + return err + } + return json.Unmarshal(data, x) +} diff --git a/pkg/cue/model/value/value_test.go b/pkg/cue/model/value/value_test.go index 1dadee1..5005856 100644 --- a/pkg/cue/model/value/value_test.go +++ b/pkg/cue/model/value/value_test.go @@ -17,6 +17,7 @@ limitations under the License. package value import ( + "encoding/json" "fmt" "testing" @@ -257,3 +258,37 @@ a: b: c: [{x: 100}, {x: 101}, {x: 102}]`, r.Equal(s, tCase.expected, tCase.name) } } + +func TestUnmarshal(t *testing.T) { + case1 := ` +provider: "kube" +do: "apply" +` + out := struct { + Provider string `json:"provider"` + Do string `json:"do"` + }{} + + r := require.New(t) + cuectx := cuecontext.New() + val := cuectx.CompileString(case1) + err := UnmarshalTo(val, &out) + r.NoError(err) + r.Equal(out.Provider, "kube") + r.Equal(out.Do, "apply") + + bt, err := val.MarshalJSON() + r.NoError(err) + expectedJson, err := json.Marshal(out) + r.NoError(err) + r.Equal(string(bt), string(expectedJson)) + + caseIncomplete := ` +provider: string +do: string +` + val = cuectx.CompileString(caseIncomplete) + r.NoError(err) + err = UnmarshalTo(val, &out) + r.Error(err) +} From 8506773c75e320e270d834f37c59b5f7c2a37758 Mon Sep 17 00:00:00 2001 From: FogDong Date: Wed, 26 Apr 2023 17:02:28 +0800 Subject: [PATCH 06/17] add time provider Signed-off-by: FogDong --- pkg/providers/legacy/legacy.go | 13 +- pkg/providers/legacy/time/time.cue | 23 ++++ pkg/providers/legacy/time/time.go | 85 ++++++++++++ pkg/providers/legacy/time/time_test.go | 131 +++++++++++++++++++ pkg/providers/legacy/workspace/workspace.cue | 4 + 5 files changed, 255 insertions(+), 1 deletion(-) create mode 100644 pkg/providers/legacy/time/time.cue create mode 100644 pkg/providers/legacy/time/time.go create mode 100644 pkg/providers/legacy/time/time_test.go diff --git a/pkg/providers/legacy/legacy.go b/pkg/providers/legacy/legacy.go index 43e9001..80b48d1 100644 --- a/pkg/providers/legacy/legacy.go +++ b/pkg/providers/legacy/legacy.go @@ -9,6 +9,7 @@ import ( "github.com/kubevela/workflow/pkg/providers/legacy/http" "github.com/kubevela/workflow/pkg/providers/legacy/kube" "github.com/kubevela/workflow/pkg/providers/legacy/metrics" + "github.com/kubevela/workflow/pkg/providers/legacy/time" "github.com/kubevela/workflow/pkg/providers/legacy/util" "github.com/kubevela/workflow/pkg/providers/legacy/workspace" ) @@ -27,6 +28,7 @@ func GetLegacyProviders() map[string]cuexruntime.ProviderFn { registerProviders(providers, http.GetProviders()) registerProviders(providers, kube.GetProviders()) registerProviders(providers, metrics.GetProviders()) + registerProviders(providers, time.GetProviders()) registerProviders(providers, util.GetProviders()) registerProviders(providers, workspace.GetProviders()) return providers @@ -34,5 +36,14 @@ func GetLegacyProviders() map[string]cuexruntime.ProviderFn { // GetLegacyTemplate get legacy template func GetLegacyTemplate() string { - return strings.Join([]string{email.GetTemplate(), http.GetTemplate(), kube.GetTemplate(), metrics.GetTemplate(), util.GetTemplate(), workspace.GetTemplate()}, "\n") + return strings.Join([]string{ + email.GetTemplate(), + http.GetTemplate(), + kube.GetTemplate(), + metrics.GetTemplate(), + time.GetTemplate(), + util.GetTemplate(), + workspace.GetTemplate(), + }, + "\n") } diff --git a/pkg/providers/legacy/time/time.cue b/pkg/providers/legacy/time/time.cue new file mode 100644 index 0000000..74498db --- /dev/null +++ b/pkg/providers/legacy/time/time.cue @@ -0,0 +1,23 @@ +// time.cue + +#DateToTimestamp: { + #do: "timestamp" + #provider: "op" + + date: string + layout: *"" | string + + timestamp?: int64 + ... +} + +#TimestampToDate: { + #do: "date" + #provider: "op" + + timestamp: int64 + layout: *"" | string + + date?: string + ... +} diff --git a/pkg/providers/legacy/time/time.go b/pkg/providers/legacy/time/time.go new file mode 100644 index 0000000..6db4543 --- /dev/null +++ b/pkg/providers/legacy/time/time.go @@ -0,0 +1,85 @@ +/* + Copyright 2021. The KubeVela Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package time + +import ( + "context" + _ "embed" + "fmt" + "time" + + cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" + providertypes "github.com/kubevela/workflow/pkg/providers/types" +) + +// Vars . +type Vars struct { + Date string `json:"date,omitempty"` + Timestamp int64 `json:"timestamp,omitempty"` + Layout string `json:"layout,omitempty"` +} + +// Params . +type Params = providertypes.LegacyParams[Vars] + +// Timestamp convert date to timestamp +func Timestamp(ctx context.Context, params *Params) (*Vars, error) { + date := params.Params.Date + layout := params.Params.Layout + if date == "" { + return nil, fmt.Errorf("empty date to convert") + } + if layout == "" { + layout = time.RFC3339 + } + t, err := time.Parse(layout, date) + if err != nil { + return nil, err + } + return &Vars{ + Timestamp: t.Unix(), + }, nil +} + +// Date convert timestamp to date +func Date(ctx context.Context, params *Params) (*Vars, error) { + timestamp := params.Params.Timestamp + layout := params.Params.Layout + if layout == "" { + layout = time.RFC3339 + } + t := time.Unix(timestamp, 0) + return &Vars{ + Date: t.UTC().Format(layout), + }, nil +} + +//go:embed time.cue +var template string + +// GetTemplate return the template +func GetTemplate() string { + return template +} + +// GetProviders return the provider +func GetProviders() map[string]cuexruntime.ProviderFn { + return map[string]cuexruntime.ProviderFn{ + "timestamp": providertypes.LegacyGenericProviderFn[Vars, Vars](Timestamp), + "date": providertypes.LegacyGenericProviderFn[Vars, Vars](Date), + } +} diff --git a/pkg/providers/legacy/time/time_test.go b/pkg/providers/legacy/time/time_test.go new file mode 100644 index 0000000..80214d8 --- /dev/null +++ b/pkg/providers/legacy/time/time_test.go @@ -0,0 +1,131 @@ +/* + Copyright 2021. The KubeVela Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package time + +import ( + "context" + "fmt" + "testing" + + "github.com/pkg/errors" + "github.com/stretchr/testify/require" +) + +func TestTimestamp(t *testing.T) { + ctx := context.Background() + testcases := map[string]struct { + from Vars + expected int64 + expectedErr error + }{ + "test convert date with default time layout": { + from: Vars{ + Date: "2021-11-07T01:47:51Z", + }, + expected: 1636249671, + expectedErr: nil, + }, + "test convert date with RFC3339 layout": { + from: Vars{ + Date: "2021-11-07T01:47:51Z", + Layout: "2006-01-02T15:04:05Z07:00", + }, + expected: 1636249671, + expectedErr: nil, + }, + "test convert date with RFC1123 layout": { + from: Vars{ + Date: "Fri, 01 Mar 2019 15:00:00 GMT", + Layout: "Mon, 02 Jan 2006 15:04:05 MST", + }, + expected: 1551452400, + expectedErr: nil, + }, + "test convert without date": { + from: Vars{}, + expected: 0, + expectedErr: fmt.Errorf("empty date to convert"), + }, + "test convert date with wrong time layout": { + from: Vars{ + Date: "2021-11-07T01:47:51Z", + Layout: "Mon, 02 Jan 2006 15:04:05 MST", + }, + expected: 0, + expectedErr: errors.New(`parsing time "2021-11-07T01:47:51Z" as "Mon, 02 Jan 2006 15:04:05 MST": cannot parse "2021-11-07T01:47:51Z" as "Mon"`), + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + r := require.New(t) + res, err := Timestamp(ctx, &Params{ + Params: tc.from, + }) + if tc.expectedErr != nil { + r.Equal(tc.expectedErr.Error(), err.Error()) + return + } + r.NoError(err) + r.Equal(tc.expected, res.Timestamp) + }) + } +} + +func TestDate(t *testing.T) { + ctx := context.Background() + testcases := map[string]struct { + from Vars + expected string + }{ + "test convert timestamp to default time layout": { + from: Vars{ + Timestamp: 1636249671, + }, + expected: "2021-11-07T01:47:51Z", + }, + "test convert date to RFC3339 layout": { + from: Vars{ + Timestamp: 1636249671, + Layout: "2006-01-02T15:04:05Z07:00", + }, + expected: "2021-11-07T01:47:51Z", + }, + "test convert date to RFC1123 layout": { + from: Vars{ + Timestamp: 1551452400, + Layout: "Mon, 02 Jan 2006 15:04:05 MST", + }, + expected: "Fri, 01 Mar 2019 15:00:00 UTC", + }, + "test convert without timestamp": { + from: Vars{}, + expected: "1970-01-01T00:00:00Z", + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + r := require.New(t) + res, err := Date(ctx, &Params{ + Params: tc.from, + }) + r.NoError(err) + r.Equal(tc.expected, res.Date) + }) + } +} diff --git a/pkg/providers/legacy/workspace/workspace.cue b/pkg/providers/legacy/workspace/workspace.cue index 67620a6..7a169d0 100644 --- a/pkg/providers/legacy/workspace/workspace.cue +++ b/pkg/providers/legacy/workspace/workspace.cue @@ -56,4 +56,8 @@ message?: string } +#Steps: { + ... +} +NoExist: _|_ context: _ From e9c0f4a60ae7946d4728244ea4d69b9f84a85ade Mon Sep 17 00:00:00 2001 From: FogDong Date: Sat, 13 Jul 2024 16:38:58 +0800 Subject: [PATCH 07/17] fix: fix compiler Signed-off-by: FogDong --- pkg/tasks/builtin/step_group.go | 5 +++-- pkg/tasks/custom/task.go | 9 ++++----- pkg/tasks/custom/task_test.go | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/tasks/builtin/step_group.go b/pkg/tasks/builtin/step_group.go index f81238f..6fbe8f4 100644 --- a/pkg/tasks/builtin/step_group.go +++ b/pkg/tasks/builtin/step_group.go @@ -27,6 +27,7 @@ import ( "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/process" + "github.com/kubevela/workflow/pkg/providers" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" ) @@ -61,7 +62,7 @@ func (tr *stepGroupTaskRunner) Name() string { func (tr *stepGroupTaskRunner) Pending(ctx monitorContext.Context, wfCtx wfContext.Context, stepStatus map[string]v1alpha1.StepStatus) (bool, v1alpha1.StepStatus) { resetter := tr.FillContextData(ctx, tr.pCtx) defer resetter(tr.pCtx) - basicVal, _ := custom.MakeBasicValue(ctx, nil, tr.pCtx) + basicVal, _ := custom.MakeBasicValue(ctx, providers.Compiler.Get(), nil, tr.pCtx) return custom.CheckPending(wfCtx, tr.step, tr.id, stepStatus, basicVal) } @@ -83,7 +84,7 @@ func (tr *stepGroupTaskRunner) Run(ctx wfContext.Context, options *types.TaskRun tracer := options.GetTracer(tr.id, tr.step).AddTag("step_name", tr.name, "step_type", types.WorkflowStepTypeStepGroup) resetter := tr.FillContextData(tracer, tr.pCtx) defer resetter(tr.pCtx) - basicVal, err := custom.MakeBasicValue(tracer, nil, tr.pCtx) + basicVal, err := custom.MakeBasicValue(tracer, providers.Compiler.Get(), nil, tr.pCtx) if err != nil { return status, nil, err } diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index bea666b..fc6cef1 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -38,7 +38,6 @@ import ( "github.com/kubevela/workflow/pkg/cue/model/value" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/hooks" - "github.com/kubevela/workflow/pkg/providers" providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) @@ -124,7 +123,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error resetter := tRunner.fillContext(ctx, options.PCtx) defer resetter(options.PCtx) - basicVal, _ := MakeBasicValue(ctx, wfStep.Properties, options.PCtx) + basicVal, _ := MakeBasicValue(ctx, options.Compiler, wfStep.Properties, options.PCtx) return CheckPending(wfCtx, wfStep, exec.wfStatus.ID, stepStatus, basicVal) } @@ -169,7 +168,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error Action: exec, }) - basicVal, err := MakeBasicValue(tracer, wfStep.Properties, options.PCtx) + basicVal, err := MakeBasicValue(tracer, options.Compiler, wfStep.Properties, options.PCtx) if err != nil { tracer.Error(err, "make context parameter") return v1alpha1.StepStatus{}, nil, errors.WithMessage(err, "make context parameter") @@ -297,9 +296,9 @@ func buildValueForStatus(ctx wfContext.Context, step v1alpha1.WorkflowStep, step } // MakeBasicValue makes basic value -func MakeBasicValue(ctx monitorContext.Context, properties *runtime.RawExtension, pCtx process.Context) (cue.Value, error) { +func MakeBasicValue(ctx monitorContext.Context, compiler *cuex.Compiler, properties *runtime.RawExtension, pCtx process.Context) (cue.Value, error) { // use default compiler to compile the basic value without providers - v, err := providers.Compiler.Get().CompileStringWithOptions(ctx, getContextTemplate(pCtx), cuex.WithExtraData( + v, err := compiler.CompileStringWithOptions(ctx, getContextTemplate(pCtx), cuex.WithExtraData( model.ParameterFieldName, properties, ), cuex.DisableResolveProviderFunctions{}) if err != nil { diff --git a/pkg/tasks/custom/task_test.go b/pkg/tasks/custom/task_test.go index b81f43c..01bdc98 100644 --- a/pkg/tasks/custom/task_test.go +++ b/pkg/tasks/custom/task_test.go @@ -41,6 +41,7 @@ import ( "github.com/kubevela/workflow/api/v1alpha1" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/process" + "github.com/kubevela/workflow/pkg/providers" providertypes "github.com/kubevela/workflow/pkg/providers/types" "github.com/kubevela/workflow/pkg/types" ) @@ -460,7 +461,7 @@ func TestValidateIfValue(t *testing.T) { r := require.New(t) logCtx := monitorContext.NewTraceContext(context.Background(), "test-app") - basicVal, err := MakeBasicValue(logCtx, &runtime.RawExtension{Raw: []byte(`{"key": "value"}`)}, pCtx) + basicVal, err := MakeBasicValue(logCtx, providers.Compiler.Get(), &runtime.RawExtension{Raw: []byte(`{"key": "value"}`)}, pCtx) r.NoError(err) testCases := []struct { From ce912dc76cc426bcb0b0d166c27908133b6a2e5a Mon Sep 17 00:00:00 2001 From: FogDong Date: Sat, 13 Jul 2024 17:29:27 +0800 Subject: [PATCH 08/17] fix: fix lint and rebase Signed-off-by: FogDong --- go.sum | 232 +---------- pkg/context/context.go | 2 +- pkg/debug/context.go | 10 +- pkg/executor/options.go | 14 - pkg/executor/workflow.go | 14 +- pkg/executor/workflow_test.go | 3 +- pkg/generator/generator.go | 6 +- pkg/providers/http/do.go | 242 ------------ pkg/providers/kube/handle.go | 369 ------------------ pkg/providers/legacy/email/email.go | 2 +- pkg/providers/legacy/kube/kube.go | 5 +- pkg/providers/legacy/metrics/prom_check.go | 2 +- pkg/providers/legacy/time/time.go | 4 +- pkg/providers/legacy/util/util.go | 6 +- pkg/providers/legacy/workspace/workspace.go | 12 +- pkg/providers/metrics/prom_check.go | 210 ---------- pkg/providers/util/util.go | 175 --------- pkg/providers/workspace/workspace.go | 198 ---------- pkg/tasks/custom/task.go | 8 +- pkg/tasks/custom/task_test.go | 19 +- pkg/tasks/discover.go | 2 +- pkg/tasks/discover_test.go | 2 +- pkg/types/types.go | 1 + pkg/utils/operation.go | 35 +- .../workflowrun/validating_handler.go | 2 +- 25 files changed, 65 insertions(+), 1510 deletions(-) delete mode 100644 pkg/providers/http/do.go delete mode 100644 pkg/providers/kube/handle.go delete mode 100644 pkg/providers/metrics/prom_check.go delete mode 100644 pkg/providers/util/util.go delete mode 100644 pkg/providers/workspace/workspace.go diff --git a/go.sum b/go.sum index 2870a2c..4c7dd44 100644 --- a/go.sum +++ b/go.sum @@ -5,50 +5,20 @@ cloud.google.com/go/compute v1.15.1 h1:7UGq3QknM33pw5xATlpzeoomNxsacIVvTqTTvbfaj cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cuelang.org/go v0.5.0 h1:D6N0UgTGJCOxFKU8RU+qYvavKNsVc/+ZobmifStVJzU= cuelang.org/go v0.5.0/go.mod h1:okjJBHFQFer+a41sAe2SaGm1glWS8oEb6CmJvn5Zdws= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -<<<<<<< HEAD -github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= -github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= -github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= -github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= -github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= -github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= -github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= -github.com/Microsoft/hcsshim v0.9.6 h1:VwnDOgLeoi2du6dAznfmspNqTiwczvjv4K7NxuY9jsY= -github.com/Microsoft/hcsshim v0.9.6/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= -github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -<<<<<<< HEAD -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= -github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= -github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= -github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= @@ -84,24 +54,6 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= -<<<<<<< HEAD -github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= -github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0= -github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ= -github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= -github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= -github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= -github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= -github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= -github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= -github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= -github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= -github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -129,23 +81,6 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= -<<<<<<< HEAD -github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= -github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= -github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= -github.com/containerd/cgroups v1.0.4 h1:jN/mbWBEaz+T1pi5OFtnkQ+8qnmEbAr1Oo1FRm5B0dA= -github.com/containerd/cgroups v1.0.4/go.mod h1:nLNQtsF7Sl2HxNebu77i1R0oDlhiTG+kO4JTrUzo6IA= -github.com/containerd/containerd v1.6.18 h1:qZbsLvmyu+Vlty0/Ex5xc0z2YtKpIsb5n45mAMI+2Ns= -github.com/containerd/containerd v1.6.18/go.mod h1:1RdCUu95+gc2v9t3IL+zIlpClSmew7/0YS8O5eQZrOw= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= @@ -157,37 +92,6 @@ github.com/crossplane/crossplane-runtime v0.19.2/go.mod h1:OJQ1NxtQK2ZTRmvtnQPoy github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -<<<<<<< HEAD -github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4= -github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/distribution/distribution/v3 v3.0.0-20220526142353-ffbd94cbe269 h1:hbCT8ZPPMqefiAWD2ZKjn7ypokIGViTvBBg/ExLSdCk= -github.com/distribution/distribution/v3 v3.0.0-20220526142353-ffbd94cbe269/go.mod h1:28YO/VJk9/64+sTGNuYaBjWxrXTPrj0C0XmgTIOjxX4= -github.com/docker/cli v20.10.20+incompatible h1:lWQbHSHUFs7KraSN2jOJK7zbMS2jNCHI4mt4xUFUVQ4= -github.com/docker/cli v20.10.20+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= -github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker v20.10.24+incompatible h1:Ugvxm7a8+Gz6vqQYQQ2W7GYq5EUPaAiuPgIfVyI3dYE= -github.com/docker/docker v20.10.24+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A= -github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c h1:+pKlWGMw7gf6bQ+oDZB4KHQFypsfjYlq/C4rfL7D3g8= -github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA= -github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8= -github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw= -github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= -github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= -github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -198,12 +102,7 @@ github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaB github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emicklei/proto v1.10.0 h1:pDGyFRVV5RvV+nkBK9iy3q67FBy9Xa7vwrOTE+g5aGw= -<<<<<<< HEAD github.com/emicklei/proto v1.10.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -224,6 +123,7 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= +github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.10.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s= @@ -267,13 +167,7 @@ github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -<<<<<<< HEAD github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M= -github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -308,13 +202,9 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -<<<<<<< HEAD -github.com/gomodule/redigo v1.8.2 h1:H5XSIre1MB5NbPYFp+i1NBbb5qN1W8Y8YAQoAYbkm8k= -github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.12.6 h1:kjeKudqV0OygrAqA9fX6J55S8gj+Jre2tckIm5RoG4M= github.com/google/cel-go v0.12.6/go.mod h1:Jk7ljRzLBhkmiAwBoUxB1sZSCVBAzkqPF25olK/iRDw= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= @@ -336,16 +226,7 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -<<<<<<< HEAD github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2 h1:SJ+NtwL6QaZ21U+IrK7d0gGgpjGGvd2kz+FzTHVzdqI= -github.com/google/safetext v0.0.0-20220905092116-b49f7bc46da2/go.mod h1:Tv1PlzqC9t8wNnpPdctvtSUOPUUg4SHeE6vR1Ir2hmg= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= -github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -354,25 +235,11 @@ github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pf github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -<<<<<<< HEAD -github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -<<<<<<< HEAD -github.com/gosuri/uitable v0.0.4 h1:IG2xLKRvErL3uhY6e1BylFzG+aJiwQviDDTfOKeKTpY= -github.com/gosuri/uitable v0.0.4/go.mod h1:tKR86bXuXPZazfOTG1FIzvjIdXzd0mo4Vtn16vt0PJo= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= -github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= @@ -419,6 +286,7 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= +github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= @@ -446,13 +314,6 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -<<<<<<< HEAD -github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= -github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= @@ -462,20 +323,6 @@ github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d h1:QMmTg33lUZEfTz94 github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d/go.mod h1:3ZWrl2+zb5ROdC2NJPPrL/4sun4M10wYfRP/9gF9WJE= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -<<<<<<< HEAD -github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= -github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= -github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= -github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= @@ -501,24 +348,10 @@ github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXx github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -<<<<<<< HEAD -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mmcloughlin/avo v0.5.0/go.mod h1:ChHFdoV7ql95Wi7vuq2YT1bwCJqiWdZrQ1im3VujLYM= -github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= -github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= -github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= -github.com/moby/sys/mountinfo v0.5.0 h1:2Ks8/r6lopsxWi9m58nlwjaeSzUX9iiL1vj5qB/9ObI= -github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= -github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= -github.com/moby/term v0.0.0-20210610120745-9d4ed1856297/go.mod h1:vgPCkQMyxTZ7IDy8SXRufE172gr8+K/JE/7hHFxHW3A= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae h1:O4SWKdcHVCvYqyDV+9CJA1fcDN2L11Bule0iFy3YlAI= -github.com/moby/term v0.0.0-20220808134915-39b0c02b01ae/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -556,11 +389,7 @@ github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvw github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= -<<<<<<< HEAD github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= @@ -575,13 +404,6 @@ github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= -<<<<<<< HEAD -github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= -github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= -github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= -github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -635,11 +457,6 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -<<<<<<< HEAD -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -648,9 +465,11 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= @@ -677,28 +496,15 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= +github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -<<<<<<< HEAD -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI= -github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= -github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE= -github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= -github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= -github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= -github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c h1:/RwRVN9EdXAVtdHxP7Ndn/tfmM9/goiwU0QTnLBgS4w= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.5 h1:BX4JIbQ7hl7+jL+g+2j5UAr0o1bctCm6/Ct+ArBGkf0= @@ -713,22 +519,11 @@ go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lL go.etcd.io/etcd/client/v3 v3.5.5 h1:q++2WTJbUgpQu4B6hCuT7VkdwaTP7Qz6Daak3WzbrlI= go.etcd.io/etcd/client/v3 v3.5.5/go.mod h1:aApjR4WGlSumpnJ2kloS75h6aHUmAyaPLjHMxpc7E7c= go.etcd.io/etcd/pkg/v3 v3.5.5 h1:Ablg7T7OkR+AeeeU32kdVhw/AGDsitkKPl7aW73ssjU= -<<<<<<< HEAD go.etcd.io/etcd/pkg/v3 v3.5.5/go.mod h1:6ksYFxttiUGzC2uxyqiyOEvhAiD0tuIqSZkX3TyPdaE= -go.etcd.io/etcd/raft/v3 v3.5.0/go.mod h1:UFOHSIvO/nKwd4lhkwabrTD3cqW5yVyYYf/KlD00Szc= go.etcd.io/etcd/raft/v3 v3.5.5 h1:Ibz6XyZ60OYyRopu73lLM/P+qco3YtlZMOhnXNS051I= go.etcd.io/etcd/raft/v3 v3.5.5/go.mod h1:76TA48q03g1y1VpTue92jZLr9lIHKUNcYdZOOGyx8rI= -go.etcd.io/etcd/server/v3 v3.5.0/go.mod h1:3Ah5ruV+M+7RZr0+Y/5mNLwC+eQlni+mQmOVdCRJoS4= go.etcd.io/etcd/server/v3 v3.5.5 h1:jNjYm/9s+f9A9r6+SC4RvNaz6AqixpOvhrFdT0PvIj0= go.etcd.io/etcd/server/v3 v3.5.5/go.mod h1:rZ95vDw/jrvsbj9XpTqPrTAB9/kzchVdhRirySPkUBc= -go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -======= -go.etcd.io/etcd/raft/v3 v3.5.5 h1:Ibz6XyZ60OYyRopu73lLM/P+qco3YtlZMOhnXNS051I= -go.etcd.io/etcd/server/v3 v3.5.5 h1:jNjYm/9s+f9A9r6+SC4RvNaz6AqixpOvhrFdT0PvIj0= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0 h1:xFSRQBbXF6VvYRf2lqMJXxoB72XI1K/azav8TekHHSw= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.35.0/go.mod h1:h8TWwRAhQpOd0aM5nYsRD8+flnkj+526GEIVlarH7eY= @@ -759,11 +554,7 @@ go.uber.org/automaxprocs v1.5.1/go.mod h1:BF4eumQw0P9GtnuxxovUd06vwm1o18oMzFtK66 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -<<<<<<< HEAD go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -======= ->>>>>>> 4a9a43c (Chore: refactor the cue engine with cuex) go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec= go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= @@ -943,6 +734,7 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/context/context.go b/pkg/context/context.go index aa20aeb..3540caf 100644 --- a/pkg/context/context.go +++ b/pkg/context/context.go @@ -191,7 +191,7 @@ func (wf *WorkflowContext) sync(ctx context.Context) error { } // LoadFromConfigMap recover workflow context from configMap. -func (wf *WorkflowContext) LoadFromConfigMap(ctx context.Context, cm corev1.ConfigMap) error { +func (wf *WorkflowContext) LoadFromConfigMap(_ context.Context, cm corev1.ConfigMap) error { if wf.store == nil { wf.store = &cm } diff --git a/pkg/debug/context.go b/pkg/debug/context.go index c90a35f..9817d58 100644 --- a/pkg/debug/context.go +++ b/pkg/debug/context.go @@ -70,21 +70,15 @@ func setStore(ctx context.Context, instance *wfTypes.WorkflowInstance, id, data } cm.Labels = map[string]string{} cm.SetOwnerReferences(instance.ChildOwnerReferences) - if err := cli.Create(ctx, cm); err != nil { - return err - } - return nil + return cli.Create(ctx, cm) } return err } cm.Data = map[string]string{ "debug": data, } - if err := cli.Update(ctx, cm); err != nil { - return err - } - return nil + return cli.Update(ctx, cm) } // NewContext new workflow context without initialize data. diff --git a/pkg/executor/options.go b/pkg/executor/options.go index 36ae2df..a01b38c 100644 --- a/pkg/executor/options.go +++ b/pkg/executor/options.go @@ -17,7 +17,6 @@ limitations under the License. package executor import ( - "github.com/kubevela/pkg/cue/cuex" "github.com/kubevela/workflow/pkg/types" ) @@ -26,19 +25,6 @@ type Option interface { ApplyTo(*workflowExecutor) } -type withCompiler struct { - compiler *cuex.Compiler -} - -func (w *withCompiler) ApplyTo(e *workflowExecutor) { - e.compiler = w.compiler -} - -// WithCompiler set the cue compiler -func WithCompiler(compiler *cuex.Compiler) Option { - return &withCompiler{compiler: compiler} -} - type withStatusPatcher struct { patcher types.StatusPatcher } diff --git a/pkg/executor/workflow.go b/pkg/executor/workflow.go index 61cc27a..7d4b775 100644 --- a/pkg/executor/workflow.go +++ b/pkg/executor/workflow.go @@ -29,7 +29,6 @@ import ( "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/util/feature" - "github.com/kubevela/pkg/cue/cuex" monitorContext "github.com/kubevela/pkg/monitor/context" "github.com/kubevela/workflow/api/v1alpha1" @@ -38,7 +37,6 @@ import ( "github.com/kubevela/workflow/pkg/features" "github.com/kubevela/workflow/pkg/hooks" "github.com/kubevela/workflow/pkg/monitor/metrics" - "github.com/kubevela/workflow/pkg/providers" "github.com/kubevela/workflow/pkg/providers/legacy/workspace" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" @@ -62,7 +60,6 @@ type workflowExecutor struct { instance *types.WorkflowInstance wfCtx wfContext.Context patcher types.StatusPatcher - compiler *cuex.Compiler } // New returns a Workflow Executor implementation. @@ -71,9 +68,6 @@ func New(instance *types.WorkflowInstance, options ...Option) WorkflowExecutor { for _, opt := range options { opt.ApplyTo(executor) } - if executor.compiler == nil { - executor.compiler = providers.Compiler.Get() - } return executor } @@ -214,7 +208,6 @@ func newEngine(ctx monitorContext.Context, wfCtx wfContext.Context, w *workflowE stepTimeout: make(map[string]time.Time), taskRunners: taskRunners, statusPatcher: w.patcher, - compiler: w.compiler, } } @@ -587,7 +580,6 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v }, StepStatus: e.stepStatus, Engine: e, - Compiler: e.compiler, PreCheckHooks: []types.TaskPreCheckHook{ func(step v1alpha1.WorkflowStep, options *types.PreCheckOptions) (*types.PreCheckResult, error) { if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { @@ -643,10 +635,7 @@ func (e *engine) generateRunOptions(ctx monitorContext.Context, dependsOnPhase v if e.debug { options.Debug = func(id string, v cue.Value) error { debugContext := debug.NewContext(e.instance, id) - if err := debugContext.Set(v); err != nil { - return err - } - return nil + return debugContext.Set(v) } } return options @@ -666,7 +655,6 @@ type engine struct { stepDependsOn map[string][]string taskRunners []types.TaskRunner statusPatcher types.StatusPatcher - compiler *cuex.Compiler } func (e *engine) finishStep(operation *types.Operation) { diff --git a/pkg/executor/workflow_test.go b/pkg/executor/workflow_test.go index 10de0a1..d997cbd 100644 --- a/pkg/executor/workflow_test.go +++ b/pkg/executor/workflow_test.go @@ -43,6 +43,7 @@ import ( wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/features" + "github.com/kubevela/workflow/pkg/providers" "github.com/kubevela/workflow/pkg/tasks/builtin" "github.com/kubevela/workflow/pkg/tasks/custom" "github.com/kubevela/workflow/pkg/types" @@ -2373,7 +2374,7 @@ func (tr *testTaskRunner) Run(ctx wfContext.Context, options *types.TaskRunOptio resetter := tr.fillContext(logCtx, options.PCtx) defer resetter(options.PCtx) - basicVal, err := custom.MakeBasicValue(logCtx, nil, options.PCtx) + basicVal, err := custom.MakeBasicValue(logCtx, providers.Compiler.Get(), nil, options.PCtx) if err != nil { return v1alpha1.StepStatus{}, nil, err } diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index ee7bcd3..0772f66 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -33,6 +33,7 @@ import ( "github.com/kubevela/workflow/pkg/executor" "github.com/kubevela/workflow/pkg/monitor/metrics" + "github.com/kubevela/workflow/pkg/providers" "github.com/kubevela/workflow/pkg/tasks" "github.com/kubevela/workflow/pkg/tasks/template" "github.com/kubevela/workflow/pkg/types" @@ -132,13 +133,16 @@ func GenerateWorkflowInstance(ctx context.Context, cli client.Client, run *v1alp return instance, nil } -func initStepGeneratorOptions(ctx monitorContext.Context, instance *types.WorkflowInstance, options types.StepGeneratorOptions) types.StepGeneratorOptions { +func initStepGeneratorOptions(_ monitorContext.Context, instance *types.WorkflowInstance, options types.StepGeneratorOptions) types.StepGeneratorOptions { if options.ProcessCtx == nil { options.ProcessCtx = process.NewContext(generateContextDataFromWorkflowRun(instance)) } if options.TemplateLoader == nil { options.TemplateLoader = template.NewWorkflowStepTemplateLoader() } + if options.Compiler == nil { + options.Compiler = providers.Compiler.Get() + } return options } diff --git a/pkg/providers/http/do.go b/pkg/providers/http/do.go deleted file mode 100644 index 4dd36a7..0000000 --- a/pkg/providers/http/do.go +++ /dev/null @@ -1,242 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package http - -import ( - "context" - "crypto/tls" - "crypto/x509" - "encoding/base64" - "fmt" - "io" - "net/http" - "strings" - "time" - - "cuelang.org/go/cue" - "github.com/pkg/errors" - v1 "k8s.io/api/core/v1" - "sigs.k8s.io/controller-runtime/pkg/client" - - monitorContext "github.com/kubevela/pkg/monitor/context" - - wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/providers/http/ratelimiter" - "github.com/kubevela/workflow/pkg/types" -) - -const ( - // ProviderName is provider name for install. - ProviderName = "http" -) - -var ( - rateLimiter *ratelimiter.RateLimiter -) - -func init() { - rateLimiter = ratelimiter.NewRateLimiter(128) -} - -type provider struct { - cli client.Client - ns string -} - -// Do process http request. -func (h *provider) Do(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - resp, err := h.runHTTP(ctx, v) - if err != nil { - return err - } - return v.FillObject(resp, "response") -} - -func (h *provider) runHTTP(ctx monitorContext.Context, v *value.Value) (interface{}, error) { - var ( - err error - method, u string - header, trailer http.Header - r io.Reader - ) - defaultClient := &http.Client{ - Transport: http.DefaultTransport, - Timeout: time.Second * 3, - } - if timeout, err := v.GetString("request", "timeout"); err == nil && timeout != "" { - duration, err := time.ParseDuration(timeout) - if err != nil { - return nil, err - } - defaultClient.Timeout = duration - } - if method, err = v.GetString("method"); err != nil { - return nil, err - } - if u, err = v.GetString("url"); err != nil { - return nil, err - } - if rl, err := v.LookupValue("request", "ratelimiter"); err == nil { - limit, err := rl.GetInt64("limit") - if err != nil { - return nil, err - } - period, err := rl.GetString("period") - if err != nil { - return nil, err - } - duration, err := time.ParseDuration(period) - if err != nil { - return nil, err - } - if !rateLimiter.Allow(fmt.Sprintf("%s-%s", method, strings.Split(u, "?")[0]), int(limit), duration) { - return nil, errors.New("request exceeds the rate limiter") - } - } - if body, err := v.LookupValue("request", "body"); err == nil { - r, err = body.CueValue().Reader() - if err != nil { - return nil, err - } - } - if header, err = parseHeaders(v.CueValue(), "header"); err != nil { - return nil, err - } - if trailer, err = parseHeaders(v.CueValue(), "trailer"); err != nil { - return nil, err - } - if header == nil { - header = map[string][]string{} - header.Set("Content-Type", "application/json") - } - - req, err := http.NewRequestWithContext(context.Background(), method, u, r) - if err != nil { - return nil, err - } - req.Header = header - req.Trailer = trailer - - if tr, err := h.getTransport(ctx, v); err == nil && tr != nil { - defaultClient.Transport = tr - } - - resp, err := defaultClient.Do(req) - if err != nil { - return nil, err - } - //nolint:errcheck - defer resp.Body.Close() - b, err := io.ReadAll(resp.Body) - // parse response body and headers - return map[string]interface{}{ - "body": string(b), - "header": resp.Header, - "trailer": resp.Trailer, - "statusCode": resp.StatusCode, - }, err -} - -func (h *provider) getTransport(ctx monitorContext.Context, v *value.Value) (http.RoundTripper, error) { - tlsConfig, err := v.LookupValue("tls_config") - if err != nil { - return nil, nil - } - tr := &http.Transport{ - TLSClientConfig: &tls.Config{ - NextProtos: []string{"http/1.1"}, - }, - } - - secretName, err := tlsConfig.GetString("secret") - if err != nil { - return nil, err - } - objectKey := client.ObjectKey{ - Namespace: h.ns, - Name: secretName, - } - index := strings.Index(secretName, "/") - if index > 0 { - objectKey.Namespace = secretName[:index-1] - objectKey.Name = secretName[index:] - } - secret := new(v1.Secret) - if err := h.cli.Get(ctx, objectKey, secret); err != nil { - return nil, err - } - if ca, ok := secret.Data["ca.crt"]; ok { - caData, err := base64.StdEncoding.DecodeString(string(ca)) - if err != nil { - return nil, err - } - pool := x509.NewCertPool() - pool.AppendCertsFromPEM(caData) - tr.TLSClientConfig.RootCAs = pool - } - var certData, keyData []byte - if clientCert, ok := secret.Data["client.crt"]; ok { - certData, err = base64.StdEncoding.DecodeString(string(clientCert)) - if err != nil { - return nil, err - } - } - if clientKey, ok := secret.Data["client.key"]; ok { - keyData, err = base64.StdEncoding.DecodeString(string(clientKey)) - if err != nil { - return nil, err - } - } - cliCrt, err := tls.X509KeyPair(certData, keyData) - if err != nil { - return nil, errors.WithMessage(err, "parse client keypair") - } - tr.TLSClientConfig.Certificates = []tls.Certificate{cliCrt} - return tr, nil -} - -func parseHeaders(obj cue.Value, label string) (http.Header, error) { - m := obj.LookupPath(value.FieldPath("request", label)) - if !m.Exists() { - return nil, nil - } - iter, err := m.Fields() - if err != nil { - return nil, err - } - h := http.Header{} - for iter.Next() { - str, err := iter.Value().String() - if err != nil { - return nil, err - } - h.Add(iter.Label(), str) - } - return h, nil -} - -// Install register handlers to provider discover. -func Install(p types.Providers, cli client.Client, ns string) { - prd := &provider{ - cli: cli, - ns: ns, - } - p.Register(ProviderName, map[string]types.Handler{ - "do": prd.Do, - }) -} diff --git a/pkg/providers/kube/handle.go b/pkg/providers/kube/handle.go deleted file mode 100644 index 94497ff..0000000 --- a/pkg/providers/kube/handle.go +++ /dev/null @@ -1,369 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package kube - -import ( - "context" - - "cuelang.org/go/cue" - "cuelang.org/go/cue/cuecontext" - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - ktypes "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" - - monitorContext "github.com/kubevela/pkg/monitor/context" - "github.com/kubevela/pkg/multicluster" - "github.com/kubevela/pkg/util/k8s" - "github.com/kubevela/pkg/util/k8s/patch" - - wfContext "github.com/kubevela/workflow/pkg/context" - velacue "github.com/kubevela/workflow/pkg/cue" - "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/types" -) - -const ( - // ProviderName is provider name for install. - ProviderName = "kube" - // AnnoWorkflowLastAppliedConfig is the annotation for last applied config - AnnoWorkflowLastAppliedConfig = "workflow.oam.dev/last-applied-configuration" - // AnnoWorkflowLastAppliedTime is annotation for last applied time - AnnoWorkflowLastAppliedTime = "workflow.oam.dev/last-applied-time" -) - -// Dispatcher is a client for apply resources. -type Dispatcher func(ctx context.Context, cluster, owner string, manifests ...*unstructured.Unstructured) error - -// Deleter is a client for delete resources. -type Deleter func(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error - -// Handlers handles resources. -type Handlers struct { - Apply Dispatcher - Delete Deleter -} - -type filters struct { - Namespace string `json:"namespace"` - MatchingLabels map[string]string `json:"matchingLabels"` -} - -type provider struct { - labels map[string]string - handlers Handlers - cli client.Client -} - -const ( - // WorkflowResourceCreator is the creator name of workflow resource - WorkflowResourceCreator string = "workflow" -) - -func handleContext(ctx context.Context, cluster string) context.Context { - return multicluster.WithCluster(ctx, cluster) -} - -type dispatcher struct { - cli client.Client -} - -func (d *dispatcher) apply(ctx context.Context, cluster, owner string, workloads ...*unstructured.Unstructured) error { //nolint:revive,unused - for _, workload := range workloads { - existing := new(unstructured.Unstructured) - existing.GetObjectKind().SetGroupVersionKind(workload.GetObjectKind().GroupVersionKind()) - if err := d.cli.Get(ctx, ktypes.NamespacedName{ - Namespace: workload.GetNamespace(), - Name: workload.GetName(), - }, existing); err != nil { - if errors.IsNotFound(err) { - // TODO: make the annotation optional - b, err := workload.MarshalJSON() - if err != nil { - return err - } - if err := k8s.AddAnnotation(workload, AnnoWorkflowLastAppliedConfig, string(b)); err != nil { - return err - } - if err := d.cli.Create(ctx, workload); err != nil { - return err - } - } else { - return err - } - } else { - patcher, err := patch.ThreeWayMergePatch(existing, workload, &patch.PatchAction{ - UpdateAnno: true, - AnnoLastAppliedConfig: AnnoWorkflowLastAppliedConfig, - AnnoLastAppliedTime: AnnoWorkflowLastAppliedTime, - }) - if err != nil { - return err - } - if err := d.cli.Patch(ctx, workload, patcher); err != nil { - return err - } - } - } - return nil -} - -func (d *dispatcher) delete(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error { //nolint:revive,unused - return d.cli.Delete(ctx, manifest) -} - -// Patch patch CR in cluster. -func (h *provider) Patch(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - val, err := v.LookupValue("value") - if err != nil { - return err - } - obj := new(unstructured.Unstructured) - if err := val.UnmarshalTo(obj); err != nil { - return err - } - key := client.ObjectKeyFromObject(obj) - if key.Namespace == "" { - key.Namespace = "default" - } - cluster, err := v.GetString("cluster") - if err != nil { - return err - } - multiCtx := handleContext(ctx, cluster) - if err := h.cli.Get(multiCtx, key, obj); err != nil { - return err - } - baseVal := cuecontext.New().CompileString("").FillPath(cue.ParsePath(""), obj) - patcher, err := v.LookupValue("patch") - if err != nil { - return err - } - - base, err := model.NewBase(baseVal) - if err != nil { - return err - } - if err := base.Unify(patcher.CueValue()); err != nil { - return err - } - workload, err := base.Unstructured() - if err != nil { - return err - } - for k, v := range h.labels { - if err := k8s.AddLabel(workload, k, v); err != nil { - return err - } - } - if err := h.handlers.Apply(multiCtx, cluster, WorkflowResourceCreator, workload); err != nil { - return err - } - return velacue.FillUnstructuredObject(v, workload, "result") -} - -// Apply create or update CR in cluster. -func (h *provider) Apply(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - val, err := v.LookupValue("value") - if err != nil { - return err - } - var workload = new(unstructured.Unstructured) - if err := val.UnmarshalTo(workload); err != nil { - return err - } - if workload.GetNamespace() == "" { - workload.SetNamespace("default") - } - for k, v := range h.labels { - if err := k8s.AddLabel(workload, k, v); err != nil { - return err - } - } - cluster, err := v.GetString("cluster") - if err != nil { - return err - } - deployCtx := handleContext(ctx, cluster) - if err := h.handlers.Apply(deployCtx, cluster, WorkflowResourceCreator, workload); err != nil { - return err - } - return velacue.FillUnstructuredObject(v, workload, "value") -} - -// ApplyInParallel create or update CRs in parallel. -func (h *provider) ApplyInParallel(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - val, err := v.LookupValue("value") - if err != nil { - return err - } - iter, err := val.CueValue().List() - if err != nil { - return err - } - workloadNum := 0 - for iter.Next() { - workloadNum++ - } - var workloads = make([]*unstructured.Unstructured, workloadNum) - if err = val.UnmarshalTo(&workloads); err != nil { - return err - } - for i := range workloads { - if workloads[i].GetNamespace() == "" { - workloads[i].SetNamespace("default") - } - } - cluster, err := v.GetString("cluster") - if err != nil { - return err - } - deployCtx := handleContext(ctx, cluster) - if err := h.handlers.Apply(deployCtx, cluster, WorkflowResourceCreator, workloads...); err != nil { - return err - } - return nil -} - -// Read get CR from cluster. -func (h *provider) Read(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - val, err := v.LookupValue("value") - if err != nil { - return err - } - obj := new(unstructured.Unstructured) - if err := val.UnmarshalTo(obj); err != nil { - return err - } - key := client.ObjectKeyFromObject(obj) - if key.Namespace == "" { - key.Namespace = "default" - } - cluster, err := v.GetString("cluster") - if err != nil { - return err - } - readCtx := handleContext(ctx, cluster) - if err := h.cli.Get(readCtx, key, obj); err != nil { - return v.FillObject(err.Error(), "err") - } - return velacue.FillUnstructuredObject(v, obj, "value") -} - -// List lists CRs from cluster. -func (h *provider) List(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - r, err := v.LookupValue("resource") - if err != nil { - return err - } - resource := &metav1.TypeMeta{} - if err := r.UnmarshalTo(resource); err != nil { - return err - } - list := &unstructured.UnstructuredList{Object: map[string]interface{}{ - "kind": resource.Kind, - "apiVersion": resource.APIVersion, - }} - - filterValue, err := v.LookupValue("filter") - if err != nil { - return err - } - filter := &filters{} - if err := filterValue.UnmarshalTo(filter); err != nil { - return err - } - cluster, err := v.GetString("cluster") - if err != nil { - return err - } - listOpts := []client.ListOption{ - client.InNamespace(filter.Namespace), - client.MatchingLabels(filter.MatchingLabels), - } - readCtx := handleContext(ctx, cluster) - if err := h.cli.List(readCtx, list, listOpts...); err != nil { - return v.FillObject(err.Error(), "err") - } - return velacue.FillUnstructuredObject(v, list, "list") -} - -// Delete deletes CR from cluster. -func (h *provider) Delete(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - val, err := v.LookupValue("value") - if err != nil { - return err - } - obj := new(unstructured.Unstructured) - if err := val.UnmarshalTo(obj); err != nil { - return err - } - cluster, err := v.GetString("cluster") - if err != nil { - return err - } - deleteCtx := handleContext(ctx, cluster) - - if filterValue, err := v.LookupValue("filter"); err == nil { - filter := &filters{} - if err := filterValue.UnmarshalTo(filter); err != nil { - return err - } - labelSelector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{MatchLabels: filter.MatchingLabels}) - if err != nil { - return err - } - if err := h.cli.DeleteAllOf(deleteCtx, obj, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: filter.Namespace, LabelSelector: labelSelector}}); err != nil { - return v.FillObject(err.Error(), "err") - } - return nil - } - - if err := h.handlers.Delete(deleteCtx, cluster, WorkflowResourceCreator, obj); err != nil { - return v.FillObject(err.Error(), "err") - } - - return nil -} - -// Install register handlers to provider discover. -func Install(p types.Providers, cli client.Client, labels map[string]string, handlers *Handlers) { - if handlers == nil { - d := &dispatcher{ - cli: cli, - } - handlers = &Handlers{ - Apply: d.apply, - Delete: d.delete, - } - } - prd := &provider{ - cli: cli, - handlers: *handlers, - labels: labels, - } - p.Register(ProviderName, map[string]types.Handler{ - "apply": prd.Apply, - "apply-in-parallel": prd.ApplyInParallel, - "read": prd.Read, - "list": prd.List, - "delete": prd.Delete, - "patch": prd.Patch, - }) -} diff --git a/pkg/providers/legacy/email/email.go b/pkg/providers/legacy/email/email.go index a26515c..7cca119 100644 --- a/pkg/providers/legacy/email/email.go +++ b/pkg/providers/legacy/email/email.go @@ -64,7 +64,7 @@ type MailParams = providertypes.LegacyParams[MailVars] var emailRoutine sync.Map // Send sends email -func Send(ctx context.Context, params *MailParams) (res *any, err error) { +func Send(_ context.Context, params *MailParams) (res *any, err error) { pCtx := params.ProcessContext act := params.Action id := fmt.Sprint(pCtx.GetData(model.ContextStepSessionID)) diff --git a/pkg/providers/legacy/kube/kube.go b/pkg/providers/legacy/kube/kube.go index d27c5cb..f925183 100644 --- a/pkg/providers/legacy/kube/kube.go +++ b/pkg/providers/legacy/kube/kube.go @@ -55,7 +55,7 @@ func handleContext(ctx context.Context, cluster string) context.Context { return multicluster.WithCluster(ctx, cluster) } -func apply(ctx context.Context, cluster, owner string, workloads ...*unstructured.Unstructured) error { +func apply(ctx context.Context, _, _ string, workloads ...*unstructured.Unstructured) error { cli := singleton.KubeClient.Get() for _, workload := range workloads { existing := new(unstructured.Unstructured) @@ -96,7 +96,8 @@ func apply(ctx context.Context, cluster, owner string, workloads ...*unstructure return nil } -func delete(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error { +// nolint:revive +func delete(ctx context.Context, _, _ string, manifest *unstructured.Unstructured) error { return singleton.KubeClient.Get().Delete(ctx, manifest) } diff --git a/pkg/providers/legacy/metrics/prom_check.go b/pkg/providers/legacy/metrics/prom_check.go index 068183c..ed255d5 100644 --- a/pkg/providers/legacy/metrics/prom_check.go +++ b/pkg/providers/legacy/metrics/prom_check.go @@ -177,7 +177,7 @@ func getQueryResult(ctx context.Context, vars PromVars) (string, error) { return valueStr, nil } -func compareValueWithCondition(ctx context.Context, valueStr string, vars PromVars) (bool, error) { +func compareValueWithCondition(_ context.Context, valueStr string, vars PromVars) (bool, error) { template := fmt.Sprintf("if: %s %s", valueStr, vars.Condition) res, err := cuecontext.New().CompileString(template).LookupPath(cue.ParsePath("if")).Bool() if err != nil { diff --git a/pkg/providers/legacy/time/time.go b/pkg/providers/legacy/time/time.go index 6db4543..e132adf 100644 --- a/pkg/providers/legacy/time/time.go +++ b/pkg/providers/legacy/time/time.go @@ -37,7 +37,7 @@ type Vars struct { type Params = providertypes.LegacyParams[Vars] // Timestamp convert date to timestamp -func Timestamp(ctx context.Context, params *Params) (*Vars, error) { +func Timestamp(_ context.Context, params *Params) (*Vars, error) { date := params.Params.Date layout := params.Params.Layout if date == "" { @@ -56,7 +56,7 @@ func Timestamp(ctx context.Context, params *Params) (*Vars, error) { } // Date convert timestamp to date -func Date(ctx context.Context, params *Params) (*Vars, error) { +func Date(_ context.Context, params *Params) (*Vars, error) { timestamp := params.Params.Timestamp layout := params.Params.Layout if layout == "" { diff --git a/pkg/providers/legacy/util/util.go b/pkg/providers/legacy/util/util.go index 0ce236f..35c94c9 100644 --- a/pkg/providers/legacy/util/util.go +++ b/pkg/providers/legacy/util/util.go @@ -48,7 +48,7 @@ type PatchResult struct { } // PatchK8sObject patch k8s object -func PatchK8sObject(ctx context.Context, params *providertypes.LegacyParams[cue.Value]) (cue.Value, error) { +func PatchK8sObject(_ context.Context, params *providertypes.LegacyParams[cue.Value]) (cue.Value, error) { base, err := model.NewBase(params.Params.LookupPath(cue.ParsePath("value"))) if err != nil { return cue.Value{}, err @@ -78,7 +78,7 @@ type StringReturns struct { type StringParams = providertypes.LegacyParams[StringVars] // String convert byte to string -func String(ctx context.Context, params *StringParams) (*StringReturns, error) { +func String(_ context.Context, params *StringParams) (*StringReturns, error) { return &StringReturns{ String: string(params.Params.Byte), }, nil @@ -155,7 +155,7 @@ func Log(ctx context.Context, params *LogParams) (*any, error) { return nil, nil } -func printDataInLog(ctx context.Context, data any, level int, pCtx process.Context) error { +func printDataInLog(_ context.Context, data any, level int, pCtx process.Context) error { var message string switch v := data.(type) { case string: diff --git a/pkg/providers/legacy/workspace/workspace.go b/pkg/providers/legacy/workspace/workspace.go index 6a70b58..1cb8414 100644 --- a/pkg/providers/legacy/workspace/workspace.go +++ b/pkg/providers/legacy/workspace/workspace.go @@ -59,7 +59,7 @@ type VarReturns struct { type VarParams = providertypes.LegacyParams[VarVars] // DoVar get & put variable from context. -func DoVar(ctx context.Context, params *VarParams) (*VarReturns, error) { +func DoVar(_ context.Context, params *VarParams) (*VarReturns, error) { wfCtx := params.RuntimeParams.WorkflowContext path := params.Params.Path @@ -111,7 +111,7 @@ type WaitVars struct { type WaitParams = providertypes.LegacyParams[WaitVars] // Wait let workflow wait. -func Wait(ctx context.Context, params *WaitParams) (*any, error) { +func Wait(_ context.Context, params *WaitParams) (*any, error) { if params.Params.Continue { return nil, nil } @@ -120,13 +120,13 @@ func Wait(ctx context.Context, params *WaitParams) (*any, error) { } // Break let workflow terminate. -func Break(ctx context.Context, params *ActionParams) (*any, error) { +func Break(_ context.Context, params *ActionParams) (*any, error) { params.Action.Terminate(params.Params.Message) return nil, errors.GenericActionError(errors.ActionTerminate) } // Fail let the step fail, its status is failed and reason is Action -func Fail(ctx context.Context, params *ActionParams) (*any, error) { +func Fail(_ context.Context, params *ActionParams) (*any, error) { params.Action.Fail(params.Params.Message) return nil, errors.GenericActionError(errors.ActionTerminate) } @@ -141,7 +141,7 @@ type SuspendVars struct { type SuspendParams = providertypes.LegacyParams[SuspendVars] // Suspend let the step suspend, its status is suspending and reason is Suspend -func Suspend(ctx context.Context, params *SuspendParams) (*any, error) { +func Suspend(_ context.Context, params *SuspendParams) (*any, error) { pCtx := params.ProcessContext wfCtx := params.WorkflowContext act := params.Action @@ -184,7 +184,7 @@ func Suspend(ctx context.Context, params *SuspendParams) (*any, error) { } // Message writes message to step status, note that the message will be overwritten by the next message. -func Message(ctx context.Context, params *ActionParams) (*any, error) { +func Message(_ context.Context, params *ActionParams) (*any, error) { params.Action.Message(params.Params.Message) return nil, nil } diff --git a/pkg/providers/metrics/prom_check.go b/pkg/providers/metrics/prom_check.go deleted file mode 100644 index 1b5f24d..0000000 --- a/pkg/providers/metrics/prom_check.go +++ /dev/null @@ -1,210 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package metrics - -import ( - "fmt" - "strconv" - "time" - - monitorContext "github.com/kubevela/pkg/monitor/context" - wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/types" - "github.com/prometheus/client_golang/api" - v1 "github.com/prometheus/client_golang/api/prometheus/v1" - "github.com/prometheus/common/model" -) - -const ( - // ProviderName is provider name for install. - ProviderName = "metrics" -) - -type provider struct{} - -// PromCheck do health check from metrics from prometheus -func (h *provider) PromCheck(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - stepID, err := v.GetString("stepID") - if err != nil { - return err - } - - valueStr, err := getQueryResult(ctx, v) - if err != nil { - return err - } - - conditionStr, err := v.GetString("condition") - if err != nil { - return err - } - - res, err := compareValueWithCondition(valueStr, conditionStr, v) - - if err != nil { - return err - } - - if res { - // meet the condition - return handleSuccessCompare(wfCtx, stepID, v, conditionStr, valueStr) - } - return handleFailCompare(wfCtx, stepID, v, conditionStr, valueStr) -} - -func handleSuccessCompare(wfCtx wfContext.Context, stepID string, v *value.Value, conditionStr, valueStr string) error { - // clean up fail timeStamp - setMetricsStatusTime(wfCtx, stepID, "fail", 0) - d, err := v.GetString("duration") - if err != nil { - return err - } - duration, err := time.ParseDuration(d) - if err != nil { - return err - } - - st := getMetricsStatusTime(wfCtx, stepID, "success") - if st == 0 { - // first success - if err := v.FillObject(fmt.Sprintf("The healthy condition should be %s, and the query result is %s, indicating success.", conditionStr, valueStr), "message"); err != nil { - return err - } - setMetricsStatusTime(wfCtx, stepID, "success", time.Now().Unix()) - return v.FillObject(false, "result") - } - successTime := time.Unix(st, 0) - if successTime.Add(duration).Before(time.Now()) { - if err = v.FillObject("The metric check has passed successfully.", "message"); err != nil { - return err - } - return v.FillObject(true, "result") - } - if err := v.FillObject(fmt.Sprintf("The healthy condition should be %s, and the query result is %s, indicating success. The success has persisted for %s, with success duration being %s.", conditionStr, valueStr, time.Since(successTime).String(), duration), "message"); err != nil { - return err - } - return v.FillObject(false, "result") -} - -func handleFailCompare(wfCtx wfContext.Context, stepID string, v *value.Value, conditionStr, valueStr string) error { - // clean up success timeStamp - setMetricsStatusTime(wfCtx, stepID, "success", 0) - ft := getMetricsStatusTime(wfCtx, stepID, "") - d, err := v.GetString("failDuration") - if err != nil { - return err - } - failDuration, err := time.ParseDuration(d) - if err != nil { - return err - } - - if ft == 0 { - // first failed - setMetricsStatusTime(wfCtx, stepID, "fail", time.Now().Unix()) - if err := v.FillObject(fmt.Sprintf("The healthy condition should be %s, but the query result is %s, indicating failure, with the failure duration being %s. This is first failed checking.", conditionStr, valueStr, failDuration), "message"); err != nil { - return err - } - return v.FillObject(false, "result") - } - - failTime := time.Unix(ft, 0) - if failTime.Add(failDuration).Before(time.Now()) { - if err = v.FillObject(true, "failed"); err != nil { - return err - } - if err := v.FillObject(fmt.Sprintf("The healthy condition should be %s, but the query result is %s, indicating failure. The failure has persisted for %s, with the failure duration being %s. The check has terminated.", conditionStr, valueStr, time.Since(failTime).String(), failDuration), "message"); err != nil { - return err - } - return v.FillObject(false, "result") - } - if err := v.FillObject(fmt.Sprintf("The healthy condition should be %s, but the query result is %s, indicating failure. The failure has persisted for %s, with the failure duration being %s.", conditionStr, valueStr, time.Since(failTime).String(), failDuration), "message"); err != nil { - return err - } - return v.FillObject(false, "result") -} - -func getQueryResult(ctx monitorContext.Context, v *value.Value) (string, error) { - addr, err := v.GetString("metricEndpoint") - if err != nil { - return "", err - } - c, err := api.NewClient(api.Config{ - Address: addr, - }) - if err != nil { - return "", err - } - promCli := v1.NewAPI(c) - query, err := v.GetString("query") - if err != nil { - return "", err - } - resp, _, err := promCli.Query(ctx, query, time.Now()) - if err != nil { - return "", err - } - - var valueStr string - switch v := resp.(type) { - case *model.Scalar: - valueStr = v.Value.String() - case model.Vector: - if len(v) != 1 { - return "", fmt.Errorf(fmt.Sprintf("ehe query is returning %d results when it should only return one. Please review the query to identify and fix the issue", len(v))) - } - valueStr = v[0].Value.String() - default: - return "", fmt.Errorf("cannot handle the not query value") - } - return valueStr, nil -} - -func compareValueWithCondition(valueStr string, conditionStr string, v *value.Value) (bool, error) { //nolint:revive,unused - template := fmt.Sprintf("if: %s %s", valueStr, conditionStr) - cueValue, err := value.NewValue(template, nil, "") - if err != nil { - return false, err - } - res, err := cueValue.GetBool("if") - if err != nil { - return false, err - } - return res, nil -} - -func setMetricsStatusTime(wfCtx wfContext.Context, stepID string, status string, time int64) { - wfCtx.SetMutableValue(strconv.FormatInt(time, 10), stepID, "metrics", status, "time") -} - -func getMetricsStatusTime(wfCtx wfContext.Context, stepID string, status string) int64 { - str := wfCtx.GetMutableValue(stepID, "metrics", status, "time") - if len(str) == 0 { - return 0 - } - t, _ := strconv.ParseInt(str, 10, 64) - return t -} - -// Install register handlers to provider discover. -func Install(p types.Providers) { - prd := &provider{} - p.Register(ProviderName, map[string]types.Handler{ - "promCheck": prd.PromCheck, - }) -} diff --git a/pkg/providers/util/util.go b/pkg/providers/util/util.go deleted file mode 100644 index 8eaad85..0000000 --- a/pkg/providers/util/util.go +++ /dev/null @@ -1,175 +0,0 @@ -/* - Copyright 2022. The KubeVela Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package util - -import ( - "encoding/json" - "fmt" - - monitorContext "github.com/kubevela/pkg/monitor/context" - - wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/cue/process" - "github.com/kubevela/workflow/pkg/types" -) - -const ( - // ProviderName is provider name for install. - ProviderName = "util" -) - -type provider struct { - pCtx process.Context -} - -func (p *provider) PatchK8sObject(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - val, err := v.LookupValue("value") - if err != nil { - return err - } - pv, err := v.LookupValue("patch") - if err != nil { - return err - } - base, err := model.NewBase(val.CueValue()) - if err != nil { - return err - } - if err = base.Unify(pv.CueValue()); err != nil { - return v.FillObject(err, "err") - } - - workload, err := base.Unstructured() - if err != nil { - return v.FillObject(err, "err") - } - return v.FillObject(workload.Object, "result") -} - -// String convert byte to string -func (p *provider) String(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - b, err := v.LookupValue("bt") - if err != nil { - return err - } - s, err := b.CueValue().Bytes() - if err != nil { - return err - } - return v.FillObject(string(s), "str") -} - -// Log print cue value in log -func (p *provider) Log(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - stepName := fmt.Sprint(p.pCtx.GetData(model.ContextStepName)) - stepID := fmt.Sprint(p.pCtx.GetData(model.ContextStepSessionID)) - config := make(map[string]types.LogConfig) - c := wfCtx.GetMutableValue(types.ContextKeyLogConfig) - if c != "" { - if err := json.Unmarshal([]byte(c), &config); err != nil { - return err - } - } - stepConfig := config[stepName] - data, err := v.LookupValue("data") - if err == nil { - level := 3 - logLevel, err := v.LookupValue("level") - if err == nil { - l, err := logLevel.CueValue().Int64() - if err == nil { - level = int(l) - } - } - if err := printDataInLog(ctx, data, level, stepID, &stepConfig); err != nil { - return err - } - } - source, err := v.LookupValue("source") - if err == nil { - if err := setSourceInLog(source, &stepConfig); err != nil { - return err - } - } - config[stepName] = stepConfig - b, err := json.Marshal(config) - if err != nil { - return err - } - wfCtx.SetMutableValue(string(b), types.ContextKeyLogConfig) - return nil -} - -func printDataInLog(ctx monitorContext.Context, data *value.Value, level int, stepID string, stepConfig *types.LogConfig) error { - stepConfig.Data = true - logCtx := ctx.Fork("cue logs") - logCtx.AddTag(model.ContextStepSessionID, stepID) - logCtx.V(level) - if s, err := data.GetString(); err == nil { - logCtx.Info(s) - return nil - } - var tmp interface{} - if err := data.UnmarshalTo(&tmp); err != nil { - return err - } - b, err := json.Marshal(tmp) - if err != nil { - return err - } - logCtx.Info(string(b)) - return nil -} - -func setSourceInLog(source *value.Value, stepConfig *types.LogConfig) error { - if stepConfig.Source == nil { - stepConfig.Source = &types.LogSource{} - } - if v, err := source.LookupValue("url"); err == nil { - url, err := v.GetString() - if err != nil { - return err - } - stepConfig.Source.URL = url - } - if v, err := source.LookupValue("resources"); err == nil { - b, err := v.CueValue().MarshalJSON() - if err != nil { - return err - } - resources := []types.Resource{} - if err := json.Unmarshal(b, &resources); err != nil { - return err - } - stepConfig.Source.Resources = resources - } - return nil -} - -// Install register handlers to provider discover. -func Install(p types.Providers, pCtx process.Context) { - prd := &provider{ - pCtx: pCtx, - } - p.Register(ProviderName, map[string]types.Handler{ - "patch-k8s-object": prd.PatchK8sObject, - "string": prd.String, - "log": prd.Log, - }) -} diff --git a/pkg/providers/workspace/workspace.go b/pkg/providers/workspace/workspace.go deleted file mode 100644 index 3e82afc..0000000 --- a/pkg/providers/workspace/workspace.go +++ /dev/null @@ -1,198 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package workspace - -import ( - "fmt" - "strings" - "time" - - monitorContext "github.com/kubevela/pkg/monitor/context" - "sigs.k8s.io/kind/pkg/errors" - - "github.com/kubevela/workflow/api/v1alpha1" - wfContext "github.com/kubevela/workflow/pkg/context" - "github.com/kubevela/workflow/pkg/cue/model" - "github.com/kubevela/workflow/pkg/cue/model/value" - "github.com/kubevela/workflow/pkg/cue/process" - "github.com/kubevela/workflow/pkg/types" -) - -const ( - // ProviderName is provider name. - ProviderName = "builtin" - // ResumeTimeStamp is resume time stamp. - ResumeTimeStamp = "resumeTimeStamp" - // SuspendTimeStamp is suspend time stamp. - SuspendTimeStamp = "suspendTimeStamp" -) - -type provider struct { - pCtx process.Context -} - -// DoVar get & put variable from context. -func (h *provider) DoVar(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - methodV, err := v.Field("method") - if err != nil { - return err - } - method, err := methodV.String() - if err != nil { - return err - } - - pathV, err := v.Field("path") - if err != nil { - return err - } - path, err := pathV.String() - if err != nil { - return err - } - - switch method { - case "Get": - value, err := wfCtx.GetVar(strings.Split(path, ".")...) - if err != nil { - return err - } - raw, err := value.String() - if err != nil { - return err - } - return v.FillRaw(raw, "value") - case "Put": - value, err := v.LookupValue("value") - if err != nil { - return err - } - return wfCtx.SetVar(value, strings.Split(path, ".")...) - } - return nil -} - -// Wait let workflow wait. -func (h *provider) Wait(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - cv := v.CueValue() - if cv.Exists() { - ret := cv.LookupPath(value.FieldPath("continue")) - if ret.Exists() { - isContinue, err := ret.Bool() - if err == nil && isContinue { - return nil - } - } - } - msg, _ := v.GetString("message") - act.Wait(msg) - return nil -} - -// Break let workflow terminate. -func (h *provider) Break(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - var msg string - if v != nil { - msg, _ = v.GetString("message") - } - act.Terminate(msg) - return nil -} - -// Fail let the step fail, its status is failed and reason is Action -func (h *provider) Fail(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - var msg string - if v != nil { - msg, _ = v.GetString("message") - } - act.Fail(msg) - return nil -} - -// Suspend let the step suspend, its status is suspending and reason is Suspend -func (h *provider) Suspend(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - stepID := fmt.Sprint(h.pCtx.GetData(model.ContextStepSessionID)) - timestamp := wfCtx.GetMutableValue(stepID, ResumeTimeStamp) - var msg string - if v != nil { - msg, _ = v.GetString("message") - if msg == "" { - msg = fmt.Sprintf("Suspended by field %s", v.FieldName()) - } - } - if timestamp != "" { - t, err := time.Parse(time.RFC3339, timestamp) - if err != nil { - return errors.Wrap(err, "failed to parse timestamp") - } - if time.Now().After(t) { - act.Resume("") - return nil - } - act.Suspend(msg) - return nil - } - if v != nil { - d, _ := v.LookupValue("duration") - if d != nil && d.CueValue().Exists() { - dur, err := d.CueValue().String() - if err != nil { - return err - } - duration, err := time.ParseDuration(dur) - if err != nil { - return errors.Wrap(err, "failed to parse duration") - } - wfCtx.SetMutableValue(time.Now().Add(duration).Format(time.RFC3339), stepID, ResumeTimeStamp) - } - } - if ts := wfCtx.GetMutableValue(stepID, v.FieldName(), SuspendTimeStamp); ts != "" { - if act.GetStatus().Phase == v1alpha1.WorkflowStepPhaseRunning { - // if it is already suspended before and has been resumed, we should not suspend it again. - return nil - } - } else { - wfCtx.SetMutableValue(time.Now().Format(time.RFC3339), stepID, v.FieldName(), SuspendTimeStamp) - } - act.Suspend(msg) - return nil -} - -// Message writes message to step status, note that the message will be overwritten by the next message. -func (h *provider) Message(ctx monitorContext.Context, wfCtx wfContext.Context, v *value.Value, act types.Action) error { //nolint:revive,unused - var msg string - if v != nil { - msg, _ = v.GetString("message") - } - act.Message(msg) - return nil -} - -// Install register handler to provider discover. -func Install(p types.Providers, pCtx process.Context) { - prd := &provider{ - pCtx: pCtx, - } - p.Register(ProviderName, map[string]types.Handler{ - "wait": prd.Wait, - "break": prd.Break, - "fail": prd.Fail, - "message": prd.Message, - "var": prd.DoVar, - "suspend": prd.Suspend, - }) -} diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index fc6cef1..daf378e 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -168,6 +168,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error Action: exec, }) + fmt.Println("===make task generator compiler", options.Compiler) basicVal, err := MakeBasicValue(tracer, options.Compiler, wfStep.Properties, options.PCtx) if err != nil { tracer.Error(err, "make context parameter") @@ -257,7 +258,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error // ValidateIfValue validates the if value func ValidateIfValue(ctx wfContext.Context, step v1alpha1.WorkflowStep, stepStatus map[string]v1alpha1.StepStatus, basicVal cue.Value) (bool, error) { s, _ := util.ToString(basicVal) - template := fmt.Sprintf("if: %s\n%s\n%s\n%s", step.If, getInputsTemplate(ctx, step, basicVal), buildValueForStatus(ctx, step, stepStatus), s) + template := fmt.Sprintf("if: %s\n%s\n%s\n%s", step.If, getInputsTemplate(ctx, step, basicVal), buildValueForStatus(ctx, stepStatus), s) v := cuecontext.New().CompileString(template).LookupPath(cue.ParsePath("if")) if v.Err() != nil { return false, errors.WithMessage(v.Err(), "invalid if value") @@ -269,7 +270,7 @@ func ValidateIfValue(ctx wfContext.Context, step v1alpha1.WorkflowStep, stepStat return check, nil } -func buildValueForStatus(ctx wfContext.Context, step v1alpha1.WorkflowStep, stepStatus map[string]v1alpha1.StepStatus) string { +func buildValueForStatus(_ wfContext.Context, stepStatus map[string]v1alpha1.StepStatus) string { statusMap := make(map[string]interface{}) for name, ss := range stepStatus { abbrStatus := struct { @@ -342,7 +343,7 @@ func getInputsTemplate(ctx wfContext.Context, step v1alpha1.WorkflowStep, basicV } // NewTaskLoader create a tasks loader. -func NewTaskLoader(lt LoadTaskTemplate, logLevel int, pCtx process.Context) *TaskLoader { +func NewTaskLoader(lt LoadTaskTemplate, logLevel int, pCtx process.Context, compiler *cuex.Compiler) *TaskLoader { return &TaskLoader{ loadTemplate: lt, runOptionsProcess: func(options *types.TaskRunOptions) { @@ -353,6 +354,7 @@ func NewTaskLoader(lt LoadTaskTemplate, logLevel int, pCtx process.Context) *Tas options.PostStopHooks = append(options.PostStopHooks, hooks.Output) } options.PCtx = pCtx + options.Compiler = compiler }, logLevel: logLevel, } diff --git a/pkg/tasks/custom/task_test.go b/pkg/tasks/custom/task_test.go index 01bdc98..ff43e67 100644 --- a/pkg/tasks/custom/task_test.go +++ b/pkg/tasks/custom/task_test.go @@ -94,7 +94,7 @@ func TestTaskLoader(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx, compiler) steps := []v1alpha1.WorkflowStep{ { @@ -154,9 +154,7 @@ func TestTaskLoader(t *testing.T) { r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) r.NoError(err) - status, action, err := run.Run(wfCtx, &types.TaskRunOptions{ - Compiler: compiler, - }) + status, action, err := run.Run(wfCtx, &types.TaskRunOptions{}) r.NoError(err) if step.Name == "wait" { r.Equal(status.Phase, v1alpha1.WorkflowStepPhaseRunning) @@ -218,7 +216,7 @@ func TestErrCases(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx, compiler) steps := []v1alpha1.WorkflowStep{ { @@ -278,7 +276,7 @@ func TestErrCases(t *testing.T) { r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) r.NoError(err) - status, operation, _ := run.Run(wfCtx, &types.TaskRunOptions{Compiler: compiler}) + status, operation, _ := run.Run(wfCtx, &types.TaskRunOptions{}) switch step.Name { case "input-replace": r.Equal(status.Message, "") @@ -334,7 +332,7 @@ func TestPendingInputCheck(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx, providers.Compiler.Get()) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) @@ -364,7 +362,7 @@ func TestPendingDependsOnCheck(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx, providers.Compiler.Get()) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) run, err := gen(step, &types.TaskGeneratorOptions{}) @@ -393,7 +391,7 @@ func TestSkip(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx, providers.Compiler.Get()) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) runner, err := gen(step, &types.TaskGeneratorOptions{}) @@ -432,7 +430,7 @@ func TestTimeout(t *testing.T) { Name: "app", Namespace: "default", }) - tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx) + tasksLoader := NewTaskLoader(mockLoadTemplate, 0, pCtx, compiler) gen, err := tasksLoader.GetTaskGenerator(context.Background(), step.Type) r.NoError(err) runner, err := gen(step, &types.TaskGeneratorOptions{}) @@ -444,7 +442,6 @@ func TestTimeout(t *testing.T) { return &types.PreCheckResult{Timeout: true}, nil }, }, - Compiler: compiler, }) r.NoError(err) r.Equal(status.Phase, v1alpha1.WorkflowStepPhaseFailed) diff --git a/pkg/tasks/discover.go b/pkg/tasks/discover.go index 28e8480..3567846 100644 --- a/pkg/tasks/discover.go +++ b/pkg/tasks/discover.go @@ -39,7 +39,7 @@ func NewTaskDiscover(ctx monitorContext.Context, options types.StepGeneratorOpti builtin: map[string]types.TaskGenerator{ types.WorkflowStepTypeStepGroup: builtin.StepGroup, }, - customTaskDiscover: custom.NewTaskLoader(options.TemplateLoader.LoadTemplate, options.LogLevel, options.ProcessCtx), + customTaskDiscover: custom.NewTaskLoader(options.TemplateLoader.LoadTemplate, options.LogLevel, options.ProcessCtx, options.Compiler), } } diff --git a/pkg/tasks/discover_test.go b/pkg/tasks/discover_test.go index 75c4430..d5ea0b7 100644 --- a/pkg/tasks/discover_test.go +++ b/pkg/tasks/discover_test.go @@ -52,7 +52,7 @@ func TestDiscover(t *testing.T) { builtin: map[string]types.TaskGenerator{ "stepGroup": builtin.StepGroup, }, - customTaskDiscover: custom.NewTaskLoader(loadTemplate, 0, pCtx), + customTaskDiscover: custom.NewTaskLoader(loadTemplate, 0, pCtx, nil), } _, err := discover.GetTaskGenerator(context.Background(), "stepGroup") diff --git a/pkg/types/types.go b/pkg/types/types.go index 250dfcb..fa8538e 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -145,6 +145,7 @@ type StepGeneratorOptions struct { TemplateLoader template.Loader StepConvertor map[string]func(step v1alpha1.WorkflowStep) (v1alpha1.WorkflowStep, error) LogLevel int + Compiler *cuex.Compiler } // Action is that workflow provider can do. diff --git a/pkg/utils/operation.go b/pkg/utils/operation.go index b56b325..dd0df6f 100644 --- a/pkg/utils/operation.go +++ b/pkg/utils/operation.go @@ -179,12 +179,9 @@ func SuspendWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.Workf if !found { return fmt.Errorf("can not find step %s", stepName) } - if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + return retry.RetryOnConflict(retry.DefaultBackoff, func() error { return cli.Status().Patch(ctx, run, client.Merge) - }); err != nil { - return err - } - return nil + }) } // OperateSteps handles the operations to the steps @@ -232,12 +229,9 @@ func ResumeWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.Workfl if !found { return fmt.Errorf("can not find step %s", stepName) } - if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + return retry.RetryOnConflict(retry.DefaultBackoff, func() error { return cli.Status().Patch(ctx, run, client.Merge) - }); err != nil { - return err - } - return nil + }) } // Rollback is not supported for WorkflowRun @@ -284,11 +278,7 @@ func RestartWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.Workf // reset the workflow status to restart the workflow run.Status = v1alpha1.WorkflowRunStatus{} - if err := cli.Status().Update(ctx, run); err != nil { - return err - } - - return nil + return cli.Status().Update(ctx, run) } // Terminate terminate workflow @@ -332,12 +322,9 @@ func TerminateWorkflow(ctx context.Context, cli client.Client, run *v1alpha1.Wor } } - if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + return retry.RetryOnConflict(retry.DefaultBackoff, func() error { return cli.Status().Patch(ctx, run, client.Merge) - }); err != nil { - return err - } - return nil + }) } // RestartFromStep restart workflow from a failed step @@ -380,13 +367,9 @@ func RestartFromStep(ctx context.Context, cli client.Client, run *v1alpha1.Workf }); err != nil { return err } - if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + return retry.RetryOnConflict(retry.DefaultBackoff, func() error { return cli.Update(ctx, cm) - }); err != nil { - return err - } - - return nil + }) } // CleanStatusFromStep cleans status and context data from a specified step diff --git a/pkg/webhook/v1alpha1/workflowrun/validating_handler.go b/pkg/webhook/v1alpha1/workflowrun/validating_handler.go index b9b6d7d..1062e51 100644 --- a/pkg/webhook/v1alpha1/workflowrun/validating_handler.go +++ b/pkg/webhook/v1alpha1/workflowrun/validating_handler.go @@ -101,7 +101,7 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a } // RegisterValidatingHandler will register application validate handler to the webhook -func RegisterValidatingHandler(mgr manager.Manager, args controllers.Args) { +func RegisterValidatingHandler(mgr manager.Manager, _ controllers.Args) { server := mgr.GetWebhookServer() server.Register("/validating-core-oam-dev-v1alpha1-workflowruns", &webhook.Admission{Handler: &ValidatingHandler{}}) } From 32340604390ac6c480a2c6f8236e149c15d651f8 Mon Sep 17 00:00:00 2001 From: FogDong Date: Mon, 15 Jul 2024 00:15:33 +0800 Subject: [PATCH 09/17] chore: update cue and fix context key Signed-off-by: FogDong --- go.mod | 30 ++++++------- go.sum | 85 +++++++++++++++++++----------------- pkg/providers/types/types.go | 36 ++++++++------- pkg/tasks/custom/task.go | 1 - 4 files changed, 79 insertions(+), 73 deletions(-) diff --git a/go.mod b/go.mod index 1824e18..ba66d98 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,13 @@ module github.com/kubevela/workflow go 1.22 require ( - cuelang.org/go v0.5.0 + cuelang.org/go v0.9.2 github.com/agiledragon/gomonkey/v2 v2.4.0 github.com/aliyun/aliyun-log-go-sdk v0.1.38 github.com/crossplane/crossplane-runtime v0.19.2 github.com/evanphx/json-patch v5.6.0+incompatible github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da - github.com/google/go-cmp v0.5.9 + github.com/google/go-cmp v0.6.0 github.com/hashicorp/go-version v1.6.0 github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6 github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d @@ -44,7 +44,7 @@ require ( github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cockroachdb/apd/v2 v2.0.2 // indirect + github.com/cockroachdb/apd/v3 v3.2.1 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -68,22 +68,19 @@ require ( github.com/google/cel-go v0.12.6 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect github.com/imdario/mergo v0.3.13 // indirect - github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jellydator/ttlcache/v3 v3.0.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kr/pretty v0.3.1 // indirect - github.com/lib/pq v1.10.7 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect github.com/nxadm/tail v1.4.8 // indirect @@ -93,7 +90,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect - github.com/spf13/cobra v1.6.1 // indirect + github.com/spf13/cobra v1.8.0 // indirect github.com/stoewer/go-strcase v1.2.0 // indirect go.etcd.io/etcd/api/v3 v3.5.5 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect @@ -111,14 +108,13 @@ require ( go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.7.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/term v0.15.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/oauth2 v0.20.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/term v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect google.golang.org/grpc v1.53.0 // indirect google.golang.org/protobuf v1.28.1 // indirect diff --git a/go.sum b/go.sum index 4c7dd44..4f3348a 100644 --- a/go.sum +++ b/go.sum @@ -2,11 +2,12 @@ cloud.google.com/go v0.100.2 h1:t9Iw5QH5v4XtlEQaCtUY7x6sCABps8sW0acw7e2WQ6Y= cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= cloud.google.com/go/compute v1.15.1 h1:7UGq3QknM33pw5xATlpzeoomNxsacIVvTqTTvbfajmE= -cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cuelang.org/go v0.5.0 h1:D6N0UgTGJCOxFKU8RU+qYvavKNsVc/+ZobmifStVJzU= -cuelang.org/go v0.5.0/go.mod h1:okjJBHFQFer+a41sAe2SaGm1glWS8oEb6CmJvn5Zdws= +cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= +cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= +cuelabs.dev/go/oci/ociregistry v0.0.0-20240404174027-a39bec0462d2 h1:BnG6pr9TTr6CYlrJznYUDj6V7xldD1W+1iXPum0wT/w= +cuelabs.dev/go/oci/ociregistry v0.0.0-20240404174027-a39bec0462d2/go.mod h1:pK23AUVXuNzzTpfMCA06sxZGeVQ/75FdVtW249de9Uo= +cuelang.org/go v0.9.2 h1:pfNiry2PdRBr02G/aKm5k2vhzmqbAOoaB4WurmEbWvs= +cuelang.org/go v0.9.2/go.mod h1:qpAYsLOf7gTM1YdEg6cxh553uZ4q9ZDWlPbtZr9q1Wk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= @@ -79,13 +80,13 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= -github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= +github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg= +github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/crossplane/crossplane-runtime v0.19.2 h1:9qBnhpqKN4x6apF2siaQ6PvgxqBXbGcKmgeD8mSIDO8= github.com/crossplane/crossplane-runtime v0.19.2/go.mod h1:OJQ1NxtQK2ZTRmvtnQPoy8LsXsARTnVydRVDQEgIuz4= @@ -162,6 +163,8 @@ github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXym github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= +github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= @@ -219,8 +222,8 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -228,8 +231,8 @@ github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3 github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= @@ -277,8 +280,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= -github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= -github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jellydator/ttlcache/v3 v3.0.1 h1:cHgCSMS7TdQcoprXnWUptJZzyFsqs18Lt8VVhRuZYVU= github.com/jellydator/ttlcache/v3 v3.0.1/go.mod h1:WwTaEmcXQ3MTjOm4bsZoDFiCu/hMvNWLO1w67RXz6h4= @@ -359,8 +362,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de h1:D5x39vF5KCwKQaw+OC9ZPiLVHXz3UFw2+psEX+gYcto= -github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de/go.mod h1:kJun4WP5gFuHZgRjZUWWuH1DTxCtxbHDOIJsudS8jzY= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -397,6 +398,10 @@ github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je4 github.com/onsi/gomega v1.27.5 h1:T/X6I0RNFw/kTqgfkZPcQ5KU6vCnWNBGdtrIx2dpGeQ= github.com/onsi/gomega v1.27.5/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= +github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725 h1:GC0oekPo2BDqK+2Mv6W/VuvkaUUMFcmqp0AZDN2vWrA= github.com/openshift/library-go v0.0.0-20230327085348-8477ec72b725/go.mod h1:OspkL5FZZapzNcka6UkNMFD7ifLT/dWUNvtwErpRK9k= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= @@ -407,7 +412,6 @@ github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6 github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.6.0+incompatible h1:Ix9yFKn1nSPBLFl/yZknTp8TU5G4Ps0JDmguYK6iH1A= github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -449,14 +453,14 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/protocolbuffers/txtpbfmt v0.0.0-20220428173112-74888fd59c2b h1:zd/2RNzIRkoGGMjE+YIsZ85CnDIz672JK2F3Zl4vux4= -github.com/protocolbuffers/txtpbfmt v0.0.0-20220428173112-74888fd59c2b/go.mod h1:KjY0wibdYKc4DYkerHSbguaf3JeIPGhNJBp2BNiFH78= +github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0 h1:sadMIsgmHpEOGbUs6VtHBXRR1OHevnj7hLx9ZcdNGW4= +github.com/protocolbuffers/txtpbfmt v0.0.0-20230328191034-3462fbc510c0/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -472,8 +476,8 @@ github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= -github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= @@ -574,8 +578,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -596,6 +600,8 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -626,8 +632,8 @@ golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -636,8 +642,8 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= +golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= +golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -646,8 +652,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -695,20 +701,20 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= @@ -733,8 +739,8 @@ golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw= +golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -751,7 +757,6 @@ google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tD google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= diff --git a/pkg/providers/types/types.go b/pkg/providers/types/types.go index ee864b9..9bfc072 100644 --- a/pkg/providers/types/types.go +++ b/pkg/providers/types/types.go @@ -28,14 +28,20 @@ import ( "github.com/kubevela/workflow/pkg/types" ) -type contextKey string +// ContextKey is the key type for context values. +type ContextKey string const ( - workflowContextKey contextKey = "workflowContext" - processContextKey contextKey = "processContext" - actionKey contextKey = "action" - labelsKey contextKey = "labels" - kubeHandlersKey contextKey = "kubeHandlers" + // WorkflowContextKey is the key for workflow context. + WorkflowContextKey ContextKey = "workflowContext" + // ProcessContextKey is the key for process context. + ProcessContextKey ContextKey = "processContext" + // ActionKey is the key for action. + ActionKey ContextKey = "action" + // LabelsKey is the key for labels. + LabelsKey ContextKey = "labels" + // KubeHandlersKey is the key for kube handlers. + KubeHandlersKey ContextKey = "kubeHandlers" ) // Dispatcher is a client for apply resources. @@ -102,33 +108,33 @@ func (fn LegacyNativeProviderFn) Call(ctx context.Context, value cue.Value) (cue // WithLabelParams returns a copy of parent in which the labels value is set func WithLabelParams(parent context.Context, labels map[string]string) context.Context { - return context.WithValue(parent, labelsKey, labels) + return context.WithValue(parent, LabelsKey, labels) } // WithRuntimeParams returns a copy of parent in which the runtime params value is set func WithRuntimeParams(parent context.Context, params RuntimeParams) context.Context { - ctx := context.WithValue(parent, workflowContextKey, params.WorkflowContext) - ctx = context.WithValue(ctx, processContextKey, params.ProcessContext) - ctx = context.WithValue(ctx, actionKey, params.Action) + ctx := context.WithValue(parent, WorkflowContextKey, params.WorkflowContext) + ctx = context.WithValue(ctx, ProcessContextKey, params.ProcessContext) + ctx = context.WithValue(ctx, ActionKey, params.Action) return ctx } // RuntimeParamsFrom returns the runtime params value stored in ctx, if any. func RuntimeParamsFrom(ctx context.Context) RuntimeParams { params := RuntimeParams{} - if wfCtx, ok := ctx.Value(workflowContextKey).(wfContext.Context); ok { + if wfCtx, ok := ctx.Value(WorkflowContextKey).(wfContext.Context); ok { params.WorkflowContext = wfCtx } - if pCtx, ok := ctx.Value(processContextKey).(process.Context); ok { + if pCtx, ok := ctx.Value(ProcessContextKey).(process.Context); ok { params.ProcessContext = pCtx } - if action, ok := ctx.Value(actionKey).(types.Action); ok { + if action, ok := ctx.Value(ActionKey).(types.Action); ok { params.Action = action } - if labels, ok := ctx.Value(labelsKey).(map[string]string); ok { + if labels, ok := ctx.Value(LabelsKey).(map[string]string); ok { params.Labels = labels } - if kubeHandlers, ok := ctx.Value(kubeHandlersKey).(*KubeHandlers); ok { + if kubeHandlers, ok := ctx.Value(KubeHandlersKey).(*KubeHandlers); ok { params.KubeHandlers = kubeHandlers } return params diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index daf378e..68b5dc9 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -168,7 +168,6 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (types.TaskGenerator, error Action: exec, }) - fmt.Println("===make task generator compiler", options.Compiler) basicVal, err := MakeBasicValue(tracer, options.Compiler, wfStep.Properties, options.PCtx) if err != nil { tracer.Error(err, "make context parameter") From 33550afed1f4e9108e824abe74b50793db87c004 Mon Sep 17 00:00:00 2001 From: FogDong Date: Mon, 15 Jul 2024 21:40:33 +0800 Subject: [PATCH 10/17] fix: fix input fill val Signed-off-by: FogDong --- pkg/cue/model/sets/utils_test.go | 14 +++++++------- pkg/hooks/data_passing.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/cue/model/sets/utils_test.go b/pkg/cue/model/sets/utils_test.go index 7c6ccd5..b83c7a9 100644 --- a/pkg/cue/model/sets/utils_test.go +++ b/pkg/cue/model/sets/utils_test.go @@ -257,13 +257,13 @@ bottom: _|_ val := cuecontext.New().BuildFile(f) s, err := toString(val) r.NoError(err) - r.Equal(s, `a: *10 | _ -a1: int -b: *"foo" | _ -b1: string -c: *true | _ -c1: bool -arr: *[1, 2] | [...] + r.Equal(s, `a: *10 | _ +a1: int +b: *"foo" | _ +b1: string +c: *true | _ +c1: bool +arr: *[1, 2] | [...] top: _ bottom: _|_ // explicit error (_|_ literal) in source `) diff --git a/pkg/hooks/data_passing.go b/pkg/hooks/data_passing.go index c6f4bc6..9bc2813 100644 --- a/pkg/hooks/data_passing.go +++ b/pkg/hooks/data_passing.go @@ -43,7 +43,7 @@ func Input(ctx wfContext.Context, paramValue cue.Value, step v1alpha1.WorkflowSt } } if input.ParameterKey != "" { - filledVal, err = value.SetValueByScript(paramValue, inputValue, strings.Join([]string{"parameter", input.ParameterKey}, ".")) + filledVal, err = value.SetValueByScript(filledVal, inputValue, strings.Join([]string{"parameter", input.ParameterKey}, ".")) if err != nil || filledVal.Err() != nil { if err != nil { return paramValue, err From 6056dcd50b9a4cfc13f7b292c9bab12c435b293c Mon Sep 17 00:00:00 2001 From: FogDong Date: Mon, 15 Jul 2024 23:17:48 +0800 Subject: [PATCH 11/17] fix: fix checkpending field path Signed-off-by: FogDong --- pkg/tasks/custom/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tasks/custom/task.go b/pkg/tasks/custom/task.go index 68b5dc9..09df92c 100644 --- a/pkg/tasks/custom/task.go +++ b/pkg/tasks/custom/task.go @@ -380,7 +380,7 @@ func CheckPending(ctx wfContext.Context, step v1alpha1.WorkflowStep, id string, for _, input := range step.Inputs { pStatus.Message = fmt.Sprintf("Pending on Input: %s", input.From) if _, err := ctx.GetVar(strings.Split(input.From, ".")...); err != nil { - if v := basicValue.LookupPath(cue.ParsePath(input.From)); !v.Exists() { + if v := basicValue.LookupPath(value.FieldPath(input.From)); !v.Exists() { return true, pStatus } } From 0102c2d689c3fc2f51339e2dc81115a0e8b3a19a Mon Sep 17 00:00:00 2001 From: FogDong Date: Fri, 19 Jul 2024 00:17:12 +0800 Subject: [PATCH 12/17] fix: fix nil pointer return in kube Signed-off-by: FogDong --- pkg/providers/legacy/kube/kube.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/providers/legacy/kube/kube.go b/pkg/providers/legacy/kube/kube.go index f925183..a4eaa94 100644 --- a/pkg/providers/legacy/kube/kube.go +++ b/pkg/providers/legacy/kube/kube.go @@ -245,7 +245,8 @@ func Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) readCtx := handleContext(ctx, params.Params.Cluster) if err := singleton.KubeClient.Get().Get(readCtx, key, workload); err != nil { return &ResourceReturns{ - Error: err, + Resource: workload, + Error: err, }, nil } return &ResourceReturns{ @@ -275,7 +276,8 @@ func List(ctx context.Context, params *ResourceParams) (*ListReturns, error) { readCtx := handleContext(ctx, params.Params.Cluster) if err := singleton.KubeClient.Get().List(readCtx, list, listOpts...); err != nil { return &ListReturns{ - Error: err, + Resources: list, + Error: err, }, nil } return &ListReturns{ @@ -296,7 +298,8 @@ func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, erro } if err := singleton.KubeClient.Get().DeleteAllOf(deleteCtx, workload, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: filter.Namespace, LabelSelector: labelSelector}}); err != nil { return &ResourceReturns{ - Error: err, + Resource: workload, + Error: err, }, nil } return nil, nil @@ -304,7 +307,8 @@ func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, erro if err := handlers.Delete(deleteCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { return &ResourceReturns{ - Error: err, + Resource: workload, + Error: err, }, nil } From 167b4a2f672078b908f0603deb33a6ad7d6ab647 Mon Sep 17 00:00:00 2001 From: FogDong Date: Fri, 19 Jul 2024 14:36:13 +0800 Subject: [PATCH 13/17] fix: fix error in return Signed-off-by: FogDong --- pkg/providers/legacy/kube/kube.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/providers/legacy/kube/kube.go b/pkg/providers/legacy/kube/kube.go index a4eaa94..e28c566 100644 --- a/pkg/providers/legacy/kube/kube.go +++ b/pkg/providers/legacy/kube/kube.go @@ -117,7 +117,7 @@ type ResourceVars struct { // ResourceReturns . type ResourceReturns struct { Resource *unstructured.Unstructured `json:"value"` - Error error `json:"err,omitempty"` + Error string `json:"err,omitempty"` } // ResourceParams . @@ -246,7 +246,7 @@ func Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) if err := singleton.KubeClient.Get().Get(readCtx, key, workload); err != nil { return &ResourceReturns{ Resource: workload, - Error: err, + Error: err.Error(), }, nil } return &ResourceReturns{ @@ -257,7 +257,7 @@ func Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) // ListReturns . type ListReturns struct { Resources *unstructured.UnstructuredList `json:"list"` - Error error `json:"err,omitempty"` + Error string `json:"err,omitempty"` } // List lists CRs from cluster. @@ -277,7 +277,7 @@ func List(ctx context.Context, params *ResourceParams) (*ListReturns, error) { if err := singleton.KubeClient.Get().List(readCtx, list, listOpts...); err != nil { return &ListReturns{ Resources: list, - Error: err, + Error: err.Error(), }, nil } return &ListReturns{ @@ -299,7 +299,7 @@ func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, erro if err := singleton.KubeClient.Get().DeleteAllOf(deleteCtx, workload, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: filter.Namespace, LabelSelector: labelSelector}}); err != nil { return &ResourceReturns{ Resource: workload, - Error: err, + Error: err.Error(), }, nil } return nil, nil @@ -308,7 +308,7 @@ func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, erro if err := handlers.Delete(deleteCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { return &ResourceReturns{ Resource: workload, - Error: err, + Error: err.Error(), }, nil } From 4e978eb22bd00f53450695fc5998cf10a6d89572 Mon Sep 17 00:00:00 2001 From: FogDong Date: Fri, 19 Jul 2024 16:50:14 +0800 Subject: [PATCH 14/17] fix: add mutex for syntax Signed-off-by: FogDong --- go.mod | 2 +- go.sum | 4 ++-- pkg/cue/model/value/value.go | 7 +++++++ pkg/hooks/data_passing.go | 3 +++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ba66d98..0a49d6c 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/google/go-cmp v0.6.0 github.com/hashicorp/go-version v1.6.0 github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6 - github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d + github.com/kubevela/pkg v1.9.2 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.27.5 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 4f3348a..90d8dd1 100644 --- a/go.sum +++ b/go.sum @@ -322,8 +322,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6 h1:VIWTjPpkB+Y8PoPsLvXHXOfjmRQF332uhtMV+B+5nkM= github.com/kubevela/kube-trigger v0.1.1-0.20230403060228-6582e7595db6/go.mod h1:8cXenu5zACvEHCMt1fnVvPOJkPN+dZQz7n8zaZf4heM= -github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d h1:QMmTg33lUZEfTz94eYJKa6Nb7GDcEOmuXsXRt/dA5vk= -github.com/kubevela/pkg v1.8.1-0.20230522085329-7d5e1241a86d/go.mod h1:3ZWrl2+zb5ROdC2NJPPrL/4sun4M10wYfRP/9gF9WJE= +github.com/kubevela/pkg v1.9.2 h1:K6pGoJikf6l8vlfehewmb36hyToX0KpUaQP4NVET/S8= +github.com/kubevela/pkg v1.9.2/go.mod h1:u/MGuFXVSECxvIWdTKS4AQs1H+USfAMQgi30BUrOb04= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= diff --git a/pkg/cue/model/value/value.go b/pkg/cue/model/value/value.go index 9c73fcd..a1fffde 100644 --- a/pkg/cue/model/value/value.go +++ b/pkg/cue/model/value/value.go @@ -21,6 +21,7 @@ import ( "fmt" "strconv" "strings" + "sync" "cuelang.org/go/cue" "cuelang.org/go/cue/ast" @@ -108,12 +109,18 @@ func setValue(orig ast.Node, expr ast.Expr, selectors []cue.Selector) error { return nil } +var syntaxLock sync.Mutex + // SetValueByScript set the value v at the given script path. // nolint:staticcheck func SetValueByScript(base, v cue.Value, path ...string) (cue.Value, error) { cuepath := FieldPath(path...) selectors := cuepath.Selectors() + + syntaxLock.Lock() node := base.Syntax(cue.ResolveReferences(true)) + syntaxLock.Unlock() + if err := setValue(node, v.Syntax(cue.ResolveReferences(true)).(ast.Expr), selectors); err != nil { return cue.Value{}, err } diff --git a/pkg/hooks/data_passing.go b/pkg/hooks/data_passing.go index 9bc2813..5b5d846 100644 --- a/pkg/hooks/data_passing.go +++ b/pkg/hooks/data_passing.go @@ -43,6 +43,9 @@ func Input(ctx wfContext.Context, paramValue cue.Value, step v1alpha1.WorkflowSt } } if input.ParameterKey != "" { + fmt.Println("===filledVal", filledVal) + fmt.Println("===inputValue", inputValue) + fmt.Println("====path", strings.Join([]string{"parameter", input.ParameterKey}, ".")) filledVal, err = value.SetValueByScript(filledVal, inputValue, strings.Join([]string{"parameter", input.ParameterKey}, ".")) if err != nil || filledVal.Err() != nil { if err != nil { From 919e7f733e4128ca9dced0549575c0dbd8f80e3b Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 23 Jul 2024 17:02:08 +0800 Subject: [PATCH 15/17] fix: add kubeclient runtime param Signed-off-by: FogDong --- pkg/providers/legacy/http/http.go | 7 +++--- pkg/providers/legacy/http/http_test.go | 6 +++-- pkg/providers/legacy/kube/kube.go | 24 +++++++++---------- pkg/providers/legacy/kube/kube_test.go | 32 ++++++++++++++++++++++---- pkg/providers/types/types.go | 17 ++++++++++++-- 5 files changed, 60 insertions(+), 26 deletions(-) diff --git a/pkg/providers/legacy/http/http.go b/pkg/providers/legacy/http/http.go index 2fbfd18..db59f2b 100644 --- a/pkg/providers/legacy/http/http.go +++ b/pkg/providers/legacy/http/http.go @@ -33,7 +33,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" cuexruntime "github.com/kubevela/pkg/cue/cuex/runtime" - "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" providertypes "github.com/kubevela/workflow/pkg/providers/types" @@ -143,7 +142,7 @@ func runHTTP(ctx context.Context, params *DoParams) (*ResponseVars, error) { req.Trailer = trailer if params.Params.TLSConfig != nil { - if tr, err := getTransport(ctx, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil { + if tr, err := getTransport(ctx, params.KubeClient, params.Params.TLSConfig.Secret, params.Params.TLSConfig.Namespace); err == nil && tr != nil { defaultClient.Transport = tr } } @@ -164,7 +163,7 @@ func runHTTP(ctx context.Context, params *DoParams) (*ResponseVars, error) { }, nil } -func getTransport(ctx context.Context, secretName, ns string) (http.RoundTripper, error) { +func getTransport(ctx context.Context, cli client.Client, secretName, ns string) (http.RoundTripper, error) { tr := &http.Transport{ TLSClientConfig: &tls.Config{ NextProtos: []string{"http/1.1"}, @@ -180,7 +179,7 @@ func getTransport(ctx context.Context, secretName, ns string) (http.RoundTripper objectKey.Name = secretName[index:] } secret := new(v1.Secret) - if err := singleton.KubeClient.Get().Get(ctx, objectKey, secret); err != nil { + if err := cli.Get(ctx, objectKey, secret); err != nil { return nil, err } if ca, ok := secret.Data["ca.crt"]; ok { diff --git a/pkg/providers/legacy/http/http_test.go b/pkg/providers/legacy/http/http_test.go index a237e35..68a2985 100644 --- a/pkg/providers/legacy/http/http_test.go +++ b/pkg/providers/legacy/http/http_test.go @@ -35,9 +35,9 @@ import ( v1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/pkg/providers/legacy/http/ratelimiter" "github.com/kubevela/workflow/pkg/providers/legacy/http/testdata" + "github.com/kubevela/workflow/pkg/providers/types" ) func TestHttpDo(t *testing.T) { @@ -277,7 +277,6 @@ func TestHTTPSDo(t *testing.T) { return nil }, } - singleton.KubeClient.Set(cli) r := require.New(t) _, err := Do(ctx, &DoParams{ Params: RequestVars{ @@ -288,6 +287,9 @@ func TestHTTPSDo(t *testing.T) { Namespace: "default", }, }, + RuntimeParams: types.RuntimeParams{ + KubeClient: cli, + }, }) r.NoError(err) } diff --git a/pkg/providers/legacy/kube/kube.go b/pkg/providers/legacy/kube/kube.go index e28c566..04197c8 100644 --- a/pkg/providers/legacy/kube/kube.go +++ b/pkg/providers/legacy/kube/kube.go @@ -33,7 +33,6 @@ import ( "github.com/kubevela/pkg/multicluster" "github.com/kubevela/pkg/util/k8s" "github.com/kubevela/pkg/util/k8s/patch" - "github.com/kubevela/pkg/util/singleton" "github.com/kubevela/workflow/pkg/cue/model" providertypes "github.com/kubevela/workflow/pkg/providers/types" @@ -55,8 +54,7 @@ func handleContext(ctx context.Context, cluster string) context.Context { return multicluster.WithCluster(ctx, cluster) } -func apply(ctx context.Context, _, _ string, workloads ...*unstructured.Unstructured) error { - cli := singleton.KubeClient.Get() +func apply(ctx context.Context, cli client.Client, _, _ string, workloads ...*unstructured.Unstructured) error { for _, workload := range workloads { existing := new(unstructured.Unstructured) existing.GetObjectKind().SetGroupVersionKind(workload.GetObjectKind().GroupVersionKind()) @@ -97,8 +95,8 @@ func apply(ctx context.Context, _, _ string, workloads ...*unstructured.Unstruct } // nolint:revive -func delete(ctx context.Context, _, _ string, manifest *unstructured.Unstructured) error { - return singleton.KubeClient.Get().Delete(ctx, manifest) +func delete(ctx context.Context, cli client.Client, _, _ string, manifest *unstructured.Unstructured) error { + return cli.Delete(ctx, manifest) } // ListFilter filter for list resources @@ -146,7 +144,7 @@ func Apply(ctx context.Context, params *ResourceParams) (*ResourceReturns, error } } deployCtx := handleContext(ctx, params.Params.Cluster) - if err := handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { + if err := handlers.Apply(deployCtx, params.KubeClient, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { return nil, err } return &ResourceReturns{ @@ -178,7 +176,7 @@ func ApplyInParallel(ctx context.Context, params *ApplyInParallelParams) (*Apply } } deployCtx := handleContext(ctx, params.Params.Cluster) - if err := handlers.Apply(deployCtx, params.Params.Cluster, WorkflowResourceCreator, workloads...); err != nil { + if err := handlers.Apply(deployCtx, params.KubeClient, params.Params.Cluster, WorkflowResourceCreator, workloads...); err != nil { return nil, err } return &ApplyInParallelReturns{ @@ -207,7 +205,7 @@ func Patch(ctx context.Context, params *providertypes.LegacyParams[cue.Value]) ( return cue.Value{}, err } multiCtx := handleContext(ctx, cluster) - if err := singleton.KubeClient.Get().Get(multiCtx, key, obj); err != nil { + if err := params.KubeClient.Get(multiCtx, key, obj); err != nil { return cue.Value{}, err } baseVal := cuecontext.New().CompileString("").FillPath(cue.ParsePath(""), obj) @@ -229,7 +227,7 @@ func Patch(ctx context.Context, params *providertypes.LegacyParams[cue.Value]) ( return cue.Value{}, err } } - if err := handlers.Apply(multiCtx, cluster, WorkflowResourceCreator, workload); err != nil { + if err := handlers.Apply(multiCtx, params.KubeClient, cluster, WorkflowResourceCreator, workload); err != nil { return cue.Value{}, err } return params.Params.FillPath(cue.ParsePath("result"), workload), nil @@ -243,7 +241,7 @@ func Read(ctx context.Context, params *ResourceParams) (*ResourceReturns, error) key.Namespace = "default" } readCtx := handleContext(ctx, params.Params.Cluster) - if err := singleton.KubeClient.Get().Get(readCtx, key, workload); err != nil { + if err := params.KubeClient.Get(readCtx, key, workload); err != nil { return &ResourceReturns{ Resource: workload, Error: err.Error(), @@ -274,7 +272,7 @@ func List(ctx context.Context, params *ResourceParams) (*ListReturns, error) { client.MatchingLabels(filter.MatchingLabels), } readCtx := handleContext(ctx, params.Params.Cluster) - if err := singleton.KubeClient.Get().List(readCtx, list, listOpts...); err != nil { + if err := params.KubeClient.List(readCtx, list, listOpts...); err != nil { return &ListReturns{ Resources: list, Error: err.Error(), @@ -296,7 +294,7 @@ func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, erro if err != nil { return nil, err } - if err := singleton.KubeClient.Get().DeleteAllOf(deleteCtx, workload, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: filter.Namespace, LabelSelector: labelSelector}}); err != nil { + if err := params.KubeClient.DeleteAllOf(deleteCtx, workload, &client.DeleteAllOfOptions{ListOptions: client.ListOptions{Namespace: filter.Namespace, LabelSelector: labelSelector}}); err != nil { return &ResourceReturns{ Resource: workload, Error: err.Error(), @@ -305,7 +303,7 @@ func Delete(ctx context.Context, params *ResourceParams) (*ResourceReturns, erro return nil, nil } - if err := handlers.Delete(deleteCtx, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { + if err := handlers.Delete(deleteCtx, params.KubeClient, params.Params.Cluster, WorkflowResourceCreator, workload); err != nil { return &ResourceReturns{ Resource: workload, Error: err.Error(), diff --git a/pkg/providers/legacy/kube/kube_test.go b/pkg/providers/legacy/kube/kube_test.go index 49d77a9..d0574d0 100644 --- a/pkg/providers/legacy/kube/kube_test.go +++ b/pkg/providers/legacy/kube/kube_test.go @@ -40,8 +40,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - "github.com/kubevela/pkg/util/singleton" - providertypes "github.com/kubevela/workflow/pkg/providers/types" ) @@ -77,8 +75,6 @@ var _ = BeforeSuite(func(done Done) { k8sClient, err = client.New(cfg, client.Options{Scheme: scheme}) Expect(err).ToNot(HaveOccurred()) Expect(k8sClient).ToNot(BeNil()) - - singleton.KubeClient.Set(k8sClient) close(done) }, 120) @@ -104,6 +100,7 @@ var _ = Describe("Test Workflow Provider Kube", func() { Labels: map[string]string{ "hello": "world", }, + KubeClient: k8sClient, }, }) Expect(err).ToNot(HaveOccurred()) @@ -136,10 +133,11 @@ var _ = Describe("Test Workflow Provider Kube", func() { Labels: map[string]string{ "hello": "world", }, + KubeClient: k8sClient, }, }) Expect(err).ToNot(HaveOccurred()) - Expect(res.Error).Should(BeNil()) + Expect(res.Error).Should(Equal("")) Expect(res.Resource.GetLabels()).Should(Equal(map[string]string{ "test": "test", "hello": "world", @@ -158,6 +156,9 @@ var _ = Describe("Test Workflow Provider Kube", func() { Params: ResourceVars{ Resource: &un, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) @@ -180,6 +181,9 @@ patch: { `) _, err = Patch(ctx, &providertypes.LegacyParams[cue.Value]{ Params: v, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) @@ -235,6 +239,9 @@ patch: { }, }, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) Expect(len(res.Resources.Items)).Should(Equal(5)) @@ -254,6 +261,9 @@ patch: { }, }, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) Expect(len(res.Resources.Items)).Should(Equal(1)) @@ -295,6 +305,9 @@ patch: { }, }, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) err = k8sClient.Get(ctx, k8stypes.NamespacedName{ @@ -349,6 +362,9 @@ patch: { }, }, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) err = k8sClient.Get(ctx, k8stypes.NamespacedName{ @@ -369,6 +385,9 @@ patch: { Params: ApplyInParallelVars{ Resources: []*unstructured.Unstructured{un1, un2}, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) pod := &corev1.Pod{} @@ -400,6 +419,9 @@ patch: { }, }, }, + RuntimeParams: providertypes.RuntimeParams{ + KubeClient: k8sClient, + }, }) Expect(err).ToNot(HaveOccurred()) Expect(res.Error).ShouldNot(BeNil()) diff --git a/pkg/providers/types/types.go b/pkg/providers/types/types.go index 9bfc072..78f8a04 100644 --- a/pkg/providers/types/types.go +++ b/pkg/providers/types/types.go @@ -22,7 +22,9 @@ import ( "cuelang.org/go/cue" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/kubevela/pkg/util/singleton" wfContext "github.com/kubevela/workflow/pkg/context" "github.com/kubevela/workflow/pkg/cue/process" "github.com/kubevela/workflow/pkg/types" @@ -42,13 +44,15 @@ const ( LabelsKey ContextKey = "labels" // KubeHandlersKey is the key for kube handlers. KubeHandlersKey ContextKey = "kubeHandlers" + // KubeClientKey is the key for kube client. + KubeClientKey ContextKey = "kubeClient" ) // Dispatcher is a client for apply resources. -type Dispatcher func(ctx context.Context, cluster, owner string, manifests ...*unstructured.Unstructured) error +type Dispatcher func(ctx context.Context, client client.Client, cluster, owner string, manifests ...*unstructured.Unstructured) error // Deleter is a client for delete resources. -type Deleter func(ctx context.Context, cluster, owner string, manifest *unstructured.Unstructured) error +type Deleter func(ctx context.Context, client client.Client, cluster, owner string, manifest *unstructured.Unstructured) error // KubeHandlers handles resources. type KubeHandlers struct { @@ -64,6 +68,7 @@ type RuntimeParams struct { FieldLabel string Labels map[string]string KubeHandlers *KubeHandlers + KubeClient client.Client } // LegacyParams is the legacy input parameters of a provider. @@ -116,6 +121,9 @@ func WithRuntimeParams(parent context.Context, params RuntimeParams) context.Con ctx := context.WithValue(parent, WorkflowContextKey, params.WorkflowContext) ctx = context.WithValue(ctx, ProcessContextKey, params.ProcessContext) ctx = context.WithValue(ctx, ActionKey, params.Action) + ctx = context.WithValue(ctx, LabelsKey, params.Labels) + ctx = context.WithValue(ctx, KubeHandlersKey, params.KubeHandlers) + ctx = context.WithValue(ctx, KubeClientKey, params.KubeClient) return ctx } @@ -137,5 +145,10 @@ func RuntimeParamsFrom(ctx context.Context) RuntimeParams { if kubeHandlers, ok := ctx.Value(KubeHandlersKey).(*KubeHandlers); ok { params.KubeHandlers = kubeHandlers } + if kubeClient, ok := ctx.Value(KubeClientKey).(client.Client); ok { + params.KubeClient = kubeClient + } else { + params.KubeClient = singleton.KubeClient.Get() + } return params } From 99ffc5485757125c807aaf2f549dc01a4ff1a8ff Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 23 Jul 2024 17:02:42 +0800 Subject: [PATCH 16/17] chore: clean up stdlib Signed-off-by: FogDong --- pkg/stdlib/README.md | 2 - pkg/stdlib/actions/v1/op.cue | 136 ----------------- pkg/stdlib/actions/v1/pkgs/config.cue | 40 ----- pkg/stdlib/actions/v1/pkgs/email.cue | 29 ---- pkg/stdlib/actions/v1/pkgs/http.cue | 41 ----- pkg/stdlib/actions/v1/pkgs/kube.cue | 104 ------------- pkg/stdlib/actions/v1/pkgs/metrics.cue | 10 -- pkg/stdlib/actions/v1/pkgs/task.cue | 198 ------------------------- pkg/stdlib/actions/v1/pkgs/time.cue | 21 --- pkg/stdlib/actions/v1/pkgs/util.cue | 44 ------ pkg/stdlib/actions/v1/pkgs/ws.cue | 23 --- pkg/stdlib/packages.go | 162 -------------------- pkg/stdlib/packages_test.go | 107 ------------- 13 files changed, 917 deletions(-) delete mode 100644 pkg/stdlib/README.md delete mode 100644 pkg/stdlib/actions/v1/op.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/config.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/email.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/http.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/kube.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/metrics.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/task.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/time.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/util.cue delete mode 100644 pkg/stdlib/actions/v1/pkgs/ws.cue delete mode 100644 pkg/stdlib/packages.go delete mode 100644 pkg/stdlib/packages_test.go diff --git a/pkg/stdlib/README.md b/pkg/stdlib/README.md deleted file mode 100644 index b87a823..0000000 --- a/pkg/stdlib/README.md +++ /dev/null @@ -1,2 +0,0 @@ -- For the stable version, the folder name and pkgName is “vela/op”, which is the same as before in order to the previous users can still use their Definition without editing. -- For other versions, the name is “vela/op/v2”,”vela/op/v3” etc. Users need to import them explicitly and change the “op.action” to “v2.action” and so on to use another version of Cue Action. \ No newline at end of file diff --git a/pkg/stdlib/actions/v1/op.cue b/pkg/stdlib/actions/v1/op.cue deleted file mode 100644 index cc0915a..0000000 --- a/pkg/stdlib/actions/v1/op.cue +++ /dev/null @@ -1,136 +0,0 @@ -import ( - "encoding/json" - "encoding/base64" - "strings" -) - -#ConditionalWait: { - #do: "wait" - - // +usage=If continue is false, the step will wait for continue to be true. - continue: bool - // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. - message?: string -} - -#Suspend: { - #do: "suspend" - - // +usage=Specify the wait duration time to resume automaticlly such as "30s", "1min" or "2m15s" - duration?: string - // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. - message?: string -} - -#Break: { - #do: "break" - - // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. - message?: string -} - -#Fail: { - #do: "fail" - - // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. - message?: string -} - -#Message: { - #do: "message" - - // +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions. - message?: string -} - -#Apply: kube.#Apply - -#Patch: kube.#Patch - -#ApplyInParallel: kube.#ApplyInParallel - -#Read: kube.#Read - -#List: kube.#List - -#Delete: kube.#Delete - -#DingTalk: #Steps & { - message: {...} - dingUrl: string - do: http.#Do & { - method: "POST" - url: dingUrl - request: { - body: json.Marshal(message) - header: "Content-Type": "application/json" - } - } -} - -#Lark: #Steps & { - message: {...} - larkUrl: string - do: http.#Do & { - method: "POST" - url: larkUrl - request: { - body: json.Marshal(message) - header: "Content-Type": "application/json" - } - } -} - -#Slack: #Steps & { - message: {...} - slackUrl: string - do: http.#Do & { - method: "POST" - url: slackUrl - request: { - body: json.Marshal(message) - header: "Content-Type": "application/json" - } - } -} - -#HTTPDo: http.#Do - -#HTTPGet: http.#Do & {method: "GET"} - -#HTTPPost: http.#Do & {method: "POST"} - -#HTTPPut: http.#Do & {method: "PUT"} - -#HTTPDelete: http.#Do & {method: "DELETE"} - -#ConvertString: util.#String - -#Log: util.#Log - -#DateToTimestamp: time.#DateToTimestamp - -#TimestampToDate: time.#TimestampToDate - -#SendEmail: email.#Send - -// The providers about the config -#CreateConfig: config.#Create -#DeleteConfig: config.#Delete -#ReadConfig: config.#Read -#ListConfig: config.#List - -#PromCheck: metrics.#PromCheck - -#PatchK8sObject: util.#PatchK8sObject - -#Steps: { - #do: "steps" - ... -} - -#Task: task.#Task - -NoExist: _|_ - -context: _ diff --git a/pkg/stdlib/actions/v1/pkgs/config.cue b/pkg/stdlib/actions/v1/pkgs/config.cue deleted file mode 100644 index dd897bc..0000000 --- a/pkg/stdlib/actions/v1/pkgs/config.cue +++ /dev/null @@ -1,40 +0,0 @@ -#Create: { - #do: "create" - #provider: "config" - - name: string - namespace: string - template?: string - config: { - ... - } -} - -#Delete: { - #do: "delete" - #provider: "config" - - name: string - namespace: string -} - -#Read: { - #do: "read" - #provider: "config" - - name: string - namespace: string - - config: {...} -} - -#List: { - #do: "list" - #provider: "config" - - // Must query with the template - template: string - namespace: string - - configs: [...{...}] -} diff --git a/pkg/stdlib/actions/v1/pkgs/email.cue b/pkg/stdlib/actions/v1/pkgs/email.cue deleted file mode 100644 index 41c8add..0000000 --- a/pkg/stdlib/actions/v1/pkgs/email.cue +++ /dev/null @@ -1,29 +0,0 @@ -#Send: { - #do: "send" - #provider: "email" - - // +usage=The info of the sender - from: { - // +usage=The address of the sender - address: string - // +usage=The alias of the sender - alias?: string - // +usage=The password of the sender - password: string - // +usage=The host of the sender server - host: string - // +usage=The port of the sender server - port: int - } - // +usgae=The email address list of the recievers - to: [...string] - // +usage=The content of the email - content: { - // +usage=The subject of the email - subject: string - // +usage=The body of the email - body: string - } - stepID: context.stepSessionID - ... -} diff --git a/pkg/stdlib/actions/v1/pkgs/http.cue b/pkg/stdlib/actions/v1/pkgs/http.cue deleted file mode 100644 index c88c208..0000000 --- a/pkg/stdlib/actions/v1/pkgs/http.cue +++ /dev/null @@ -1,41 +0,0 @@ -#Do: { - #do: "do" - #provider: "http" - - // +usage=The method of HTTP request - method: *"GET" | "POST" | "PUT" | "DELETE" - // +usage=The url to request - url: string - // +usage=The request config - request?: { - // +usage=The timeout of this request - timeout?: string - // +usage=The request body - body?: string - // +usage=The header of the request - header?: [string]: string - // +usage=The trailer of the request - trailer?: [string]: string - // +usage=The rate limiter of the request - ratelimiter?: { - limit: int - period: string - } - ... - } - // +usgae=The tls config of the request - tls_config?: secret: string - // +usage=The response of the request will be filled in this field after the action is executed - response: { - // +usage=The body of the response - body: string - // +usage=The header of the response - header?: [string]: [...string] - // +usage=The trailer of the response - trailer?: [string]: [...string] - // +usage=The status code of the response - statusCode: int - ... - } - ... -} diff --git a/pkg/stdlib/actions/v1/pkgs/kube.cue b/pkg/stdlib/actions/v1/pkgs/kube.cue deleted file mode 100644 index 758a47c..0000000 --- a/pkg/stdlib/actions/v1/pkgs/kube.cue +++ /dev/null @@ -1,104 +0,0 @@ -#Apply: { - #do: "apply" - #provider: "kube" - - // +usage=The cluster to use - cluster: *"" | string - // +usage=The resource to apply - value: {...} - // +usage=The patcher that will be applied to the resource, you can define the strategy of list merge through comments. Reference doc here: https://kubevela.io/docs/platform-engineers/traits/patch-trait#patch-in-workflow-step - patch?: {...} - ... -} - -#Patch: { - #do: "patch" - #provider: "kube" - - // +usage=The cluster to use - cluster: *"" | string - // +usage=The resource to patch, we'll first get the resource from the cluster, then apply the patcher to it - value: {...} - // +usage=The patcher that will be applied to the resource, you can define the strategy of list merge through comments. Reference doc here: https://kubevela.io/docs/platform-engineers/traits/patch-trait#patch-in-workflow-step - patch: {...} - // +usage=The resource after applied will be filled in this field after the action is executed - result?: {...} - ... -} - -#ApplyInParallel: { - #do: "apply-in-parallel" - #provider: "kube" - - // +usage=The cluster to use - cluster: *"" | string - // +usage=The resources to apply in parallel - value: [...{...}] - ... -} - -#Read: { - #do: "read" - #provider: "kube" - - // +usage=The cluster to use - cluster: *"" | string - // +usage=The resource to read, this field will be filled with the resource read from the cluster after the action is executed - value?: {...} - ... -} - -#List: { - #do: "list" - #provider: "kube" - - // +usage=The cluster to use - cluster: *"" | string - // +usage=The resource to list - resource: { - // +usage=The api version of the resource - apiVersion: string - // +usage=The kind of the resource - kind: string - } - // +usage=The filter to list the resources - filter?: { - // +usage=The namespace to list the resources - namespace?: *"" | string - // +usage=The label selector to filter the resources - matchingLabels?: {...} - } - // +usage=The listed resources will be filled in this field after the action is executed - list?: {...} - ... -} - -#Delete: { - #do: "delete" - #provider: "kube" - - // +usage=The cluster to use - cluster: *"" | string - // +usage=The resource to delete - value: { - // +usage=The api version of the resource - apiVersion: string - // +usage=The kind of the resource - kind: string - // +usage=The metadata of the resource - metadata: { - // +usage=The name of the resource - name?: string - // +usage=The namespace of the resource - namespace: *"default" | string - } - } - // +usage=The filter to delete the resources - filter?: { - // +usage=The namespace to list the resources - namespace?: string - // +usage=The label selector to filter the resources - matchingLabels?: {...} - } - ... -} diff --git a/pkg/stdlib/actions/v1/pkgs/metrics.cue b/pkg/stdlib/actions/v1/pkgs/metrics.cue deleted file mode 100644 index 98df154..0000000 --- a/pkg/stdlib/actions/v1/pkgs/metrics.cue +++ /dev/null @@ -1,10 +0,0 @@ -#PromCheck: { - #do: "promCheck" - #provider: "metrics" - - query: string - promAddress: string - condition: string - duration: string - ... -} diff --git a/pkg/stdlib/actions/v1/pkgs/task.cue b/pkg/stdlib/actions/v1/pkgs/task.cue deleted file mode 100644 index 4e43c0e..0000000 --- a/pkg/stdlib/actions/v1/pkgs/task.cue +++ /dev/null @@ -1,198 +0,0 @@ - -let defaultToolImage = "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/entrypoint:v0.27.2" -let defaultBaseImage = "gcr.io/distroless/base@sha256:aa4fd987555ea10e1a4ec8765da8158b5ffdfef1e72da512c7ede509bc9966c4" - -#Task: { - #do: "steps" - name: string - namespace: string - workspaces: [_name_=string]: #workspace & {name: "\(_name_)"} - secrets: [_name_=string]: #secret & {name: "\(_name_)"} - pullSecrets: [...string] - steps: [...#Script] - - toolImage: *defaultToolImage | string - baseImage: *defaultBaseImage | string - - generate_scripts_: [ for i, x in steps { - """ - scriptfile="/vela/scripts/script-\(i)" - touch ${scriptfile} && chmod +x ${scriptfile} - cat > ${scriptfile} << _EOF_ - \(base64.Encode(null, x.script)) - _EOF_ - /vela/tools/entrypoint decode-script ${scriptfile} - - """ - }] - - name_: name - namespace_: namespace - - apply: #Apply & { - value: #PodTask & { - _settings: { - scripts_: strings.Join(generate_scripts_, "") - workspaces_: workspaces - secrets_: secrets - pullSecrets_: pullSecrets - toolImage_: toolImage - baseImage_: baseImage - } - - metadata: { - name: name_ - namespace: namespace_ - } - spec: containers: [ for i, step in steps { - #StepContainer - name: step.name - image: step.image - env: step.envs - - _settings: { - workspaceMounts_: step.workspaceMounts - secretMounts_: step.secretMounts - index_: i - } - }] - } - } -} - -#Script: { - name: string - image: string - script: string - envs: [...{name: string, value: string}] - workspaceMounts: [...{workspace: #workspace, mountPath: string}] - secretMounts: [...{secret: #secret, mountPath: string}] -} - -#workspace: { - name: string -} - -#secret: { - name: string - items: [...{key: string, path: string}] -} - -#PodTask: { - _settings: { - scripts_: string - workspaces_: {...} - secrets_: {...} - pullSecrets_: [...string] - volumes_: [ for x in workspaces_ {name: x.name, emptyDir: {}}] - secretVolumes_: [ for x in secrets_ {name: x.name, secret: {secretName: x.name, items: x.items}}] - toolImage_: string - baseImage_: string - } - - apiVersion: "v1" - kind: "Pod" - metadata: { - annotations: "vela.dev/ready": "READY" - namespace: *"default" | string - name: string - } - spec: { - containers: [...#StepContainer] - initContainers: [ - { - name: "place-tools" - command: ["/ko-app/entrypoint", "cp", "/ko-app/entrypoint", "/vela/tools/entrypoint"] - image: _settings.toolImage_ - imagePullPolicy: "IfNotPresent" - volumeMounts: [{name: "vela-internal-tools", mountPath: "/vela/tools"}] - }, { - name: "place-scripts" - imagePullPolicy: "IfNotPresent" - image: _settings.baseImage_ - command: ["sh"] - args: ["-c", _settings.scripts_] - volumeMounts: [{name: "vela-internal-scripts", mountPath: "/vela/scripts"}, {name: "vela-internal-tools", mountPath: "/vela/tools"}] - }] - volumes: [ - {emptyDir: {} - name: "vela-internal-workspace" - }, - {emptyDir: {} - name: "vela-internal-home" - }, - {emptyDir: {} - name: "vela-internal-results" - }, - {emptyDir: {} - name: "vela-internal-steps" - }, - {emptyDir: {} - name: "vela-internal-scripts" - }, - {emptyDir: {} - name: "vela-internal-tools" - }, - {downwardAPI: { - defaultMode: 420 - items: [{ - fieldRef: { - apiVersion: "v1" - fieldPath: "metadata.annotations['vela.dev/ready']" - } - path: "ready" - }] - } - name: "vela-internal-downward" - }] + _settings.volumes_ + _settings.secretVolumes_ - restartPolicy: "Never" - imagePullSecrets: [ for x in _settings.pullSecrets_ {name: x}] - } -} - -#StepContainer: { - _settings: { - index_: int - workspaceMounts_: [...{workspace: #workspace, mountPath: string}] - volumeMounts_: [ for v in workspaceMounts_ {name: v.workspace.name, mountPath: v.mountPath}] - - secretMounts_: [...{secret: #secret, mountPath: string}] - secretVolumeMounts_: [ for v in secretMounts_ {name: v.secret.name, mountPath: v.mountPath}] - } - - name: string - command: ["/vela/tools/entrypoint"] - - args: *["-wait_file", "/vela/downward/ready", "-wait_file_content", "-post_file", "/vela/tools/\(_settings.index_)", "-termination_path", "/vela/termination", "-step_metadata_dir", "/vela/steps/step-\(name)", "-step_metadata_dir_link", "/vela/steps/\(_settings.index_)", "-entrypoint", "/vela/scripts/script-\(_settings.index_)", "--"] | [...string] - if _settings.index_ > 0 { - args: ["-wait_file", "/vela/tools/\(_settings.index_-1)", "-post_file", "/vela/tools/\(_settings.index_)", "-termination_path", "/vela/termination", "-step_metadata_dir", "/vela/steps/step-\(name)", "-step_metadata_dir_link", "/vela/steps/\(_settings.index_)", "-entrypoint", "/vela/scripts/script-\(_settings.index_)", "--"] - } - - env?: _ - image: string - imagePullPolicy: "Always" - terminationMessagePath: "/vela/termination" - terminationMessagePolicy: "File" - volumeMounts: [{ - name: "vela-internal-scripts" - mountPath: "/vela/scripts" - }, { - name: "vela-internal-tools" - mountPath: "/vela/tools" - }, { - name: "vela-internal-downward" - mountPath: "/vela/downward" - }, { - name: "vela-internal-workspace" - mountPath: "/workspace" - }, { - name: "vela-internal-home" - mountPath: "/vela/home" - }, { - name: "vela-internal-results" - mountPath: "/vela/results" - }, { - name: "vela-internal-steps" - mountPath: "/vela/steps" - }] + _settings.volumeMounts_ + _settings.secretVolumeMounts_ -} diff --git a/pkg/stdlib/actions/v1/pkgs/time.cue b/pkg/stdlib/actions/v1/pkgs/time.cue deleted file mode 100644 index a5faca6..0000000 --- a/pkg/stdlib/actions/v1/pkgs/time.cue +++ /dev/null @@ -1,21 +0,0 @@ -#DateToTimestamp: { - #do: "timestamp" - #provider: "time" - - date: string - layout: *"" | string - - timestamp?: int64 - ... -} - -#TimestampToDate: { - #do: "date" - #provider: "time" - - timestamp: int64 - layout: *"" | string - - date?: string - ... -} diff --git a/pkg/stdlib/actions/v1/pkgs/util.cue b/pkg/stdlib/actions/v1/pkgs/util.cue deleted file mode 100644 index 30ed85c..0000000 --- a/pkg/stdlib/actions/v1/pkgs/util.cue +++ /dev/null @@ -1,44 +0,0 @@ -#PatchK8sObject: { - #do: "patch-k8s-object" - #provider: "util" - value: {...} - patch: {...} - result: {...} - ... -} - -#String: { - #do: "string" - #provider: "util" - - bt: bytes - str?: string - ... -} - -#Log: { - #do: "log" - #provider: "util" - - // +usage=The data to print in the controller logs - data?: {...} | string - // +usage=The log level of the data - level: *3 | int - // +usage=The log source of this step. You can specify it from a url or resources. Note that if you set source in multiple op.#Log, only the latest one will work - source?: close({ - // +usage=Specify the log source url of this step - url: string - }) | close({ - // +usage=Specify the log resources of this step - resources?: [...{ - // +usage=Specify the name of the resource - name?: string - // +usage=Specify the cluster of the resource - cluster?: string - // +usage=Specify the namespace of the resource - namespace?: string - // +usage=Specify the label selector of the resource - labelSelector?: {...} - }] - }) -} diff --git a/pkg/stdlib/actions/v1/pkgs/ws.cue b/pkg/stdlib/actions/v1/pkgs/ws.cue deleted file mode 100644 index 2c002d9..0000000 --- a/pkg/stdlib/actions/v1/pkgs/ws.cue +++ /dev/null @@ -1,23 +0,0 @@ -#Load: { - #do: "load" - component?: string - value?: {...} - ... -} - -#Export: { - #do: "export" - component: string - value: _ -} - -#DoVar: { - #do: "var" - - // +usage=The method to call on the variable - method: *"Get" | "Put" - // +usage=The path to the variable - path: string - // +usage=The value of the variable - value?: _ -} diff --git a/pkg/stdlib/packages.go b/pkg/stdlib/packages.go deleted file mode 100644 index d213a8b..0000000 --- a/pkg/stdlib/packages.go +++ /dev/null @@ -1,162 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package stdlib - -import ( - "embed" - "fmt" - "os" - "path/filepath" - "strings" - - "cuelang.org/go/cue/ast" - "cuelang.org/go/cue/build" - "cuelang.org/go/cue/parser" - "k8s.io/klog/v2" -) - -func init() { - var err error - pkgs, err := GetPackages() - if err != nil { - klog.ErrorS(err, "Unable to init builtin packages for imports") - os.Exit(1) - } - builtinImport, err = InitBuiltinImports(pkgs) - if err != nil { - klog.ErrorS(err, "Unable to init builtin imports") - os.Exit(1) - } -} - -var ( - //go:embed actions - fs embed.FS - // builtinImport is the builtin import for cue - builtinImport []*build.Instance -) - -const ( - builtinPackageName = "vela/op" - builtinActionPath = "actions" - packagePath = "pkgs" - defaultVersion = "v1" -) - -// SetupBuiltinImports setup builtin imports -func SetupBuiltinImports(pkgs map[string]string) error { - builtin, err := GetPackages() - if err != nil { - return err - } - for k, v := range pkgs { - file, err := parser.ParseFile("-", v, parser.ParseComments) - if err != nil { - return err - } - if original, ok := builtin[k]; ok { - builtin[k] = mergeFiles(original, file) - } else { - builtin[k] = file - } - } - builtinImport, err = InitBuiltinImports(builtin) - if err != nil { - return err - } - return nil -} - -// GetPackages Get Stdlib packages -func GetPackages() (map[string]*ast.File, error) { - versions, err := fs.ReadDir(builtinActionPath) - if err != nil { - return nil, err - } - ret := make(map[string]*ast.File) - - for _, dirs := range versions { - pathPrefix := fmt.Sprintf("%s/%s", builtinActionPath, dirs.Name()) - files, err := fs.ReadDir(fmt.Sprintf("%s/%s", pathPrefix, packagePath)) - if err != nil { - return nil, err - } - opBytes, err := fs.ReadFile(fmt.Sprintf("%s/%s", pathPrefix, "op.cue")) - if err != nil { - return nil, err - } - opContent := string(opBytes) + "\n" - for _, file := range files { - body, err := fs.ReadFile(fmt.Sprintf("%s/%s/%s", pathPrefix, packagePath, file.Name())) - if err != nil { - return nil, err - } - pkgContent := fmt.Sprintf("%s: {\n%s\n}\n", strings.TrimSuffix(file.Name(), ".cue"), string(body)) - opContent += pkgContent - } - f, err := parser.ParseFile("-", opContent, parser.ParseComments) - if err != nil { - return nil, err - } - if dirs.Name() == defaultVersion { - ret[builtinPackageName] = f - } - ret[filepath.Join(builtinPackageName, dirs.Name())] = f - } - return ret, nil -} - -// AddImportsFor install imports for build.Instance. -func AddImportsFor(inst *build.Instance, tagTempl string) error { - inst.Imports = append(inst.Imports, builtinImport...) - if tagTempl != "" { - p := &build.Instance{ - PkgName: filepath.Base("vela/custom"), - ImportPath: "vela/custom", - } - file, err := parser.ParseFile("-", tagTempl, parser.ParseComments) - if err != nil { - return err - } - if err := p.AddSyntax(file); err != nil { - return err - } - inst.Imports = append(inst.Imports, p) - } - return nil -} - -// InitBuiltinImports init built in imports -func InitBuiltinImports(pkgs map[string]*ast.File) ([]*build.Instance, error) { - imports := make([]*build.Instance, 0) - for path, content := range pkgs { - p := &build.Instance{ - PkgName: filepath.Base(path), - ImportPath: path, - } - if err := p.AddSyntax(content); err != nil { - return nil, err - } - imports = append(imports, p) - } - return imports, nil -} - -func mergeFiles(base, file *ast.File) *ast.File { - base.Decls = append(base.Decls, file.Decls...) - return base -} diff --git a/pkg/stdlib/packages_test.go b/pkg/stdlib/packages_test.go deleted file mode 100644 index 2fbbd41..0000000 --- a/pkg/stdlib/packages_test.go +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright 2022 The KubeVela Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package stdlib - -import ( - "testing" - - "cuelang.org/go/cue" - "cuelang.org/go/cue/build" - "cuelang.org/go/cue/cuecontext" - "cuelang.org/go/cue/parser" - "github.com/kubevela/workflow/pkg/cue/model/sets" - "github.com/stretchr/testify/require" -) - -func TestGetPackages(t *testing.T) { - //test vela/op - r := require.New(t) - pkg, err := GetPackages() - r.NoError(err) - cuectx := cuecontext.New() - _ = cuectx.BuildFile(pkg[builtinPackageName]) - - file, err := parser.ParseFile("-", ` -import "vela/custom" -out: custom.context`) - r.NoError(err) - builder := &build.Instance{} - err = builder.AddSyntax(file) - r.NoError(err) - err = AddImportsFor(builder, "context: id: \"xxx\"") - r.NoError(err) - - inst := cuectx.BuildInstance(builder) - str, err := inst.LookupPath(cue.ParsePath("out.id")).String() - r.NoError(err) - r.Equal(str, "xxx") - - //test vela/op/v1 - testVersion := "vela/op/v1" - cuectx1 := cuecontext.New() - _ = cuectx1.BuildFile(pkg[testVersion]) - - file, err = parser.ParseFile("-", ` -import "vela/op/v1" -out: v1.#Break & { - message: "break" -} -`) - r.NoError(err) - builder1 := &build.Instance{} - err = builder1.AddSyntax(file) - r.NoError(err) - err = AddImportsFor(builder1, "") - r.NoError(err) - inst1 := cuectx1.BuildInstance(builder1) - str1, err := inst1.LookupPath(cue.ParsePath("out.message")).String() - r.NoError(err) - r.Equal(str1, "break") -} - -func TestSetupBuiltinImports(t *testing.T) { - //test vela/op - r := require.New(t) - err := SetupBuiltinImports(map[string]string{"vela/op": "test: kube.#Apply"}) - r.NoError(err) - file, err := parser.ParseFile("-", ` -import "vela/op" -step: op.#Steps -apply: op.test`) - r.NoError(err) - builder := &build.Instance{} - err = builder.AddSyntax(file) - r.NoError(err) - err = AddImportsFor(builder, "") - r.NoError(err) - - cuectx := cuecontext.New() - inst := cuectx.BuildInstance(builder) - r.NoError(inst.Value().Err()) - v := inst.LookupPath(cue.ParsePath("step")) - r.NoError(err) - r.NoError(v.Err()) - s, err := sets.ToString(v) - r.NoError(err) - r.Equal(s, "#do: \"steps\"\n") - v = inst.LookupPath(cue.ParsePath("apply")) - r.NoError(err) - r.NoError(v.Err()) - s, err = sets.ToString(v) - r.NoError(err) - r.Contains(s, "apply") -} From 5de159eb484cd6d134efd533d91b5540e0f1f311 Mon Sep 17 00:00:00 2001 From: FogDong Date: Tue, 23 Jul 2024 20:40:17 +0800 Subject: [PATCH 17/17] fix: do not override runtime params Signed-off-by: FogDong --- pkg/providers/types/types.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/providers/types/types.go b/pkg/providers/types/types.go index 78f8a04..4a78c54 100644 --- a/pkg/providers/types/types.go +++ b/pkg/providers/types/types.go @@ -121,9 +121,6 @@ func WithRuntimeParams(parent context.Context, params RuntimeParams) context.Con ctx := context.WithValue(parent, WorkflowContextKey, params.WorkflowContext) ctx = context.WithValue(ctx, ProcessContextKey, params.ProcessContext) ctx = context.WithValue(ctx, ActionKey, params.Action) - ctx = context.WithValue(ctx, LabelsKey, params.Labels) - ctx = context.WithValue(ctx, KubeHandlersKey, params.KubeHandlers) - ctx = context.WithValue(ctx, KubeClientKey, params.KubeClient) return ctx }