chaosblade

Форк
0
/
executor.go 
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

17
package cri
18

19
import (
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

28
type Executor struct {
29
	executors map[string]spec.Executor
30
}
31

32
func NewExecutor() spec.Executor {
33
	return &Executor{
34
		executors: exec.GetAllExecutors(),
35
	}
36
}
37

38
func (*Executor) Name() string {
39
	return "cri"
40
}
41

42
func (e *Executor) Exec(uid string, ctx context.Context, model *spec.ExpModel) *spec.Response {
43
	key := exec.GetExecutorKey(model.Target, model.ActionName)
44
	executor := e.executors[key]
45
	if executor == nil {
46
		log.Errorf(ctx, spec.CriExecNotFound.Sprintf(key))
47
		return spec.ResponseFailWithFlags(spec.CriExecNotFound, key)
48
	}
49
	executor.SetChannel(channel.NewLocalChannel())
50
	return executor.Exec(uid, ctx, model)
51
}
52

53
func (*Executor) SetChannel(channel spec.Channel) {
54
}
55

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.