package tools

import (
	"errors"
	"io"

	"k8s.io/apimachinery/pkg/watch"
)

type Tool interface {
	CreateArgoWorkflow(path string, ns string) (string, error)
	CreateAccessSecret(ns string, login string, password string) (string, error)
	GetArgoWatch(executionId string, wfName string) (watch.Interface, error)
	GetPodLogger(ns string, wfName string, podName string) (io.ReadCloser, error)
}

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()
}