chaosblade
54 строки · 1.5 Кб
1/*
2* Copyright 1999-2020 Alibaba Group Holding Ltd.
3*
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*/
16
17package cri18
19import (20"context"21"github.com/chaosblade-io/chaosblade-spec-go/log"22
23"github.com/chaosblade-io/chaosblade-exec-cri/exec"24"github.com/chaosblade-io/chaosblade-spec-go/channel"25"github.com/chaosblade-io/chaosblade-spec-go/spec"26)
27
28type Executor struct {29executors map[string]spec.Executor30}
31
32func NewExecutor() spec.Executor {33return &Executor{34executors: exec.GetAllExecutors(),35}36}
37
38func (*Executor) Name() string {39return "cri"40}
41
42func (e *Executor) Exec(uid string, ctx context.Context, model *spec.ExpModel) *spec.Response {43key := exec.GetExecutorKey(model.Target, model.ActionName)44executor := e.executors[key]45if executor == nil {46log.Errorf(ctx, spec.CriExecNotFound.Sprintf(key))47return spec.ResponseFailWithFlags(spec.CriExecNotFound, key)48}49executor.SetChannel(channel.NewLocalChannel())50return executor.Exec(uid, ctx, model)51}
52
53func (*Executor) SetChannel(channel spec.Channel) {54}
55