oc-monitord/tools/interface.go

30 lines
896 B
Go
Raw Normal View History

2025-02-14 12:00:29 +01:00
package tools
import (
"errors"
"io"
2025-02-17 16:54:25 +01:00
"oc-monitord/models"
2025-02-14 12:00:29 +01:00
"sync"
)
type Tool interface {
2025-02-17 16:54:25 +01:00
CreateArgoWorkflow(path string, ns string) (string, error)
2025-02-14 12:00:29 +01:00
CreateAccessSecret(ns string, login string, password string) (string, error)
2025-02-17 16:54:25 +01:00
LogWorkflow(execID string, namespace string, workflowName string, argoFilePath string, stepMax int, current_watch *models.ArgoWatch, previous_watch *models.ArgoWatch,
argoLogs *models.ArgoLogs, seen []string,
logFunc func(argoFilePath string, stepMax int, pipe io.ReadCloser, current_watch *models.ArgoWatch, previous_watch *models.ArgoWatch,
argoLogs *models.ArgoLogs, seen []string, wg *sync.WaitGroup)) error
2025-02-14 12:00:29 +01:00
}
var _service = map[string]func() (Tool, error){
"kubernetes": NewKubernetesTool,
}
func NewService(name string) (Tool, error) {
service, ok := _service[name]
if !ok {
return nil, errors.New("service not found")
}
return service()
}