Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions consul/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ import (
"strings"

"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshery-adapter-library/status"
"github.com/layer5io/meshery-consul/internal/config"
meshery_kube "github.com/layer5io/meshkit/utils/kubernetes"
)

const (
// SMIManifest is the manifest.yaml file for smi conformance tool
SMIManifest = "https://raw.githubusercontent.com/layer5io/learn-layer5/master/smi-conformance/manifest.yml"
)

func (h *Consul) ApplyOperation(ctx context.Context, request adapter.OperationRequest) error {
operations := make(adapter.Operations)
err := h.Config.GetObject(adapter.OperationsKey, &operations)
Expand Down Expand Up @@ -79,6 +85,26 @@ func (h *Consul) ApplyOperation(ctx context.Context, request adapter.OperationRe
e.Summary = fmt.Sprintf("%s %s successfully.", opDesc, status)
e.Details = e.Summary

case config.SmiConformanceOperation:
go func(hh *Consul, ee *adapter.Event) {
name := operations[request.OperationName].Description
_, err := hh.RunSMITest(adapter.SMITestOptions{
Ctx: context.TODO(),
OperationID: ee.Operationid,
Labels: make(map[string]string),
Namespace: "meshery",
Manifest: SMIManifest,
Annotations: map[string]string{
"consul.hashicorp.com/connect-inject": "true",
},
})
if err != nil {
e.Summary = fmt.Sprintf("Error while %s %s test", status.Running, name)
e.Details = err.Error()
hh.StreamErr(e, err)
return
}
}(h, e)
default:
h.StreamErr(e, adapter.ErrOpInvalid)
return adapter.ErrOpInvalid
Expand Down
Loading